Update app.py
Browse files
app.py
CHANGED
|
@@ -1,19 +1,25 @@
|
|
| 1 |
import os
|
| 2 |
os.environ["TRANSFORMERS_NO_TF"] = "1"
|
|
|
|
| 3 |
from transformers import pipeline
|
| 4 |
import gradio as gr
|
| 5 |
|
| 6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
def transcribe(audio):
|
| 9 |
-
|
| 10 |
-
return text
|
| 11 |
|
| 12 |
demo = gr.Interface(
|
| 13 |
fn=transcribe,
|
| 14 |
-
inputs=gr.Audio(sources=["microphone","upload"], type="filepath"),
|
| 15 |
outputs="text",
|
| 16 |
-
title="
|
| 17 |
-
description="Realtime demo for English speech recognition
|
| 18 |
)
|
| 19 |
-
|
|
|
|
|
|
|
|
|
| 1 |
import os
|
| 2 |
os.environ["TRANSFORMERS_NO_TF"] = "1"
|
| 3 |
+
|
| 4 |
from transformers import pipeline
|
| 5 |
import gradio as gr
|
| 6 |
|
| 7 |
+
# Explicitly define the task so HF knows it's ASR
|
| 8 |
+
pipe = pipeline(
|
| 9 |
+
task="automatic-speech-recognition",
|
| 10 |
+
model="Devion333/wav2vec2-xls-r-300m-dv"
|
| 11 |
+
)
|
| 12 |
|
| 13 |
def transcribe(audio):
|
| 14 |
+
return pipe(audio)["text"]
|
|
|
|
| 15 |
|
| 16 |
demo = gr.Interface(
|
| 17 |
fn=transcribe,
|
| 18 |
+
inputs=gr.Audio(sources=["microphone", "upload"], type="filepath"),
|
| 19 |
outputs="text",
|
| 20 |
+
title="Wav2Vec2 ASR Demo",
|
| 21 |
+
description="Realtime demo for English speech recognition using Devion333/wav2vec2-xls-r-300m-dv."
|
| 22 |
)
|
| 23 |
+
|
| 24 |
+
if __name__ == "__main__":
|
| 25 |
+
demo.launch()
|