forked from React-Group/interstellar_ai
		
	Compare commits
	
		
			3 commits
		
	
	
		
			26fcc50f31
			...
			95eadb5ee2
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 95eadb5ee2 | |||
|   | 787c158be1 | ||
|   | 92d6688d64 | 
					 2 changed files with 16 additions and 7 deletions
				
			
		|  | @ -99,12 +99,13 @@ 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(): | ||||||
|             recognition_type = request.args.get('type') |             type = request.args.get('type') | ||||||
|             audio = request.args.get('audio') |             audio = request.args.get('audio') | ||||||
|             option = request.args.get('option') |             option = request.args.get('option') | ||||||
|             if recognition_type == "basic": |             if 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}) | ||||||
|  |             else: | ||||||
|                 return jsonify({'status': 401, 'response': "Invalid type"}) |                 return jsonify({'status': 401, 'response': "Invalid type"}) | ||||||
| 
 | 
 | ||||||
|         @self.app.route('/interstellar_ai/api/weather', methods=['POST']) |         @self.app.route('/interstellar_ai/api/weather', methods=['POST']) | ||||||
|  |  | ||||||
							
								
								
									
										12
									
								
								py/voice.py
									
										
									
									
									
								
							
							
						
						
									
										12
									
								
								py/voice.py
									
										
									
									
									
								
							|  | @ -4,12 +4,20 @@ import speech_recognition as sr | ||||||
| class VoiceRecognition: | class VoiceRecognition: | ||||||
|     @staticmethod |     @staticmethod | ||||||
|     def basic_recognition(audio, option): |     def basic_recognition(audio, option): | ||||||
|  |         print("preparing") | ||||||
|         r = sr.Recognizer() |         r = sr.Recognizer() | ||||||
|         if option == "online": |         if option == "online": | ||||||
|  |             print("online") | ||||||
|             with audio as source: |             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": |         elif option == "offline": | ||||||
|  |             print("offline") | ||||||
|             with audio as source: |             with audio as source: | ||||||
|                 return r.recognize_sphinx(source) |                 text = r.recognize_sphinx(source) | ||||||
|  |                 print("recognized as: " + text) | ||||||
|  |                 return text | ||||||
| 
 | 
 | ||||||
|  |         print("nothing") | ||||||
|         return False |         return False | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue