drenayaz
commited on
Commit
·
1abda7c
1
Parent(s):
947c1da
add delay on sounds
Browse files- hand_tracker_v2/main.py +8 -1
hand_tracker_v2/main.py
CHANGED
|
@@ -46,6 +46,10 @@ class HandTrackerV2(ReachyMiniApp):
|
|
| 46 |
self.idle_timeout = 1.0
|
| 47 |
self.is_idle = False
|
| 48 |
self.last_play_sound = 0.0
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
|
| 50 |
self.show_img = False
|
| 51 |
self.track_mode = True
|
|
@@ -195,9 +199,12 @@ class HandTrackerV2(ReachyMiniApp):
|
|
| 195 |
def play_sound(self,reachy_mini, sound_name: str):
|
| 196 |
if time.time() - self.last_play_sound < 2.0:
|
| 197 |
return
|
|
|
|
|
|
|
| 198 |
sound_path = self.recorded_moves.sounds[sound_name]
|
| 199 |
reachy_mini.media.play_sound(sound_path)
|
| 200 |
self.last_play_sound = time.time()
|
|
|
|
| 201 |
|
| 202 |
|
| 203 |
def track(self, reachy_mini: ReachyMini, stop_event: threading.Event):
|
|
@@ -223,7 +230,7 @@ class HandTrackerV2(ReachyMiniApp):
|
|
| 223 |
if all(count == stable_hand_count for count in self.hand_count_history):
|
| 224 |
if stable_hand_count > self.previous_number_hands:
|
| 225 |
self.play_sound(reachy_mini, "success2")
|
| 226 |
-
elif stable_hand_count < self.previous_number_hands:
|
| 227 |
self.play_sound(reachy_mini, "irritated1")
|
| 228 |
|
| 229 |
self.previous_number_hands = stable_hand_count
|
|
|
|
| 46 |
self.idle_timeout = 1.0
|
| 47 |
self.is_idle = False
|
| 48 |
self.last_play_sound = 0.0
|
| 49 |
+
self.last_emotion_sound = {
|
| 50 |
+
"success2": time.time(),
|
| 51 |
+
"irritated1": time.time(),
|
| 52 |
+
}
|
| 53 |
|
| 54 |
self.show_img = False
|
| 55 |
self.track_mode = True
|
|
|
|
| 199 |
def play_sound(self,reachy_mini, sound_name: str):
|
| 200 |
if time.time() - self.last_play_sound < 2.0:
|
| 201 |
return
|
| 202 |
+
if time.time() - self.last_emotion_sound[sound_name] < 5.0:
|
| 203 |
+
return
|
| 204 |
sound_path = self.recorded_moves.sounds[sound_name]
|
| 205 |
reachy_mini.media.play_sound(sound_path)
|
| 206 |
self.last_play_sound = time.time()
|
| 207 |
+
self.last_emotion_sound[sound_name] = time.time()
|
| 208 |
|
| 209 |
|
| 210 |
def track(self, reachy_mini: ReachyMini, stop_event: threading.Event):
|
|
|
|
| 230 |
if all(count == stable_hand_count for count in self.hand_count_history):
|
| 231 |
if stable_hand_count > self.previous_number_hands:
|
| 232 |
self.play_sound(reachy_mini, "success2")
|
| 233 |
+
elif stable_hand_count < self.previous_number_hands and stable_hand_count == 0:
|
| 234 |
self.play_sound(reachy_mini, "irritated1")
|
| 235 |
|
| 236 |
self.previous_number_hands = stable_hand_count
|