Whisper-Konkani / app.py
thak123's picture
Update app.py
b357c71
raw
history blame
903 Bytes
from transformers import WhisperTokenizer
tokenizer = WhisperTokenizer.from_pretrained("openai/whisper-small", language="marathi", task="transcribe")
from transformers import pipeline
import gradio as gr
import torch
pipe = pipeline(model="thak123/whisper-small-gom",
task="automatic-speech-recognition", tokenizer= tokenizer) # change to "your-username/the-name-you-picked"
pipe.model.config.forced_decoder_ids = (
pipe.tokenizer.get_decoder_prompt_ids(
language="marathi", task="transcribe"
)
)
def transcribe(audio):
text = pipe(audio)["text"]
return text
iface = gr.Interface(
fn=transcribe,
inputs=gr.Audio(source="microphone", type="filepath"),
outputs="text",
title="Whisper Small Konkani",
description="Realtime demo for Konkani speech recognition using a fine-tuned Whisper small model.",
)
iface.launch()