[PR #8650] [MERGED] fix(tts): a speaker the extractor names by first name uses that card's voice #8723

Closed
opened 2026-11-07 17:39:14 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/8650
Author: @SpicyMarinara
Created: 11/1/2026
Status: ✅ Merged
Merged: 11/1/2026
Merged by: @SpicyMarinara

Base: staging ← Head: fix/speaker-extractor-card-voices-8638


📝 Commits (5)

  • 7ec424a fix(tts): a speaker the extractor names by first name uses that card's voice (#8638)
  • e4f2394 fix(tts): a two-letter first name is a short form of a card's name (#8638)
  • 43771f2 fix(tts): a name that fits two chat cards never takes an outside card's voice; different titles are two people (#8638)
  • 8476a92 fix(tts): an initial in a short name must fit the card's name (#8638)
  • 448fa44 fix(tts): Game narration also keeps a roster-ambiguous speaker off an outside card's voice (#8638)

📊 Changes

8 files changed (+349 additions, -12 deletions)

View changed files

📝 packages/client/src/components/chat/ChatArea.tsx (+5 -0)
📝 packages/client/src/components/chat/ChatMessage.tsx (+7 -0)
📝 packages/client/src/components/game/GameNarration.tsx (+19 -3)
📝 packages/client/src/lib/tts-dialogue.ts (+53 -8)
📝 packages/client/src/lib/tts-roleplay-speaker-extractor.ts (+2 -0)
📝 packages/shared/src/utils/game-character-name-match.ts (+43 -0)
📝 scripts/regressions/game-tts-emotion.regression.ts (+25 -1)
📝 scripts/regressions/tts-source-persistence.regression.ts (+195 -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 #8638

Why this change

  • With the TTS speaker extractor on, a line credited to "Junpei" was never voiced as the "Junpei Iori" card, even though that card has a voice of its own. The voice resolver matched a speaker to a card's voice only by exact name or base name, and the card wasn't in the chat. So Junpei got the default voice. On ElevenLabs with no default voice, his line was dropped completely, which is the "not played" symptom in the issue.

What changed

  • isShortFormOfCharacterName (shared, game-character-name-match.ts): every word of the speaker's name must appear in the card's name.

    • "Junpei", "Iori", "Ms. Kirijo" and "Li" (for "Li Mei") match.
    • "Fatui Guard" doesn't match "Fatui Harbinger Dottore": sharing one word isn't enough.
    • Short forms keep two-letter words and drop only titles (Mr, Mrs, Ms, Dr, Sr, Jr, St).
    • A title on one side only is ignored, but two different titles are two people: "Mr. Tanaka" isn't "Mrs. Tanaka", and Jr isn't Sr.
    • An initial must start one of the card's words: "J. Smith" is John Smith, never Bob Smith.
    • Game character matching (characterNamesMatch) keeps its own tokenizer, unchanged.
  • Chat lookup (findTTSCharacterIdBySpeakerName): after the exact and base-name steps, a short name links to the one chat card or persona it fits, so a chat card keeps its own voice settings. The new isTTSSpeakerAmbiguous reports when a name fits more than one chat card.

  • resolveTTSVoiceForSpeaker: when no chat card claims the speaker, it falls back to the one voiced card whose name contains the speaker's name. Cards that would give different voices give none. It skips this fallback when the name fits several chat cards: "Junpei" with "Junpei Iori" and "Junpei Kato" in the chat never takes an outside "Junpei Sato" card's voice. Exact and base-name matches still win, and narrator names still follow the narrator setting. A card's configured voice still comes before the random NPC voice pool.

  • Request builders (buildTTSVoiceRequests, buildExtractedRoleplayTTSVoiceRequests) take an optional ambiguity check. ChatArea and ChatMessage pass one built from the same chat roster they already use for the card lookup.

  • Regressions in scripts/regressions/tts-source-persistence.regression.ts cover:

    • an outside card voicing its short name;
    • two outside cards with different voices;
    • an exact match winning;
    • a chat card without a voice;
    • a persona short name;
    • "Li";
    • "Ms. Kirijo";
    • a bare title;
    • one shared word;
    • narration;
    • Mr/Mrs and Jr/Sr;
    • initials;
    • a roster-ambiguous speaker, in both builders.

    Each new case fails without its fix.

Behaviour to know about. The fallback runs wherever a speaker has no card ID, including Game narration and combat lines. A Game NPC called by part of a voiced card's name now uses that card's voice instead of the random NPC pool. A single title word that a voiced card's name contains, such as "Professor" for a card named "Professor Mari", also takes that card's voice.

Left as is (from review). An outside card whose name is exactly the speaker's name, such as a card named "Junpei", still voices "Junpei" even when two chat cards also fit. That exact-name lookup was already there before this PR, and an exact name is the strongest match there is. Changing it would change behaviour beyond #8638.

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

What the agent ran locally:

  • After rebasing on staging, node ./scripts/pnpm-runner.mjs check passes.
  • These regressions pass: tts-source-persistence, avatar-director, avatar-tts-lipsync, game-tts-emotion, roleplay-vn-tts, tts-sequence-cache-identity, generate-reply-text-cleanup, multiplayer-game-persona, multiplayer-room-fight and open-issues.
  • Review history:
    • An independent review agent fixed a chat card being shadowed by an outside card.
    • Dottore found two defects: the roster-ambiguous speaker and Mr/Mrs titles. Both are fixed, each with a regression that fails without its fix.
    • CodeRabbit raised two-letter names and initials (both fixed, with regressions) and the exact-name case above (left as is, for the stated reason).

To verify by hand:

  • Manually verify in a Roleplay chat with the TTS speaker extractor and per-character voices on: give a card that isn't in the chat (for example "Junpei Iori") a voice, get a reply where the extractor credits dialogue to "Junpei", and confirm the line plays in that card's voice. On ElevenLabs it used to be skipped.
  • Manually verify that with two voiced cards sharing a first name and different voices (for example "Junpei Iori" and "Junpei Kurosawa"), a line credited to "Junpei" uses the default or NPC-pool voice, not either card's.
  • Manually verify that narration still uses the narrator or global voice, and that the Character Editor's voice label for a card without its own voice is unchanged.

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)

No docs change: this fixes matching behind an existing setting.

🤖 Generated with Claude Code


🔄 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/8650 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 11/1/2026 **Status:** ✅ Merged **Merged:** 11/1/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/speaker-extractor-card-voices-8638` --- ### 📝 Commits (5) - [`7ec424a`](https://github.com/Pasta-Devs/Marinara-Engine/commit/7ec424a50dd23739a5aa126075937cb59c69dbcc) fix(tts): a speaker the extractor names by first name uses that card's voice (#8638) - [`e4f2394`](https://github.com/Pasta-Devs/Marinara-Engine/commit/e4f239448aea1c87fa6cb6233d60c887a1ec7399) fix(tts): a two-letter first name is a short form of a card's name (#8638) - [`43771f2`](https://github.com/Pasta-Devs/Marinara-Engine/commit/43771f22aa0a4d9fcdcb92a183da222b609107ad) fix(tts): a name that fits two chat cards never takes an outside card's voice; different titles are two people (#8638) - [`8476a92`](https://github.com/Pasta-Devs/Marinara-Engine/commit/8476a922688d76242af6ba147aeb5b2177a15361) fix(tts): an initial in a short name must fit the card's name (#8638) - [`448fa44`](https://github.com/Pasta-Devs/Marinara-Engine/commit/448fa44b5128f02460a6ee875a912cf8b63d9c1c) fix(tts): Game narration also keeps a roster-ambiguous speaker off an outside card's voice (#8638) ### 📊 Changes **8 files changed** (+349 additions, -12 deletions) <details> <summary>View changed files</summary> 📝 `packages/client/src/components/chat/ChatArea.tsx` (+5 -0) 📝 `packages/client/src/components/chat/ChatMessage.tsx` (+7 -0) 📝 `packages/client/src/components/game/GameNarration.tsx` (+19 -3) 📝 `packages/client/src/lib/tts-dialogue.ts` (+53 -8) 📝 `packages/client/src/lib/tts-roleplay-speaker-extractor.ts` (+2 -0) 📝 `packages/shared/src/utils/game-character-name-match.ts` (+43 -0) 📝 `scripts/regressions/game-tts-emotion.regression.ts` (+25 -1) 📝 `scripts/regressions/tts-source-persistence.regression.ts` (+195 -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`. ## Linked issue Closes #8638 ## Why this change - With the TTS speaker extractor on, a line credited to "Junpei" was never voiced as the "Junpei Iori" card, even though that card has a voice of its own. The voice resolver matched a speaker to a card's voice only by exact name or base name, and the card wasn't in the chat. So Junpei got the default voice. On ElevenLabs with no default voice, his line was dropped completely, which is the "not played" symptom in the issue. ## What changed - **`isShortFormOfCharacterName`** (shared, `game-character-name-match.ts`): every word of the speaker's name must appear in the card's name. - "Junpei", "Iori", "Ms. Kirijo" and "Li" (for "Li Mei") match. - "Fatui Guard" doesn't match "Fatui Harbinger Dottore": sharing one word isn't enough. - Short forms keep two-letter words and drop only titles (Mr, Mrs, Ms, Dr, Sr, Jr, St). - A title on one side only is ignored, but two different titles are two people: "Mr. Tanaka" isn't "Mrs. Tanaka", and Jr isn't Sr. - An initial must start one of the card's words: "J. Smith" is John Smith, never Bob Smith. - Game character matching (`characterNamesMatch`) keeps its own tokenizer, unchanged. - **Chat lookup** (`findTTSCharacterIdBySpeakerName`): after the exact and base-name steps, a short name links to the one chat card or persona it fits, so a chat card keeps its own voice settings. The new `isTTSSpeakerAmbiguous` reports when a name fits more than one chat card. - **`resolveTTSVoiceForSpeaker`**: when no chat card claims the speaker, it falls back to the one voiced card whose name contains the speaker's name. Cards that would give different voices give none. It skips this fallback when the name fits several chat cards: "Junpei" with "Junpei Iori" and "Junpei Kato" in the chat never takes an outside "Junpei Sato" card's voice. Exact and base-name matches still win, and narrator names still follow the narrator setting. A card's configured voice still comes before the random NPC voice pool. - **Request builders** (`buildTTSVoiceRequests`, `buildExtractedRoleplayTTSVoiceRequests`) take an optional ambiguity check. `ChatArea` and `ChatMessage` pass one built from the same chat roster they already use for the card lookup. - **Regressions** in `scripts/regressions/tts-source-persistence.regression.ts` cover: - an outside card voicing its short name; - two outside cards with different voices; - an exact match winning; - a chat card without a voice; - a persona short name; - "Li"; - "Ms. Kirijo"; - a bare title; - one shared word; - narration; - Mr/Mrs and Jr/Sr; - initials; - a roster-ambiguous speaker, in both builders. Each new case fails without its fix. **Behaviour to know about.** The fallback runs wherever a speaker has no card ID, including Game narration and combat lines. A Game NPC called by part of a voiced card's name now uses that card's voice instead of the random NPC pool. A single title word that a voiced card's name contains, such as "Professor" for a card named "Professor Mari", also takes that card's voice. **Left as is (from review).** An outside card whose name is exactly the speaker's name, such as a card named "Junpei", still voices "Junpei" even when two chat cards also fit. That exact-name lookup was already there before this PR, and an exact name is the strongest match there is. Changing it would change behaviour beyond #8638. ## 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 What the agent ran locally: - After rebasing on staging, `node ./scripts/pnpm-runner.mjs check` passes. - These regressions pass: `tts-source-persistence`, `avatar-director`, `avatar-tts-lipsync`, `game-tts-emotion`, `roleplay-vn-tts`, `tts-sequence-cache-identity`, `generate-reply-text-cleanup`, `multiplayer-game-persona`, `multiplayer-room-fight` and `open-issues`. - Review history: - An independent review agent fixed a chat card being shadowed by an outside card. - Dottore found two defects: the roster-ambiguous speaker and Mr/Mrs titles. Both are fixed, each with a regression that fails without its fix. - CodeRabbit raised two-letter names and initials (both fixed, with regressions) and the exact-name case above (left as is, for the stated reason). To verify by hand: - Manually verify in a Roleplay chat with the TTS speaker extractor and per-character voices on: give a card that isn't in the chat (for example "Junpei Iori") a voice, get a reply where the extractor credits dialogue to "Junpei", and confirm the line plays in that card's voice. On ElevenLabs it used to be skipped. - Manually verify that with two voiced cards sharing a first name and different voices (for example "Junpei Iori" and "Junpei Kurosawa"), a line credited to "Junpei" uses the default or NPC-pool voice, not either card's. - Manually verify that narration still uses the narrator or global voice, and that the Character Editor's voice label for a card without its own voice is unchanged. ## 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) No docs change: this fixes matching behind an existing setting. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 17:39: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#8723
No description provided.