Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import pipeline
|
2 |
+
from transformers import WhisperForConditionalGeneration, WhisperProcessor
|
3 |
+
from transformers import WhisperTokenizer
|
4 |
+
from transformers import WhisperFeatureExtractor
|
5 |
+
import gradio as gr
|
6 |
+
|
7 |
+
tokenizer = WhisperTokenizer.from_pretrained("openai/whisper-small", language="Spanish", task="transcribe")
|
8 |
+
model = WhisperForConditionalGeneration.from_pretrained("mirari/whisper-small-es")
|
9 |
+
feature_extractor = WhisperFeatureExtractor.from_pretrained("openai/whisper-small")
|
10 |
+
|
11 |
+
pipe = pipeline(task="automatic-speech-recognition",model=model, tokenizer=tokenizer,feature_extractor=feature_extractor)
|
12 |
+
|
13 |
+
|
14 |
+
|
15 |
+
def transcribe(audio):
|
16 |
+
text = pipe(audio)["text"]
|
17 |
+
return text
|
18 |
+
|
19 |
+
iface = 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 |
+
|
27 |
+
iface.launch()
|