| import gradio as gr |
| from transformers import ( |
| WhisperProcessor, |
| WhisperForConditionalGeneration, |
| pipeline |
| ) |
|
|
| MODEL_ID = "TuniSpeech-AI/whisper-tunisian-dialect" |
|
|
| processor = WhisperProcessor.from_pretrained(MODEL_ID) |
| model = WhisperForConditionalGeneration.from_pretrained(MODEL_ID) |
|
|
| asr_pipe = pipeline( |
| "automatic-speech-recognition", |
| model=model, |
| tokenizer=processor.tokenizer, |
| feature_extractor=processor.feature_extractor |
| ) |
|
|
| def transcribe(audio): |
| result = asr_pipe(audio) |
| return result["text"] |
|
|
| iface = gr.Interface( |
| fn=transcribe, |
| inputs=gr.Audio(type="filepath"), |
| outputs="text", |
| title="Tunisian Dialect ASR" |
| ) |
|
|
| iface.launch() |