Skip to content

Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.

fix(wake): accept garbled prefix confirmations

Ruben Lütke063e67a54d94
diff --git a/jarvis/plugins/wake/vosk_kws_provider.py b/jarvis/plugins/wake/vosk_kws_provider.py
index e940ec1ecb..97f8539c52 100644
--- a/jarvis/plugins/wake/vosk_kws_provider.py
+++ b/jarvis/plugins/wake/vosk_kws_provider.py
@@ -98,6 +98,18 @@ _CONFIRM_RATIO = 0.55
_PREFIXED_CORE_RATIO = 0.70
_UNPREFIXED_CORE_RATIO = 0.80
+# A free decoder often preserves the wake core while garbling the short
+# prefix completely (production examples for "Hey Jarvis": "age avis",
+# "a jarvis", "page avis", "pay jarvis"). Requiring the prefix to be one of
+# WAKE_PREFIXES therefore makes the detector deaf even though the grammar
+# pass re-heard the full phrase at high confidence. The rescue remains
+# narrow: the localised transcript must contain exactly one prefix-shaped
+# token plus the core, and the core itself must clear this stronger floor.
+# This does not revive the old whole-window fuzzy match that accepted
+# unrelated multi-word speech.
+_GARBLED_PREFIX_CORE_RATIO = 0.80
+_GARBLED_PREFIX_PHRASE_RATIO = 0.62
+
# Word-agnostic energy floor for a candidate window (mirrors the stt_match
# path's RollingWhisperWake._match_min_rms — AP-27: silence is gated on raw
# energy, never on transcript content).
@@ -176,6 +188,27 @@ def sound_confirm(free_text: str, phrase: str, *, ratio: float = _CONFIRM_RATIO)
core_score = SequenceMatcher(None, target_core, heard_core).ratio()
if core_score >= core_floor:
return True
+
+ # Recall rescue for an ASR-garbled prefix. Do not slide this over longer
+ # speech: exact local token coverage is what keeps a mention of the core
+ # inside an ordinary sentence from becoming a wake. Split/merged core
+ # spellings still work through ``core_sizes``.
+ if has_prefix:
+ target_phrase = " ".join(sound_fold(token) for token in phrase_tokens)
+ for size in core_sizes:
+ if len(words) != 1 + size:
+ continue
+ heard_core = "".join(words[1:])
+ core_score = SequenceMatcher(None, target_core, heard_core).ratio()
+ heard_phrase = " ".join(words)
+ phrase_score = SequenceMatcher(
+ None, target_phrase, heard_phrase
+ ).ratio()
+ if (
+ core_score >= max(float(ratio), _GARBLED_PREFIX_CORE_RATIO)
+ and phrase_score >= _GARBLED_PREFIX_PHRASE_RATIO
+ ):
+ return True
return False
diff --git a/tests/unit/plugins/wake/test_vosk_kws_provider.py b/tests/unit/plugins/wake/test_vosk_kws_provider.py
index 19cf7cbb3c..fa785fb6d8 100644
--- a/tests/unit/plugins/wake/test_vosk_kws_provider.py
+++ b/tests/unit/plugins/wake/test_vosk_kws_provider.py
@@ -40,6 +40,20 @@ def test_sound_confirm_accepts_sound_close_mishearing() -> None:
assert sound_confirm("hey joe avis", "Hey Jarvis") is True
+ "heard",
+ (
+ "age avis",
+ "a jarvis",
+ "page avis",
+ "pay jarvis",
+ ),
+)
+def test_sound_confirm_accepts_live_garbled_prefix_wakes(heard: str) -> None:
+ """A free decoder may preserve the core but lose the short prefix."""
+ assert sound_confirm(heard, "Hey Jarvis") is True
+
+
def test_sound_confirm_rejects_unrelated_speech() -> None:
assert sound_confirm("vielen dank", "Hey Ruben") is False # i18n-allow: utterance under test
@@ -65,6 +79,10 @@ def test_alternative_known_prefix_still_needs_a_matching_core() -> None:
assert sound_confirm("hey room", "Hey Ruben") is False
+def test_garbled_prefix_rescue_does_not_fish_the_core_from_longer_speech() -> None:
+ assert sound_confirm("we discussed jarvis today", "Hey Jarvis") is False
+
+
def test_unprefixed_wake_requires_strong_core_evidence() -> None:
assert sound_confirm("joseph", "Joseph") is True
assert sound_confirm("das ist etwas", "Joseph") is False # i18n-allow: utterance under test