Spaces:
Running
Running
import gradio as gr | |
from faster_whisper import WhisperModel | |
# Load the Faster Whisper model | |
model_name = "Systran/faster-whisper-large-v3" | |
model = WhisperModel(model_name, device="cpu") # Use "cuda" if you have a GPU | |
# Define a transcription function | |
def transcribe_audio(audio_file): | |
try: | |
segments, info = model.transcribe(audio_file, beam_size=5) # Customize parameters as needed | |
transcription = " ".join([segment.text for segment in segments]) | |
return transcription | |
except Exception as e: | |
return f"Error: {str(e)}" | |
# Create Gradio interface | |
interface = gr.Interface( | |
fn=transcribe_audio, | |
inputs=gr.Audio(source="upload", type="filepath", label="Upload Audio"), | |
outputs=gr.Textbox(label="Transcription"), | |
title="Sinhala Audio-to-Text Transcription", | |
description="Upload an audio file and get the transcription in Sinhala using the Faster Whisper model.", | |
allow_flagging="never" | |
) | |
# Launch the Gradio app | |
if __name__ == "__main__": | |
interface.launch(server_name="0.0.0.0", server_port=7860, share=True) | |