juliuserictuliao commited on
Commit
9e8f0e1
·
verified ·
1 Parent(s): 096dea5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -35,7 +35,10 @@ def asr_transcript(audio):
35
 
36
  def real_time_asr(audio, state=""):
37
  try:
38
- audio = np.array(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(source="microphone", streaming=True), gr.State()],
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",