Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
+
import time
|
4 |
+
|
5 |
+
pipe = pipeline("automatic-speech-recognition", model="openai/whisper-base.en")
|
6 |
+
|
7 |
+
def transcribe(audio, state=""):
|
8 |
+
print(audio)
|
9 |
+
time.sleep(2)
|
10 |
+
text = pipe(audio)["text"]
|
11 |
+
state += text + " "
|
12 |
+
return state, state
|
13 |
+
|
14 |
+
|
15 |
+
with gr.Blocks() as demo:
|
16 |
+
state = gr.State(value="")
|
17 |
+
with gr.Row():
|
18 |
+
with gr.Column():
|
19 |
+
audio = gr.Audio(source="microphone", type="filepath")
|
20 |
+
with gr.Column():
|
21 |
+
textbox = gr.Textbox()
|
22 |
+
audio.stream(fn=transcribe, inputs=[audio, state], outputs=[textbox, state])
|
23 |
+
|
24 |
+
demo.launch(debug=True)
|