Spaces:
Running
Running
kingabzpro
commited on
Commit
β’
415aae1
1
Parent(s):
5cda7b0
Update Gradio/app.py
Browse files- Gradio/app.py +3 -4
Gradio/app.py
CHANGED
@@ -19,11 +19,11 @@ Model = "kingabzpro/wav2vec2-large-xls-r-300m-Urdu"
|
|
19 |
|
20 |
############## Inference ##############################
|
21 |
|
22 |
-
|
23 |
def asr(audio):
|
24 |
|
25 |
asr = pipeline("automatic-speech-recognition", model=Model)
|
26 |
-
prediction = asr(audio, chunk_length_s=
|
27 |
return unicodedata.normalize("NFC",prediction["text"])
|
28 |
|
29 |
|
@@ -50,11 +50,10 @@ examples = [["Sample/sample1.mp3"], ["Sample/sample2.mp3"], ["Sample/sample3.mp3
|
|
50 |
Input = gr.inputs.Audio(
|
51 |
source="microphone",
|
52 |
type="filepath",
|
53 |
-
optional=True,
|
54 |
label="Please Record Your Voice",
|
55 |
)
|
56 |
Output = gr.outputs.Textbox(label="Urdu Script")
|
57 |
-
|
58 |
|
59 |
def main():
|
60 |
iface = gr.Interface(
|
|
|
19 |
|
20 |
############## Inference ##############################
|
21 |
|
22 |
+
device = 0 if torch.cuda.is_available() else "cpu"
|
23 |
def asr(audio):
|
24 |
|
25 |
asr = pipeline("automatic-speech-recognition", model=Model)
|
26 |
+
prediction = asr(audio, chunk_length_s=30, device=device)
|
27 |
return unicodedata.normalize("NFC",prediction["text"])
|
28 |
|
29 |
|
|
|
50 |
Input = gr.inputs.Audio(
|
51 |
source="microphone",
|
52 |
type="filepath",
|
|
|
53 |
label="Please Record Your Voice",
|
54 |
)
|
55 |
Output = gr.outputs.Textbox(label="Urdu Script")
|
56 |
+
inputs= gr.Audio(source="microphone", type="filepath", streaming=True),
|
57 |
|
58 |
def main():
|
59 |
iface = gr.Interface(
|