File size: 878 Bytes
c60e096
87107a2
c60e096
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1a8b6da
c60e096
 
 
 
 
 
 
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
import gradio as gr
import whisper

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

def transcribe(audio_file):
    # Process the audio file
    audio = whisper.load_audio(audio_file.name)
    audio = whisper.pad_or_trim(audio)

    # Make predictions
    mel = whisper.log_mel_spectrogram(audio).to(model.device)
    options = whisper.DecodingOptions(fp16=False)
    result = whisper.decode(model, mel, options)

    # Return the transcription
    return result.text

# Create the Gradio interface
iface = gr.Interface(fn=transcribe,
                     inputs=gr.Audio(sources="upload", type="filepath"),
                     outputs="text",
                     title="Whisper Transcription",
                     description="Upload an audio file to transcribe it using OpenAI's Whisper model.")

# Launch the app
if __name__ == "__main__":
    iface.launch()