File size: 1,185 Bytes
2459bb2 d9cee8f 2459bb2 ae87c60 d9cee8f ae87c60 d9cee8f a62c4d4 d9cee8f 2a84333 d9cee8f ae87c60 2a84333 ae87c60 d9cee8f 2459bb2 d9cee8f 2459bb2 d9cee8f |
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 31 32 33 34 35 36 37 |
import gradio as gr
import whisper
import os
# Load Whisper model
model = whisper.load_model("base")
# Function to transcribe audio file using Whisper
def transcribe_audio(audio_file):
# Check if the audio file exists and print the file path for debugging
if audio_file is None:
return "No audio file provided."
# Debugging: Print the file path to check if Gradio passes the file path correctly
print(f"Audio file path: {audio_file}")
if not os.path.exists(audio_file):
return "The audio file does not exist or is inaccessible."
# Load and transcribe the audio file
result = model.transcribe(audio_file)
transcription = result['text']
return transcription
# Gradio interface for transcription
iface = gr.Interface(
fn=transcribe_audio, # Function to process audio file
inputs=gr.Audio(type="filepath"), # Audio upload, pass file path
outputs="text", # Output the transcription as text
title="Whisper Audio Transcription",
description="Upload an audio file and get the transcription."
)
# Launch the Gradio interface with a shareable link (required for Colab)
iface.launch(share=True)
|