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.
Python agent-orchestrationai-agentai-coding-assistantclaude-codecoding-agentcomputer-usedesktop-applocal-firstmcppersonal-jarvisvoice-assistantvoice-coding
fix(wake): stop verifying every custom wake in German, warn on an unspeakable phrase — and revert the shape-window narrowing
Ruben Lütke9add2c57aa86
diff --git a/jarvis/plugins/wake/vosk_kws_provider.py b/jarvis/plugins/wake/vosk_kws_provider.pyindex bf955ef8fb..339fefbafc 100644--- a/jarvis/plugins/wake/vosk_kws_provider.py+++ b/jarvis/plugins/wake/vosk_kws_provider.py@@ -1118,25 +1118,26 @@ class VoskKwsProvider:if w.get("end", 0.0) >= span_a and w.get("start", 0.0) <= span_b]free_local = " ".join(w.get("word", "") for w in local_words)- # The SHAPE path must not see what comes AFTER the phrase. A command- # word starting inside the trailing slack is the user's request, not- # evidence about the wake call — and counting it pushes the token- # count over the phrase's own, which disables the shape path- # outright (_SHAPE_TOKEN_SLACK is 0). For an out-of-vocabulary name- # the spelling path cannot cover that gap, so both confirm routes- # failed at once and the natural way people talk — wake word and- # command in ONE breath — was materially less likely to fire than an- # isolated call plus a pause.+ # OPEN (2026-07-25, measured): a wake spoken in ONE breath with the+ # command is materially less likely to fire than an isolated call.+ # A command word starting inside the trailing 0.3 s slack is counted+ # into the candidate and pushes the token count over the phrase's+ # own, which disables the shape path outright (_SHAPE_TOKEN_SLACK is+ # 0) — and for an out-of-vocabulary name the spelling path cannot+ # cover that gap, so BOTH confirm routes fail at once.#- # Keep the LEADING slack (alignment jitter before the phrase) and- # admit any word that OVERLAPS the phrase span, so a name the free- # ear stretched past the grammar's end boundary still counts. The- # false-wake class this gate exists for ("hey ho", live 2026-07-13)- # sits INSIDE the span and is unaffected.- shape_words = [- w for w in fres.get("result", [])- if w.get("end", 0.0) >= span_a and w.get("start", 0.0) <= end_s- ]+ # Narrowing the shape window to [span_a, end_s] fixes that case and+ # was TRIED — but it also costs precision, because the token-count+ # bound relies on surrounding words being counted: on the room-speech+ # fixture the narrower window admits 2 words instead of 3, lands ON+ # the phrase's token count, and ACCEPTS (verified: it breaks+ # test_free_words_outside_the_span_cannot_confirm plus two+ # storm/suppression guards).+ #+ # So this is a real latency/recall-vs-precision trade, not a free+ # win, and it must be calibrated against the recorded corpora+ # (250/1650 windows) rather than a fixture — same gate as the+ # _SHAPE_MAX_VOICED_S_PER_TOKEN bump. Do not narrow it on a hunch.except Exception as exc: # noqa: BLE001 — polarity via fail_openlog.warning("vosk-kws: verify failed (%s) — %s.",@@ -1162,7 +1163,7 @@ class VoskKwsProvider:# untouched: a free ear that spelled the phrase still fires instantly.ok = sound_confirm(free_local, self._phrase, ratio=self._confirm_ratio)by_shape = False- if not ok and candidate_shape_ok(shape_words, self._phrase):+ if not ok and candidate_shape_ok(local_words, self._phrase):ok = by_shape = self._shape_competition_ok(pcm, model_path)if not ok:self._stat_suppressed_shape_competition += 1diff --git a/jarvis/speech/pipeline.py b/jarvis/speech/pipeline.pyindex fc3746dff3..c5942b643a 100644--- a/jarvis/speech/pipeline.py+++ b/jarvis/speech/pipeline.py@@ -5254,9 +5254,22 @@ class SpeechPipeline:# open is engine-dependent — see below.)if not pcm_snapshot:return False+ # Pass the RESOLVED wake language. Omitting it fell back to the+ # parameter default ("de"), so every custom-model wake on earth was+ # verified by telling the cloud STT the audio is German — a systematic+ # garble for an English, Spanish or any other user, on the one engine+ # AP-25 names as the endgame. Uses the same resolver the wake plan and+ # the model download use, so selection and verification always agree.+ try:+ from jarvis.speech.wake_model_fetch import resolve_wake_language++ verify_language = resolve_wake_language(self._config)+ except Exception: # noqa: BLE001 — never let a language lookup kill a wake+ verify_language = Nonematched, text = await verify_wake_with_stt(self._utterance_stt,pcm_snapshot,+ language=verify_language,matcher=getattr(self, "_wake_matcher", None),)if matched:diff --git a/jarvis/speech/wake_verifier.py b/jarvis/speech/wake_verifier.pyindex ac45fcc4b5..88bd6c7a1d 100644--- a/jarvis/speech/wake_verifier.py+++ b/jarvis/speech/wake_verifier.py@@ -110,7 +110,13 @@ async def verify_wake_with_stt(stt: _SupportsTranscribePCM,pcm_bytes: bytes,sample_rate: int = 16_000,- language: str | None = "de",+ # None = let the provider auto-detect. This default used to be "de", which+ # every caller that omitted the argument silently inherited — so a wake was+ # verified by asserting the audio is German regardless of who was speaking.+ # A wrong pin garbles the transcript the matcher then has to satisfy;+ # auto-detect is the honest fallback. Callers that KNOW the language (the+ # pipeline resolves it through ``resolve_wake_language``) still pass it.+ language: str | None = None,matcher: Any | None = None,) -> tuple[bool, str | None]:"""Transcribe ``pcm_bytes`` and confirm the configured wake phrase.diff --git a/jarvis/ui/web/settings_routes.py b/jarvis/ui/web/settings_routes.pyindex ac9f56c8ba..00a5ea5d64 100644--- a/jarvis/ui/web/settings_routes.py+++ b/jarvis/ui/web/settings_routes.py@@ -970,6 +970,37 @@ async def put_wake_word(body: WakeWordBody, request: Request) -> dict[str, objecexcept Exception as exc: # noqa: BLE001 — never fail the save on a live-apply hiccuplog.warning("wake-word live-apply failed (persisted; applies on restart): %s", exc)+ # Out-of-vocabulary check AT SAVE TIME. The probe already existed but its+ # only caller was the self-test button, so a user whose phrase is missing+ # from the model's lexicon had a wake that can NEVER fire and found out by+ # chance. Reported, never enforced: the probe fails open, the union of+ # installed models may still hear the phrase, and blocking a save on a+ # lexicon guess is exactly the AP-27 trap (a spelling rule deciding whether+ # a wake word is allowed to exist).+ phrase_in_vocab: bool | None = None+ if plan.engine == "vosk_kws":+ try:+ from jarvis.speech.wake_constants import resolve_vosk_model_path++ model_path = resolve_vosk_model_path(_wake_lang)+ if model_path:+ from jarvis.plugins.wake.vosk_kws_provider import (+ vosk_model_supports_phrase,+ )++ phrase_in_vocab = await asyncio.to_thread(+ vosk_model_supports_phrase, model_path, body.phrase+ )+ if phrase_in_vocab is False:+ log.info(+ "wake-word saved but %r is not in the %s model's "+ "vocabulary — that phrase cannot fire on this engine.",+ body.phrase,+ _wake_lang,+ )+ except Exception: # noqa: BLE001 — a probe hiccup must never fail a save+ phrase_in_vocab = None+return {"ok": True,"phrase": body.phrase,@@ -979,6 +1010,10 @@ async def put_wake_word(body: WakeWordBody, request: Request) -> dict[str, objec# False when no local model matches the user's word: the wake word is off# and the Call shortcut is the activation."wake_available": plan.wake_available,+ # None = not applicable / not probed. False is a WARNING, not a+ # rejection: the phrase saved, but this engine's lexicon has no entry+ # for it, so the UI should say so instead of leaving the user guessing.+ "phrase_in_vocab": phrase_in_vocab,"message": plan.message,"persisted": persisted,# When live-applied, the running pipeline already swapped the detector;diff --git a/tests/unit/plugins/wake/test_vosk_wake_word_agnostic.py b/tests/unit/plugins/wake/test_vosk_wake_word_agnostic.pyindex 2faa5513f0..1c50086b68 100644--- a/tests/unit/plugins/wake/test_vosk_wake_word_agnostic.py+++ b/tests/unit/plugins/wake/test_vosk_wake_word_agnostic.py@@ -379,21 +379,32 @@ def test_the_competition_grammar_derives_from_the_configured_phrase() -> None:# --- the wake spoken in ONE breath with the command (2026-07-25) -------------+ reason=(+ "OPEN, measured 2026-07-25: a wake spoken in one breath with the "+ "command loses BOTH confirm routes. Narrowing the shape window to the "+ "phrase span fixes it but costs precision — the token-count bound "+ "relies on surrounding words being counted, so the narrower window "+ "makes the room-speech fixture land ON the token count and ACCEPT. "+ "Needs corpus calibration (250/1650 windows), not a fixture."+ ),+ strict=True,+)def test_a_wake_followed_immediately_by_the_command_still_fires(monkeypatch) -> None:"""The natural way people address an assistant must not be the hard case.The shape gate localises the free ear's words to the phrase span, and that- window used to extend 0.3 s PAST the phrase. So any command word starting- inside that trailing slack was counted into the candidate, pushed the token- count over the phrase's own (``_SHAPE_TOKEN_SLACK`` is 0) and disabled the- shape path outright. For an out-of-vocabulary name the spelling path cannot- cover that gap either, so BOTH confirm routes failed at once — an isolated- call plus a pause fired, while the same call followed by the request did- not.-- A command word carries no evidence about the wake call, so the shape gate- must not see it. This is word-agnostic: nothing here reads how the name is- spelled.+ window extends 0.3 s PAST the phrase. So any command word starting inside+ that trailing slack is counted into the candidate, pushes the token count+ over the phrase's own (``_SHAPE_TOKEN_SLACK`` is 0) and disables the shape+ path outright. For an out-of-vocabulary name the spelling path cannot cover+ that gap either, so BOTH confirm routes fail at once — an isolated call plus+ a pause fires, while the same call followed by the request does not.++ Kept as a STRICT xfail rather than deleted: it is the executable statement+ of the defect, so whoever calibrates the corpus can see exactly what has to+ start passing — and if a future change makes it pass by accident, strict+ mode flags that too."""p = VoskKwsProvider("Hey Ruben", model_path="fake", keyword="ruben")diff --git a/tests/unit/speech/test_wake_verifier.py b/tests/unit/speech/test_wake_verifier.pyindex 62405fece7..21aa0256bc 100644--- a/tests/unit/speech/test_wake_verifier.py+++ b/tests/unit/speech/test_wake_verifier.py@@ -134,7 +134,14 @@ async def test_verify_returns_true_when_transcript_has_hey_prefix() -> None:assert matched is Trueassert transcript == "Hey Jarvis, was läuft" # i18n-allow- assert stt.calls == [(len(PCM_2S_16K), 16_000, "de")]+ # The omitted-language default is None (provider auto-detect), NOT "de".+ # It used to be German, which every caller that passed no language silently+ # inherited — so a wake was verified by ASSERTING the audio is German no+ # matter who was speaking, garbling the transcript the matcher then has to+ # satisfy. A layer that cannot tell must fall back honestly, never guess one+ # locale (CLAUDE.md runtime-output-language rule, and the same §3+ # universality contract that forbids tuning to one user).+ assert stt.calls == [(len(PCM_2S_16K), 16_000, None)]async def test_verify_returns_false_when_transcript_is_bare_jarvis() -> None: