Spaces:
Runtime error
Runtime error
bofenghuang
commited on
Commit
β’
fe32065
1
Parent(s):
694d4c4
add streaming mode
Browse files- README.md +3 -3
- app.py +18 -8
- packages.txt +1 -0
- requirements.txt +4 -0
README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
---
|
2 |
-
title:
|
3 |
-
emoji:
|
4 |
-
colorFrom:
|
5 |
colorTo: pink
|
6 |
sdk: gradio
|
7 |
sdk_version: 3.9
|
|
|
1 |
---
|
2 |
+
title: Automatic Speech Recognition in French
|
3 |
+
emoji: π
|
4 |
+
colorFrom: blue
|
5 |
colorTo: pink
|
6 |
sdk: gradio
|
7 |
sdk_version: 3.9
|
app.py
CHANGED
@@ -3,16 +3,26 @@ import gradio as gr
|
|
3 |
|
4 |
pipe = pipeline(model="bhuang/wav2vec2-xls-r-1b-cv9-fr")
|
5 |
|
6 |
-
def transcribe(audio):
|
7 |
-
text = pipe(audio)["text"]
|
8 |
-
|
|
|
9 |
|
10 |
iface = gr.Interface(
|
11 |
fn=transcribe,
|
12 |
-
inputs=
|
13 |
-
|
14 |
-
|
15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
)
|
17 |
|
18 |
-
iface.launch()
|
|
|
|
3 |
|
4 |
pipe = pipeline(model="bhuang/wav2vec2-xls-r-1b-cv9-fr")
|
5 |
|
6 |
+
def transcribe(audio, state=""):
|
7 |
+
text = pipe(audio, chunk_length_s=5, stride_length_s=1)["text"]
|
8 |
+
state += text + " "
|
9 |
+
return state, state
|
10 |
|
11 |
iface = gr.Interface(
|
12 |
fn=transcribe,
|
13 |
+
inputs=[
|
14 |
+
gr.Audio(source="microphone", type="filepath", streaming=True, label="Record something..."),
|
15 |
+
"state"
|
16 |
+
],
|
17 |
+
outputs=[
|
18 |
+
"textbox",
|
19 |
+
"state"
|
20 |
+
],
|
21 |
+
title="Realtime ASR in French",
|
22 |
+
# description="Realtime demo for French ASR using a fine-tuned wav2vec2 model.",
|
23 |
+
allow_flagging="never",
|
24 |
+
live=True
|
25 |
)
|
26 |
|
27 |
+
# iface.launch()
|
28 |
+
iface.launch(server_name="0.0.0.0", share=True)
|
packages.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
ffmpeg
|
requirements.txt
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
transformers
|
2 |
+
torch
|
3 |
+
pyctcdecode
|
4 |
+
pypi-kenlm
|