import gradio as gr
import whisper

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

def transcribe(audio_path):
    """Transcribes the given audio file using OpenAI's Whisper model."""
    if audio_path is None:
        return "No audio file provided."

    # Load and transcribe the audio
    result = model.transcribe(audio_path)
    return result["text"]

# Create Gradio interface
app = gr.Interface(fn=transcribe, inputs=gr.Audio(type="filepath"), outputs="text")
app.launch()