| import gradio as gr | |
| from transformers import pipeline | |
| # Load fine-tuned Urdu Whisper model | |
| pipe = pipeline( | |
| "automatic-speech-recognition", | |
| model="hadiqa123/whisper-small-ur", | |
| device=-1 # Use 0 if GPU is available | |
| ) | |
| # Transcription function | |
| def transcribe(audio): | |
| if audio is None: | |
| return "β οΈ No audio input detected." | |
| result = pipe(audio) | |
| return result["text"] | |
| # Gradio interface | |
| gr.Interface( | |
| fn=transcribe, | |
| inputs=gr.Audio(type="filepath", label="ποΈ Record or Upload Urdu Audio"), | |
| outputs=gr.Textbox(label="π Transcribed Urdu Text"), | |
| title="π£οΈ Urdu Speech to Text Converter", | |
| ).launch() | |