-
Notifications
You must be signed in to change notification settings - Fork 10
/
app.py
51 lines (44 loc) · 1.56 KB
/
app.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
import time
import paho.mqtt.client as mqtt
from flow import Flow
# Developer: Roshan Lamichhane
Host = 'localhost'
PORT = 1883
def on_connect(client, userdata, flags, rc):
print("Connected to {0} with result code {1}".format(HOST, rc))
# Subscribe to the hotword detected topic
client.subscribe("hermes/hotword/default/detected")
# Subscribe to intent topic
client.subscribe('hermes/intent/#')
def on_message(client, userdata, msg):
current_pose = None
f = ['tree_pose', 'warrior_1', 'crescent_lunge', 'warrior_2', 'triangle', 'half_moon', 'plank', 'chaturanga_dandasana', 'cobra']
elif msg.topic == 'hermes/intent/smayorquin:BeginClass':
#Sample flow
flow = Flow(f)
flow.run()
elif msg.topic == 'hermes/intent/smayorquin:StopClass':
print("StopClass Intent detected!")
try:
del flow
except:
pass
elif msg.topic == 'hermes/intent/smayorquin:PauseClass':
print("PauseClass Intent detected!")
current_pose = flow.current_pose
try:
del flow
except:
pass
elif msg.topic == 'hermes/intent/smayorquin:RestartClass':
print("RestartClass Intent detected!")
flow = Flow(f, current_pose=current_pose)
flow.run()
# Need to add more features
# features maybe be anything that
# improves the applition but does not slow it down
client = mqtt.Client()
client.on_connect = on_connect
client.on_message = on_message
client.connect(HOST, PORT, 60)
client.loop_forever()