File size: 633 Bytes
eeffd0f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import os
os.environ["TRANSFORMERS_NO_TF"] = "1"

from transformers import pipeline
import gradio as gr

# Explicitly define the task so HF knows it's ASR
pipe = pipeline(
    task="automatic-speech-recognition",
    model="Sammau/wav2vec2-large-xls-r-300m-dv-ng"
)

def transcribe(audio):
    return pipe(audio)["text"]

demo = gr.Interface(
    fn=transcribe,
    inputs=gr.Audio(sources=["microphone", "upload"], type="filepath"),
    outputs="text",
    title="Wav2Vec2 ASR Demo",
    description="Realtime demo for English speech recognition using Sammau/wav2vec2-large-xls-r-300m-dv-ng."
)

if name == "main":
    demo.launch()