File size: 728 Bytes
20ae1ed
 
 
 
 
 
 
 
fb41c74
 
 
20ae1ed
 
 
7d99d92
 
fb41c74
072fff6
20ae1ed
fb41c74
20ae1ed
 
fb41c74
7d99d92
e2fd9c8
7d99d92
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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)