File size: 522 Bytes
20ae1ed
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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"""
    result = model.transcribe(audio)
    return result["text"]

# Gradio UI with Microphone
gr.Interface(
    fn=transcribe,
    inputs=gr.Audio(source="microphone", type="filepath"),
    outputs="text",
    title="Whisper Speech-to-Text",
    description="Speak into the microphone and get text output.",
).launch()