Spaces:
Sleeping
Sleeping
juliuserictuliao
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -35,7 +35,10 @@ def asr_transcript(audio):
|
|
35 |
|
36 |
def real_time_asr(audio, state=""):
|
37 |
try:
|
38 |
-
audio
|
|
|
|
|
|
|
39 |
transcription = asr_transcript(audio)
|
40 |
state += " " + transcription
|
41 |
return state, state
|
@@ -45,7 +48,7 @@ def real_time_asr(audio, state=""):
|
|
45 |
# Create the Gradio interface
|
46 |
iface = gr.Interface(
|
47 |
fn=real_time_asr,
|
48 |
-
inputs=[gr.Audio(
|
49 |
outputs=[gr.Textbox(), gr.State()],
|
50 |
live=True,
|
51 |
title="Real-Time ASR using Wav2Vec 2.0",
|
|
|
35 |
|
36 |
def real_time_asr(audio, state=""):
|
37 |
try:
|
38 |
+
if isinstance(audio, dict) and 'array' in audio:
|
39 |
+
audio = audio['array']
|
40 |
+
else:
|
41 |
+
audio = np.array(audio)
|
42 |
transcription = asr_transcript(audio)
|
43 |
state += " " + transcription
|
44 |
return state, state
|
|
|
48 |
# Create the Gradio interface
|
49 |
iface = gr.Interface(
|
50 |
fn=real_time_asr,
|
51 |
+
inputs=[gr.Audio(streaming=True), gr.State()],
|
52 |
outputs=[gr.Textbox(), gr.State()],
|
53 |
live=True,
|
54 |
title="Real-Time ASR using Wav2Vec 2.0",
|