[GH-ISSUE #2756] [Issue]: TTS provider request building — no speed clamp, ignored WAV format, missing model-family gates #1396

Closed
opened 2026-10-21 05:33:01 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @kolacheee on GitHub (Jun 21, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2756

Originally assigned to: @SpicyMarinara on GitHub.

Summary

The TTS proxy builds provider request bodies with several gaps around speed clamping, audio format, and per-model/per-provider gating. The user-impacting one is that an ElevenLabs speed outside 0.7-1.2 produces a silent no-audio 502; the rest are inconsistency/diagnostic defects.

Sub-bug 1: ElevenLabs speed out-of-range -> no audio (#1) [primary]

  • How it breaks: The ElevenLabs direct branch builds voice_settings: { stability, speed: cfg.speed } (657-660) with no clamp. ElevenLabs accepts speed only in [0.7,1.2] -> 422 -> mapped to 502 'TTS provider returned 422'. The schema allows 0.25-4.0 (tts.ts:112) and the UI Speed slider (TTSConfigCard.tsx:1134-1153) is ungated, advertising the full range to ElevenLabs users.
  • Repro: Source = ElevenLabs (direct), set speed to e.g. 0.5 or 2.0, speak -> no audio, 502.

Sub-bug 2: WAV ignored for ElevenLabs (#2)

  • How it breaks: The ElevenLabs URL hardcodes ?output_format=mp3_44100_128 (611-612) and never references cfg.audioFormat, unlike OpenAI/NanoGPT/PocketTTS. A carried-over audioFormat: 'wav' is a no-op (playback still works via provider content-type).

Sub-bug 3: NanoGPT non-TTS-model guard skipped (#39)

  • How it breaks: The friendly 400 for ElevenLabs non-TTS models is gated on !useNanoGptSpeech (599), so a NanoGPT+ElevenLabs user selecting a TTV model gets an opaque 502 instead.

Sub-bug 4: instructions injected for ElevenLabs-family NanoGPT models (#40)

  • How it breaks: speechInstructions for NanoGPT is computed from useNanoGptSpeech only (617), with no model-family gate, so a tone causes an instructions field to be sent to Elevenlabs-V3/Turbo NanoGPT models that have no such concept.

Sub-bug 5: speed sent for eleven_v3 (#41)

  • How it breaks: voice_settings.speed is always sent (655-660) with no per-model gating; for eleven_v3 it may be ignored. (Provider-side impact unconfirmed; correctness/cleanliness defect.)

Sub-bug 6: instructions gate uses raw cfg.model (#4) [latent]

  • How it breaks: The OpenAI instructions gate passes cfg.model (619) instead of the resolved/trimmed model (592-597). No behavioral divergence today (default tts-1 isn't gpt-4o*), but it misfires if the default ever changes to a gpt-4o* model.

Suggested Fix

  • Clamp speed per-provider before building the ElevenLabs body (Math.min(1.2, Math.max(0.7, cfg.speed))) and/or constrain the slider when source==='elevenlabs'.
  • Map cfg.audioFormat to an ElevenLabs output_format, or hide WAV for ElevenLabs.
  • Run the non-TTS-model check whenever the resolved model is one of those ids, independent of useNanoGptSpeech.
  • Gate NanoGPT instructions on an OpenAI-style model family; omit speed for models that don't support it.
  • Pass the resolved model to openAiModelSupportsSpeechInstructions.

Verification checklist (all manual)

  • Manually verify ElevenLabs TTS produces audio at speeds across 0.25-4.0 (clamped to the supported band)
  • Verify ElevenLabs audio format selection is consistent (WAV honored or hidden)
  • Verify a NanoGPT+ElevenLabs non-TTS model selection surfaces a helpful error
  • Verify instructions/speed are only sent to models that support them
  • Run pnpm check

Affected files

  • packages/server/src/routes/tts.routes.ts
  • packages/shared/src/types/tts.ts
  • packages/client/src/components/panels/settings/TTSConfigCard.tsx

Audit provenance

Found by a multi-agent static audit of the TTS/voice + image-generation subsystems (Round 1 + round-2 gap sweep + completeness critic, each finding adversarially verified) against the merged staging tree. Severity: MEDIUM.

AI-drafted from a static read; validation/test-plan boxes intentionally left UNCHECKED for a human to verify before close.

Originally created by @kolacheee on GitHub (Jun 21, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2756 Originally assigned to: @SpicyMarinara on GitHub. ## Summary The TTS proxy builds provider request bodies with several gaps around speed clamping, audio format, and per-model/per-provider gating. The user-impacting one is that an ElevenLabs speed outside 0.7-1.2 produces a silent no-audio 502; the rest are inconsistency/diagnostic defects. ## Sub-bug 1: ElevenLabs speed out-of-range -> no audio (#1) [primary] - **How it breaks:** The ElevenLabs direct branch builds `voice_settings: { stability, speed: cfg.speed }` (657-660) with no clamp. ElevenLabs accepts speed only in [0.7,1.2] -> 422 -> mapped to 502 'TTS provider returned 422'. The schema allows 0.25-4.0 (tts.ts:112) and the UI Speed slider (TTSConfigCard.tsx:1134-1153) is ungated, advertising the full range to ElevenLabs users. - **Repro:** Source = ElevenLabs (direct), set speed to e.g. 0.5 or 2.0, speak -> no audio, 502. ## Sub-bug 2: WAV ignored for ElevenLabs (#2) - **How it breaks:** The ElevenLabs URL hardcodes `?output_format=mp3_44100_128` (611-612) and never references `cfg.audioFormat`, unlike OpenAI/NanoGPT/PocketTTS. A carried-over `audioFormat: 'wav'` is a no-op (playback still works via provider content-type). ## Sub-bug 3: NanoGPT non-TTS-model guard skipped (#39) - **How it breaks:** The friendly 400 for ElevenLabs non-TTS models is gated on `!useNanoGptSpeech` (599), so a NanoGPT+ElevenLabs user selecting a TTV model gets an opaque 502 instead. ## Sub-bug 4: instructions injected for ElevenLabs-family NanoGPT models (#40) - **How it breaks:** `speechInstructions` for NanoGPT is computed from `useNanoGptSpeech` only (617), with no model-family gate, so a tone causes an `instructions` field to be sent to Elevenlabs-V3/Turbo NanoGPT models that have no such concept. ## Sub-bug 5: speed sent for eleven_v3 (#41) - **How it breaks:** voice_settings.speed is always sent (655-660) with no per-model gating; for eleven_v3 it may be ignored. (Provider-side impact unconfirmed; correctness/cleanliness defect.) ## Sub-bug 6: instructions gate uses raw cfg.model (#4) [latent] - **How it breaks:** The OpenAI instructions gate passes `cfg.model` (619) instead of the resolved/trimmed `model` (592-597). No behavioral divergence today (default tts-1 isn't gpt-4o*), but it misfires if the default ever changes to a gpt-4o* model. ## Suggested Fix - Clamp speed per-provider before building the ElevenLabs body (`Math.min(1.2, Math.max(0.7, cfg.speed))`) and/or constrain the slider when source==='elevenlabs'. - Map `cfg.audioFormat` to an ElevenLabs `output_format`, or hide WAV for ElevenLabs. - Run the non-TTS-model check whenever the resolved model is one of those ids, independent of `useNanoGptSpeech`. - Gate NanoGPT `instructions` on an OpenAI-style model family; omit speed for models that don't support it. - Pass the resolved `model` to `openAiModelSupportsSpeechInstructions`. ## Verification checklist (all manual) - [ ] Manually verify ElevenLabs TTS produces audio at speeds across 0.25-4.0 (clamped to the supported band) - [ ] Verify ElevenLabs audio format selection is consistent (WAV honored or hidden) - [ ] Verify a NanoGPT+ElevenLabs non-TTS model selection surfaces a helpful error - [ ] Verify `instructions`/`speed` are only sent to models that support them - [ ] Run `pnpm check` --- ### Affected files - `packages/server/src/routes/tts.routes.ts` - `packages/shared/src/types/tts.ts` - `packages/client/src/components/panels/settings/TTSConfigCard.tsx` ### Audit provenance Found by a multi-agent static audit of the TTS/voice + image-generation subsystems (Round 1 + round-2 gap sweep + completeness critic, each finding adversarially verified) against the merged `staging` tree. Severity: **MEDIUM**. > AI-drafted from a static read; validation/test-plan boxes intentionally left UNCHECKED for a human to verify before close.
Author
Owner

@SpicyMarinara commented on GitHub (Jun 21, 2026):

Addressed on PR #2747. Direct ElevenLabs TTS now clamps speed to 0.7-1.2 when supported, omits speed for Eleven v3, and treats ElevenLabs audio format as mp3 server-side to match the UI. The non-TTS ElevenLabs model guard now also applies when routed through NanoGPT. NanoGPT ElevenLabs-family models no longer receive OpenAI-style instructions or speed fields, and OpenAI instruction gating now uses the resolved model id. Settings now shows the ElevenLabs speed range/clamped effective value instead of advertising the full OpenAI/local range. Validated with git diff --check for the touched files; full pnpm validation is deferred until the end of the issue sweep per maintainer request.

<!-- gh-comment-id:4763310120 --> @SpicyMarinara commented on GitHub (Jun 21, 2026): Addressed on PR #2747. Direct ElevenLabs TTS now clamps speed to 0.7-1.2 when supported, omits speed for Eleven v3, and treats ElevenLabs audio format as mp3 server-side to match the UI. The non-TTS ElevenLabs model guard now also applies when routed through NanoGPT. NanoGPT ElevenLabs-family models no longer receive OpenAI-style instructions or speed fields, and OpenAI instruction gating now uses the resolved model id. Settings now shows the ElevenLabs speed range/clamped effective value instead of advertising the full OpenAI/local range. Validated with git diff --check for the touched files; full pnpm validation is deferred until the end of the issue sweep per maintainer request.
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#1396
No description provided.