mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #1143] [CLOSED] feat(tts): auto-split quoted dialogue from prose narration #4944
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#4944
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/1143
Author: @etherious1804
Created: 5/24/2026
Status: ❌ Closed
Base:
staging← Head:feat/tts-narrator-auto-split📝 Commits (3)
0954666fix(tts): apply playback rate client-side for local OAI-compatible serversefdf859feat(tts): stream audio per sentence as the model generates393ee8cfeat(tts): auto-split quoted dialogue from prose narration📊 Changes
8 files changed (+814 additions, -28 deletions)
View changed files
📝
packages/client/src/components/chat/ChatArea.tsx(+35 -2)📝
packages/client/src/components/chat/ChatMessage.tsx(+52 -23)📝
packages/client/src/components/panels/settings/TTSConfigCard.tsx(+13 -0)➕
packages/client/src/hooks/use-streaming-tts.ts(+368 -0)➕
packages/client/src/lib/sentence-chunker.ts(+246 -0)📝
packages/client/src/lib/tts-dialogue.ts(+79 -2)📝
packages/client/src/lib/tts-service.ts(+12 -1)📝
packages/shared/src/types/tts.ts(+9 -0)📄 Description
Linked issue
Closes #1144
Why this change
When
narratorVoiceEnabledis configured with single-voice mode (no<speaker>tags from the model), the entire reply currently plays in the character's voice — even the action prose. The configured narrator voice is set but never selected. Users who set up a separate narrator (intending a novel-style narrator-reads-the-action, character-speaks-the-dialogue split) hear a single voice reading every word.Roleplay convention already disambiguates this without structured tags:
"..."is speech, surrounding prose is narration. This PR acts on that convention. Applies to both on-demand playback (speaker icon) AND the streaming-TTS path (#1142).What changed
Client — quote-aware dialogue/narration splitter
packages/client/src/lib/tts-dialogue.ts: newsplitQuotedDialogueAndNarration(text, fallbackSpeaker)walks the text. Each quoted span (matched against the existingDIALOGUE_QUOTE_PATTERN_SOURCE— covers ASCII, smart double, guillemet, and Japanese corner/double-corner pairs) becomes a{ speaker: fallbackSpeaker }utterance; surrounding prose becomes{ speaker: "Narrator" }. The previous fallback that re-routed all-narrator output back to character voice has been removed — when narrator is enabled, narration-only chunks correctly stay on the narrator voice (matters for streaming where the first chunk may be action-only).buildTTSVoiceRequestsinvokes the new splitter whennarratorVoiceEnabled && !dialogueOnly && !hasSpeakerTags && voiceMode === "single". Other paths (speaker-tagged output, dialogue-only, per-character voices) are untouched.Client — quote-aware sentence chunker
packages/client/src/lib/sentence-chunker.ts: newisInsideUnclosedQuote(text, pos)walks[0..pos)tracking the same five quote pairs the splitter recognizes. ASCII"is treated as a toggle (no separate close form); smart/guillemet/Japanese pairs use a paired stack. A sentence-end candidate that falls inside an open quote is skipped — so a multi-sentence dialogue block like"Hello. How are you. I am fine."emits as one chunk at the closing quote, not fragmented into pieces with unbalanced quotes the splitter can't classify.Without this chunker change, the streaming-TTS path (#1142) would fragment quoted dialogue mid-stream — each piece would have an unbalanced quote, fall through the splitter's pattern match, and route to all-narrator. The visible symptom would be "dialogue-heavy reply plays entirely in the narrator voice when streaming." The on-demand path doesn't hit this because it works on the full message text, not a growing buffer.
Dependency
Includes #1141 (client-side playback rate) and #1142 (streaming TTS) as base commits. Once those merge, this PR's diff will shrink to just the narrator-split changes.
Validation
pnpm checkpasses locallyContainer (Docker / Podman) built and ran without issue
Ran the app, clicked through the changes manually
Checked edge cases (light + dark mode, mobile viewport, empty states, error paths)
Above manual verification completed (describe below)
Read and followed
CONTRIBUTING.mdManual verification notes
What was verified on the branch (against a running Marinara dev server, local mlx-audio TTS with separate "naesala" and "narrator" voices, local Gemma 4 26B LLM, Roleplay mode with narratorVoiceEnabled + voiceMode single):
"Hello, traveler."style dialogue with action prose plays each in its own voice (narrator for the prose, character for the quoted spans) — confirmed both for on-demand speaker-icon playback and for streaming-TTS sentence-by-sentence playback."...") plays in the narrator voice — does NOT fall back to the character voice as it used to."Approach me. I have a question."emits as a single character-voice chunk; the chunker waits for the closing quote.narratorVoiceEnabledoff reverts to pre-existing single-voice behavior (entire reply on the configuredcfg.voice).To verify in browser:
narratorVoiceEnabled, voiceMode = single.Docs and release impact
UI evidence (if applicable)
No UI changes — purely routing logic that respects the existing TTS settings.
🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.