[PR #7851] [MERGED] feat(tts): use an existing Audio connection in the Text to Speech card #7968

Closed
opened 2026-10-24 04:09:14 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/7851
Author: @SpicyMarinara
Created: 10/19/2026
Status: ✅ Merged
Merged: 10/19/2026
Merged by: @SpicyMarinara

Base: staging ← Head: feat/7848-tts-audio-connection


📝 Commits (1)

  • 978e5c3 feat(tts): use an existing Audio connection in the Text to Speech card

📊 Changes

11 files changed (+951 additions, -203 deletions)

View changed files

📝 docs/connections/providers-reference.md (+1 -1)
📝 docs/media/tts-setup.md (+19 -1)
📝 e2e/tts-pcm-settings.e2e.ts (+86 -0)
📝 packages/client/src/components/characters/CharacterVoicePicker.tsx (+6 -1)
📝 packages/client/src/components/game/GameSurface.tsx (+13 -7)
📝 packages/client/src/components/panels/settings/TTSConfigCard.tsx (+353 -164)
📝 packages/client/src/hooks/use-tts.ts (+10 -6)
📝 packages/client/src/localization/locales/en.json (+5 -0)
📝 packages/server/src/routes/tts.routes.ts (+109 -23)
📝 packages/shared/src/types/tts.ts (+33 -0)
➕ scripts/regressions/tts-audio-connection-source.regression.ts (+316 -0)

📄 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 #7848

Thanks to @ebev for the proposal and the careful write-up in #7848. This PR builds it as discussed on the issue.

Why this change

  • Audio connections (#5146 / #5152) already hold a voice service's address, key and model, but the Connections → Text to Speech card could only use its own four sources. People had to enter the same address, key and model twice, and the card's preview and voice list could not use the connection that chats speak with.
  • Voices were kept per adapter, and a connection with blank fields could borrow the card's address, model or voice. Two connections on the same adapter (for example two OpenAI-compatible services) could not keep their own voices.

What changed

  • Source list: the card's Source dropdown lists usable Audio connections under Audio connections, after the four regular sources. Picking one stores only its ID (connectionId) in the TTS settings.
  • Server resolution: speech, the card's Preview, voice discovery and Character Editor previews read the adapter, address, key, model and request timeout from the chosen connection on the server. The key is never copied into the TTS settings and never sent to the browser. GET /api/tts/config shows the connection's adapter, address and model (no key), so every reader (Game narration, character voices, the speech cache) sees what it speaks with.
  • Per-connection profiles: voices and speech settings (voice, voice mode, character voices, narrator, NPC pools, speed, stability, language, audio format) are kept in connectionProfiles by connection ID. A connection with a profile uses only its own address and model (blank fields use the adapter's defaults), so two connections never borrow each other's or the card's values.
  • Regular sources unchanged: the four sources keep their saved settings exactly as before, with no migration. While a connection is chosen, the card's own address, key and model stay as stored and come back when you switch back.
  • Missing or unusable connection: a deleted connection, or one held for review after an import, is refused with a clear 409 (speech, preview, voices, models, game audio, roleplay sound effects). Nothing falls back to the default connection or to the card's own key. The card shows Missing Audio connection in its header and a short notice under Source.
  • Unlisted voices: when the chosen connection returns its own voice list, the card names saved voices that are not on it.
  • Routing preserved: a game's explicit audio connection still wins for that game's sound effects and music, and the card's switch still turns Text to Speech on and off. The resolution order is: explicit request, then the card's chosen connection, then the default and fallback audio connections, then the card's own source. Game Mode's client-side capability check mirrors that order.
  • Card UI: with a connection chosen, Base URL, API Key, Model, Request timeout and the ElevenLabs game audio switches are hidden (the connection has its own), and a one-line hint says so. New English strings are under tts.connection.*; warnings use the steady theme accent.
  • Docs: docs/media/tts-setup.md gains a "Use an Audio connection" section and a troubleshooting entry; docs/connections/providers-reference.md links to it. The release translation sweep covers the other languages.
  • Regression proof: scripts/regressions/tts-audio-connection-source.regression.ts covers selection stored by ID, credentials read from the connection (including a rotated key), profiles isolated between two connections on the same adapter, regular sources unchanged, the master switch, explicit game routing, deleted and under-review connections refused without fallback, and no key in the stored settings or in /config and /voices responses. e2e/tts-pcm-settings.e2e.ts gains a desktop test for the selector: saved by ID, fields hidden, kept after reload, and the missing-connection notice.

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

Agent-run checks (for reference, not a substitute for the boxes above):

  • pnpm check: passed (exit 0). Its only lint output is an existing warning in HomeProfessorMariChat.tsx.
  • node ./scripts/run-regressions.mjs --filter tts: 11/11 passed, including the new regression. One run while the machine was very busy (load average about 98) reported 1/11 failed without naming the file; the two reruns on the final commit passed 11/11. Also passed: roleplay-commands, open-issues and the other regressions that read the touched client files.
  • npx playwright test --project=desktop-chromium e2e/tts-pcm-settings.e2e.ts e2e/tts-request-timeout.e2e.ts e2e/scene-tts-preferences.e2e.ts e2e/tts-mobile-playback.e2e.ts: 12/12 passed. tts-pcm-settings and tts-request-timeout passed again on the final commit (3/3).

Manual verification notes

Please check these by hand:

  • Manually verify in the browser: create two Audio connections with the same adapter (for example two OpenAI-compatible servers). Pick the first one as the Text to Speech Source, choose a voice, then pick the second one and confirm its voices and voice list are its own. Switch back to the first and confirm its voice returned.
  • Manually verify that Preview speaks through the chosen connection, and that a new key saved on the connection is used without touching the card.
  • Manually verify that switching back to a regular source (for example ElevenLabs) restores its address, key, model and voices exactly as before.
  • Manually verify that deleting the chosen connection shows Missing Audio connection in the card header and the notice under Source, that Preview is disabled, and that chat playback reports the missing connection instead of speaking with another one.
  • Manually verify that a game with its own audio connection still makes sound effects and music with that connection while the card uses a different one.
  • Manually verify the Character Editor Voice tab lists the chosen connection's voices and its preview speaks through the connection.
  • Manually verify the card in light and dark mode, with Accent Pulse on, and at mobile width.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README) 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)

English docs updated: docs/media/tts-setup.md and docs/connections/providers-reference.md. Translations are left to the release translation sweep. No CHANGELOG entry (compiled at release time).

UI evidence (if applicable)

The new e2e attaches two screenshots to its Playwright report: tts-card-audio-connection-source (connection chosen, hint shown, address/key/model hidden) and tts-card-missing-audio-connection (missing-connection notice and header label).

Summary by CodeRabbit

  • New Features
    • Use an Audio connection as the source for text-to-speech. Its provider settings are managed by the connection, while speech settings are saved separately for each connection.
    • The TTS settings show when a selected connection is unavailable or a saved voice isn’t offered by that connection. An unavailable connection won’t silently switch to another source.
  • Documentation
    • Updated the Audio connection and text-to-speech setup guides with selection instructions and troubleshooting tips.

🔄 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/7851 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 10/19/2026 **Status:** ✅ Merged **Merged:** 10/19/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `feat/7848-tts-audio-connection` --- ### 📝 Commits (1) - [`978e5c3`](https://github.com/Pasta-Devs/Marinara-Engine/commit/978e5c3fccf2a7ade196f76f0150beac4955d802) feat(tts): use an existing Audio connection in the Text to Speech card ### 📊 Changes **11 files changed** (+951 additions, -203 deletions) <details> <summary>View changed files</summary> 📝 `docs/connections/providers-reference.md` (+1 -1) 📝 `docs/media/tts-setup.md` (+19 -1) 📝 `e2e/tts-pcm-settings.e2e.ts` (+86 -0) 📝 `packages/client/src/components/characters/CharacterVoicePicker.tsx` (+6 -1) 📝 `packages/client/src/components/game/GameSurface.tsx` (+13 -7) 📝 `packages/client/src/components/panels/settings/TTSConfigCard.tsx` (+353 -164) 📝 `packages/client/src/hooks/use-tts.ts` (+10 -6) 📝 `packages/client/src/localization/locales/en.json` (+5 -0) 📝 `packages/server/src/routes/tts.routes.ts` (+109 -23) 📝 `packages/shared/src/types/tts.ts` (+33 -0) ➕ `scripts/regressions/tts-audio-connection-source.regression.ts` (+316 -0) </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 #7848 Thanks to @ebev for the proposal and the careful write-up in #7848. This PR builds it as discussed on the issue. ## Why this change - Audio connections (#5146 / #5152) already hold a voice service's address, key and model, but the **Connections → Text to Speech** card could only use its own four sources. People had to enter the same address, key and model twice, and the card's preview and voice list could not use the connection that chats speak with. - Voices were kept per adapter, and a connection with blank fields could borrow the card's address, model or voice. Two connections on the same adapter (for example two OpenAI-compatible services) could not keep their own voices. ## What changed - **Source list:** the card's **Source** dropdown lists usable Audio connections under **Audio connections**, after the four regular sources. Picking one stores only its ID (`connectionId`) in the TTS settings. - **Server resolution:** speech, the card's **Preview**, voice discovery and Character Editor previews read the adapter, address, key, model and request timeout from the chosen connection on the server. The key is never copied into the TTS settings and never sent to the browser. `GET /api/tts/config` shows the connection's adapter, address and model (no key), so every reader (Game narration, character voices, the speech cache) sees what it speaks with. - **Per-connection profiles:** voices and speech settings (voice, voice mode, character voices, narrator, NPC pools, speed, stability, language, audio format) are kept in `connectionProfiles` by connection ID. A connection with a profile uses only its own address and model (blank fields use the adapter's defaults), so two connections never borrow each other's or the card's values. - **Regular sources unchanged:** the four sources keep their saved settings exactly as before, with no migration. While a connection is chosen, the card's own address, key and model stay as stored and come back when you switch back. - **Missing or unusable connection:** a deleted connection, or one held for review after an import, is refused with a clear 409 (speech, preview, voices, models, game audio, roleplay sound effects). Nothing falls back to the default connection or to the card's own key. The card shows **Missing Audio connection** in its header and a short notice under **Source**. - **Unlisted voices:** when the chosen connection returns its own voice list, the card names saved voices that are not on it. - **Routing preserved:** a game's explicit audio connection still wins for that game's sound effects and music, and the card's switch still turns Text to Speech on and off. The resolution order is: explicit request, then the card's chosen connection, then the default and fallback audio connections, then the card's own source. Game Mode's client-side capability check mirrors that order. - **Card UI:** with a connection chosen, **Base URL**, **API Key**, **Model**, **Request timeout** and the ElevenLabs game audio switches are hidden (the connection has its own), and a one-line hint says so. New English strings are under `tts.connection.*`; warnings use the steady theme accent. - **Docs:** `docs/media/tts-setup.md` gains a "Use an Audio connection" section and a troubleshooting entry; `docs/connections/providers-reference.md` links to it. The release translation sweep covers the other languages. - **Regression proof:** `scripts/regressions/tts-audio-connection-source.regression.ts` covers selection stored by ID, credentials read from the connection (including a rotated key), profiles isolated between two connections on the same adapter, regular sources unchanged, the master switch, explicit game routing, deleted and under-review connections refused without fallback, and no key in the stored settings or in `/config` and `/voices` responses. `e2e/tts-pcm-settings.e2e.ts` gains a desktop test for the selector: saved by ID, fields hidden, kept after reload, and the missing-connection notice. ## 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` Agent-run checks (for reference, not a substitute for the boxes above): - `pnpm check`: passed (exit 0). Its only lint output is an existing warning in `HomeProfessorMariChat.tsx`. - `node ./scripts/run-regressions.mjs --filter tts`: 11/11 passed, including the new regression. One run while the machine was very busy (load average about 98) reported 1/11 failed without naming the file; the two reruns on the final commit passed 11/11. Also passed: `roleplay-commands`, `open-issues` and the other regressions that read the touched client files. - `npx playwright test --project=desktop-chromium e2e/tts-pcm-settings.e2e.ts e2e/tts-request-timeout.e2e.ts e2e/scene-tts-preferences.e2e.ts e2e/tts-mobile-playback.e2e.ts`: 12/12 passed. `tts-pcm-settings` and `tts-request-timeout` passed again on the final commit (3/3). ### Manual verification notes Please check these by hand: - Manually verify in the browser: create two Audio connections with the same adapter (for example two OpenAI-compatible servers). Pick the first one as the Text to Speech **Source**, choose a voice, then pick the second one and confirm its voices and voice list are its own. Switch back to the first and confirm its voice returned. - Manually verify that **Preview** speaks through the chosen connection, and that a new key saved on the connection is used without touching the card. - Manually verify that switching back to a regular source (for example ElevenLabs) restores its address, key, model and voices exactly as before. - Manually verify that deleting the chosen connection shows **Missing Audio connection** in the card header and the notice under **Source**, that Preview is disabled, and that chat playback reports the missing connection instead of speaking with another one. - Manually verify that a game with its own audio connection still makes sound effects and music with that connection while the card uses a different one. - Manually verify the Character Editor **Voice** tab lists the chosen connection's voices and its preview speaks through the connection. - Manually verify the card in light and dark mode, with Accent Pulse on, and at mobile width. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README) 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) English docs updated: `docs/media/tts-setup.md` and `docs/connections/providers-reference.md`. Translations are left to the release translation sweep. No CHANGELOG entry (compiled at release time). ## UI evidence (if applicable) The new e2e attaches two screenshots to its Playwright report: `tts-card-audio-connection-source` (connection chosen, hint shown, address/key/model hidden) and `tts-card-missing-audio-connection` (missing-connection notice and header label). <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Use an Audio connection as the source for text-to-speech. Its provider settings are managed by the connection, while speech settings are saved separately for each connection. * The TTS settings show when a selected connection is unavailable or a saved voice isn’t offered by that connection. An unavailable connection won’t silently switch to another source. * **Documentation** * Updated the Audio connection and text-to-speech setup guides with selection instructions and troubleshooting tips. <!-- 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-24 04:09:14 +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#7968
No description provided.