|
import gradio as gr |
|
import whisper |
|
import os |
|
|
|
|
|
model = whisper.load_model("base") |
|
|
|
|
|
def transcribe_audio(audio_file): |
|
|
|
if audio_file is None: |
|
return "No audio file provided." |
|
|
|
|
|
print(f"Audio file path: {audio_file}") |
|
|
|
if not os.path.exists(audio_file): |
|
return "The audio file does not exist or is inaccessible." |
|
|
|
|
|
result = model.transcribe(audio_file) |
|
transcription = result['text'] |
|
|
|
return transcription |
|
|
|
|
|
iface = gr.Interface( |
|
fn=transcribe_audio, |
|
inputs=gr.Audio(type="filepath"), |
|
outputs="text", |
|
title="Whisper Audio Transcription", |
|
description="Upload an audio file and get the transcription." |
|
) |
|
|
|
|
|
iface.launch(share=True) |
|
|