Spaces:
Runtime error
Runtime error
Initial ASR commit
Browse files- app.py +22 -0
- requirements.txt +2 -0
app.py
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import pipeline
|
2 |
+
import gradio as gr
|
3 |
+
|
4 |
+
model = pipeline("automatic-speech-recognition")
|
5 |
+
|
6 |
+
def transcribe_audio(mic=None, file=None):
|
7 |
+
if mic is not None:
|
8 |
+
audio = mic
|
9 |
+
elif file is not None:
|
10 |
+
audio = file
|
11 |
+
else:
|
12 |
+
return("You must either provide a mic recording or a file")
|
13 |
+
transcription = model(audio)["text"]
|
14 |
+
return transcription
|
15 |
+
|
16 |
+
gr.Interface(
|
17 |
+
fn=transcribe_audio,
|
18 |
+
inputs=[gr.Audio(source="microphone", type="filepath", optional=True),
|
19 |
+
gr.Audio(source ="upload", type="filepath", optional=True)],
|
20 |
+
outputs="text",
|
21 |
+
css=".footer{display:none !important}"
|
22 |
+
).launch()
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
torch
|
2 |
+
transformers
|