truongghieu commited on
Commit
4a60c8d
1 Parent(s): 9ef6323

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -3
app.py CHANGED
@@ -4,9 +4,8 @@ import numpy as np
4
 
5
 
6
  def recognize_speech(audio_data):
7
- # nontype to numpy array
8
- audio_data = np.frombuffer(audio_data, dtype=np.int16)
9
- audio_data = sr.AudioData(audio_data, sample_rate=16000,sample_width=2).get_wav_data(convert_rate=16000, convert_width=2)
10
  recognizer = sr.Recognizer()
11
  try:
12
  text = recognizer.recognize_google(audio_data)
 
4
 
5
 
6
  def recognize_speech(audio_data):
7
+ # nontype to wav
8
+ audio_data = sr.AudioData(np.array(audio_data) , sample_rate=16000, sample_width=2)
 
9
  recognizer = sr.Recognizer()
10
  try:
11
  text = recognizer.recognize_google(audio_data)