import gradio as gr | |
import whisper | |
# Load the Whisper model (you can change to "base", "small", "medium", etc.) | |
model = whisper.load_model("base") | |
# Function to process the audio file and transcribe | |
def transcribe_audio(audio): | |
# Transcribe the audio using Whisper | |
result = model.transcribe(audio) | |
return result['text'] | |
# Create a Gradio interface for audio transcription | |
iface = gr.Interface( | |
fn=transcribe_audio, # The function that will process the audio | |
inputs=gr.Audio(source="upload", type="filepath"), # Upload audio input | |
outputs="text", # Output transcription as text | |
title="Whisper Audio Transcription", # Title of the interface | |
description="Upload an audio file and get the transcription using OpenAI's Whisper model." # Description | |
) | |
# Launch the interface | |
iface.launch() | |