Spaces:
Runtime error
Runtime error
example
Browse files- .gitignore +1 -0
- README.md +3 -3
- app.py +17 -5
- requirements.txt +1 -0
.gitignore
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
venv
|
README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
colorTo: pink
|
| 6 |
sdk: gradio
|
| 7 |
sdk_version: 2.9.4
|
|
|
|
| 1 |
---
|
| 2 |
+
title: Speech Recognition Example
|
| 3 |
+
emoji: 🗣
|
| 4 |
+
colorFrom: red
|
| 5 |
colorTo: pink
|
| 6 |
sdk: gradio
|
| 7 |
sdk_version: 2.9.4
|
app.py
CHANGED
|
@@ -4,8 +4,20 @@ from transformers import pipeline
|
|
| 4 |
|
| 5 |
model = pipeline(task="automatic-speech-recognition",
|
| 6 |
model="facebook/s2t-medium-librispeech-asr")
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
model = pipeline(task="automatic-speech-recognition",
|
| 6 |
model="facebook/s2t-medium-librispeech-asr")
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
def predict_speech_to_text(audio):
|
| 10 |
+
prediction = model(audio)
|
| 11 |
+
text = prediction['text']
|
| 12 |
+
return text
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
gr.Interface(fn=predict_speech_to_text,
|
| 16 |
+
title="Automatic Speech Recognition (ASR)",
|
| 17 |
+
inputs=gr.inputs.Audio(
|
| 18 |
+
source="microphone", type="filepath", label="Input"),
|
| 19 |
+
outputs=gr.outputs.Textbox(label="Output"),
|
| 20 |
+
description="Using pipeline with Facebook S2T for ASR.",
|
| 21 |
+
examples=['ljspeech.wav'],
|
| 22 |
+
allow_flagging='never'
|
| 23 |
+
).launch()
|
requirements.txt
CHANGED
|
@@ -2,3 +2,4 @@ torch
|
|
| 2 |
torchaudio
|
| 3 |
transformers
|
| 4 |
sentencepiece
|
|
|
|
|
|
| 2 |
torchaudio
|
| 3 |
transformers
|
| 4 |
sentencepiece
|
| 5 |
+
gradio
|