diff --git a/jarvis/main.py b/jarvis/main.py index a8687fa..1933d2d 100644 --- a/jarvis/main.py +++ b/jarvis/main.py @@ -1,7 +1,10 @@ +import os import struct +import threading import pvporcupine import pyaudio +import simpleaudio as sa import speech_recognition as sr from jarvis.utils import server_utils, config_utils @@ -27,7 +30,8 @@ def wake_word_listening(): keyword_index = wake_word_handler.process(pcm) if keyword_index >= 0: - print("Recognized") + threading.Thread( + target=sa.WaveObject.from_wave_file(os.getcwd() + "/sounds/" + "listening.wav").play).start() record() @@ -35,10 +39,10 @@ def record(): # obtain audio from the microphone r = sr.Recognizer() with sr.Microphone() as source: - print("Say something!") - r.adjust_for_ambient_noise(source=source, duration=0.5) + r.adjust_for_ambient_noise(source=source, duration=0.7) audio = r.listen(source, timeout=2, phrase_time_limit=5) + threading.Thread(target=sa.WaveObject.from_wave_file(os.getcwd() + "/sounds/" + "listened.wav").play).start() server_utils.send_record_to_server(audio.frame_data) diff --git a/jarvis/sounds/listened.wav b/jarvis/sounds/listened.wav new file mode 100644 index 0000000..5a3f225 Binary files /dev/null and b/jarvis/sounds/listened.wav differ diff --git a/jarvis/sounds/listening.wav b/jarvis/sounds/listening.wav new file mode 100644 index 0000000..2986ba4 Binary files /dev/null and b/jarvis/sounds/listening.wav differ diff --git a/requirements.txt b/requirements.txt index f2472fb..43899de 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,5 @@ pvporcupine~=1.9.5 PyAudio~=0.2.11 SpeechRecognition~=3.8.1 -requests~=2.26.0 \ No newline at end of file +requests~=2.26.0 +simpleaudio~=1.0.4 \ No newline at end of file