joheras/speech-recognition
0
1from transformers import pipeline2from transformers import WhisperForConditionalGeneration, WhisperProcessor3from transformers import WhisperTokenizer4from transformers import WhisperFeatureExtractor5import gradio as gr6 7tokenizer = WhisperTokenizer.from_pretrained("openai/whisper-small", language="Spanish", task="transcribe")8model = WhisperForConditionalGeneration.from_pretrained("mirari/whisper-small-es")9feature_extractor = WhisperFeatureExtractor.from_pretrained("openai/whisper-small")10 11pipe = pipeline(task="automatic-speech-recognition",model=model, tokenizer=tokenizer,feature_extractor=feature_extractor) 12 13 14 15def transcribe(audio):16 text = pipe(audio)["text"]17 return text18 19iface = gr.Interface(20 fn=transcribe, 21 inputs=gr.Audio(source="microphone", type="filepath"), 22 outputs="text",23 title="Whisper Small Hindi",24 description="Realtime demo for Spanish speech recognition using a fine-tuned Whisper small model.",25)26 27iface.launch()