-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmindfulness_coach.py
54 lines (44 loc) · 1.68 KB
/
mindfulness_coach.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
from furhat_remote_api import FurhatRemoteAPI
import detect_faces
import interactive_system
import time
import threading
import sys
import queue
from joblib import load
# The main file that controls the main application
# It starts the two other threads with the emotion detection system and the interaction system
end_time_seconds = 30
def get_emotion(furhat, queue, model, name):
lock = threading.Lock()
t_end = time.time() + end_time_seconds
while time.time() < t_end:
print("reading emotion", flush=True)
sys.stdout.flush()
with lock:
em = queue.get()
#em = predict_emotion(aus, model)
print("controller emotion " + em, flush=True)
print(list(queue.queue))
if em is not None or em != '':
interactive_system.furhat_interaction(em, furhat)
time.sleep(4)
def start_furhat_and_get_a_name():
# Furhter improvements would be that the assistant reacts to user's last session that the assistant stored
furhat = interactive_system.set_furhat()
name = interactive_system.start_furhat(furhat)
return furhat, name
def predict_emotion(aus, model):
emotion = model.predict(aus)
return emotion
if __name__ == "__main__":
queue = queue.Queue()
model = load('svm_model.joblib')
detect_faces_thread = threading.Thread(target=detect_faces.create_video, args = [queue, model])
detect_faces_thread.start()
furhat, name = start_furhat_and_get_a_name()
furhat_interaction = threading.Thread(target=interactive_system.run_conversation_loop, args=[name, furhat, queue])
time.sleep(3)
furhat_interaction.start()
detect_faces_thread.join()
furhat_interaction.join()