Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,16 +1,18 @@
|
|
| 1 |
from transformers import pipeline
|
| 2 |
asr_pipe = pipeline("automatic-speech-recognition", model="Abdullah17/whisper-small-urdu")
|
| 3 |
from difflib import SequenceMatcher
|
| 4 |
-
|
|
|
|
|
|
|
| 5 |
# List of commands
|
| 6 |
-
commands = [
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
]
|
| 14 |
# replies = [
|
| 15 |
# 1,2,
|
| 16 |
# ]
|
|
@@ -29,8 +31,9 @@ def find_most_similar_command(statement, command_list):
|
|
| 29 |
i+=1
|
| 30 |
|
| 31 |
return best_match,reply
|
| 32 |
-
def transcribe_the_command(audio):
|
| 33 |
import soundfile as sf
|
|
|
|
| 34 |
sample_rate, audio_data = audio
|
| 35 |
file_name = "recorded_audio.wav"
|
| 36 |
sf.write(file_name, audio_data, sample_rate)
|
|
@@ -50,7 +53,7 @@ import gradio as gr
|
|
| 50 |
|
| 51 |
iface = gr.Interface(
|
| 52 |
fn=transcribe_the_command,
|
| 53 |
-
inputs=gr.inputs.Audio(label="Recorded Audio",source="microphone"),
|
| 54 |
outputs="text",
|
| 55 |
title="Whisper Small Urdu Command",
|
| 56 |
description="Realtime demo for Urdu speech recognition using a fine-tuned Whisper small model and outputting the estimated command on the basis of speech transcript.",
|
|
|
|
| 1 |
from transformers import pipeline
|
| 2 |
asr_pipe = pipeline("automatic-speech-recognition", model="Abdullah17/whisper-small-urdu")
|
| 3 |
from difflib import SequenceMatcher
|
| 4 |
+
import json
|
| 5 |
+
with open("tasks.json", "r") as json_file:
|
| 6 |
+
urdu_data = json.load(json_file)
|
| 7 |
# List of commands
|
| 8 |
+
# commands = [
|
| 9 |
+
# "نمائندے ایجنٹ نمائندہ",
|
| 10 |
+
# " سم ایکٹیویٹ ",
|
| 11 |
+
# " سم بلاک بند ",
|
| 12 |
+
# "موبائل پیکیجز انٹرنیٹ پیکیج",
|
| 13 |
+
# " چالان جمع چلان",
|
| 14 |
+
# " گانا "
|
| 15 |
+
# ]
|
| 16 |
# replies = [
|
| 17 |
# 1,2,
|
| 18 |
# ]
|
|
|
|
| 31 |
i+=1
|
| 32 |
|
| 33 |
return best_match,reply
|
| 34 |
+
def transcribe_the_command(audio,id):
|
| 35 |
import soundfile as sf
|
| 36 |
+
commands=urdu_data[id]
|
| 37 |
sample_rate, audio_data = audio
|
| 38 |
file_name = "recorded_audio.wav"
|
| 39 |
sf.write(file_name, audio_data, sample_rate)
|
|
|
|
| 53 |
|
| 54 |
iface = gr.Interface(
|
| 55 |
fn=transcribe_the_command,
|
| 56 |
+
inputs=[gr.inputs.Audio(label="Recorded Audio",source="microphone"),gr.inputs.Number(label="id")],
|
| 57 |
outputs="text",
|
| 58 |
title="Whisper Small Urdu Command",
|
| 59 |
description="Realtime demo for Urdu speech recognition using a fine-tuned Whisper small model and outputting the estimated command on the basis of speech transcript.",
|