[PR #1255] [MERGED] feat(tts): split quoted dialogue from prose narration #5005

Closed
opened 2026-10-22 04:12:23 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/1255
Author: @cha1latte
Created: 5/26/2026
Status: ✅ Merged
Merged: 5/26/2026
Merged by: @cha1latte

Base: refactor ← Head: port/pr-1143-refactor


📝 Commits (3)

  • 8240437 feat(tts): split quoted dialogue from narration
  • d4c564b Address TTS review feedback
  • 43705b5 Normalize narrator voice settings

📊 Changes

11 files changed (+521 additions, -39 deletions)

View changed files

📝 src/engine/contracts/types/tts.ts (+2 -0)
📝 src/features/modes/shared/chat-ui/components/ChatMessage.tsx (+18 -16)
📝 src/features/modes/shared/chat-ui/hooks/use-chat-tts-autoplay.ts (+6 -9)
📝 src/features/modes/shared/chat-ui/hooks/use-streaming-tts.test.tsx (+52 -3)
📝 src/features/shell/settings/components/settings/TTSConfigCard.tsx (+79 -0)
📝 src/shared/lib/dialogue-quotes.ts (+4 -3)
📝 src/shared/lib/sentence-chunker.test.ts (+29 -0)
📝 src/shared/lib/sentence-chunker.ts (+42 -3)
➕ src/shared/lib/tts-dialogue.test.ts (+90 -0)
📝 src/shared/lib/tts-dialogue.ts (+64 -5)
📝 src/shared/lib/tts-service.ts (+135 -0)

📄 Description

Linked issue

Closes #1144
Ports #1143 to the refactor branch.

Why this change

Users can configure a separate narrator voice, but unstructured roleplay replies without <speaker> tags were still spoken as one character-voice utterance. That meant prose narration and quoted dialogue could not use separate voices in normal roleplay output.

This adds quote-aware routing so prose outside quotes uses the narrator voice and quoted dialogue keeps the fallback character voice when narrator splitting is enabled.

What changed

  • Added narratorVoiceEnabled and narratorVoice TTS config fields.
  • Added a TTS settings control to enable quote/prose splitting and choose the narrator voice.
  • Added shared quote/prose splitting for unstructured TTS text.
  • Updated speaker-icon playback and end-of-stream autoplay to use sequenced TTS requests.
  • Made the streaming sentence chunker wait for balanced quoted spans before emitting mid-quote punctuation.
  • Added regression coverage for narrator routing, streaming routing, doubled ASCII quotes, guillemets, and Japanese quote closers.

Refactor impact

Primary owner:

shared TTS / chat playback

Impact areas reviewed:

  • src/shared/lib TTS helpers, sentence chunker, and TTS service
  • shared chat message speaker-button playback
  • shared chat TTS autoplay hook
  • shell TTS settings card
  • TTS contract schema

Boundary notes:

  • No server route, storage, Rust command, remote runtime, or provider API changes.
  • Existing dialogueOnly, <speaker> tag, VN/Game speaker-line paths are intentionally left in their existing routing path.
  • Per-character voice mode is not changed by narrator splitting.

Pressure points touched:

  • shared mode UI: ChatMessage
  • shared mode autoplay hook: use-chat-tts-autoplay
  • settings UI: TTSConfigCard
  • shared TTS service sequencing

Validation

  • pnpm check passes locally
  • pnpm typecheck passes locally
  • pnpm build passes locally
  • pnpm check:architecture passes locally
  • pnpm check:docs passes locally
  • cargo check --manifest-path src-tauri/Cargo.toml --workspace passes locally
  • Rust clippy/tests were run for Rust behavior changes
  • Browser or Tauri app manual verification completed
  • Playwright, screenshot, or recording evidence added for UI changes
  • Remote runtime smoke checked when relevant

Manual verification notes

Codex verification run:

  • pnpm test -- src/shared/lib/tts-dialogue.test.ts src/shared/lib/sentence-chunker.test.ts src/features/modes/shared/chat-ui/hooks/use-streaming-tts.test.tsx passed: 3 files, 13 tests.
  • pnpm check passed.
  • pnpm build passed.
  • pnpm lint passed.
  • Bunny review pass completed with no blocking findings.

Manual/provider smoke still recommended before marking ready:

  • Configure TTS with one character voice and one narrator voice.
  • Enable “Split quoted dialogue from narration.”
  • Use a message with prose plus quoted dialogue and confirm the speaker icon plays prose with the narrator voice and quoted text with the character voice.
  • Repeat with streaming TTS enabled to confirm the same routing during streamed playback.

Docs and release impact

  • No docs changes needed
  • Updated README.md
  • Updated CONTRIBUTING.md
  • Updated docs/developer/
  • Updated repo skills or AGENTS.md
  • Confirmed this PR does not restore old staging/package-workspace/release claims

UI evidence

No screenshot attached. This adds a small TTS settings control and changes playback routing; local compile/build/tests passed, but real provider voice timbre still needs manual smoke verification.

Summary by CodeRabbit

  • New Features

    • Narrator voice option in single-voice TTS: toggle to split narration from quoted dialogue and choose a narrator voice in settings
    • Sequential TTS playback: multiple text segments speak in order for smoother narration and dialogue handling
    • UI/Autoplay updates: TTS play controls and autoplay now respect whether there is speakable TTS content
  • Bug Fixes

    • Improved quote and sentence detection (including doubled ASCII quotes and additional quote styles) to avoid premature sentence emission
  • Tests

    • Added tests covering narrator/dialogue routing, sentence-chunking, and streaming behavior

Review Change Stack


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/1255 **Author:** [@cha1latte](https://github.com/cha1latte) **Created:** 5/26/2026 **Status:** ✅ Merged **Merged:** 5/26/2026 **Merged by:** [@cha1latte](https://github.com/cha1latte) **Base:** `refactor` ← **Head:** `port/pr-1143-refactor` --- ### 📝 Commits (3) - [`8240437`](https://github.com/Pasta-Devs/Marinara-Engine/commit/8240437a36bce96553b88a63c04305a6412d45ae) feat(tts): split quoted dialogue from narration - [`d4c564b`](https://github.com/Pasta-Devs/Marinara-Engine/commit/d4c564b49f72566f187f7117d95120ee5bc92cfa) Address TTS review feedback - [`43705b5`](https://github.com/Pasta-Devs/Marinara-Engine/commit/43705b53f06929e48a7fc2f80b5c6678748a08e2) Normalize narrator voice settings ### 📊 Changes **11 files changed** (+521 additions, -39 deletions) <details> <summary>View changed files</summary> 📝 `src/engine/contracts/types/tts.ts` (+2 -0) 📝 `src/features/modes/shared/chat-ui/components/ChatMessage.tsx` (+18 -16) 📝 `src/features/modes/shared/chat-ui/hooks/use-chat-tts-autoplay.ts` (+6 -9) 📝 `src/features/modes/shared/chat-ui/hooks/use-streaming-tts.test.tsx` (+52 -3) 📝 `src/features/shell/settings/components/settings/TTSConfigCard.tsx` (+79 -0) 📝 `src/shared/lib/dialogue-quotes.ts` (+4 -3) 📝 `src/shared/lib/sentence-chunker.test.ts` (+29 -0) 📝 `src/shared/lib/sentence-chunker.ts` (+42 -3) ➕ `src/shared/lib/tts-dialogue.test.ts` (+90 -0) 📝 `src/shared/lib/tts-dialogue.ts` (+64 -5) 📝 `src/shared/lib/tts-service.ts` (+135 -0) </details> ### 📄 Description ## Linked issue Closes #1144 Ports #1143 to the refactor branch. ## Why this change Users can configure a separate narrator voice, but unstructured roleplay replies without `<speaker>` tags were still spoken as one character-voice utterance. That meant prose narration and quoted dialogue could not use separate voices in normal roleplay output. This adds quote-aware routing so prose outside quotes uses the narrator voice and quoted dialogue keeps the fallback character voice when narrator splitting is enabled. ## What changed - Added `narratorVoiceEnabled` and `narratorVoice` TTS config fields. - Added a TTS settings control to enable quote/prose splitting and choose the narrator voice. - Added shared quote/prose splitting for unstructured TTS text. - Updated speaker-icon playback and end-of-stream autoplay to use sequenced TTS requests. - Made the streaming sentence chunker wait for balanced quoted spans before emitting mid-quote punctuation. - Added regression coverage for narrator routing, streaming routing, doubled ASCII quotes, guillemets, and Japanese quote closers. ## Refactor impact Primary owner: shared TTS / chat playback Impact areas reviewed: - `src/shared/lib` TTS helpers, sentence chunker, and TTS service - shared chat message speaker-button playback - shared chat TTS autoplay hook - shell TTS settings card - TTS contract schema Boundary notes: - No server route, storage, Rust command, remote runtime, or provider API changes. - Existing `dialogueOnly`, `<speaker>` tag, VN/Game speaker-line paths are intentionally left in their existing routing path. - Per-character voice mode is not changed by narrator splitting. Pressure points touched: - shared mode UI: `ChatMessage` - shared mode autoplay hook: `use-chat-tts-autoplay` - settings UI: `TTSConfigCard` - shared TTS service sequencing ## Validation - [ ] `pnpm check` passes locally - [ ] `pnpm typecheck` passes locally - [ ] `pnpm build` passes locally - [ ] `pnpm check:architecture` passes locally - [ ] `pnpm check:docs` passes locally - [ ] `cargo check --manifest-path src-tauri/Cargo.toml --workspace` passes locally - [ ] Rust clippy/tests were run for Rust behavior changes - [ ] Browser or Tauri app manual verification completed - [ ] Playwright, screenshot, or recording evidence added for UI changes - [ ] Remote runtime smoke checked when relevant ### Manual verification notes Codex verification run: - `pnpm test -- src/shared/lib/tts-dialogue.test.ts src/shared/lib/sentence-chunker.test.ts src/features/modes/shared/chat-ui/hooks/use-streaming-tts.test.tsx` passed: 3 files, 13 tests. - `pnpm check` passed. - `pnpm build` passed. - `pnpm lint` passed. - Bunny review pass completed with no blocking findings. Manual/provider smoke still recommended before marking ready: - Configure TTS with one character voice and one narrator voice. - Enable “Split quoted dialogue from narration.” - Use a message with prose plus quoted dialogue and confirm the speaker icon plays prose with the narrator voice and quoted text with the character voice. - Repeat with streaming TTS enabled to confirm the same routing during streamed playback. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated `README.md` - [ ] Updated `CONTRIBUTING.md` - [ ] Updated `docs/developer/` - [ ] Updated repo skills or `AGENTS.md` - [ ] Confirmed this PR does not restore old staging/package-workspace/release claims ## UI evidence No screenshot attached. This adds a small TTS settings control and changes playback routing; local compile/build/tests passed, but real provider voice timbre still needs manual smoke verification. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Narrator voice option in single-voice TTS: toggle to split narration from quoted dialogue and choose a narrator voice in settings * Sequential TTS playback: multiple text segments speak in order for smoother narration and dialogue handling * UI/Autoplay updates: TTS play controls and autoplay now respect whether there is speakable TTS content * **Bug Fixes** * Improved quote and sentence detection (including doubled ASCII quotes and additional quote styles) to avoid premature sentence emission * **Tests** * Added tests covering narrator/dialogue routing, sentence-chunking, and streaming behavior <!-- review_stack_entry_start --> [![Review Change Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/Pasta-Devs/Marinara-Engine/pull/1255?utm_source=github_walkthrough&utm_medium=github&utm_campaign=change_stack) <!-- review_stack_entry_end --> <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-22 04:12:23 +07:00
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#5005
No description provided.