[PR #8641] [MERGED] fix(tts): Game mode no longer speaks the sprite emotion before each line (#8619) #8719

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

📋 Pull Request Information

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

Base: staging ← Head: fix/game-tts-emotion-8619


📝 Commits (1)

  • d4b473f fix(tts): Game mode no longer speaks the sprite emotion before each line

📊 Changes

8 files changed (+223 additions, -99 deletions)

View changed files

📝 packages/client/src/components/game/GameCombatUI.tsx (+2 -1)
📝 packages/client/src/components/game/GameNarration.tsx (+2 -76)
➕ packages/client/src/lib/game-tts-emotion.ts (+62 -0)
📝 packages/server/src/routes/tts.routes.ts (+19 -5)
📝 packages/shared/src/types/tts.ts (+54 -0)
📝 scripts/regressions/game-tts-emotion.regression.ts (+22 -5)
📝 scripts/regressions/prompt.regression.ts (+60 -10)
📝 scripts/regressions/tts-source-persistence.regression.ts (+2 -2)

📄 Description

Closes #8619

Why this change

With ElevenLabs, Game mode reads the line's emotion aloud before the dialogue — the reporter hears "neutral. Four thirty-one…" — while Roleplay does not, and no combination of TTS toggles helps. Their attached report (ElevenLabs, eleven_v4) traced it accurately:

  • Game mode resolves every line's sprite expression and sends it as the speech tone, falling back to neutral for a plain line (GameNarration's resolveGameSegmentTtsEmotion).
  • For ElevenLabs, the server prepends that tone to the spoken text as an audio tag: [smirk] Four thirty-one… (buildElevenLabsTextInput).
  • ElevenLabs performs its documented audio tags and reads other bracketed words aloud. Most game expressions — neutral, smirk, thinking, sleepy, blushing, … — are not documented tags.

It is worse on the default model: eleven_multilingual_v2 (and flash/turbo) have no audio tags at all, so they read every bracket aloud. The prefix is added server-side after the client's speech filters run, which is why no setting could remove it. Roleplay was unaffected because it does not send a sprite expression as the tone.

What changed

  • One vocabulary, in shared (types/tts.ts): the game's 16 expressions (GAME_TTS_EMOTIONS) and the documented ElevenLabs tag each one is spoken with, or null when none means it: happy, sad, angry, surprised as themselves; thinking → thoughtful, disgusted → appalled, laughing → laughs, crying → crying, smirk → mischievously; neutral, scared, blushing, embarrassed, determined, confused, sleepy → no tag. Tags are taken from ElevenLabs' v3/v4 prompting guide. The map is a complete Record, so a new expression cannot be added without deciding its tag.
  • The tag is sent only where it is performed. buildElevenLabsTextInput(text, tone, model) adds nothing unless the model reads audio tags (eleven_v3, eleven_v4, NanoGPT's Elevenlabs-V3). A game expression becomes its documented tag or none. Any other tone is a cue written to be performed — the Roleplay speaker extractor's opt-in emotion indicators — and is kept as written.
  • Combat dialogue sent its raw line.expression (e.g. grin) with no normalisation, so it had the same problem. The expression normaliser moves from GameNarration to lib/game-tts-emotion.ts, and combat now folds its expression into the same vocabulary (grin → happy; an expression that names none sends no tone).

OpenAI-compatible sources are unchanged: they receive the tone as spoken instructions (Use a … tone.), never as text.

Validation

  • prompt.regression.ts: the case that pinned [neutral], [thinking] and [smirk] (the bug itself) is rewritten to the new contract — undocumented expressions send no tag, mapped ones send their documented tag, every map value is a documented tag, free-form cues pass through, non-tag models get no bracket, NanoGPT's Eleven v3 does. On the route before this change it fails: '[neutral] Reserved. Tomorrow afternoon.'.
  • game-tts-emotion.regression.ts now uses the real moved module, and proves combat folds grin → happy, Smirking → smirk, and sends no tone for an expression that names none. On the combat code before this change it fails: tone 'grin'.
  • All 17 TTS / Game narration regressions pass; every scripts/regressions/tsconfig*.json lane typechecks; client and server tsc --noEmit pass; lint has 0 errors; Prettier clean.

One deliberate limit: eleven_v4_turbo is left out of the audio-tag models. ElevenLabs' guide documents tags for Eleven v3 and v4 only; if turbo performs them too, adding it to ELEVENLABS_AUDIO_TAG_MODELS is a one-word change.

Test plan

  • ElevenLabs eleven_v4, Game narration autoplay on: play several Game lines with different expressions; confirm no emotion word is spoken before any line.
  • Same with the default eleven_multilingual_v2; confirm no bracketed word is spoken and lines are read plainly.
  • On eleven_v4, confirm a happy, sad or angry line still sounds delivered with that emotion.
  • Trigger combat dialogue with TTS on; confirm no expression word is spoken.
  • Roleplay with Enable emotion indicators on and eleven_v3/eleven_v4: confirm the extractor's cues still shape delivery as before.
  • An OpenAI TTS source in Game mode: confirm lines still sound the same.

🤖 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/8641 **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/game-tts-emotion-8619` --- ### 📝 Commits (1) - [`d4b473f`](https://github.com/Pasta-Devs/Marinara-Engine/commit/d4b473f543972f165f9fcd325714f63a29936ed2) fix(tts): Game mode no longer speaks the sprite emotion before each line ### 📊 Changes **8 files changed** (+223 additions, -99 deletions) <details> <summary>View changed files</summary> 📝 `packages/client/src/components/game/GameCombatUI.tsx` (+2 -1) 📝 `packages/client/src/components/game/GameNarration.tsx` (+2 -76) ➕ `packages/client/src/lib/game-tts-emotion.ts` (+62 -0) 📝 `packages/server/src/routes/tts.routes.ts` (+19 -5) 📝 `packages/shared/src/types/tts.ts` (+54 -0) 📝 `scripts/regressions/game-tts-emotion.regression.ts` (+22 -5) 📝 `scripts/regressions/prompt.regression.ts` (+60 -10) 📝 `scripts/regressions/tts-source-persistence.regression.ts` (+2 -2) </details> ### 📄 Description Closes #8619 ## Why this change With ElevenLabs, Game mode reads the line's emotion aloud before the dialogue — the reporter hears *"neutral. Four thirty-one…"* — while Roleplay does not, and no combination of TTS toggles helps. Their attached report (ElevenLabs, `eleven_v4`) traced it accurately: - Game mode resolves every line's sprite expression and sends it as the speech `tone`, falling back to `neutral` for a plain line (`GameNarration`'s `resolveGameSegmentTtsEmotion`). - For ElevenLabs, the server prepends that tone to the spoken text as an audio tag: `[smirk] Four thirty-one…` (`buildElevenLabsTextInput`). - ElevenLabs performs its documented audio tags and reads other bracketed words aloud. Most game expressions — `neutral`, `smirk`, `thinking`, `sleepy`, `blushing`, … — are not documented tags. It is worse on the default model: `eleven_multilingual_v2` (and flash/turbo) have no audio tags at all, so they read **every** bracket aloud. The prefix is added server-side after the client's speech filters run, which is why no setting could remove it. Roleplay was unaffected because it does not send a sprite expression as the tone. ## What changed - **One vocabulary, in shared** (`types/tts.ts`): the game's 16 expressions (`GAME_TTS_EMOTIONS`) and the documented ElevenLabs tag each one is spoken with, or `null` when none means it: `happy`, `sad`, `angry`, `surprised` as themselves; `thinking → thoughtful`, `disgusted → appalled`, `laughing → laughs`, `crying → crying`, `smirk → mischievously`; `neutral`, `scared`, `blushing`, `embarrassed`, `determined`, `confused`, `sleepy` → no tag. Tags are taken from ElevenLabs' v3/v4 prompting guide. The map is a complete `Record`, so a new expression cannot be added without deciding its tag. - **The tag is sent only where it is performed.** `buildElevenLabsTextInput(text, tone, model)` adds nothing unless the model reads audio tags (`eleven_v3`, `eleven_v4`, NanoGPT's `Elevenlabs-V3`). A game expression becomes its documented tag or none. Any other tone is a cue written to be performed — the Roleplay speaker extractor's opt-in emotion indicators — and is kept as written. - **Combat dialogue** sent its raw `line.expression` (e.g. `grin`) with no normalisation, so it had the same problem. The expression normaliser moves from `GameNarration` to `lib/game-tts-emotion.ts`, and combat now folds its expression into the same vocabulary (`grin → happy`; an expression that names none sends no tone). OpenAI-compatible sources are unchanged: they receive the tone as spoken *instructions* (`Use a … tone.`), never as text. ## Validation - `prompt.regression.ts`: the case that pinned `[neutral]`, `[thinking]` and `[smirk]` (the bug itself) is rewritten to the new contract — undocumented expressions send no tag, mapped ones send their documented tag, every map value is a documented tag, free-form cues pass through, non-tag models get no bracket, NanoGPT's Eleven v3 does. On the route **before** this change it fails: `'[neutral] Reserved. Tomorrow afternoon.'`. - `game-tts-emotion.regression.ts` now uses the real moved module, and proves combat folds `grin → happy`, `Smirking → smirk`, and sends no tone for an expression that names none. On the combat code **before** this change it fails: tone `'grin'`. - All 17 TTS / Game narration regressions pass; every `scripts/regressions/tsconfig*.json` lane typechecks; client and server `tsc --noEmit` pass; `lint` has 0 errors; Prettier clean. One deliberate limit: `eleven_v4_turbo` is left out of the audio-tag models. ElevenLabs' guide documents tags for Eleven v3 and v4 only; if turbo performs them too, adding it to `ELEVENLABS_AUDIO_TAG_MODELS` is a one-word change. ## Test plan - [ ] ElevenLabs `eleven_v4`, Game narration autoplay on: play several Game lines with different expressions; confirm no emotion word is spoken before any line. - [ ] Same with the default `eleven_multilingual_v2`; confirm no bracketed word is spoken and lines are read plainly. - [ ] On `eleven_v4`, confirm a happy, sad or angry line still sounds delivered with that emotion. - [ ] Trigger combat dialogue with TTS on; confirm no expression word is spoken. - [ ] Roleplay with **Enable emotion indicators** on and `eleven_v3`/`eleven_v4`: confirm the extractor's cues still shape delivery as before. - [ ] An OpenAI TTS source in Game mode: confirm lines still sound the same. 🤖 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:12 +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#8719
No description provided.