Spaces:
Sleeping
Sleeping
File size: 849 Bytes
22060a9 6f71fdf 22060a9 ac93905 22060a9 |
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 |
import gradio as gr
import whisper
# Load the smallest model variant for fast CPU inference
model = whisper.load_model("base")
def transcribe_audio(audio_file):
"""
Transcribe the audio file using Whisper
"""
try:
# Transcribe the audio
result = model.transcribe(audio_file)
return result["text"]
except Exception as e:
return f"Error during transcription: {str(e)}"
# Create the Gradio interface
interface = gr.Interface(
fn=transcribe_audio,
inputs=gr.Audio(type="filepath"), # Updated syntax
outputs="text",
title="Speech to Text Converter",
description="Upload an audio file to convert speech to text using Whisper",
examples=[["sample1.mp3"], ["sample2.wav"]],
cache_examples=True
)
# Launch the app
if __name__ == "__main__":
interface.launch(share=True) |