Spaces:
Running
Running
File size: 1,227 Bytes
305c59b 1e0f1bc cd0a212 1e0f1bc cd0a212 1e0f1bc |
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 38 39 |
import gradio as gr
from transformers import pipeline
# Specify the correct model name and adjust the loading configuration
model_name = "Subhaka/whisper-small-Sinhala-Fine_Tune"
# Define the pipeline with `use_safetensors=True`
def load_pipeline():
return pipeline(
"automatic-speech-recognition",
model=model_name,
use_safetensors=True, # Ensure compatibility with safetensors
)
# Load the model pipeline
transcriber = load_pipeline()
# Define a transcription function
def transcribe_audio(audio_file):
try:
transcription = transcriber(audio_file)["text"]
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 Whisper model fine-tuned by Subhaka.",
allow_flagging="never"
)
# Launch the Gradio app
if __name__ == "__main__":
interface.launch(server_name="0.0.0.0", server_port=7860, share=True)
|