forked from JBramauer/pepperspeechrecognition
-
Notifications
You must be signed in to change notification settings - Fork 0
/
module_eyecontact.py
35 lines (26 loc) · 1.13 KB
/
module_eyecontact.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
from naoqi import ALProxy, ALModule
class EyeContactModule(ALModule):
def __init__(self, name):
ALModule.__init__(self, name)
self.BIND_PYTHON( self.getName(),"callback" )
self.face_detected = False
self.speech = ALProxy("ALTextToSpeech")
self.memory = ALProxy("ALMemory")
self.memory.subscribeToEvent("FaceDetected", name, "on_face_detected")
def __del__( self ):
print( "INF: EyeContactModule.__del__: cleaning everything" )
self.stop()
def on_face_detected(self, event_name, value):
if value and not self.face_detected:
self.handle_status_change(True)
elif not value and self.face_detected:
self.handle_status_change(False)
def handle_status_change(self, status):
# print(status)
# if status:
# self.speech.say("Hello, I'm pepper, how can I help you today?")
self.face_detected = status
self.memory.raiseEvent('EyeContact', status)
def stop(self):
self.memory.unsubscribeToEvent("FaceDetected", self.getName())
print( "INF: EyeContactModule: stopped!" )