fixed stuff?

This commit is contained in:
Patrick_Pluto 2024-09-26 08:33:11 +02:00
parent 42b12f73b4
commit 6d03e1fafc
2 changed files with 5 additions and 3 deletions

View file

@ -100,7 +100,7 @@ class API:
@self.app.route('/interstellar_ai/api/voice_recognition', methods=['POST'])
def voice_recognition():
recognition_type = request.args.get('type')
audio = request.args.get('audio_data')
audio = request.files['audio']
option = request.args.get('option')
if recognition_type == "basic":
return jsonify({'status': 200, 'response': self.voice.basic_recognition(audio, option)})

View file

@ -6,8 +6,10 @@ class VoiceRecognition:
def basic_recognition(audio, option):
r = sr.Recognizer()
if option == "online":
return r.recognize_google_cloud(audio)
with audio as source:
return r.recognize_google_cloud(source)
elif option == "offline":
return r.recognize_sphinx(audio)
with audio as source:
return r.recognize_sphinx(source)
return False