-
Notifications
You must be signed in to change notification settings - Fork 0
/
Run.py
58 lines (50 loc) · 2.28 KB
/
Run.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
from SimpleLogger import SimpleLogger
from AudioManager import AudioManager
from DisplayManager import DisplayManager
from AIManager import AIManager
from AutomationManager import AutomationManager
from VoiceOutputManager import VoiceOutputManager
from SoundManager import SoundManager
import configparser
import time
if __name__ == "__main__":
config_file = "config.ini"
config = configparser.ConfigParser()
config.read(config_file)
l = SimpleLogger("DEBUG")
if l is None:
exit()
# Manages the display. All modules call various event functions to
# make different things happen on the display
display_man = DisplayManager(l, config_file)
# Plays various beeps and boops in response to events
sound_man = SoundManager(l, config_file)
# Waits for a wakeword, collects the user's voice, and transcribes it
audio_man = AudioManager(l, config_file, display_man, sound_man)
# Passes transcribed audio to GPT-3, and parses the response
ai_man = AIManager(l, config_file, display_man, sound_man)
# Handles art introduction & navigation tasks request by AIManager
auto_man = AutomationManager(l, config_file, display_man)
# Speaks the output from GPT-3
voice_man = VoiceOutputManager(l, config_file, display_man)
try:
while True:
if not audio_man.output_queue.empty():
transcription = audio_man.output_queue.get()
ai_man.handle_command(transcription)
if not ai_man.result_outputs.empty():
command = ai_man.result_outputs.get()
# Handle automation (respond with specific art introduction etc.)
auto_man.handle_command(command)
voice_man.handle_command(command)
else:
# The display needs to update on the main thread, so this
# handle_gui_events function needs to be called frequently
# to make animations look good.
if config["Display"]["use_display"] == "True":
display_man.handle_gui_events()
time.sleep(0.01)
except KeyboardInterrupt:
# AudioManager is the only module with a separate loop that needs
# to stop in order to have a clean exit
audio_man.stop()