Sulav commited on
Commit
e8878dc
·
1 Parent(s): 854c230

trying an asr model with streaming microphone input

Browse files
Files changed (1) hide show
  1. app.py +17 -4
app.py CHANGED
@@ -1,8 +1,21 @@
1
  import gradio as gr
 
2
 
 
3
 
4
- def greet(name):
5
- return f"Hello {name}!!"
 
 
6
 
7
- app_interface = gr.Interface(fn=greet, inputs='text', outputs='text')
8
- app_interface.launch()
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
+ from transformers import pipeline
3
 
4
+ p = pipeline("automatic-speech-recognition", model='openai/whisper-small')
5
 
6
+ def transcribe(audio, state=""):
7
+ text = p(audio)
8
+ state += text["text"] + " "
9
+ return state, state
10
 
11
+ gr.Interface(
12
+ fn=transcribe,
13
+ inputs=[
14
+ gr.Audio(source="microphone", type="filepath", streaming=True),
15
+ "state"
16
+ ],
17
+ outputs=[
18
+ "textbox",
19
+ "state"
20
+ ],
21
+ live=True).launch()