truongghieu commited on
Commit
e37f379
1 Parent(s): c143727

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -1
app.py CHANGED
@@ -1,5 +1,8 @@
1
  import speech_recognition as sr
2
  import gradio as gr
 
 
 
3
  def recognize_speech(audio_data):
4
  audio_data = sr.AudioData(audio_data, sample_rate=16000,sample_width=2)
5
  recognizer = sr.Recognizer()
@@ -12,5 +15,7 @@ def recognize_speech(audio_data):
12
  except sr.RequestError as e:
13
  return f"Could not request results from Google Speech Recognition service; {e}"
14
 
15
- iface = gr.Interface(fn=recognize_speech, inputs="microphone", outputs="text")
 
 
16
  iface.launch()
 
1
  import speech_recognition as sr
2
  import gradio as gr
3
+ import numpy as np
4
+
5
+
6
  def recognize_speech(audio_data):
7
  audio_data = sr.AudioData(audio_data, sample_rate=16000,sample_width=2)
8
  recognizer = sr.Recognizer()
 
15
  except sr.RequestError as e:
16
  return f"Could not request results from Google Speech Recognition service; {e}"
17
 
18
+ input_audio = gr.inputs.Audio(source="microphone", type="numpy", label="Recording")
19
+
20
+ iface = gr.Interface(fn=recognize_speech, inputs=input_audio, outputs="text")
21
  iface.launch()