forked from React-Group/interstellar_ai
		
	voice recognition trial 4
This commit is contained in:
		
							parent
							
								
									0c02d76d6f
								
							
						
					
					
						commit
						ea3fd09ea2
					
				
					 2 changed files with 14 additions and 9 deletions
				
			
		| 
						 | 
				
			
			@ -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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										10
									
								
								py/api.py
									
										
									
									
									
								
							
							
						
						
									
										10
									
								
								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:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue