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): loud degrade when a custom word lands on stt_match only

Ruben Lütke53067f2e39e2
diff --git a/jarvis/speech/wake_phrase.py b/jarvis/speech/wake_phrase.py
index 91b9292ede..37d10776d5 100644
--- a/jarvis/speech/wake_phrase.py
+++ b/jarvis/speech/wake_phrase.py
@@ -449,23 +449,46 @@ def resolve_wake_plan(
or engine_pref == "openwakeword" # legacy engine value, no model ships
)
if want_stt and local_whisper_available:
- # A STALE custom model (belongs to another phrase) is NOT a degrade:
- # the transcript match IS the regular path for the new phrase, and the
- # model stays configured for when the user switches back.
- degraded = custom_missing or engine_pref == "openwakeword"
if custom_missing:
+ # A configured custom model file is gone. Best-effort fallback to
+ # transcript match, but this IS a degrade — the user's trained
+ # model no longer applies.
+ degraded = True
message = (
f"Custom ONNX not found ({custom_path}); "
"using local-Whisper transcript match instead."
)
elif custom_stale:
+ # A STALE custom model (belongs to another phrase) is NOT a
+ # degrade: the transcript match IS the regular path for the new
+ # phrase, and the model stays configured for when the user
+ # switches back.
+ degraded = False
message = (
f"Custom wake model '{Path(custom_path).name}' belongs to a "
f"different phrase; '{phrase}' uses the local-Whisper "
"transcript match."
)
else:
- message = f"Custom phrase '{phrase}' via local-Whisper transcript match."
+ # A custom word served ONLY by the transcribe-and-match path is
+ # UNRELIABLE for hard proper nouns (AP-27): the base model garbles
+ # the name and matched stays 0. This is a LOUD degrade, not silent
+ # success — point the user at the reliable any-word engine.
+ degraded = True
+ _lang = language or "the configured language"
+ message = (
+ f"Custom phrase '{phrase}' is on the local-Whisper transcript "
+ f"match — this is UNRELIABLE for a hard name. Download the Vosk "
+ f"model for {_lang} to make it reliable (Settings -> Wake word -> "
+ "'Download wake model')."
+ )
+ log.warning(
+ "Wake word '%s' resolved to stt_match only (no Vosk model, no "
+ "custom ONNX) — recognition will be unreliable for a hard name. "
+ "Provision the Vosk model for %s.",
+ phrase,
+ _lang,
+ )
return WakeWordPlan(
phrase=phrase,
engine="stt_match",
diff --git a/tests/unit/speech/test_wake_phrase.py b/tests/unit/speech/test_wake_phrase.py
index 20855d5b36..f6bbb460a7 100644
--- a/tests/unit/speech/test_wake_phrase.py
+++ b/tests/unit/speech/test_wake_phrase.py
@@ -251,7 +251,9 @@ def test_jarvis_phrase_resolves_generically_not_to_a_bundled_model() -> None:
assert plan.engine == "stt_match" # vosk is fenced off by the autouse fixture
assert plan.oww_model_path is None
assert plan.oww_keyword == "jarvis"
- assert plan.degraded is False
+ # Task 5 (B3): an ordinary custom phrase served ONLY by stt_match is now a
+ # LOUD degrade (AP-27) — no Vosk model, no custom ONNX in this fixture.
+ assert plan.degraded is True
def test_brand_phrase_never_loads_an_upstream_package_model() -> None:
@@ -275,7 +277,9 @@ def test_arbitrary_phrase_with_local_whisper_resolves_to_stt_match() -> None:
assert plan.engine == "stt_match"
assert plan.needs_local_whisper is True
assert plan.oww_model_path is None
- assert plan.degraded is False
+ # Task 5 (B3): stt_match-only for an ordinary custom phrase is a LOUD
+ # degrade (AP-27), not silent success.
+ assert plan.degraded is True
assert plan.matcher.search("hey computer") is not None
@@ -355,7 +359,8 @@ def test_jarvis_stays_typeable_through_the_generic_chain() -> None:
plan = resolve_wake_plan(_cfg(phrase="Hey Jarvis"), local_whisper_available=True)
assert plan.engine == "stt_match"
assert plan.oww_model_path is None
- assert plan.degraded is False
+ # Task 5 (B3): stt_match-only is now a LOUD degrade (AP-27).
+ assert plan.degraded is True
def test_just_jarvis_stays_typeable_through_the_generic_chain() -> None:
@@ -363,7 +368,8 @@ def test_just_jarvis_stays_typeable_through_the_generic_chain() -> None:
plan = resolve_wake_plan(_cfg(phrase="Jarvis"), local_whisper_available=True)
assert plan.engine == "stt_match"
assert plan.oww_model_path is None
- assert plan.degraded is False
+ # Task 5 (B3): stt_match-only is now a LOUD degrade (AP-27).
+ assert plan.degraded is True
def test_sensitivity_to_poll_interval_makes_the_slider_control_speed() -> None:
diff --git a/tests/unit/speech/test_wake_plan_loud_degrade.py b/tests/unit/speech/test_wake_plan_loud_degrade.py
new file mode 100644
index 0000000000..3f5513d089
--- /dev/null
+++ b/tests/unit/speech/test_wake_plan_loud_degrade.py
@@ -0,0 +1,49 @@
+"""Task 5 (B3): a plain custom phrase served ONLY by stt_match (local-Whisper
+transcript match) must be a LOUD degrade, not a silent success.
+
+AP-27: the base Whisper model structurally cannot recognize a hard proper
+noun reliably via transcription — it garbles it on speech and can hallucinate
+it on silence. Landing there for an ordinary custom word must surface a clear
+`degraded=True` + remedy message (install the Vosk any-word model), not report
+success as if the wake word just works.
+"""
+from __future__ import annotations
+
+from types import SimpleNamespace
+
+from jarvis.speech.wake_phrase import resolve_wake_plan
+
+
+def _cfg(phrase: str, engine: str = "auto") -> SimpleNamespace:
+ return SimpleNamespace(
+ phrase=phrase,
+ engine=engine,
+ custom_model_path="",
+ sensitivity=0.5,
+ fuzzy_match_ratio=0.8,
+ )
+
+
+def test_stt_match_custom_word_is_loudly_degraded() -> None:
+ # No vosk model, whisper present -> lands on stt_match. For a custom word
+ # this must be a LOUD degrade, not silent success.
+ plan = resolve_wake_plan(
+ _cfg("Athena"), local_whisper_available=True, vosk_available=False
+ )
+ assert plan.engine == "stt_match"
+ assert plan.degraded is True
+ assert "vosk" in plan.message.lower() or "reliable" in plan.message.lower()
+
+
+def test_vosk_preferred_over_stt_match_when_available(monkeypatch) -> None:
+ import jarvis.speech.wake_phrase as wp
+
+ monkeypatch.setattr(wp, "resolve_vosk_model_path", lambda lang: "/fake/de")
+ plan = resolve_wake_plan(
+ _cfg("Athena"),
+ local_whisper_available=True,
+ vosk_available=True,
+ language="de",
+ )
+ assert plan.engine == "vosk_kws"
+ assert plan.degraded is False