import whisper | |
import gradio as gr | |
# Load the Whisper model (you can change "base" to "small", "medium", or "large" depending on your needs) | |
model = whisper.load_model("base") | |
# Define the transcription function | |
def transcribe(audio_file): | |
# Transcribe the audio file using Whisper | |
result = model.transcribe(audio_file) | |
return result["text"] | |
# Gradio Interface for uploading audio and returning the transcription | |
iface = gr.Interface( | |
fn=transcribe, | |
inputs=gr.Audio(type="filepath"), # Use 'filepath' to get the path to the uploaded file | |
outputs="text", | |
title="Whisper Transcription", | |
description="Upload an audio or video file to transcribe." | |
) | |
iface.launch() | |