Skip to content

Commit f137eb5

Browse files
committed
(joke) use picovoice on the robot
1 parent 48d7f2f commit f137eb5

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

script/joke.py

+22-7
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from smach_msgs.msg import SmachContainerStatus
1111
from hmi import TimeoutException
1212
from robot_skills import get_robot
13+
from robot_skills.simulation import is_sim_modes
1314

1415

1516
# clue should be separated with 15 spaces
@@ -100,14 +101,28 @@ def joke(self):
100101

101102
self._robot.speech.speak("Would you like to hear another one?")
102103

103-
r = None
104-
try:
105-
r = self._robot.hmi.query('', 'T -> yes | no', 'T').sentence
106-
except TimeoutException:
107-
pass
104+
stop: bool = False
105+
answer = None
106+
if is_sim_modes():
107+
try:
108+
answer = self._robot.hmi.query('', 'T -> yes | no', 'T').sentence
109+
except TimeoutException:
110+
pass
111+
112+
if not answer or answer == "no":
113+
stop = True
114+
115+
else:
116+
try:
117+
answer = self._robot.picovoice.get_intent("yesOrNo", None, True, self.timeout)
118+
except TimeoutException:
119+
pass
120+
121+
if not answer or not answer.semantics or answer.semantics == "no"
122+
stop = True
108123

109-
if not r or r == "no":
110-
self._robot.speech.speak("Ok, I will be quiet for another %d minutes" % self._standby_min)
124+
if stop:
125+
self._robot.speech.speak(f"Ok, I will be quiet for another {self._standby_min} minutes")
111126
self._last_update = rospy.Time.now()
112127

113128

0 commit comments

Comments
 (0)