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(dictation): a recited Whisper prompt is dropped, and the dictionary repairs only what sounds alike

rubenluetke10-beepa021de1cd556
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9f258a0c91..ab6a2c601a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -20,6 +20,16 @@ versioning per [SemVer](https://semver.org/).
else: the overview, the catalogue, the server tab, the Tune sheet, and the
quiet six-hourly self-check behind the sidebar badge.
+### Fixed
+
+- **Dictation no longer ends in a recited word list.** Whisper answered a
+ silent stretch by reading the STT dictionary's own words back
+ ("…, Claude, Agentic IDE, Claude, Agentic"); such a run is now dropped from
+ the end of a transcript before the dictionary applies. The dictionary's
+ near-miss repair also became strict: a word is rewritten only when it
+ SOUNDS like the registered one ("Klaude" → "Claude"), never because a
+ common word is one letter away ("grob" stays "grob"). (BUG-185)
+
---
## [1.6.0] — 2026-08-25
diff --git a/docs/BUGS.md b/docs/BUGS.md
index dd327626e1..58a7591028 100644
--- a/docs/BUGS.md
+++ b/docs/BUGS.md
@@ -12987,3 +12987,61 @@ profiles, recap/prompt composers — spent on the configured primary brain
**Lesson.** A report that depends on every caller remembering to report is a
report of the callers that remembered. Meter where the object is made, not
where it is used.
+
+## BUG-185: a dictation ended in "IDE, Agentic IDE, Agentic IDE, …, Claude, Agentic IDE, Claude, Agentic" — Whisper recited its bias prompt, and the dictionary rewrote nearby common words toward the user's terms (HIGH, FIXED 2026-08-26)
+
+**Symptom.** A 40-second German dictation (2026-08-26 17:24 UTC, Groq
+`whisper-large-v3`) landed in the chat with a tail nobody said:
+`… der bebeamtlich ist. IDE, Agentic IDE, Agentic IDE, Agentic IDE, Agentic IDE, Claude, Agentic IDE, Claude, Agentic`.
+The maintainer read it as the STT dictionary replacing far too much.
+Separately, the live dictionary held `GitHuib` (a typo), and every correctly
+heard "GitHub" was being rewritten INTO the typo.
+
+**Root cause.** Two independent things.
+
+1. The recitation is not a replacement. `build_stt_from_config` hands the
+ dictionary's canonical words to prompt-capable providers as a
+ comma-separated Whisper `prompt` — here
+ `GitHuib, Grok, Claude, Agentic IDE, Agentic`. Whisper treats the prompt
+ as the previous segment and, given a stretch with no speech in it,
+ continues the list. The dictation lane's truncation repair
+ (`stt_audit: truncation_repairs:1`, four STT calls for two windows)
+ re-read a near-silent piece and accepted the result because the merged
+ text had MORE tokens than before — the one acceptance rule a hallucinated
+ list always passes. The repo already withholds the prompt from the local
+ engine for exactly this reason (Bug #8) and never guarded the cloud lane.
+2. The fuzzy repair rewrote any token within raw edit distance 1 (2 from
+ eight characters) of a dictionary word that shared its first letter. That
+ is a spelling neighbourhood, not a sound: "grob" → "Grok",
+ "Clause" → "Claude", and "GitHub" → "GitHuib".
+
+**Fix.**
+
+* `jarvis/speech/stt_dictionary.py` — `TranscriptCorrector.strip_prompt_echo()`
+ drops a run of dictionary items that closes a finished transcript when it
+ holds three or more items, repeats one, or is the whole transcript (two
+ items suffice there: a silent piece comes back as the list alone).
+ Fragments of multi-word entries ("IDE") may start the run but never count.
+ `DictionaryCorrectingSTT._apply` runs it before correction on `text` and
+ `raw_text`, skips partials, and logs what it dropped at INFO.
+* Same file — the fuzzy repair now compares phonetic folds (`_phonetic_fold`:
+ c/k, v/f, ph/f, th/t, ie/i, ei/ai/ey/ay, ou/au, doubled letters, silent h)
+ and rewrites only an identical fold, or one edit apart on the fold for
+ tokens of eight letters or more. "Veltrok" → "Veltroc", "Klaude" and
+ "Cloude" → "Claude" still repair; "grob", "Cloud", "Clause" stay.
+* The maintainer's live sidecar: `GitHuib` → `GitHub` through
+ `DictionaryStore.update`, so the corrector reloaded on the next utterance.
+
+**Guard.** `tests/unit/speech/test_stt_dictionary.py` — `TestPromptEcho`
+(the verbatim tail from the history, a whole-window recitation, a repeat,
+and five sentences ending in dictionary words that must survive),
+`TestWrapper::test_recited_prompt_is_dropped_before_correction`,
+`::test_partial_transcripts_keep_their_tail`,
+`TestVocabularyWords::test_fuzzy_repairs_only_what_sounds_the_same`,
+`::test_fuzzy_long_tokens_allow_one_sound_apart`,
+`::test_fuzzy_never_rewrites_toward_a_misspelt_entry`.
+
+**Lesson.** A decoder bias is text the model will happily read back to you;
+whatever goes into a Whisper prompt needs a guard on the way out. And "one
+letter apart" is a property of spelling — the person who registers a word is
+describing how it sounds.
diff --git a/jarvis/speech/stt_dictionary.py b/jarvis/speech/stt_dictionary.py
index 7f5843d04a..437185b9d3 100644
--- a/jarvis/speech/stt_dictionary.py
+++ b/jarvis/speech/stt_dictionary.py
@@ -5,11 +5,17 @@ Dictation-tool-style feature: the user registers words the STT keeps getting wro
``word`` plus optional ``misheard`` variants:
- ``misheard`` empty → plain vocabulary word. The corrector canonicalizes the
- casing of exact (case-insensitive) hits and repairs conservative near-misses
- of single tokens ("Veltrok" → "Veltroc").
+ casing of exact (case-insensitive) hits and repairs single tokens that
+ SOUND like the word ("Veltrok" → "Veltroc", "Klaude" → "Claude") — never a
+ common word that merely sits one letter away ("grob" stays "grob").
- ``misheard`` non-empty → explicit replacement pairs ("Gitter" → "GitHub"),
word-boundary + case-insensitive, multi-word capable.
+The canonical words are also handed to prompt-capable Whisper providers as a
+decoder bias, and Whisper answers silence by reciting that list back
+("…, Claude, Agentic IDE, Claude, Agentic"). The provider wrapper drops such a
+run from the end of a transcript before correcting it (BUG-185).
+
Design constraints (see the plan file and CLAUDE.md):
- Pure string ops — regex + a bounded edit distance. NO LLM call, NO network:
@@ -50,12 +56,51 @@ MAX_ENTRIES = 2_000
MAX_WORD_LEN = 100
MAX_MISHEARD_PER_ENTRY = 20
-# Conservative fuzzy-repair gates (plain vocabulary words only). A token is
-# rewritten toward a dictionary word only when ALL hold: same first letter,
-# minimum length, and edit distance within the length-scaled budget below.
-# This keeps "table" from becoming "Fable" while still fixing "Veltrok".
+# Fuzzy-repair gates (plain vocabulary words only). A token is rewritten
+# toward a dictionary word only when the two SOUND the same: both fold to the
+# same phonetic key (``_phonetic_fold``), or — for long tokens only — the
+# folded forms are one edit apart. A raw edit distance used to be enough,
+# which turned "grob" into "Grok" and "Clause" into "Claude": a person who
+# registers a word wants it fixed when they SAID it, not whenever they say a
+# common word that happens to be spelled nearby (BUG-185).
_FUZZY_MIN_TOKEN_LEN = 4
-_FUZZY_DISTANCE_BUDGET = ((8, 2), (_FUZZY_MIN_TOKEN_LEN, 1))
+_FUZZY_LONG_TOKEN_LEN = 8
+_FUZZY_LONG_TOKEN_BUDGET = 1
+
+# Spelling variants that sound alike in German and English, applied in order
+# on the casefolded token. Deliberately a short list: every rule makes MORE
+# tokens equal, and the whole point of the fold is to stay strict. The two
+# placeholders protect "sch"/"ch" from the c- and h-rules that follow.
+_FOLD_RULES: tuple[tuple[str, str], ...] = (
+ ("ä", "e"),
+ ("ae", "e"),
+ ("sch", "\x01"),
+ ("ch", "\x02"),
+ ("ph", "f"),
+ ("th", "t"),
+ ("ck", "k"),
+ ("dt", "t"),
+ ("tz", "ts"),
+ ("z", "ts"),
+ ("qu", "kv"),
+ ("x", "ks"),
+ ("c", "k"),
+ ("v", "f"),
+ ("w", "v"),
+ ("y", "i"),
+ ("ie", "i"),
+ ("ei", "ai"),
+ ("ou", "au"), # English "ou" is German "au": "Cloude" is how STT spells "Claude"
+)
+_FOLD_SILENT_H_RE = re.compile(r"(?<!^)h")
+_FOLD_REPEAT_RE = re.compile(r"(.)\1+")
+
+# Prompt-echo guard. A run of dictionary items at the END of a transcript is
+# Whisper reciting its bias prompt, never speech, when it is long enough or
+# repeats itself; a whole transcript made of nothing else needs fewer items,
+# because a stretch of silence is exactly where the recitation happens.
+_ECHO_MIN_TAIL_ITEMS = 3
+_ECHO_MIN_WHOLE_ITEMS = 2
# Re-stat the sidecar at most this often — the corrector is consulted per
# STT call (including the live-preview probe at a few calls/second).
@@ -305,11 +350,67 @@ def _edit_distance_within(a: str, b: str, budget: int) -> bool:
return prev[-1] <= budget
-def _fuzzy_budget(length: int) -> int:
- for min_len, budget in _FUZZY_DISTANCE_BUDGET:
- if length >= min_len:
- return budget
- return 0
+def _phonetic_fold(token: str) -> str:
+ """Collapse a token to how it sounds, so spelling twins compare equal.
+
+ "Veltrok"/"Veltroc", "Klaude"/"Claude", "Meier"/"Mayer" and
+ "Anthropik"/"Anthropic" fold to one key each; "grob"/"Grok" and
+ "Clause"/"Claude" do not. Only ever compared with another fold — the
+ result is a key, not a spelling.
+ """
+ folded = token.casefold()
+ for source, target in _FOLD_RULES:
+ folded = folded.replace(source, target)
+ folded = _FOLD_SILENT_H_RE.sub("", folded)
+ folded = folded.replace("\x01", "sh").replace("\x02", "ch")
+ return _FOLD_REPEAT_RE.sub(r"\1", folded)
+
+
+def _sounds_like(token: str, token_fold: str, word: str, word_fold: str) -> bool:
+ """True iff ``token`` may be repaired to ``word`` — they sound the same."""
+ if token_fold == word_fold:
+ return True
+ if len(token) < _FUZZY_LONG_TOKEN_LEN or len(word) < _FUZZY_LONG_TOKEN_LEN:
+ return False
+ return _edit_distance_within(token_fold, word_fold, _FUZZY_LONG_TOKEN_BUDGET)
+
+
+def _compile_echo_patterns(
+ entries: list[DictionaryEntry],
+) -> tuple[re.Pattern[str] | None, re.Pattern[str] | None]:
+ """Patterns behind :meth:`TranscriptCorrector.strip_prompt_echo`.
+
+ ``tail`` matches a run of dictionary items that closes the text —
+ whole entries, plus the single tokens of multi-word entries, because a
+ recitation may start mid-phrase ("IDE, Agentic IDE, …"). ``item`` finds
+ the WHOLE entries inside such a run; fragments never count as items.
+ """
+ phrases = sorted({e.word for e in entries}, key=len, reverse=True)
+ if not phrases:
+ return None, None
+ whole = [r"\s+".join(re.escape(tok) for tok in p.split()) for p in phrases]
+ known = {p.casefold() for p in phrases}
+ fragments = sorted(
+ {
+ tok
+ for p in phrases
+ if " " in p
+ for tok in p.split()
+ if len(tok) >= 2 and tok.casefold() not in known
+ },
+ key=len,
+ reverse=True,
+ )
+ item_alt = "|".join(whole)
+ run_alt = "|".join(whole + [re.escape(f) for f in fragments])
+ separator = r"(?:\s*[,;:]\s*|\s*\.\s+|\s+)"
+ tail = re.compile(
+ rf"(?<!\w)(?P<run>(?:{run_alt})(?:{separator}(?:{run_alt}))+)(?!\w)"
+ r"[\s,.;:!?]*$",
+ re.IGNORECASE | re.UNICODE,
+ )
+ item = re.compile(rf"(?<!\w)(?:{item_alt})(?!\w)", re.IGNORECASE | re.UNICODE)
+ return tail, item
class TranscriptCorrector:
@@ -334,9 +435,9 @@ class TranscriptCorrector:
]
# Fuzzy-repair index for SINGLE-token canonical words, keyed by the
- # casefolded first letter. Multi-token phrases are excluded — near-miss
- # repair across token splits is what explicit pairs are for.
- self._fuzzy_index: dict[str, list[str]] = {}
+ # first letter of the phonetic fold. Multi-token phrases are excluded —
+ # near-miss repair across token splits is what explicit pairs are for.
+ self._fuzzy_index: dict[str, list[tuple[str, str]]] = {}
self._canonical_tokens: set[str] = set()
for entry in entries:
word = entry.word
@@ -345,11 +446,41 @@ class TranscriptCorrector:
continue
if not word[0].isalpha():
continue
- self._fuzzy_index.setdefault(word[0].casefold(), []).append(word)
+ fold = _phonetic_fold(word)
+ self._fuzzy_index.setdefault(fold[:1], []).append((word, fold))
self._token_re = re.compile(r"[^\W\d_][\w''\-]*", re.UNICODE)
+ self._echo_tail_re, self._echo_item_re = _compile_echo_patterns(entries)
self.rule_count = len(self._replacements) + len(self._casing)
+ def strip_prompt_echo(self, text: str) -> str:
+ """Drop a recited bias prompt from the end of ``text``.
+
+ Prompt-capable Whisper providers receive the canonical words as a
+ comma-separated decoder bias, and Whisper answers a stretch of silence
+ by continuing that list — "…, Claude, Agentic IDE, Claude, Agentic".
+ A run of dictionary items closing the transcript is that recitation
+ when it holds at least ``_ECHO_MIN_TAIL_ITEMS`` items or repeats one;
+ a transcript made of nothing else needs ``_ECHO_MIN_WHOLE_ITEMS``.
+ One trailing word, or two different ones, is a sentence and stays:
+ "…nutze Claude, Agentic IDE." is something a person says.
+ """
+ if not text or self._echo_tail_re is None or self._echo_item_re is None:
+ return text
+ match = self._echo_tail_re.search(text)
+ if match is None:
+ return text
+ run = match.group("run")
+ items = [
+ " ".join(m.group(0).casefold().split())
+ for m in self._echo_item_re.finditer(run)
+ ]
+ whole = match.start("run") == 0 or not text[: match.start("run")].strip()
+ needed = _ECHO_MIN_WHOLE_ITEMS if whole else _ECHO_MIN_TAIL_ITEMS
+ if len(items) < needed and len(items) == len(set(items)):
+ return text
+ return text[: match.start("run")].rstrip()
+
def correct(self, text: str) -> str:
if not text or self.rule_count == 0:
return text
@@ -371,15 +502,13 @@ class TranscriptCorrector:
folded = token.casefold()
if len(token) < _FUZZY_MIN_TOKEN_LEN or folded in self._canonical_tokens:
return token
- candidates = self._fuzzy_index.get(token[0].casefold())
+ token_fold = _phonetic_fold(token)
+ candidates = self._fuzzy_index.get(token_fold[:1])
if not candidates:
return token
best: str | None = None
- for word in candidates:
- allowed = min(_fuzzy_budget(len(token)), _fuzzy_budget(len(word)))
- if allowed <= 0:
- continue
- if _edit_distance_within(folded, word.casefold(), allowed):
+ for word, word_fold in candidates:
+ if _sounds_like(token, token_fold, word, word_fold):
if best is not None and best != word:
return token # ambiguous between two entries — leave it
best = word
@@ -508,21 +637,36 @@ class DictionaryCorrectingSTT:
if not text:
return transcript
corrector = get_corrector(self._store)
- corrected = corrector.correct(text)
# A provider may also carry the pre-cleanup string on ``raw_text``,
# and the dictation lane transcribes from THAT. The user's spelling
# corrections are not part of the cleanup they opted out of — they
# are words a person registered by name — so they have to reach both
# fields or dictation silently stops honouring the dictionary.
raw = getattr(transcript, "raw_text", "") or ""
+ # A finished transcript that ends in a recited bias prompt loses
+ # that tail BEFORE correction. Partials are still growing — an
+ # enumeration cut off mid-list is not evidence of anything.
+ if not getattr(transcript, "is_partial", False):
+ kept = corrector.strip_prompt_echo(text)
+ if kept != text:
+ log.info(
+ "STT dictionary dropped a recited bias prompt from the "
+ "transcript tail: %r",
+ text[len(kept) :].strip(),
+ )
+ text = kept
+ raw = corrector.strip_prompt_echo(raw) if raw else raw
+ corrected = corrector.correct(text)
corrected_raw = corrector.correct(raw) if raw else raw
- if corrected == text and corrected_raw == raw:
+ original_text = getattr(transcript, "text", "")
+ original_raw = getattr(transcript, "raw_text", "") or ""
+ if corrected == original_text and corrected_raw == original_raw:
return transcript
- log.debug("STT dictionary corrected: %r -> %r", text, corrected)
+ log.debug("STT dictionary corrected: %r -> %r", original_text, corrected)
updates: dict[str, Any] = {"text": corrected}
# Only when the provider actually has the field: passing it to a
# provider that does not would raise instead of correcting.
- if raw:
+ if original_raw:
updates["raw_text"] = corrected_raw
if dataclasses.is_dataclass(transcript):
return dataclasses.replace(transcript, **updates)
diff --git a/tests/unit/speech/test_stt_dictionary.py b/tests/unit/speech/test_stt_dictionary.py
index 3e449a0de5..e13b060e1d 100644
--- a/tests/unit/speech/test_stt_dictionary.py
+++ b/tests/unit/speech/test_stt_dictionary.py
@@ -171,11 +171,32 @@ class TestVocabularyWords:
def test_fuzzy_leaves_distant_words_alone(self) -> None:
c = corrector_for(("Fable", []))
# "Farbe" (a common German word, the real-world STT garble of "Fable"
- # from the AP-27 forensics) is distance 2 at length 5 — beyond the
- # ≤7-char budget of 1, so it is NOT auto-rewritten (explicit pairs are
- # the tool for that).
+ # from the AP-27 forensics) does not SOUND like "Fable", so it is NOT
+ # auto-rewritten (explicit pairs are the tool for that).
assert c.correct("welche Farbe hat das") == "welche Farbe hat das" # i18n-allow: German STT-garble token under test
+ def test_fuzzy_repairs_only_what_sounds_the_same(self) -> None:
+ # BUG-185: a raw edit distance of 1 rewrote common words toward the
+ # user's terms. Spelling twins are repaired; neighbours by spelling
+ # that sound different are not.
+ c = corrector_for(("Claude", []), ("Grok", []), ("Anthropic", []))
+ assert c.correct("one Klaude terminal") == "one Claude terminal"
+ assert c.correct("one Cloude terminal") == "one Claude terminal"
+ assert c.correct("ask Anthropik") == "ask Anthropic"
+ neighbours = ("Clause", "Cloud", "grob", "Gros", "Grad") # i18n-allow: German words
+ for untouched in neighbours:
+ assert c.correct(f"say {untouched} now") == f"say {untouched} now"
+
+ def test_fuzzy_long_tokens_allow_one_sound_apart(self) -> None:
+ c = corrector_for(("Kubernetes", []))
+ assert c.correct("deploy on Kubernetis") == "deploy on Kubernetes"
+
+ def test_fuzzy_never_rewrites_toward_a_misspelt_entry(self) -> None:
+ # The live dictionary held "GitHuib" (a typo); the raw distance rule
+ # then rewrote every correctly heard "GitHub" INTO the typo.
+ c = corrector_for(("GitHuib", []))
+ assert c.correct("open GitHub now") == "open GitHub now"
+
def test_fuzzy_ambiguous_between_entries_is_left_alone(self) -> None:
# "Nicko" is within distance 1 of BOTH entries — ambiguous, so the
# corrector must not guess.
@@ -199,6 +220,61 @@ class TestVocabularyWords:
assert c.correct("nothing to do here") == "nothing to do here"
+# ----------------------------------------------------------------------
+# Prompt echo (BUG-185)
+# ----------------------------------------------------------------------
+
+
+def _live_corrector() -> TranscriptCorrector:
+ """The maintainer's dictionary on the evening the recitation landed."""
+ return corrector_for(
+ ("GitHub", ["Gitter"]),
+ ("Grok", ["Grog"]),
+ ("Claude", []),
+ ("Agentic IDE", ["Genetic-ID"]),
+ ("Agentic", ["Genetic"]),
+ )
+
+
+class TestPromptEcho:
+ def test_recited_prompt_is_dropped_from_the_tail(self) -> None:
+ # Verbatim from dictation history 2026-08-26 17:24 UTC: Groq Whisper
+ # answered the silent tail of a window by continuing its bias prompt,
+ # "…, Claude, Agentic IDE, Agentic", starting mid-phrase.
+ c = _live_corrector()
+ spoken = "It has to be a smooth transition that looks professional."
+ recited = (
+ " IDE, Agentic IDE, Agentic IDE, Agentic IDE, Agentic IDE, Claude, "
+ "Agentic IDE, Claude, Agentic"
+ )
+ assert c.strip_prompt_echo(spoken + recited) == spoken
+
+ def test_whole_window_of_recitation_becomes_empty(self) -> None:
+ # A window with no speech in it comes back as the list alone.
+ assert _live_corrector().strip_prompt_echo("Claude, Agentic IDE") == ""
+
+ def test_a_repeated_item_is_enough(self) -> None:
+ c = _live_corrector()
+ assert c.strip_prompt_echo("And then Agentic IDE, Agentic IDE") == "And then"
+
+ def test_a_sentence_ending_in_dictionary_words_stays(self) -> None:
+ c = _live_corrector()
+ for sentence in (
+ "Claude",
+ "open Claude.",
+ "I use Claude, Agentic IDE.",
+ "do it with Claude Agentic IDE.",
+ "Claude, Agentic IDE, Grok are the three sections.",
+ ):
+ assert c.strip_prompt_echo(sentence) == sentence
+
+ def test_empty_dictionary_never_strips(self) -> None:
+ c = corrector_for()
+ assert c.strip_prompt_echo("Claude, Agentic IDE, Claude") == (
+ "Claude, Agentic IDE, Claude"
+ )
+
+
# ----------------------------------------------------------------------
# Live-reloading shared corrector + bias words
# ----------------------------------------------------------------------
@@ -291,6 +367,31 @@ class TestWrapper:
result = await wrapped.transcribe_pcm(b"")
assert result.text == ""
+ async def test_recited_prompt_is_dropped_before_correction(
+ self, store: DictionaryStore, monkeypatch: pytest.MonkeyPatch
+ ) -> None:
+ monkeypatch.setattr(sd, "_RELOAD_CHECK_INTERVAL_S", 0.0)
+ store.add("Claude")
+ store.add("Agentic IDE", ["Genetic-ID"])
+ heard = "open Gitter. Claude, Agentic IDE, Claude, Agentic IDE"
+ store.add("GitHub", ["Gitter"])
+ wrapped = DictionaryCorrectingSTT(_FakeSTT(heard), store=store)
+ result = await wrapped.transcribe_pcm(b"\x00\x00")
+ assert result.text == "open GitHub."
+
+ async def test_partial_transcripts_keep_their_tail(
+ self, store: DictionaryStore, monkeypatch: pytest.MonkeyPatch
+ ) -> None:
+ # A partial is still growing: an enumeration cut off mid-list is not a
+ # recitation, so only the finished transcript loses the run.
+ monkeypatch.setattr(sd, "_RELOAD_CHECK_INTERVAL_S", 0.0)
+ store.add("Claude")
+ store.add("Agentic IDE")
+ heard = "Claude, Agentic IDE, Claude"
+ wrapped = DictionaryCorrectingSTT(_FakeSTT(heard), store=store)
+ texts = [t.text async for t in wrapped.stream_transcribe(None)]
+ assert texts == [heard, ""]
+
def test_delegates_unknown_attributes(
self, wrapped: DictionaryCorrectingSTT
) -> None: