You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Voice: TTS text is not shaped for speech — markdown, file paths, URLs and code fences read aloud #13102
Text sent to TTS is not shaped for speech. Assistant replies routinely contain
markdown, file paths, URLs, and fenced code blocks — read aloud these are symbol
soup ("autobot dash backend slash l l c slash adapters slash base dot p y").
This is worst exactly where voice matters most: replies from coding agents, which
are dense with paths and code.
Evidence
autobot-frontend/src/composables/useVoiceConversation.ts:146-167 — _sanitizeForSpeech() removes [THOUGHT]/[PLANNING]/[DEBUG]/[SOURCES]
markers, <TOOL_CALL> tags, and all HTML, then truncates at a sentence boundary.
It does not touch:
markdown syntax (*, _, #, >, list bullets, numbered lists, link syntax)
fenced code blocks
file paths and filenames
URLs
Proposed approach
New pure helper in autobot-frontend/src/utils/ttsSentences.ts (next to the
existing sentence logic — pure, no browser deps, unit-testable). _sanitizeForSpeech() delegates to it; the logic does not go into useVoiceConversation.ts, which is already carrying too much.
Transformations:
links → their text; inline code → its contents; strip *_~#> and list markers
URLs → a spoken placeholder
path-shaped tokens and known code-file extensions → a spoken placeholder
fenced code blocks dropped entirely, with state carried across streaming
deltas — the ``` marker can split across two chunks, so a held-back trailing
backtick buffer is required or a fence leaks through
repair a missing space at a sentence join (now.Right → now. Right)
Constraints
Conservative matching. Ordinary prose must survive — "and/or", "24/7",
"e.g.", decimals, and arr[0] in a legitimately spoken context.
i18n: the replacement strings are user-visible and need all 11 locales.
This is the real cost of this issue, not the regex.
The written transcript must be unaffected — this shapes the spoken stream
only.
Acceptance criteria
Pure, unit-tested helper in utils/ttsSentences.ts
Fence stripping is correct when the ``` marker splits across two streamed
deltas (explicit test)
Consolidation note — the HTML half already exists; only the speech half is new.
_sanitizeForSpeech() (useVoiceConversation.ts:146-167) hand-rolls HTML stripping — a script-tag regex plus a while (prev !== clean) tag-stripping loop, carrying two codeql[js/incomplete-multi-character-sanitization] suppressions.
Meanwhile autobot-frontend/src/utils/sanitize.ts already provides sanitizeHtml(), sanitizeChatHtml(), and sanitizeKnowledgeHtml().
So this issue splits cleanly in two:
Delegate the HTML-stripping half to the existing sanitize.ts — removes hand-rolled sanitization and its CodeQL suppressions rather than porting them to a new file.
Add only the genuinely new speech-shaping logic (markdown, paths, URLs, fenced code) in utils/ttsSentences.ts.
Moving the hand-rolled version into ttsSentences.ts as-is would relocate the duplication instead of removing it.
Delivered by #17954 (merge 7f8e7385db). Verified against origin/main:
Pure, unit-tested helper in utils/ttsSentences.ts
createSpeechShaper / shapeForSpeech, with openingFence / closesFence (CommonMark line-start rules).
No browser dependencies; placeholders are passed in.
Tests are in utils/__tests__/ttsSpeechShaping.test.ts.
Fence stripping is correct when the ``` marker splits across two streamed deltas (explicit test)
Case drops the block when the ``` marker splits across two streamed deltas.
Also keeps fence state across slices, keeps a four-backtick block closed against an inner ``` line, and does not treat ``` in the middle of a line as a fence.
Prose false-positive cases covered by tests
it.each over 11 prose sentences: "and/or", "24/7", "e.g.", "3.14", arr[0], "Node.js", my_var/2 * 3, a bare "/etc", a date, "he/she/they", "TCP/IP/UDP". Each is asserted unchanged.
Replacement strings localized in all 11 locales
voice.speech.url / voice.speech.path are translated in ar, de, en, es, fa, fr, he, lv, pl, pt, ur ("a link" / "a file path", "ein Link" / "ein Dateipfad", …).
Displayed transcript unchanged — verified by test
Case advances the streaming cursor over the RAW text while only the spoken copy is shaped. The raw transcript is unchanged, consumed === transcript.length, and spans.join('') === transcript.slice(0, consumed).
Shaping happens only on the TTS copy: ChatInterface.vue_speechShaper.push(span), and useVoiceConversation._sanitizeForSpeech, which runs after the bubble stores the raw response.
Activity
mrveiss commentedon Jul 31, 2026
Parent: #13096 (capability audit umbrella).
mrveiss commentedon Jul 31, 2026
Consolidation note — the HTML half already exists; only the speech half is new.
_sanitizeForSpeech()(useVoiceConversation.ts:146-167) hand-rolls HTML stripping — a script-tag regex plus awhile (prev !== clean)tag-stripping loop, carrying twocodeql[js/incomplete-multi-character-sanitization]suppressions.Meanwhile
autobot-frontend/src/utils/sanitize.tsalready providessanitizeHtml(),sanitizeChatHtml(), andsanitizeKnowledgeHtml().So this issue splits cleanly in two:
sanitize.ts— removes hand-rolled sanitization and its CodeQL suppressions rather than porting them to a new file.utils/ttsSentences.ts.Moving the hand-rolled version into
ttsSentences.tsas-is would relocate the duplication instead of removing it.fix(voice): fences open and close only at line start by CommonMark's …
fix(voice): TTS text shaped for speech, CommonMark-correct fences, an…
mrveiss commentedon Oct 4, 2026
Delivered by #17954 (merge
7f8e7385db). Verified againstorigin/main:utils/ttsSentences.tscreateSpeechShaper/shapeForSpeech, withopeningFence/closesFence(CommonMark line-start rules).utils/__tests__/ttsSpeechShaping.test.ts.drops the block when the ``` marker splits across two streamed deltas.keeps fence state across slices,keeps a four-backtick block closed against an inner ``` line, anddoes not treat ``` in the middle of a line as a fence.it.eachover 11 prose sentences: "and/or", "24/7", "e.g.", "3.14",arr[0], "Node.js",my_var/2 * 3, a bare "/etc", a date, "he/she/they", "TCP/IP/UDP". Each is asserted unchanged.voice.speech.url/voice.speech.pathare translated in ar, de, en, es, fa, fr, he, lv, pl, pt, ur ("a link" / "a file path", "ein Link" / "ein Dateipfad", …).advances the streaming cursor over the RAW text while only the spoken copy is shaped. The raw transcript is unchanged,consumed === transcript.length, andspans.join('') === transcript.slice(0, consumed).ChatInterface.vue_speechShaper.push(span), anduseVoiceConversation._sanitizeForSpeech, which runs after the bubble stores the rawresponse.