import gradio as gr from transformers import pipeline # Load ASR model transcriber = pipeline( "automatic-speech-recognition", model="openai/whisper-base" ) # Transcription function def transcribe_audio(audio): if audio is None: return "No audio recorded. Please record something." result = transcriber(audio) return result["text"] # Create interface interface = gr.Interface( fn=transcribe_audio, inputs=gr.Audio(sources=["microphone"], type="filepath"), outputs=gr.Textbox(label="Transcription"), title="Automatic Speech Recognition", description="Click the microphone icon, speak, then click stop. Your speech will be transcribed." ) # Launch interface.launch()