Spaces:
Runtime error
Runtime error
zahoor54321
commited on
Commit
•
4fe4722
1
Parent(s):
e72779d
Update app.py
Browse files
app.py
CHANGED
@@ -2,44 +2,37 @@ from transformers import pipeline
|
|
2 |
import gradio as gr
|
3 |
import time
|
4 |
import unicodedata
|
5 |
-
p = pipeline("automatic-speech-recognition",model="kingabzpro/wav2vec2-large-xls-r-300m-Urdu")
|
6 |
|
7 |
-
|
8 |
-
time.sleep(2)
|
9 |
-
text = p(audio)["text"]
|
10 |
-
state += unicodedata.normalize("NFC",text) + " "
|
11 |
-
return state, state
|
12 |
-
|
13 |
-
################### Gradio Web APP ################################
|
14 |
-
|
15 |
-
title = "Real-Time Urdu ASR"
|
16 |
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
</center>
|
22 |
-
</p>
|
23 |
-
<center>
|
24 |
-
<img src="https://huggingface.co/spaces/kingabzpro/real-time-Urdu-ASR/resolve/main/Images/cover.jpg" alt="logo" width="550"/>
|
25 |
-
</center>
|
26 |
-
"""
|
27 |
-
|
28 |
-
article = "<p style='text-align: center'><a href='https://dagshub.com/kingabzpro/Urdu-ASR-SOTA' target='_blank'>Source Code on DagsHub</a></p><p style='text-align: center'><a href='https://huggingface.co/blog/fine-tune-xlsr-wav2vec2' target='_blank'>Fine-tuning XLS-R for Multi-Lingual ASR with 🤗 Transformers</a></p></center><center><img src='https://visitor-badge.glitch.me/badge?page_id=kingabzpro/real-time-Urdu-ASR' alt='visitor badge'></center></p>"
|
29 |
|
|
|
|
|
30 |
|
31 |
-
gr.Interface(
|
32 |
-
fn=transcribe,
|
33 |
-
inputs=
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
|
|
|
|
|
|
|
|
|
|
44 |
theme='EveryPizza/Cartoony-Gradio-Theme',
|
45 |
-
live=True
|
|
|
|
|
|
|
|
2 |
import gradio as gr
|
3 |
import time
|
4 |
import unicodedata
|
|
|
5 |
|
6 |
+
p = pipeline("automatic-speech-recognition", model="kingabzpro/wav2vec2-large-xls-r-300m-Urdu")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
|
8 |
+
def transcribe(audio):
|
9 |
+
text = p(audio)["text"]
|
10 |
+
transcription = unicodedata.normalize("NFC", text)
|
11 |
+
return transcription
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
|
13 |
+
audio_input = gr.inputs.Audio(source="microphone", type="file", label="Upload audio file")
|
14 |
+
text_output = gr.outputs.Textbox(label="Transcription")
|
15 |
|
16 |
+
interface = gr.Interface(
|
17 |
+
fn=transcribe,
|
18 |
+
inputs=audio_input,
|
19 |
+
outputs=text_output,
|
20 |
+
title="Real-Time Urdu ASR",
|
21 |
+
description="""
|
22 |
+
<p>
|
23 |
+
<center>
|
24 |
+
This model is a fine-tuned version of facebook/wav2vec2-xls-r-300m on the common_voice dataset.
|
25 |
+
</center>
|
26 |
+
</p>
|
27 |
+
<center>
|
28 |
+
<img src="https://huggingface.co/spaces/kingabzpro/real-time-Urdu-ASR/resolve/main/Images/cover.jpg" alt="logo" width="550"/>
|
29 |
+
</center>
|
30 |
+
""",
|
31 |
+
article="""
|
32 |
+
<p style='text-align: center'><a href='https://dagshub.com/kingabzpro/Urdu-ASR-SOTA' target='_blank'>Source Code on DagsHub</a></p><p style='text-align: center'><a href='https://huggingface.co/blog/fine-tune-xlsr-wav2vec2' target='_blank'>Fine-tuning XLS-R for Multi-Lingual ASR with 🤗 Transformers</a></p></center><center><img src='https://visitor-badge.glitch.me/badge?page_id=kingabzpro/real-time-Urdu-ASR' alt='visitor badge'></center></p>
|
33 |
+
""",
|
34 |
theme='EveryPizza/Cartoony-Gradio-Theme',
|
35 |
+
live=True
|
36 |
+
)
|
37 |
+
|
38 |
+
interface.launch()
|