[PR #5060] [MERGED] fix(tts): preserve complete roleplay narration #6606

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/5060
Author: @SpicyMarinara
Created: 8/15/2026
Status: ✅ Merged
Merged: 8/15/2026
Merged by: @SpicyMarinara

Base: staging ← Head: fix/5059-complete-roleplay-tts


📝 Commits (5)

  • 2e7fba1 fix(tts): preserve complete roleplay narration
  • dbe260a fix(tts): start playback before background agents
  • bf593af fix(tts): clean up superseded playback
  • e630245 Merge branch 'staging' into fix/5059-complete-roleplay-tts
  • 980ee46 fix(tts): isolate progressive queue iterations

📊 Changes

10 files changed (+486 additions, -190 deletions)

View changed files

📝 CHANGELOG.md (+3 -0)
📝 packages/client/src/components/chat/ChatArea.tsx (+92 -66)
📝 packages/client/src/hooks/use-generate.ts (+16 -0)
📝 packages/client/src/lib/tts-autoplay.ts (+8 -0)
📝 packages/client/src/lib/tts-roleplay-speaker-extractor.ts (+2 -1)
📝 packages/client/src/lib/tts-service.ts (+83 -87)
📝 packages/server/src/routes/generate.routes.ts (+62 -34)
📝 packages/server/src/routes/tts.routes.ts (+7 -1)
📝 scripts/regressions/roleplay-streaming.regression.ts (+42 -0)
📝 scripts/regressions/tts-source-persistence.regression.ts (+171 -1)

📄 Description

Important

Contributions target staging. Only SpicyMarinara may promote this repository's staging branch or a same-repository hotfix/* branch to main.
Outside and first-time contributors also require an approving review from SpicyMarinara.

Linked issue

Closes #5059

Why this change

  • Long Roleplay messages could lose narration during TTS because non-progressive playback generated every paragraph concurrently and silently discarded failed provider requests.

What changed

  • Pack adjacent extracted narration into the existing normal-sized TTS chunks instead of one request per paragraph.
  • Generate non-progressive voice clips serially so providers with low concurrency limits receive an ordered request stream.
  • Stop and expose a TTS error when any clip fails instead of continuing with missing prose.
  • Start autoplay from a finalized-assistant-message event before Illustrator, trackers, summaries, and other non-rewriting agent work finishes.
  • Delay that event when a text-rewrite agent is active so Prose Guardian, Continuity Checker, Immersive HTML, and custom rewrite agents remain authoritative.
  • Mention json in the extractor input message for Responses API structured-output compatibility.
  • Add regressions for the exact reported message and a concurrency-limited provider.

Validation

  • pnpm check passes locally
  • Container (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.md

Manual verification notes

  • Automated: pnpm check passes.
  • Automated: pnpm regression:tts passes.
  • Automated: pnpm regression:roleplay passes and verifies the early event occurs before parallel-agent waiting while the rewrite event occurs after editing.
  • Automated: the reported Columbina message retains every cited narration passage and packs into four ordered voice requests.
  • Automated: a simulated provider limited to one concurrent request now receives a peak of one and all three queued clips play.
  • Live provider/browser retest remains for Mari after pulling this branch.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed
  • Translated docs on the docs-i18n branch updated to match, or a [docs-i18n] follow-up issue opened (see CONTRIBUTING.md § Translated documentation)
  • Version/release files updated (only if this PR includes a version bump)

UI evidence (if applicable)

Not applicable; no UI layout changed.

Summary by CodeRabbit

  • Bug Fixes
    • Improved TTS autoplay timing, reducing duplicate playback and starting speech as soon as finalized messages are ready.
    • Fixed compatibility when extracting roleplay speakers through the Responses API.
    • Long roleplay readings now process sequentially, preserving narration and preventing skipped audio.
    • Audio playback now stops clearly when generation fails instead of continuing with partial results.
    • Improved handling of rewritten messages so speech uses the final available text.

🔄 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/5060 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 8/15/2026 **Status:** ✅ Merged **Merged:** 8/15/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/5059-complete-roleplay-tts` --- ### 📝 Commits (5) - [`2e7fba1`](https://github.com/Pasta-Devs/Marinara-Engine/commit/2e7fba1de9ab86e313a6d6c8b1f5ca45863f9ab4) fix(tts): preserve complete roleplay narration - [`dbe260a`](https://github.com/Pasta-Devs/Marinara-Engine/commit/dbe260abf03e760ff19c06189da22d1290ecdfc5) fix(tts): start playback before background agents - [`bf593af`](https://github.com/Pasta-Devs/Marinara-Engine/commit/bf593af0e1b1923f5358fac47827bc248ad557cf) fix(tts): clean up superseded playback - [`e630245`](https://github.com/Pasta-Devs/Marinara-Engine/commit/e6302459ba6402e250ab5b69deb9c4c821aefbf3) Merge branch 'staging' into fix/5059-complete-roleplay-tts - [`980ee46`](https://github.com/Pasta-Devs/Marinara-Engine/commit/980ee460ee5b08f2644df02d8882d2f9dcfffffd) fix(tts): isolate progressive queue iterations ### 📊 Changes **10 files changed** (+486 additions, -190 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+3 -0) 📝 `packages/client/src/components/chat/ChatArea.tsx` (+92 -66) 📝 `packages/client/src/hooks/use-generate.ts` (+16 -0) 📝 `packages/client/src/lib/tts-autoplay.ts` (+8 -0) 📝 `packages/client/src/lib/tts-roleplay-speaker-extractor.ts` (+2 -1) 📝 `packages/client/src/lib/tts-service.ts` (+83 -87) 📝 `packages/server/src/routes/generate.routes.ts` (+62 -34) 📝 `packages/server/src/routes/tts.routes.ts` (+7 -1) 📝 `scripts/regressions/roleplay-streaming.regression.ts` (+42 -0) 📝 `scripts/regressions/tts-source-persistence.regression.ts` (+171 -1) </details> ### 📄 Description > [!IMPORTANT] > Contributions target `staging`. Only `SpicyMarinara` may promote this repository's `staging` branch or a same-repository `hotfix/*` branch to `main`. > Outside and first-time contributors also require an approving review from `SpicyMarinara`. <!-- See CONTRIBUTING.md § Branches. --> ## Linked issue Closes #5059 ## Why this change - Long Roleplay messages could lose narration during TTS because non-progressive playback generated every paragraph concurrently and silently discarded failed provider requests. ## What changed - Pack adjacent extracted narration into the existing normal-sized TTS chunks instead of one request per paragraph. - Generate non-progressive voice clips serially so providers with low concurrency limits receive an ordered request stream. - Stop and expose a TTS error when any clip fails instead of continuing with missing prose. - Start autoplay from a finalized-assistant-message event before Illustrator, trackers, summaries, and other non-rewriting agent work finishes. - Delay that event when a text-rewrite agent is active so Prose Guardian, Continuity Checker, Immersive HTML, and custom rewrite agents remain authoritative. - Mention `json` in the extractor input message for Responses API structured-output compatibility. - Add regressions for the exact reported message and a concurrency-limited provider. ## Validation - [ ] `pnpm check` passes locally - [ ] Container (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.md` ### Manual verification notes - Automated: `pnpm check` passes. - Automated: `pnpm regression:tts` passes. - Automated: `pnpm regression:roleplay` passes and verifies the early event occurs before parallel-agent waiting while the rewrite event occurs after editing. - Automated: the reported Columbina message retains every cited narration passage and packs into four ordered voice requests. - Automated: a simulated provider limited to one concurrent request now receives a peak of one and all three queued clips play. - Live provider/browser retest remains for Mari after pulling this branch. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed - [ ] Translated docs on the `docs-i18n` branch updated to match, or a `[docs-i18n]` follow-up issue opened (see CONTRIBUTING.md § Translated documentation) - [ ] Version/release files updated (only if this PR includes a version bump) ## UI evidence (if applicable) Not applicable; no UI layout changed. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Bug Fixes** - Improved TTS autoplay timing, reducing duplicate playback and starting speech as soon as finalized messages are ready. - Fixed compatibility when extracting roleplay speakers through the Responses API. - Long roleplay readings now process sequentially, preserving narration and preventing skipped audio. - Audio playback now stops clearly when generation fails instead of continuing with partial results. - Improved handling of rewritten messages so speech uses the final available text. <!-- 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-23 04:12:01 +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#6606
No description provided.