voice recognition trial 4

This commit is contained in:
YasinOnm08 2024-09-26 09:46:32 +02:00
parent 0c02d76d6f
commit ea3fd09ea2
2 changed files with 14 additions and 9 deletions

View file

@ -7,10 +7,13 @@ class VoiceSend {
console.log(typeof (audio_data)); console.log(typeof (audio_data));
console.log(audio_data instanceof Blob); console.log(audio_data instanceof Blob);
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 } const dataSend = { option:"offline", type:"basic",audio:audio_data }
axios.post("http://localhost:5000/interstellar_ai/api/voice_recognition", dataSend) axios.post("http://localhost:5000/interstellar_ai/api/voice_recognition", formdata)
.then((response) => { .then((response) => {
console.log(response.data) console.log(response.data)
return response.data.response return response.data.response

View file

@ -99,10 +99,12 @@ 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():
type = request.args.get('type') print(request.args)
audio = request.args.get('audio') recog_type = request.form.get('type')
option = request.args.get('option') print(recog_type)
if type == "basic": audio = request.files.get('audio')
option = request.form.get('option')
if recog_type == "basic":
text = self.voice.basic_recognition(audio, option) text = self.voice.basic_recognition(audio, option)
return jsonify({'status': 200, 'response': text}) return jsonify({'status': 200, 'response': text})
else: else: