Spaces:
Sleeping
Sleeping
truongghieu
commited on
Commit
•
b576a68
1
Parent(s):
2cca408
Update app.py
Browse files
app.py
CHANGED
@@ -4,7 +4,8 @@ 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()
|
9 |
|
10 |
try:
|
@@ -15,7 +16,5 @@ def recognize_speech(audio_data):
|
|
15 |
except sr.RequestError as e:
|
16 |
return f"Could not request results from Google Speech Recognition service; {e}"
|
17 |
|
18 |
-
|
19 |
-
|
20 |
-
iface = gr.Interface(fn=recognize_speech, inputs=input_audio, outputs="text")
|
21 |
iface.launch()
|
|
|
4 |
|
5 |
|
6 |
def recognize_speech(audio_data):
|
7 |
+
audio_data = sr.AudioData(audio_data, sample_rate=16000,sample_width=2).get_wav_data(convert_rate=16000, convert_width=2)
|
8 |
+
|
9 |
recognizer = sr.Recognizer()
|
10 |
|
11 |
try:
|
|
|
16 |
except sr.RequestError as e:
|
17 |
return f"Could not request results from Google Speech Recognition service; {e}"
|
18 |
|
19 |
+
iface = gr.Interface(fn=recognize_speech, inputs="microphone", outputs="text")
|
|
|
|
|
20 |
iface.launch()
|