File size: 872 Bytes
58a6f46
 
 
3df97f4
58a6f46
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3df97f4
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
30
31
32
# import gradio as gr

# gr.load("models/openai/whisper-large-v3").launch()
import gradio as gr
import whisper

# Load the Whisper model
model = whisper.load_model("large")

def transcribe_audio(audio):
    # Load the audio file
    audio = whisper.load_audio(audio)
    # Transcribe the audio using Whisper
    result = model.transcribe(audio)
    return result["text"]

# Create a Gradio interface with both microphone and file upload inputs
interface = gr.Interface(
    fn=transcribe_audio,
    inputs=[
        gr.Audio(source="microphone", type="filepath", label="Record using Microphone"),
        gr.Audio(source="upload", type="filepath", label="Upload Audio File")
    ],
    outputs="text",
    live=True,
    description="Speak into your microphone or upload an audio file to see the transcription in real-time."
)

# Launch the Gradio app
interface.launch()