bryandts commited on
Commit
8e4caba
1 Parent(s): ac814d0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -20
app.py CHANGED
@@ -1,25 +1,8 @@
1
- from transformers import WhisperForConditionalGeneration, WhisperProcessor
2
  import gradio as gr
3
 
4
- model = WhisperForConditionalGeneration.from_pretrained("bryandts/whisper-base-en-india-accent-svarah")
5
- processor = WhisperProcessor.from_pretrained("openai/whisper-base")
6
-
7
- model.config.forced_decoder_ids = None
8
-
9
-
10
 
11
  def transcribe(audio):
12
- input_features = processor(audio["array"], sampling_rate=audio["sampling_rate"], return_tensors="pt").input_features
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
- iface.launch()
 
 
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()