From 92d6688d64f6d1f61c4eda0091aac74f239f9435 Mon Sep 17 00:00:00 2001 From: Patrick_Pluto Date: Thu, 26 Sep 2024 09:32:14 +0200 Subject: [PATCH 1/2] super cool fix --- py/api.py | 3 ++- py/voice.py | 12 ++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/py/api.py b/py/api.py index 404f41d..52fe922 100644 --- a/py/api.py +++ b/py/api.py @@ -103,7 +103,8 @@ class API: audio = request.args.get('audio') option = request.args.get('option') if recognition_type == "basic": - return jsonify({'status': 200, 'response': self.voice.basic_recognition(audio, option)}) + text = self.voice.basic_recognition(audio, option) + return jsonify({'status': 200, 'response': text}) return jsonify({'status': 401, 'response': "Invalid type"}) diff --git a/py/voice.py b/py/voice.py index d589eab..ddf2a6d 100644 --- a/py/voice.py +++ b/py/voice.py @@ -4,12 +4,20 @@ import speech_recognition as sr class VoiceRecognition: @staticmethod def basic_recognition(audio, option): + print("preparing") r = sr.Recognizer() if option == "online": + print("online") with audio as source: - return r.recognize_google_cloud(source) + text = r.recognize_google_cloud(source) + print("recognized as: " + text) + return text elif option == "offline": + print("offline") with audio as source: - return r.recognize_sphinx(source) + text = r.recognize_sphinx(source) + print("recognized as: " + text) + return text + print("nothing") return False From 787c158be1ceaddbac0716b8dae308f71f721378 Mon Sep 17 00:00:00 2001 From: Patrick_Pluto Date: Thu, 26 Sep 2024 09:36:28 +0200 Subject: [PATCH 2/2] super cool fix 2 --- py/api.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/py/api.py b/py/api.py index 52fe922..e152cdc 100644 --- a/py/api.py +++ b/py/api.py @@ -99,14 +99,14 @@ class API: @self.app.route('/interstellar_ai/api/voice_recognition', methods=['POST']) def voice_recognition(): - recognition_type = request.args.get('type') + type = request.args.get('type') audio = request.args.get('audio') option = request.args.get('option') - if recognition_type == "basic": + if type == "basic": text = self.voice.basic_recognition(audio, option) return jsonify({'status': 200, 'response': text}) - - return jsonify({'status': 401, 'response': "Invalid type"}) + else: + return jsonify({'status': 401, 'response': "Invalid type"}) @self.app.route('/interstellar_ai/api/weather', methods=['POST']) def get_weather():