Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -43,16 +43,16 @@ def listen(audio):
|
|
| 43 |
sample_width = audio_data.dtype.itemsize
|
| 44 |
|
| 45 |
|
| 46 |
-
#
|
| 47 |
-
|
| 48 |
-
|
| 49 |
|
| 50 |
-
#
|
| 51 |
-
|
| 52 |
-
#
|
| 53 |
-
|
| 54 |
|
| 55 |
-
|
| 56 |
return sample_width
|
| 57 |
|
| 58 |
gr.Interface(fn=listen,inputs="audio",outputs="text").launch()
|
|
|
|
| 43 |
sample_width = audio_data.dtype.itemsize
|
| 44 |
|
| 45 |
|
| 46 |
+
# create BytesIO object from the audio data
|
| 47 |
+
audio_bytesio = io.BytesIO()
|
| 48 |
+
np.savetxt(audio_bytesio, audio_data, fmt="%d")
|
| 49 |
|
| 50 |
+
# create AudioData object from the BytesIO object
|
| 51 |
+
with sr.AudioData(audio_bytesio.getvalue(), sample_rate=sample_rate, sample_width=sample_width) as source:
|
| 52 |
+
# recognize speech using Google Speech Recognition
|
| 53 |
+
audio = r.record(source)
|
| 54 |
|
| 55 |
+
audio_text = r.recognize_google(audio,language="ur")
|
| 56 |
return sample_width
|
| 57 |
|
| 58 |
gr.Interface(fn=listen,inputs="audio",outputs="text").launch()
|