faizeeb commited on
Commit
28ce21c
·
1 Parent(s): c371b10

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -8
app.py CHANGED
@@ -43,16 +43,16 @@ def listen(audio):
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=1) 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()
 
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()