papasega commited on
Commit
34d644e
1 Parent(s): 9876963

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -10
app.py CHANGED
@@ -22,22 +22,18 @@ import gradio as gr
22
 
23
  model = EncoderASR.from_hparams("speechbrain/asr-wav2vec2-dvoice-wolof")
24
 
25
- def transcribe(stream, new_chunk):
26
- sr, y = new_chunk
27
  y = y.astype(np.float32)
28
  y /= np.max(np.abs(y))
29
 
30
- if stream is not None:
31
- stream = np.concatenate([stream, y])
32
- else:
33
- stream = y
34
- return stream, transcriber({"sampling_rate": sr, "raw": stream})["text"]
35
 
36
  demo = gr.Interface(
37
  transcribe,
38
- ["state", gr.Audio(sources=["microphone"], streaming=True)],
39
- ["state", "text"],
40
- live=True,
41
  )
42
 
43
  demo.launch()
 
22
 
23
  model = EncoderASR.from_hparams("speechbrain/asr-wav2vec2-dvoice-wolof")
24
 
25
+ def transcribe(audio):
26
+ sr, y = audio
27
  y = y.astype(np.float32)
28
  y /= np.max(np.abs(y))
29
 
30
+ return transcriber({"sampling_rate": sr, "raw": y})["text"]
31
+
 
 
 
32
 
33
  demo = gr.Interface(
34
  transcribe,
35
+ gr.Audio(sources=["microphone"]),
36
+ "text",
 
37
  )
38
 
39
  demo.launch()