Skip to content

The agent that grows with you

fix(voice): early-exit sliding window on match, clear barge phase in finally, fix test helper

kshitij20e01f935b13
diff --git a/cli.py b/cli.py
index c72aef01ae6..541d112a527 100644
--- a/cli.py
+++ b/cli.py
@@ -12764,6 +12764,7 @@ class HermesCLI(CLIAgentSetupMixin, CLICommandsMixin, CLIBillingMixin):
except OSError:
pass
self._voice_barge_capture.clear()
+ self._voice_barge_phase = None
# No usable transcript: hand the mic back to the normal loop.
if not submitted and self._voice_mode and self._voice_continuous and not self._voice_recording:
self._voice_restart_recording_async()
diff --git a/tests/tools/test_voice_cli_integration.py b/tests/tools/test_voice_cli_integration.py
index 389419cc10b..e8c04cedbad 100644
--- a/tests/tools/test_voice_cli_integration.py
+++ b/tests/tools/test_voice_cli_integration.py
@@ -30,6 +30,8 @@ def _make_voice_cli(**overrides):
cli._voice_tts_done.set()
cli._voice_tts_stop = None
cli._voice_barge_capture = threading.Event()
+ cli._voice_last_tts_text = ""
+ cli._voice_barge_phase = None
cli._pending_input = queue.Queue()
cli._app = None
cli._attached_images = []
diff --git a/tools/voice_mode.py b/tools/voice_mode.py
index ec1e49703a6..aef09fdafcf 100644
--- a/tools/voice_mode.py
+++ b/tools/voice_mode.py
@@ -1374,13 +1374,11 @@ def is_tts_echo(
return True
if len(a) < MIN_FRAGMENT_LENGTH_FOR_ECHO or len(a) >= len(b):
return False
- best_ratio = 0.0
for start in range(0, len(b) - len(a) + 1):
window = b[start : start + len(a)]
- ratio = difflib.SequenceMatcher(None, a, window).ratio()
- if ratio > best_ratio:
- best_ratio = ratio
- return best_ratio >= threshold
+ if difflib.SequenceMatcher(None, a, window).ratio() >= threshold:
+ return True
+ return False
def voice_stop_hint() -> str: