lorem commited on
Commit
d28fad4
·
verified ·
1 Parent(s): 4b0910a

Update app.py

Browse files

Transcribe func fixed

Files changed (1) hide show
  1. app.py +7 -4
app.py CHANGED
@@ -2,15 +2,18 @@ import gradio as gr
2
  import time
3
  from transformers import pipeline
4
 
5
- cls = pipeline('automatic-speech-recognition',model = "openai/whisper-tiny")
6
 
7
  def transcribe(audio):
8
- transcript = cls(audio)
9
- return transcript['text']
 
 
 
10
 
11
  demo = gr.Interface(
12
  transcribe,
13
  gr.Audio(sources=["microphone"]),
14
- "textbox"
15
  )
16
  demo.launch()
 
2
  import time
3
  from transformers import pipeline
4
 
5
+ transcriber = pipeline('automatic-speech-recognition',model = "openai/whisper-tiny")
6
 
7
  def transcribe(audio):
8
+ sr, y = audio
9
+ y = y.astype(np.float32)
10
+ y /= np.max(np.abs(y))
11
+
12
+ return transcriber({"sampling_rate": sr, "raw": y})["text"]
13
 
14
  demo = gr.Interface(
15
  transcribe,
16
  gr.Audio(sources=["microphone"]),
17
+ "text"
18
  )
19
  demo.launch()