Update app.py
Browse files
app.py
CHANGED
@@ -1,25 +1,8 @@
|
|
1 |
-
from transformers import WhisperForConditionalGeneration, WhisperProcessor
|
2 |
import gradio as gr
|
3 |
|
4 |
-
|
5 |
-
processor = WhisperProcessor.from_pretrained("openai/whisper-base")
|
6 |
-
|
7 |
-
model.config.forced_decoder_ids = None
|
8 |
-
|
9 |
-
|
10 |
|
11 |
def transcribe(audio):
|
12 |
-
|
13 |
-
predicted_ids = model.generate(input_features)
|
14 |
-
transcription = processor.batch_decode(predicted_ids, skip_special_tokens=True)
|
15 |
-
return transcription[0]
|
16 |
-
|
17 |
-
iface = gr.Interface(
|
18 |
-
fn=transcribe,
|
19 |
-
inputs=gr.Audio(source="microphone", type="filepath"),
|
20 |
-
outputs="text",
|
21 |
-
title="Whisper Base English",
|
22 |
-
description="Realtime India-accented English speech recognition using a fine-tuned Whisper base model.",
|
23 |
-
)
|
24 |
|
25 |
-
|
|
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
+
whisper = gr.load("models/bryandts/whisper-base-en-india-accent-svarah")
|
|
|
|
|
|
|
|
|
|
|
4 |
|
5 |
def transcribe(audio):
|
6 |
+
return whisper(audio).replace("AutomaticSpeechRecognitionOutput(text=' ", "").replace("', chunks=None)", "")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
|
8 |
+
gr.Interface(transcribe, gr.Audio(type="filepath"), gr.Textbox()).launch()
|