File size: 739 Bytes
0f2d91c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import gradio as gr
import whisper

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

def transcribe_audio(audio):
    """
    This function takes in an audio file and returns its transcription.
    """
    # Transcribe the audio using Whisper
    result = model.transcribe(audio)
    return result['text']

# Create the Gradio interface for real-time transcription
interface = gr.Interface(
    fn=transcribe_audio,  # Function to process the audio input
    inputs=gr.Audio(source="microphone", type="filepath"),  # Real-time audio input from the microphone
    outputs="text",  # Display the transcription as text
    live=True  # Enables real-time transcription
)

# Launch the Gradio interface
interface.launch(share=True)