-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGUI.py
More file actions
131 lines (95 loc) · 3.11 KB
/
Copy pathGUI.py
File metadata and controls
131 lines (95 loc) · 3.11 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
import asyncio
import multiprocessing
import platform
import threading
import time
from Hal.Classes import Response
from Hal.Decorators import reg
from Hal.Skill import Skill
from Event_Handler import event_handler
def run_app(queue: multiprocessing.Queue,):
from .KivyApp import App
application = App()
application.run(queue)
def run_main():
q = multiprocessing.Queue()
app = multiprocessing.Process(target=run_app, args=(q,))
app.start()
return q, app
class GUI(Skill):
def __init__(self):
self.q, self.app = run_main()
self.setup_routes()
event_handler.on("Audio_End", self.audio_end)
t = threading.Thread(target=self.check_if_gui_is_running)
if platform.system() == "Linux":
t.start()
def check_if_gui_is_running(self):
while True:
if not self.app.is_alive():
if self.q.close :
self.q = None
self.app = None
self.q, self.app = run_main()
time.sleep(0.5)
def audio_end(self):
self.change_indecator_bar_color("grey")
time.sleep(3)
self.change_emotion("neutral")
def setup_routes(self):
def sentament(sentament : str):
self.q.put(f"E{sentament}")
event_handler.on("sentament", sentament)
def indecator_bar_color(color : str):
self.q.put(f"C{color}")
event_handler.on("indecator_bar_color", indecator_bar_color)
def change_color_blue():
self.change_indecator_bar_color("blue")
event_handler.on("Keyword", change_color_blue)
def ready():
self.q.put("Cgrey")
event_handler.on("Ready", ready)
@reg(name="change_indecator_bar_color")
def change_indecator_bar_color(self, color="grey"):
"""
Changes the color of the indecator bar
:param string color: (Optional) The color you want to change the indector bar to. Options: blue, green, red, yellow, grey. Default: grey
"""
self.q.put(f"C{color}")
return Response(True)
@reg(name="change_emotion")
def change_emotion(self, emotion="neutral"):
"""
Changes the emotion of the assistant
:param string emotion: (Optional) The emotion you want to change the assistant to. One of
admiration
amusement
anger
annoyance
approval
caring
confusion
curiosity
desire
disappointment
disapproval
disgust
embarrassment
excitement
fear
gratitude
grief
joy
love
nervousness
optimism
pride
realization
relief
remorse
sadness
surprise
neutral
"""
self.q.put(f"E{emotion}")
return Response(True)