Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from transformers import pipeline
|
| 2 |
+
import gradio as gr
|
| 3 |
+
import time
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
p = pipeline("automatic-speech-recognition")
|
| 7 |
+
|
| 8 |
+
def transcribe(audio, state=""):
|
| 9 |
+
time.sleep(3)
|
| 10 |
+
text = p(audio)["text"]
|
| 11 |
+
state += text + " "
|
| 12 |
+
return state, state
|
| 13 |
+
|
| 14 |
+
gr.Interface(
|
| 15 |
+
fn=transcribe,
|
| 16 |
+
inputs=[
|
| 17 |
+
gr.inputs.Audio(source="microphone", type="filepath"),
|
| 18 |
+
'state'
|
| 19 |
+
],
|
| 20 |
+
outputs=[
|
| 21 |
+
"textbox",
|
| 22 |
+
"state"
|
| 23 |
+
],
|
| 24 |
+
live=True).launch()
|
| 25 |
+
|