from transformers import pipeline import gradio as gr import torch pipe = pipeline( task="automatic-speech-recognition", model="iamgarvit/whisper-small-hi-asr", device=0 if torch.cuda.is_available() else -1, ) def transcribe(audio_path): if audio_path is None: return "" result = pipe(audio_path) return result["text"] demo = gr.Interface( fn=transcribe, inputs=gr.Audio(type="filepath", label="Speak or upload audio"), outputs=gr.Textbox(label="Transcription"), title="Whisper Small Hindi ASR", description=( "Hindi ASR (Automatic Speech Recognition) using a fine-tuned Whisper-small model. " "To use the microphone, click **Record** and allow microphone access when prompted " "by your browser. If microphone access is unavailable, you can upload an audio file instead." ), ) demo.launch()