File size: 830 Bytes
9a52329
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
26
27
28
29
30
31
# Load model directly
from transformers import AutoProcessor, AutoModelForSpeechSeq2Seq

processor = AutoProcessor.from_pretrained("mustafoyev202/whisper-uz-adv")
model = AutoModelForSpeechSeq2Seq.from_pretrained("mustafoyev202/whisper-uz-adv")


from transformers import pipeline
import gradio as gr

pipe = pipeline(
    task="automatic-speech-recognition", 
    model=model, 
    tokenizer=processor.tokenizer, 
    feature_extractor=processor.feature_extractor, 
    return_timestamps=True 
)

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

iface = gr.Interface(
    fn=transcribe,
    inputs=gr.Audio(type="filepath"),
    outputs="text",
    title="Whisper Small Uzbek",
    description="Realtime demo for Uzbek speech recognition using a fine-tuned Whisper small model.",
)

iface.launch(share=True)