[GH-ISSUE #2754] [Issue]: TTS dialogue segmentation speaks markdown/code literally and mis-classifies bracketed lines #1392

Closed
opened 2026-10-21 05:32:53 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @kolacheee on GitHub (Jun 21, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2754

Originally assigned to: @SpicyMarinara on GitHub.

Summary

tts-dialogue.ts text cleaning and dialogue classification mishandle common roleplay/markdown formatting. cleanTTSInputText removes {effect:}/[tag:]/<html> but no markdown, so asterisk actions, emphasis, headings, and code are sent verbatim to the synth. Separately, the dialogueOnly VN-line regex over-matches incidental [x]: y lines and short-circuits the quote fallback, dropping genuine dialogue.

Sub-bug 1: Markdown spoken literally (#7)

  • How it breaks: cleanTTSInputText (236-243) has rules only for {effect:}, [tag:] (requires a colon inside brackets), and <...> — nothing for * _ ** # ~~ or [label](url). In the default non-dialogueOnly path with no <speaker> tags, the whole cleaned message is spoken.
  • Repro: Default config; an RP message *She smiles* **Hello**, run \npm test`` is POSTed to TTS with asterisks/backticks intact -> odd pauses or literal vocalization.

Sub-bug 2: Code blocks spoken (#69)

  • How it breaks: Same missing rules; fenced ``` blocks and inline backticks survive into the spoken text. ElevenLabs (raw passthrough) gets no instructions hint; OpenAI/NanoGPT only get a soft hint that doesn't strip characters.
  • Repro: A message containing a fenced code block is read with backticks and code content verbatim — long garbled audio + wasted TTS cost.

Sub-bug 3: VN-line over-match drops dialogue (#8)

  • How it breaks: In dialogueOnly mode, extractDialogueUtterances matches vnLineRe (376) whose speaker group accepts any non-bracket content. [note]: https://..., [12:30]: ..., [OOC]: be right back all parse as utterances; because any match triggers an early return (394-395), the quote-based fallback never runs and real quoted dialogue is dropped.
  • Repro: dialogueOnly enabled; message [OOC]: be right back\n"Where did everyone go?" -> speaks 'be right back', the real quote is never spoken.

Suggested Fix

Extend cleanTTSInputText to strip fenced/inline code, emphasis markers (** __ * _ ~~), heading/blockquote/list markers, and convert [label](url) to label, before whitespace collapse. Tighten vnLineRe so the bracketed speaker can't be a URL/time/known meta tag (or require a known-speaker set), and don't early-return on a single weak VN match so the quote fallback can still contribute.

Verification checklist (all manual)

  • Manually verify an RP message with actions/bold/inline-code is spoken without literal markdown
  • Verify a message with a fenced code block does not read backticks/code aloud
  • Verify dialogueOnly mode does not speak [OOC]:/reference-link/timestamp lines as dialogue and still speaks genuine quotes
  • Run pnpm check

Affected files

  • packages/client/src/lib/tts-dialogue.ts

Audit provenance

Found by a multi-agent static audit of the TTS/voice + image-generation subsystems (Round 1 + round-2 gap sweep + completeness critic, each finding adversarially verified) against the merged staging tree. Severity: MEDIUM.

AI-drafted from a static read; validation/test-plan boxes intentionally left UNCHECKED for a human to verify before close.

Originally created by @kolacheee on GitHub (Jun 21, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2754 Originally assigned to: @SpicyMarinara on GitHub. ## Summary `tts-dialogue.ts` text cleaning and dialogue classification mishandle common roleplay/markdown formatting. `cleanTTSInputText` removes `{effect:}`/`[tag:]`/`<html>` but no markdown, so asterisk actions, emphasis, headings, and code are sent verbatim to the synth. Separately, the dialogueOnly VN-line regex over-matches incidental `[x]: y` lines and short-circuits the quote fallback, dropping genuine dialogue. ## Sub-bug 1: Markdown spoken literally (#7) - **How it breaks:** `cleanTTSInputText` (236-243) has rules only for `{effect:}`, `[tag:]` (requires a colon inside brackets), and `<...>` — nothing for `* _ ` ` ` `** # ~~` or `[label](url)`. In the default non-dialogueOnly path with no `<speaker>` tags, the whole cleaned message is spoken. - **Repro:** Default config; an RP message `*She smiles* **Hello**, run \`npm test\`` is POSTed to TTS with asterisks/backticks intact -> odd pauses or literal vocalization. ## Sub-bug 2: Code blocks spoken (#69) - **How it breaks:** Same missing rules; fenced ``` blocks and inline backticks survive into the spoken text. ElevenLabs (raw passthrough) gets no instructions hint; OpenAI/NanoGPT only get a soft hint that doesn't strip characters. - **Repro:** A message containing a fenced code block is read with backticks and code content verbatim — long garbled audio + wasted TTS cost. ## Sub-bug 3: VN-line over-match drops dialogue (#8) - **How it breaks:** In dialogueOnly mode, `extractDialogueUtterances` matches `vnLineRe` (376) whose speaker group accepts any non-bracket content. `[note]: https://...`, `[12:30]: ...`, `[OOC]: be right back` all parse as utterances; because any match triggers an early return (394-395), the quote-based fallback never runs and real quoted dialogue is dropped. - **Repro:** dialogueOnly enabled; message `[OOC]: be right back\n"Where did everyone go?"` -> speaks 'be right back', the real quote is never spoken. ## Suggested Fix Extend `cleanTTSInputText` to strip fenced/inline code, emphasis markers (`** __ * _ ~~`), heading/blockquote/list markers, and convert `[label](url)` to `label`, before whitespace collapse. Tighten `vnLineRe` so the bracketed speaker can't be a URL/time/known meta tag (or require a known-speaker set), and don't early-return on a single weak VN match so the quote fallback can still contribute. ## Verification checklist (all manual) - [ ] Manually verify an RP message with *actions*/**bold**/inline-code is spoken without literal markdown - [ ] Verify a message with a fenced code block does not read backticks/code aloud - [ ] Verify dialogueOnly mode does not speak `[OOC]:`/reference-link/timestamp lines as dialogue and still speaks genuine quotes - [ ] Run `pnpm check` --- ### Affected files - `packages/client/src/lib/tts-dialogue.ts` ### Audit provenance Found by a multi-agent static audit of the TTS/voice + image-generation subsystems (Round 1 + round-2 gap sweep + completeness critic, each finding adversarially verified) against the merged `staging` tree. Severity: **MEDIUM**. > AI-drafted from a static read; validation/test-plan boxes intentionally left UNCHECKED for a human to verify before close.
Author
Owner

@SpicyMarinara commented on GitHub (Jun 21, 2026):

Addressed on PR #2747. TTS input cleaning now strips fenced and inline code, markdown links/images, headings, blockquotes, list markers, and emphasis markers before synthesis. Dialogue-only VN parsing now rejects likely meta labels such as OOC/note/timestamps/URLs/numeric labels, and quote fallback always runs so a bad bracket line cannot suppress real quoted dialogue. Validated with git diff --check for the touched file; full pnpm validation is deferred until the end of the issue sweep per maintainer request.

<!-- gh-comment-id:4763296345 --> @SpicyMarinara commented on GitHub (Jun 21, 2026): Addressed on PR #2747. TTS input cleaning now strips fenced and inline code, markdown links/images, headings, blockquotes, list markers, and emphasis markers before synthesis. Dialogue-only VN parsing now rejects likely meta labels such as OOC/note/timestamps/URLs/numeric labels, and quote fallback always runs so a bad bracket line cannot suppress real quoted dialogue. Validated with git diff --check for the touched file; full pnpm validation is deferred until the end of the issue sweep per maintainer request.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#1392
No description provided.