Skip to content

feat: allow a custom TTS model and voice - #6944

Open
yoyoismee wants to merge 1 commit into
ChatGPTNextWeb:mainfrom
yoyoismee:tts-custom-model-voice
Open

yoyoismee wants to merge 1 commit into
ChatGPTNextWeb:mainfrom
yoyoismee:tts-custom-model-voice

Conversation

@yoyoismee

Copy link
Copy Markdown

💻 变更类型 | Change Type

  • feat
  • fix
  • refactor
  • perf
  • style
  • test
  • docs
  • ci
  • chore
  • build

🔀 变更说明 | Description of Change

In Settings, the OpenAI-TTS Model and Voice are fixed dropdowns (tts-1/tts-1-hd and six voices). This turns both into text fields that keep the same values as suggestions, so you can use whatever model and voice your speech endpoint supports, including any OpenAI-compatible /v1/audio/speech server behind the OpenAI endpoint you already set (Custom Endpoint in the browser, or BASE_URL on the server).

Why now: OpenAI's deprecations page says tts-1, tts-1-hd and gpt-4o-mini-tts "will be removed from the API on January 6, 2027". The replacement it lists, gpt-realtime-2.1-mini, runs on the Realtime API and isn't supported on /v1/audio/speech. After that date the OpenAI-TTS engine only works against another OpenAI-compatible server, which has its own model and voice names, and today there's no way to enter them.

What changed:

  • tts-config.tsx: Model and Voice are text inputs with a <datalist> of the current lists. The placeholder shows the default.
  • TTSConfigValidator.model() and .voice() trim the value and fall back to tts-1 / alloy when it's empty, and the speech call in chat.tsx runs the saved values through them. The fields themselves store exactly what you type, so they can be cleared and edited normally.
  • No new settings and no new strings (the rows keep their labels). ttsConfig.model and ttsConfig.voice were already plain strings, so saved settings load as before and the store needs no migration.
  • The default stays tts-1. Whether to change it is your call. Edge-TTS is untouched.

📝 补充信息 | Additional Information

How I checked it:

  • yarn test:ci passes. I extended test/tts-config-validator.test.ts: a custom model and voice come back trimmed, an empty or blank value falls back to the default, and a custom model and voice survive a save and reload of the config store. On main the trim and fallback tests fail (" my-speech-model " comes back as is, "" comes back empty).
  • yarn build and npx tsc --noEmit pass.
  • In headless Chrome against next dev, with a small local stub as the OpenAI-compatible server: I set the model to my-speech-model and the voice to my-voice, reloaded (both were still set), and clicked Play on a reply. The stub got POST /v1/audio/speech with {"model":"my-speech-model","input":"…","voice":"my-voice","speed":1}, both through /api/openai with BASE_URL pointing at the stub and with Custom Endpoint on. With the model padded with spaces and the voice cleared, it got "model":"my-speech-model" and "voice":"alloy". On main the same run can only choose from the two models and six voices.

Unrelated, but you may hit it: yarn lint stops on app/constant.ts with Cannot read properties of undefined (reading 'loc') from unused-imports/no-unused-imports. It does the same on main, and this PR doesn't touch that file. With that rule turned off, eslint reports the same warnings as on main and no errors.

A server-side default (DEFAULT_TTS_MODEL / DEFAULT_TTS_VOICE env vars, like DEFAULT_MODEL) would fit on top of this. I left it out to keep the change small.

The OpenAI-TTS model and voice were fixed dropdowns, so read-aloud only
worked with tts-1/tts-1-hd and the six built-in voices. They are now
text fields that keep those values as suggestions, so any
OpenAI-compatible speech server behind the configured endpoint works.

The request trims both values, and an empty field falls back to the
default model or voice. The settings shape is unchanged (both were
already plain strings), so saved settings keep working without a
migration.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant