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
chore: auto-save WIP via Claude stop-hook safety net (2026-07-01 18:41)
Ruben Lütkefe08a36b0773
diff --git a/jarvis/speech/wake_constants.py b/jarvis/speech/wake_constants.pyindex 51638f0a5c..8e7fd0ba01 100644--- a/jarvis/speech/wake_constants.py+++ b/jarvis/speech/wake_constants.py@@ -123,6 +123,32 @@ def phrase_core_for_match(phrase: str) -> list[str]:return core or tokens+def sound_fold(token: str) -> str:+ """Collapse sound-equivalent spelling variants onto one canonical form.++ A small local Whisper mis-spells a proper-noun wake word in sound-equivalent+ ways ("Nico" -> "Niko"/"Nicko"/"Nikko", "Sophie" -> "Sofie"). Folding the+ common variances a wake word actually sees — ``c``/``k``, ``ck``, ``ph``/``f``,+ ``y``/``i``, and doubled letters — makes those forms compare EQUAL so the+ match no longer needs a perfect spelling. It only canonicalises spelling; it+ does NOT loosen the fuzzy ratio, so clearly different words still do not+ match (no extra false wakes). Expects an already lower-cased, accent-folded+ token (see :func:`normalize_phrase_for_match`). Applied AFTER wake-prefix+ stripping so a folded "hey" can never break prefix detection. Pure stdlib, so+ it behaves identically on every OS.+ """+ if not token:+ return token+ t = token.replace("ph", "f").replace("ck", "k")+ t = t.replace("c", "k").replace("y", "i")+ out: list[str] = []+ for ch in t:+ if out and out[-1] == ch: # collapse doubles: Nikko -> niko, Emma -> ema+ continue+ out.append(ch)+ return "".join(out)++def match_known_oww_model(phrase: str) -> str | None:"""Map a phrase onto a pretrained openWakeWord model name, or ``None``.@@ -195,6 +221,7 @@ __all__ = ["normalize_phrase_for_match","phrase_core","phrase_core_for_match",+ "sound_fold","match_known_oww_model","resolve_oww_model_path",]diff --git a/jarvis/speech/wake_phrase.py b/jarvis/speech/wake_phrase.pyindex 0a301df2c2..07b7819d65 100644--- a/jarvis/speech/wake_phrase.py+++ b/jarvis/speech/wake_phrase.py@@ -37,6 +37,7 @@ from jarvis.speech.wake_constants import (phrase_core,phrase_core_for_match,resolve_oww_model_path,+ sound_fold,)log = logging.getLogger("jarvis.wake.phrase")@@ -99,7 +100,9 @@ class WakeMatcher:is_jarvis_default: bool = False,) -> None:self._pattern = pattern- self._core = core_tokens or []+ # Sound-fold the core so a sound-equivalent ASR spelling of the wake word+ # ("Nico" -> "Niko"/"Nicko"/"Nikko") compares equal (see ``sound_fold``).+ self._core = [sound_fold(c) for c in (core_tokens or [])]self._ratio = fuzzy_ratioself._is_jarvis = is_jarvis_default@@ -133,22 +136,29 @@ class WakeMatcher:return Noneif self._pattern is not None:return self._pattern.search(text)- tokens = normalize_phrase_for_match(text)+ # Compare on sound-FOLDED tokens so a sound-equivalent ASR spelling of the+ # wake word lines up with the (also folded) core, but return the ORIGINAL+ # heard text as the match so the yielded keyword / logs are unchanged.+ # Prefix stripping already happened for the core, and the transcript is+ # only window-scanned for the core token, so folding here has no prefix+ # side effect.+ orig = normalize_phrase_for_match(text)+ folded = [sound_fold(t) for t in orig]n = len(self._core)- if n == 0 or len(tokens) < n:+ if n == 0 or len(folded) < n:return None# Length-aware threshold: average the per-core-token required ratios so a# short name tolerates a little pronunciation drift while a longer one# (or a multi-word phrase with long tokens) keeps the strict bar.threshold = sum(self._effective_ratio(c) for c in self._core) / n- for i in range(0, len(tokens) - n + 1):- window = tokens[i : i + n]+ for i in range(0, len(folded) - n + 1):+ window = folded[i : i + n]score = sum(SequenceMatcher(None, c, w).ratio()for c, w in zip(self._core, window, strict=False)) / nif score >= threshold:- return _FuzzyMatch(" ".join(window))+ return _FuzzyMatch(" ".join(orig[i : i + n]))return Nonediff --git a/tests/unit/speech/test_wake_phrase_phonetic.py b/tests/unit/speech/test_wake_phrase_phonetic.pynew file mode 100644index 0000000000..0ddcf37cd8--- /dev/null+++ b/tests/unit/speech/test_wake_phrase_phonetic.py@@ -0,0 +1,54 @@+"""Sound-folding makes the wake matcher robust to ASR spelling variance.++A small local Whisper mis-spells a proper-noun wake word in sound-equivalent+ways ("Nico" -> "Niko" / "Nicko" / "Nikko" / "Neko"). The exact-token match then+fails and the wake needs repeating. Folding sound-equivalent spellings (c/k/ck,+ph/f, y/i, doubled letters) BEFORE the fuzzy compare collapses those variants+onto one form so they match — WITHOUT loosening the ratio threshold, so clearly+different words still do not match (no extra false wakes). Pure Python, so it+behaves identically on Windows, Linux and macOS.+"""+from __future__ import annotations++import pytest++from jarvis.speech.wake_phrase import compile_wake_matcher+++ "heard",+ ["Nico", "Niko", "Nicko", "Nikko", "Neko", "hey niko", "ok, niko"],+)+def test_sound_equivalent_spellings_of_the_wake_word_match(heard: str) -> None:+ m = compile_wake_matcher("Nico")+ assert m.search(heard) is not None, f"{heard!r} should match the 'Nico' wake"+++ "heard",+ ["Marco", "Hallo", "Computer", "das war die Welt", "Schule fertig"],+)+def test_clearly_different_words_still_do_not_match(heard: str) -> None:+ m = compile_wake_matcher("Nico")+ assert m.search(heard) is None, f"{heard!r} must NOT match the 'Nico' wake"+++def test_sound_folding_helps_a_longer_name_too() -> None:+ m = compile_wake_matcher("Marc")+ assert m.search("mark") is not None # c -> k+ assert m.search("marc") is not None+ assert m.search("computer") is None+++def test_double_letter_and_ph_folding() -> None:+ assert compile_wake_matcher("Emma").search("Ema") is not None # doubled m+ assert compile_wake_matcher("Sophie").search("Sofie") is not None # ph -> f+++def test_jarvis_default_is_untouched_by_folding() -> None:+ # The default jarvis phrase uses the strict legacy regex, not the fuzzy/folded+ # path, so its exact behaviour is preserved.+ m = compile_wake_matcher("Jarvis")+ assert m.search("hey jarvis") is not None+ assert m.search("jarvis") is None # bare jarvis still rejected+ assert m.search("marco") is None