Spaces:
Running
Running
Oliver Nitsche Claude Sonnet 4.6 commited on
Commit ·
83afe82
1
Parent(s): c29ef09
Hold GREETING state for at least 4 s so UI always shows recognition
Browse filesWhen TTS is unavailable speak() returns in milliseconds, causing the
GREETING state to be entered and exited before the UI's 1-second poll
could catch it — the user saw the robot go straight to sleep with no
feedback at all.
Fix: record the time before speak(); after it returns, sleep the
remaining time up to a 4-second minimum. The UI is guaranteed to see
at least three poll cycles with state="greeting" and the face snapshot,
regardless of whether TTS is working.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- recognizer/main.py +6 -2
recognizer/main.py
CHANGED
|
@@ -187,9 +187,13 @@ class Recognizer(ReachyMiniApp):
|
|
| 187 |
elif state == State.GREETING:
|
| 188 |
with _lock:
|
| 189 |
_shared["state"] = "greeting"
|
| 190 |
-
|
| 191 |
-
# If TTS is unavailable the name remains visible in the UI.
|
| 192 |
speak(f"Hi {greeting_name}!", reachy_mini)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 193 |
reachy_mini.goto_sleep()
|
| 194 |
with _lock:
|
| 195 |
_shared["recognized_name"] = None
|
|
|
|
| 187 |
elif state == State.GREETING:
|
| 188 |
with _lock:
|
| 189 |
_shared["state"] = "greeting"
|
| 190 |
+
greeting_t0 = time.time()
|
|
|
|
| 191 |
speak(f"Hi {greeting_name}!", reachy_mini)
|
| 192 |
+
# Keep greeting visible for at least 4 s so the UI poll
|
| 193 |
+
# (1 s interval) always catches it, even when TTS is absent.
|
| 194 |
+
remaining = 4.0 - (time.time() - greeting_t0)
|
| 195 |
+
if remaining > 0:
|
| 196 |
+
time.sleep(remaining)
|
| 197 |
reachy_mini.goto_sleep()
|
| 198 |
with _lock:
|
| 199 |
_shared["recognized_name"] = None
|