From ea3fd09ea2107c2636c3f1f87d685c8586ab5a84 Mon Sep 17 00:00:00 2001 From: YasinOnm08 Date: Thu, 26 Sep 2024 09:46:32 +0200 Subject: [PATCH] voice recognition trial 4 --- app/backend/voice_backend.ts | 13 ++++++++----- py/api.py | 10 ++++++---- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/app/backend/voice_backend.ts b/app/backend/voice_backend.ts index d2466c2..a93fd89 100644 --- a/app/backend/voice_backend.ts +++ b/app/backend/voice_backend.ts @@ -6,11 +6,14 @@ class VoiceSend { console.log("sending recording..."); console.log(typeof (audio_data)); console.log(audio_data instanceof Blob); - - - - const dataSend = { option:"offline", type: "basic",audio:audio_data } - axios.post("http://localhost:5000/interstellar_ai/api/voice_recognition", dataSend) + + const formdata = new FormData() + formdata.append("audio", audio_data) + formdata.append("option", "offline") + formdata.append("type", "basic") + + const dataSend = { option:"offline", type:"basic",audio:audio_data } + axios.post("http://localhost:5000/interstellar_ai/api/voice_recognition", formdata) .then((response) => { console.log(response.data) return response.data.response diff --git a/py/api.py b/py/api.py index e152cdc..0951717 100644 --- a/py/api.py +++ b/py/api.py @@ -99,10 +99,12 @@ class API: @self.app.route('/interstellar_ai/api/voice_recognition', methods=['POST']) def voice_recognition(): - type = request.args.get('type') - audio = request.args.get('audio') - option = request.args.get('option') - if type == "basic": + print(request.args) + recog_type = request.form.get('type') + print(recog_type) + audio = request.files.get('audio') + option = request.form.get('option') + if recog_type == "basic": text = self.voice.basic_recognition(audio, option) return jsonify({'status': 200, 'response': text}) else: