-
Notifications
You must be signed in to change notification settings - Fork 1
/
facevis_demo.py
143 lines (120 loc) · 3.46 KB
/
facevis_demo.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
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
132
133
134
135
136
137
138
139
140
141
142
143
from furhat_remote_api import FurhatRemoteAPI
from time import sleep
# "Sweating": 43,
frame_count_dict = {
"Mask": 25,
"Landscape": 35,
"Flowers": 32,
"Tears": 24,
# "Sweating": 43,
"Sweating": 30,
"Battery": 13,
"Eyes": 23,
"Clock": 25
}
###### demo order ######
# Landscape
# Mask
# Sweating
# Flowers
CHAR_NAME = "Flowers"
CHAR_FRAME_COUNT = frame_count_dict[CHAR_NAME]
DELAY_TIME = 1.5 # seconds
def check_flowers(index):
# Flowers: frame count = 32
frame_count = 32
sadness = float(index/frame_count) * 3
# Perform a custom gesture
furhat.gesture(body={
"frames": [
{
"time": [
0.5
],
"params": {
"EXPR_SAD": sadness
}
}
],
"class": "furhatos.gestures.Gesture"
})
def check_sweating(index):
# Sweating: frame count = 30
frame_count = 30
happiness = float(index/frame_count) * 1.5 - 0.5
# Perform a custom gesture
furhat.gesture(body={
"frames": [
{
"time": [
0.5
],
"params": {
"SMILE_OPEN": happiness
}
}
],
"class": "furhatos.gestures.Gesture"
})
def check_clock(index):
# Clock: frame count = 25
if index % 3 == 0:
# 3, 6, 9, 12, 15, 18, 21, 24
furhat.gesture(name="BrowFrown")
else:
if index % 4 == 0:
# 4, 8, 16, 20
furhat.gesture(name="ExpressFear")
else:
if index % 5 == 0:
# 5, 10, 15, 25
furhat.gesture(name="ExpressSad")
# Create an instance of the FurhatRemoteAPI class, providing the address of the robot or the SDK running the virtual robot
# furhat = FurhatRemoteAPI("localhost")
# furhat = FurhatRemoteAPI("10.100.238.89")
furhat = FurhatRemoteAPI("10.100.239.12")
# furhat = FurhatRemoteAPI("192.168.0.100")
# Get the voices on the robot
voices = furhat.get_voices()
# Set the voice of the robot
# furhat.set_voice(name='Matthew')
# if CHAR_NAME == "Landscape":
# furhat.set_voice(name='Matthew')
# load
# furhat.set_face(mask="adult",character="James")
# Say "Hi there!"
# furhat.say(text="Top of the morning to ya!")
# furhat.say(text="I am in the Telstra Creator Space")
# Perform a named gesture
# furhat.gesture(name="BrowRaise")
# Loop through faces to create animation
start_index = 1
end_index = CHAR_FRAME_COUNT+1
step = 1
if CHAR_NAME == "Battery":
start_index = CHAR_FRAME_COUNT
end_index = 0
step = -1
for i in range(start_index, end_index, step):
# furhat.set_face(mask="adult",character="Amauri/Amauri"+str(i))
curr_face = CHAR_NAME+"/"+CHAR_NAME+str(i)
print("Setting face to %s" % curr_face)
furhat.set_face(mask="adult",character=curr_face)
# check if need to perform gestures
if CHAR_NAME == "Mask":
if i >= 26:
furhat.gesture(name="CloseEyes")
if CHAR_NAME == "Sweating":
check_sweating(i)
if CHAR_NAME == "Flowers":
check_flowers(i)
if CHAR_NAME == "Clock":
check_clock(i)
# delay
sleep(DELAY_TIME)
# furhat.set_face(mask="adult", character="Amauri/Victor")
# furhat.set_face(mask="adult", character="StandardExtras/Luna")
# Set the voice of the robot
# furhat.set_voice(name='Brian')
# Say "Hi there!"
# furhat.say(text="See ya later aligator!")