Compare commits

..

No commits in common. "95eadb5ee2ef0c08c2629952c323e18aee158c4c" and "26fcc50f318f2b43b278e42eabad8e8a872a1133" have entirely different histories.

2 changed files with 7 additions and 16 deletions

View file

@ -99,14 +99,13 @@ class API:
@self.app.route('/interstellar_ai/api/voice_recognition', methods=['POST'])
def voice_recognition():
type = request.args.get('type')
recognition_type = request.args.get('type')
audio = request.args.get('audio')
option = request.args.get('option')
if type == "basic":
text = self.voice.basic_recognition(audio, option)
return jsonify({'status': 200, 'response': text})
else:
return jsonify({'status': 401, 'response': "Invalid type"})
if recognition_type == "basic":
return jsonify({'status': 200, 'response': self.voice.basic_recognition(audio, option)})
return jsonify({'status': 401, 'response': "Invalid type"})
@self.app.route('/interstellar_ai/api/weather', methods=['POST'])
def get_weather():

View file

@ -4,20 +4,12 @@ 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:
text = r.recognize_google_cloud(source)
print("recognized as: " + text)
return text
return r.recognize_google_cloud(source)
elif option == "offline":
print("offline")
with audio as source:
text = r.recognize_sphinx(source)
print("recognized as: " + text)
return text
return r.recognize_sphinx(source)
print("nothing")
return False