Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -22,15 +22,20 @@ import gradio as gr
|
|
| 22 |
|
| 23 |
model = EncoderASR.from_hparams("speechbrain/asr-wav2vec2-dvoice-wolof")
|
| 24 |
|
| 25 |
-
def transcribe(
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
|
| 31 |
demo = gr.Interface(
|
| 32 |
transcribe,
|
| 33 |
-
["state", gr.
|
| 34 |
["state", "text"],
|
| 35 |
live=True,
|
| 36 |
)
|
|
|
|
| 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 |
)
|