| import gradio as gr |
| from transformers import pipeline |
|
|
| |
| pipe = pipeline( |
| "automatic-speech-recognition", |
| model="lyimo/whisper-small-sw-badili-v4" |
| ) |
|
|
| def transcribe(audio): |
| if audio is None: |
| return "" |
| |
| |
| result = pipe( |
| audio, |
| generate_kwargs={"language": "swahili"} |
| ) |
| return result["text"] |
|
|
| |
| interface = gr.Interface( |
| fn=transcribe, |
| inputs=gr.Audio(sources=["microphone", "upload"], type="filepath"), |
| outputs=gr.Textbox(label="Transcription"), |
| title="Swahili Speech Recognition", |
| description="Record or upload Swahili audio to see the Whisper transcription", |
| allow_flagging="never" |
| ) |
|
|
| |
| interface.launch() |