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(realtime): stop a subtitle outro from becoming a turn the user never spoke
rubenluetke10-beep1f66a2cd06ce
diff --git a/jarvis/realtime/input_transcription.py b/jarvis/realtime/input_transcription.pyindex 6a874429b1..03acb9680a 100644--- a/jarvis/realtime/input_transcription.py+++ b/jarvis/realtime/input_transcription.py@@ -34,6 +34,11 @@ from collections import dequefrom dataclasses import dataclassfrom typing import Any+# Leaf module, stdlib-only — importing it here drags in neither the speech+# pipeline nor any recognizer runtime. It owns the ONE silence-boilerplate+# verdict the dictation delivery gate uses as well (BUG-008 drift rule).+from jarvis.speech.wake_constants import is_silence_hallucination+log = logging.getLogger(__name__)# Endpointing: deliberately simple and dependency-free. The far end runs its@@ -661,6 +666,26 @@ class LocalInputTranscriber:InputTranscriptEvent(kind=TRANSCRIPT_FAILED, voiced_ms=voiced_ms))return+ if is_silence_hallucination(text, voiced_ms / 1000.0):+ # Whisper-family boilerplate over near-silence, whole-utterance and+ # inside the short window (the shared dictation verdict — never a+ # keyword ban on real speech). Live 2026-08-06 17:39:57 the+ # recognizer delivered a subtitle outro as a genuine turn: it+ # grounded a response the user never asked for AND flipped the+ # call's output language on its way through. Treated as a failed+ # transcript, so the far end's own caption for the same audio can+ # still stand in — the endpointer only vouched for ENERGY, and+ # energy is what a speaker leak has too.+ log.info(+ "Discarding a %d ms local input transcript as silence "+ "boilerplate: %r",+ voiced_ms,+ text[:80],+ )+ self._emit(+ InputTranscriptEvent(kind=TRANSCRIPT_FAILED, voiced_ms=voiced_ms)+ )+ returnlog.info("realtime local input transcript (%.0f ms): %r",(time.monotonic() - started) * 1000,diff --git a/jarvis/speech/pipeline.py b/jarvis/speech/pipeline.pyindex 28c50ba29a..805d4ba0b3 100644--- a/jarvis/speech/pipeline.py+++ b/jarvis/speech/pipeline.py@@ -1383,63 +1383,16 @@ WAKE_ONLY_RE = re.compile(# Whisper emits on an empty mic / speaker leak). Blocked before the brain# call. Single definition lives in wake_constants (the rolling wake's# bias-echo confirm consumes the same list — BUG-008 drift rule).+# The short-recording + whole-utterance verdict itself lives beside the pattern+# in that same leaf module, because the realtime input recognizer needs exactly+# this judgement too and a second copy would drift (BUG-008).from jarvis.speech.wake_constants import ( # noqa: E402STT_HALLUCINATION_RE as _STT_HALLUCINATION_RE,)--# Longest recording the silence-hallucination filter is allowed to judge. Above-# it the filter stands down entirely: a person who spoke for three seconds said-# something, and "thank you very much for the update" is a real sentence that-# happens to open with the same words as the boilerplate. Below it there is-# barely room for a real utterance, which is exactly the window in which a-# near-silent microphone makes a Whisper-family model produce its subtitle-# credits.-_DICTATION_HALLUCINATION_MAX_S = 2.5--# Words that occur in the hallucination markers themselves, DERIVED from the one-# shared pattern rather than written out a second time — a second list would-# stop agreeing with the first the day either is touched (BUG-008). Regex-# metacharacters contribute the odd single letter, so anything shorter than two-# characters is dropped; digits never enter, which is what lets a boilerplate-# year ("copyright 2020") count as covered.-_HALLUCINATION_WORD_RE = re.compile(r"[^\W\d_]{2,}", re.UNICODE)-_HALLUCINATION_VOCABULARY: frozenset[str] = frozenset(- _HALLUCINATION_WORD_RE.findall(_STT_HALLUCINATION_RE.pattern.lower())+from jarvis.speech.wake_constants import ( # noqa: E402+ is_silence_hallucination as _is_silence_hallucination,)--def _is_silence_hallucination(text: str, duration_s: float) -> bool:- """Is *text* boilerplate a silent microphone produced, not speech?-- Two independent conditions, and BOTH are needed — either one alone gets a- real dictation deleted:-- * **The recording is short.** Whisper hallucinates on near-silence, so the- filter only judges recordings too short to hold much else. The audio- length is the honest measure here (see the caller), not the wall clock.- * **The boilerplate is the WHOLE utterance.** ``_STT_HALLUCINATION_RE``- matches a substring, which is the right shape for the voice lane — there- the question is "may this reach the brain". On a transcript the question- is different: "thank you very much for the update" contains a marker and- is a sentence the user dictated. So a match is necessary but not- sufficient; every word of the transcript must also come from the markers'- own vocabulary. "Thank you for watching!" passes that test (the shared- pattern spells the outro "thanks for watching", and the vocabulary covers- the other spelling for free); "vielen Dank für das Update" does not,- because "update" is nobody's boilerplate.-- Digits are ignored on purpose: the markers carry years, and a year is not- what distinguishes a hallucination from a sentence.- """- if duration_s >= _DICTATION_HALLUCINATION_MAX_S:- return False- body = (text or "").strip()- if not body or _STT_HALLUCINATION_RE.search(body) is None:- return False- words = _HALLUCINATION_WORD_RE.findall(body.lower())- return bool(words) and all(word in _HALLUCINATION_VOCABULARY for word in words)--# Paraphrase prefixes Gemini/Claude put in front of an answer when unsure.# Cut off as post-processing before the TTS call._PARAPHRASE_PREFIXES: tuple[str, ...] = (diff --git a/jarvis/speech/wake_constants.py b/jarvis/speech/wake_constants.pyindex 821f6e80c6..d8520d299e 100644--- a/jarvis/speech/wake_constants.py+++ b/jarvis/speech/wake_constants.py@@ -73,6 +73,64 @@ STT_HALLUCINATION_RE = re.compile(re.IGNORECASE,)+# Longest recording the silence-hallucination filter is allowed to judge. Above+# it the filter stands down entirely: a person who spoke for three seconds said+# something, and "thank you very much for the update" is a real sentence that+# happens to open with the same words as the boilerplate. Below it there is+# barely room for a real utterance, which is exactly the window in which a+# near-silent microphone makes a Whisper-family model produce its subtitle+# credits.+SILENCE_HALLUCINATION_MAX_S = 2.5++# Words that occur in the hallucination markers themselves, DERIVED from the one+# shared pattern rather than written out a second time — a second list would+# stop agreeing with the first the day either is touched (BUG-008). Regex+# metacharacters contribute the odd single letter, so anything shorter than two+# characters is dropped; digits never enter, which is what lets a boilerplate+# year ("copyright 2020") count as covered.+_HALLUCINATION_WORD_RE = re.compile(r"[^\W\d_]{2,}", re.UNICODE)+_HALLUCINATION_VOCABULARY: frozenset[str] = frozenset(+ _HALLUCINATION_WORD_RE.findall(STT_HALLUCINATION_RE.pattern.lower())+)+++def is_silence_hallucination(text: str, duration_s: float) -> bool:+ """Is *text* boilerplate a silent microphone produced, not speech?++ Two independent conditions, and BOTH are needed — either one alone gets a+ real utterance deleted:++ * **The recording is short.** Whisper hallucinates on near-silence, so the+ filter only judges recordings too short to hold much else. The audio+ length is the honest measure here (see the callers), not the wall clock.+ * **The boilerplate is the WHOLE utterance.** ``STT_HALLUCINATION_RE``+ matches a substring, which is the right shape for the voice lane — there+ the question is "may this reach the brain". On a transcript the question+ is different: "thank you very much for the update" contains a marker and+ is a sentence the user dictated. So a match is necessary but not+ sufficient; every word of the transcript must also come from the markers'+ own vocabulary. "Thank you for watching!" passes that test (the shared+ pattern spells the outro "thanks for watching", and the vocabulary covers+ the other spelling for free); the German sentence+ "vielen Dank für das Update" does not, because "update" is nobody's # i18n-allow: the pattern lists "vielen dank", so the sentence that must SURVIVE it is shown in that same language+ boilerplate.++ Digits are ignored on purpose: the markers carry years, and a year is not+ what distinguishes a hallucination from a sentence.++ Lives here, in the leaf module beside the pattern itself, because BOTH the+ dictation delivery gate and the realtime input recognizer need the same+ verdict — a second copy would stop agreeing with the first (BUG-008).+ """+ if duration_s >= SILENCE_HALLUCINATION_MAX_S:+ return False+ body = (text or "").strip()+ if not body or STT_HALLUCINATION_RE.search(body) is None:+ return False+ words = _HALLUCINATION_WORD_RE.findall(body.lower())+ return bool(words) and all(word in _HALLUCINATION_VOCABULARY for word in words)++# Common wake prefixes stripped when deriving the phrase *core* for model# lookup and canonical keyword names. The matcher may still keep an explicit# prefix when the configured phrase includes one.diff --git a/tests/unit/realtime/test_input_transcription.py b/tests/unit/realtime/test_input_transcription.pyindex 8cbba5b62d..d76d70fac6 100644--- a/tests/unit/realtime/test_input_transcription.py+++ b/tests/unit/realtime/test_input_transcription.py@@ -328,6 +328,40 @@ async def test_an_empty_result_also_announces_itself() -> None:await transcriber.close()+async def test_silence_boilerplate_never_becomes_a_grounded_turn() -> None:+ """Live 2026-08-06 17:39:57: a subtitle outro became a real user turn.++ The endpointer only ever vouches for ENERGY, and a speaker leak has energy+ too — so a Whisper-family model produced its end-card boilerplate over+ that leak, the far end answered a question nobody asked, and the call's+ output language flipped to English on the way through. It must land as a+ FAILED transcript, so the far end's own caption for the same audio can+ still stand in for the turn.+ """+ stt = _FakeSTT("Thank you for watching!")+ transcriber = LocalInputTranscriber(sample_rate=RATE, stt_factory=lambda: stt)+ _speak(transcriber)++ events = await _drain(transcriber, 2)+ assert events[0].kind == module.SPEECH_STARTED+ assert events[1].kind == module.TRANSCRIPT_FAILED+ await transcriber.close()+++async def test_a_real_sentence_that_merely_starts_like_boilerplate_survives() -> None:+ """The other half: a keyword ban would delete what the user really said."""+ stt = _FakeSTT("Thank you very much for the update on the wiki.")+ transcriber = LocalInputTranscriber(sample_rate=RATE, stt_factory=lambda: stt)+ _speak(transcriber)++ events = await _drain(transcriber, 2)+ assert events[1].kind == module.TRANSCRIPT+ assert events[1].text == "Thank you very much for the update on the wiki."+ await transcriber.close()++# -- sample rate ------------------------------------------------------------