[PR #1141] [CLOSED] fix(tts): apply playback rate client-side for local OAI-compatible servers #4943

Closed
opened 2026-10-22 04:11:54 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/1141
Author: @etherious1804
Created: 5/24/2026
Status: ❌ Closed

Base: staging ← Head: fix/tts-speed-client-side-fallback


📝 Commits (1)

  • 0954666 fix(tts): apply playback rate client-side for local OAI-compatible servers

📊 Changes

5 files changed (+59 additions, -6 deletions)

View changed files

📝 packages/client/src/components/chat/ChatArea.tsx (+9 -2)
📝 packages/client/src/components/chat/ChatMessage.tsx (+10 -3)
📝 packages/client/src/components/panels/settings/TTSConfigCard.tsx (+2 -0)
📝 packages/client/src/lib/tts-dialogue.ts (+26 -0)
📝 packages/client/src/lib/tts-service.ts (+12 -1)

📄 Description

Linked issue

Closes #1140

Why this change

The TTS settings panel exposes a Speed slider that's supposed to control playback rate, but for local OpenAI-compatible TTS servers (mlx-audio, openedai-speech, etc.) the speed parameter in /v1/audio/speech is an OpenAI extension that most local implementations silently ignore. The user moves the slider and nothing changes — the synthesized audio comes back at exactly the same rate every time. Cloud OpenAI honors the parameter; local servers don't.

We can fix this universally without re-synthesis by applying playbackRate on the HTMLAudioElement client-side. Pitch is preserved by default. The slider becomes uniformly effective across every provider, with no extra server round-trip.

What changed

Shared types

  • packages/shared/src/types/tts.ts: no new type fields; existing speed on TTSConfig is unchanged. The value continues to be sent to providers that respect it server-side.

Client — client-side playback rate

  • packages/client/src/lib/tts-dialogue.ts: new exported clientSidePlaybackRate(config) helper that returns the configured speed (or 1 when undefined/unset). Single source of truth for the "speed-as-playbackRate" interpretation.
  • packages/client/src/lib/tts-service.ts: speakSequence accepts a playbackRate option and applies it to each HTMLAudioElement (audio.playbackRate = rate) immediately after constructing the element, before play().
  • packages/client/src/components/chat/ChatArea.tsx and packages/client/src/components/chat/ChatMessage.tsx: pass clientSidePlaybackRate(ttsConfig) into the existing speakSequence call sites (autoplay and per-message manual speak).
  • packages/client/src/components/panels/settings/TTSConfigCard.tsx: existing Speed slider is untouched UI-wise — it simply works now.

The change is intentionally minimal: no surgery in the request builders, no provider-specific branches. The speed request param continues to be sent (for providers that honor it — pitch may also be adjusted server-side), and the client-side playbackRate layer is purely additive.

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

Generated PR — unchecked boxes are left for the merger to confirm manually per the repo's AI-PR guidance.

What was verified on the branch:

  • TypeScript build and lint pass cleanly via pnpm check.
  • The new clientSidePlaybackRate export is consumed at three call sites: autoplay-after-stream (ChatArea.tsx), per-message manual speak (ChatMessage.tsx), and the streaming-TTS hook (use-streaming-tts.ts in #1142).
  • Code path: speakSequence reads the option, assigns audio.playbackRate = rate before audio.play(). Standard HTMLAudioElement behavior — pitch preserved, no extra fetch round-trip.

To verify in browser:

  • Move the Speed slider to a non-default value (e.g. 1.5×).
  • Trigger TTS on a message via the speaker icon.
  • Audio plays back at the new rate without any change in pitch.
  • Reset slider to 1.0×, re-play — back to normal speed.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed
  • Version/release files updated (only if this PR includes a version bump)

UI evidence (if applicable)

No UI changes — only the existing Speed slider becomes effective.

🤖 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/1141 **Author:** [@etherious1804](https://github.com/etherious1804) **Created:** 5/24/2026 **Status:** ❌ Closed **Base:** `staging` ← **Head:** `fix/tts-speed-client-side-fallback` --- ### 📝 Commits (1) - [`0954666`](https://github.com/Pasta-Devs/Marinara-Engine/commit/09546664294536995d2917c56babf6bcb6f50370) fix(tts): apply playback rate client-side for local OAI-compatible servers ### 📊 Changes **5 files changed** (+59 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `packages/client/src/components/chat/ChatArea.tsx` (+9 -2) 📝 `packages/client/src/components/chat/ChatMessage.tsx` (+10 -3) 📝 `packages/client/src/components/panels/settings/TTSConfigCard.tsx` (+2 -0) 📝 `packages/client/src/lib/tts-dialogue.ts` (+26 -0) 📝 `packages/client/src/lib/tts-service.ts` (+12 -1) </details> ### 📄 Description ## Linked issue Closes #1140 ## Why this change The TTS settings panel exposes a Speed slider that's supposed to control playback rate, but for local OpenAI-compatible TTS servers (mlx-audio, openedai-speech, etc.) the `speed` parameter in `/v1/audio/speech` is an OpenAI extension that most local implementations silently ignore. The user moves the slider and nothing changes — the synthesized audio comes back at exactly the same rate every time. Cloud OpenAI honors the parameter; local servers don't. We can fix this universally without re-synthesis by applying `playbackRate` on the HTMLAudioElement client-side. Pitch is preserved by default. The slider becomes uniformly effective across every provider, with no extra server round-trip. ## What changed **Shared types** - `packages/shared/src/types/tts.ts`: no new type fields; existing `speed` on `TTSConfig` is unchanged. The value continues to be sent to providers that respect it server-side. **Client — client-side playback rate** - `packages/client/src/lib/tts-dialogue.ts`: new exported `clientSidePlaybackRate(config)` helper that returns the configured speed (or 1 when undefined/unset). Single source of truth for the "speed-as-playbackRate" interpretation. - `packages/client/src/lib/tts-service.ts`: `speakSequence` accepts a `playbackRate` option and applies it to each `HTMLAudioElement` (`audio.playbackRate = rate`) immediately after constructing the element, before `play()`. - `packages/client/src/components/chat/ChatArea.tsx` and `packages/client/src/components/chat/ChatMessage.tsx`: pass `clientSidePlaybackRate(ttsConfig)` into the existing `speakSequence` call sites (autoplay and per-message manual speak). - `packages/client/src/components/panels/settings/TTSConfigCard.tsx`: existing Speed slider is untouched UI-wise — it simply works now. The change is intentionally minimal: no surgery in the request builders, no provider-specific branches. The `speed` request param continues to be sent (for providers that honor it — pitch may also be adjusted server-side), and the client-side `playbackRate` layer is purely additive. ## Validation - [x] `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 > Generated PR — unchecked boxes are left for the merger to confirm manually per the repo's AI-PR guidance. **What was verified on the branch:** - TypeScript build and lint pass cleanly via `pnpm check`. - The new `clientSidePlaybackRate` export is consumed at three call sites: autoplay-after-stream (`ChatArea.tsx`), per-message manual speak (`ChatMessage.tsx`), and the streaming-TTS hook (`use-streaming-tts.ts` in #1142). - Code path: `speakSequence` reads the option, assigns `audio.playbackRate = rate` before `audio.play()`. Standard HTMLAudioElement behavior — pitch preserved, no extra fetch round-trip. **To verify in browser:** - Move the Speed slider to a non-default value (e.g. 1.5×). - Trigger TTS on a message via the speaker icon. - Audio plays back at the new rate without any change in pitch. - Reset slider to 1.0×, re-play — back to normal speed. ## Docs and release impact - [x] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed - [ ] Version/release files updated (only if this PR includes a version bump) ## UI evidence (if applicable) No UI changes — only the existing Speed slider becomes effective. 🤖 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-10-22 04:11:54 +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#4943
No description provided.