Sammau commited on
Commit
eeffd0f
·
verified ·
1 Parent(s): 37867c7

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -0
app.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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="Sammau/wav2vec2-large-xls-r-300m-dv-ng"
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 Sammau/wav2vec2-large-xls-r-300m-dv-ng."
22
+ )
23
+
24
+ if name == "main":
25
+ demo.launch()