forked from React-Group/interstellar_ai
fixed stuff?
This commit is contained in:
parent
42b12f73b4
commit
6d03e1fafc
2 changed files with 5 additions and 3 deletions
|
@ -100,7 +100,7 @@ class API:
|
||||||
@self.app.route('/interstellar_ai/api/voice_recognition', methods=['POST'])
|
@self.app.route('/interstellar_ai/api/voice_recognition', methods=['POST'])
|
||||||
def voice_recognition():
|
def voice_recognition():
|
||||||
recognition_type = request.args.get('type')
|
recognition_type = request.args.get('type')
|
||||||
audio = request.args.get('audio_data')
|
audio = request.files['audio']
|
||||||
option = request.args.get('option')
|
option = request.args.get('option')
|
||||||
if recognition_type == "basic":
|
if recognition_type == "basic":
|
||||||
return jsonify({'status': 200, 'response': self.voice.basic_recognition(audio, option)})
|
return jsonify({'status': 200, 'response': self.voice.basic_recognition(audio, option)})
|
||||||
|
|
|
@ -6,8 +6,10 @@ class VoiceRecognition:
|
||||||
def basic_recognition(audio, option):
|
def basic_recognition(audio, option):
|
||||||
r = sr.Recognizer()
|
r = sr.Recognizer()
|
||||||
if option == "online":
|
if option == "online":
|
||||||
return r.recognize_google_cloud(audio)
|
with audio as source:
|
||||||
|
return r.recognize_google_cloud(source)
|
||||||
elif option == "offline":
|
elif option == "offline":
|
||||||
return r.recognize_sphinx(audio)
|
with audio as source:
|
||||||
|
return r.recognize_sphinx(source)
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
Loading…
Reference in a new issue