import whisper import gradio as gr # Load Whisper Model model = whisper.load_model("small") # Change to "base", "medium", or "large" if needed def transcribe(audio): """Transcribe Speech to Text""" if audio is None: return "No audio detected. Please try again." result = model.transcribe(audio) return result["text"] # Corrected Gradio UI app = gr.Interface( fn=transcribe, inputs=gr.Audio(sources=["microphone"], type="filepath"), outputs="text", title="Whisper Speech-to-Text", description="Click 'Record', speak into the microphone, then stop recording to get text output.", allow_flagging="never" ) app.launch(server_name="0.0.0.0", server_port=7860, share=True)