diff --git a/jarvis.py b/jarvis.py index a9a81c5..f98f86b 100644 --- a/jarvis.py +++ b/jarvis.py @@ -5,6 +5,7 @@ from src import microphone from src import commonsense from src import brain +from excp.exception import NotUnderstoodException exit_flag = 0 tts_engine = google_tts.Google_TTS() @@ -34,7 +35,7 @@ def sleep(): if 'wake' in words_stt_response or 'jarvis' in words_stt_response or 'wakeup' in words_stt_response: tts_engine.say("Hello Sir, I am back once again.") wakeup() - except: + except Exception: pass @@ -57,8 +58,12 @@ def wakeup(): response = k.respond(stt_response) print(response) tts_engine.say(response) - except: + except NotUnderstoodException: commonsense.sorry() + except Exception: + print("Error in processing loop:") + traceback.print_exc() + commonsense.uhoh() k.loadBrain('data/jarvis.brn') try: diff --git a/src/commonsense.py b/src/commonsense.py index 9e23fd0..dfc9ea1 100644 --- a/src/commonsense.py +++ b/src/commonsense.py @@ -3,6 +3,19 @@ import random speak_engine = google_tts.Google_TTS() +UHOH_PATH = "wav/uhoh/" +uhoh_files = os.listdir(UHOH_PATH) + + +def uhoh(): + ''' + This method will play pre-recorded uhoh wav files + ''' + speak_engine.play_wav( + UHOH_PATH + + random.choice(uhoh_files) + ) + SORRY_PATH = "wav/sorry/" sorry_files = os.listdir(SORRY_PATH) diff --git a/wav/uhoh/sorry4.wav b/wav/uhoh/sorry4.wav new file mode 100644 index 0000000..26219ed Binary files /dev/null and b/wav/uhoh/sorry4.wav differ