zahoor54321 commited on
Commit
4fe4722
1 Parent(s): e72779d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -36
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
- def transcribe(audio, state=""):
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
- description = """
18
- <p>
19
- <center>
20
- This model is a fine-tuned version of facebook/wav2vec2-xls-r-300m on the common_voice dataset.
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
- gr.Audio(source="microphone", type="filepath", streaming=True),
35
- "state"
36
- ],
37
- outputs=[
38
- "textbox",
39
- "state"
40
- ],
41
- title=title,
42
- description=description,
43
- article=article,
 
 
 
 
 
44
  theme='EveryPizza/Cartoony-Gradio-Theme',
45
- live=True).launch()
 
 
 
 
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()