Skip to content

Studio: add an opt-in setting to read replies aloud automatically - #13357

Merged
danielhanchen merged 3 commits into
mainfrom
studio-auto-read-aloud
Oct 12, 2026
Merged

danielhanchen merged 3 commits into
mainfrom
studio-auto-read-aloud

Conversation

@danielhanchen

@danielhanchen danielhanchen commented Oct 12, 2026 •

Copy link
Copy Markdown
Member

Fixes #12303

Summary

Read aloud in Studio and Desktop only works through the speaker button on each reply, so hands-free use needs a click after every message. This adds an opt-in Read replies automatically switch under Settings > Voice > Read aloud. When it is on, each reply is read aloud as soon as it finishes.

This is opt-in. The switch is off by default (autoReadAloud: false), and only a saved true turns it on, so existing and new users hear nothing new unless they flip it. Read aloud keeps working exactly as today: one click on the speaker icon per reply.

What it does

  • Reuses the exact path the Read aloud button uses (message.speak() through StudioSpeechSynthesisAdapter), so it honours the chosen TTS engine (system voices, the Studio speech model, or a custom connection), voice, speed, pitch and volume, and the existing markdown stripping.
  • Speaks only the newest assistant reply, and only when it finished normally. Stopped, failed, cut-off (length, interrupted stream, context window), tool-approval and empty replies stay silent.
  • A new run stops the previous reply's playback instead of talking over it, and a later reply replaces the earlier one (no queue).
  • The Stop reading control works as it does today.
  • Compare panes do not auto-read, and neither does the single chat kept mounted behind Compare, so two panes never talk at once.
  • Switching to another chat stops the playback auto read-aloud started there, so two replies never play over each other.
  • runEnd can fire before the final message state lands, so a reply that is still settling is retried once its status updates, and a reply is never spoken twice.

Changes

  • voice-settings-store.ts: autoReadAloud (default false), persisted with the other voice settings.
  • voice-tab.tsx: the new switch, right under the Read aloud button switch; added to Settings search.
  • auto-read-aloud.tsx: a small headless component mounted in the chat thread (not in Compare panes).
  • utils/auto-read-aloud.ts: the decision of whether to speak, wait or skip, kept pure so it is unit tested.
  • Translations for the two new strings in every locale (i18n:check:strict passes).

Tests

  • tests/auto-read-aloud.test.ts: speaks a finished reply, waits on a settling one, skips stopped, failed, cut-off, tool-approval, reasoning-only and empty replies, checks the opt-in default, that Compare panes do not mount it, that a hidden chat stays silent and that leaving a chat stops its own playback. The cut-off case fails with the check removed.
  • npm run typecheck, npm run i18n:check:strict, npm test (11332 passed, 0 failed) and npm run build all pass.
  • Live in a browser against two fresh Studio installs (merge base vs this branch), with a scripted reply on a connection and the speech engine recorded: with the setting on, the finished reply text reached the speech engine and the reply showed Stop reading; on main nothing was spoken. With the setting off, nothing was spoken on either side.
  • Studio regression switchboard (auth, settings, crawl, upstream CI, inference settings, compaction): no functional regression; the only visual change is the new row in Settings > Voice.

Before / after

Settings > Voice > Read aloud on a fresh install. The new switch sits under the Read aloud button switch and is off by default (main on the left, this branch on the right):

Settings > Voice before and after, new switch off by default

The same scripted reply on both sides after turning the setting on. On this branch the finished reply is sent to the speech engine and its speaker icon turns into Stop reading; on main nothing is spoken:

Chat reply before and after

@danielhanchen danielhanchen self-assigned this Oct 12, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-12T05:29:28.857729Z 426b7c3 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 12, 2026
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

Reviewed commit: 9336af36b4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

danielhanchen pushed a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Oct 12, 2026
danielhanchen pushed a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Oct 12, 2026
danielhanchen pushed a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Oct 12, 2026
@danielhanchen
danielhanchen merged commit f1eb893 into main Oct 12, 2026
@danielhanchen
danielhanchen deleted the studio-auto-read-aloud branch October 12, 2026 08:48
danielhanchen added a commit that referenced this pull request Oct 19, 2026
…#14191)

## Summary

Fixes #9163 (its second ask, reading replies aloud automatically,
shipped in #13357).

Read aloud with an Unsloth Studio speech model could not run next to the
chat model. On main, loading a TTS model in Audio unloaded the chat
model, even with Keep multiple models loaded set to When they fit. The
next chat message reloaded the chat model and unloaded the TTS model.
And with both loaded, Read aloud still failed with "No speech model is
loaded", because the request named no model and reached the chat model.

The backend already supports both models loaded at once, so all fixes
are in the frontend:

- The Audio TTS load and the chat auto-load ("Loading last used
model...") now send `alongside: true`. Under When they fit or Always,
both models stay loaded. Off behaves as before, since the server ignores
`alongside` there.
- Read aloud looks up the loaded speech model in `/v1/models` and names
it in `/audio/generate`. Audio page Generate does the same when its
model sits beside the chat model.
- The Audio page shows, generates with and ejects its own speech model,
never the chat model. With only a chat model loaded, the header says "No
TTS model loaded" instead of showing the chat model. Switching speech
models unloads the old one first, so two TTS models don't pile up.
- Every status read updates the Keep multiple models loaded mode, so a
session that starts on the Audio page still knows it.

Copy changes, in all 14 locales:

- Settings > Voice: the engine option "Load TTS model" is now "Unsloth
model" (Desktop shows these strings, so no "Unsloth Studio", per the
Tauri branding contract), and the TTS model row says which model is
loaded. Under Off, a new row explains that loading a speech model
unloads the chat model and offers "Keep both loaded" (switches to When
they fit).
- Under Off, loading a TTS model in Audio says up front that it unloads
the chat model, and the success toast has the same "Keep both loaded"
action.
- Loads that unload another model say which one. Read aloud errors point
at Audio > Text to Speech (the old text said "Speak"). The Keep multiple
models loaded description now mentions speech models.

`generateStudioTtsAudio(text, signal)` keeps its signature, so it stays
compatible with the Voice mode work in #12384.

## Testing

Colab L4 (23 GB), Qwen3-1.7B UD-Q4_K_XL for chat, Kokoro-82M Q8_0 and
KittenTTS for speech, headless Chrome driven by Playwright.

Before the fix (main), these failed:

- Off: loading Kokoro in Audio unloaded the chat model with no warning.
The next chat message reloaded chat and unloaded Kokoro, then Read aloud
failed with "No speech model is loaded".
- When they fit: loading Kokoro still unloaded the chat model, and the
chat reload still unloaded Kokoro.
- With both loaded (simulated `alongside`), Read aloud returned 400 "No
speech model is loaded".

After the fix (main 2fee36f + this branch), these passed:

- Off: the load toast warns that the chat model will be unloaded, the
success toast names it, and "Keep both loaded" in Settings > Voice
switches to When they fit.
- When they fit, chat loaded first: loading Kokoro in Audio keeps both.
The Audio header shows Kokoro, and Generate sends `model=Kokoro` and
returns 200.
- When they fit, Kokoro loaded first: the chat auto-load sends
`alongside: true` and both stay loaded. Read aloud sends `model=Kokoro`
and returns 200.
- Ejecting in Audio unloads only the speech model. Switching Kokoro to
KittenTTS unloads Kokoro, then loads KittenTTS beside chat.
- Cold page load on `/audio` under When they fit: loading Kokoro keeps
chat loaded, and Read aloud on a chat reply returns 200.

Local checks:

```bash
cd studio/frontend
npm test            # 12,677 tests: 12,676 pass, 0 fail, 1 skipped
npm run typecheck
npm run i18n:check:strict
npx vite build
npx eslint <touched files>   # no new findings vs base
npm run bundle:check
```

`bundle:check` is over budget on main too (2005.9 KB vs 2003.5 KB). This
change adds about 0.6 KB transfer.

New and updated tests: `read-aloud-beside-chat.test.ts`,
`audio-page-policy.test.ts`, `read-aloud-studio-voice.test.ts`,
`openai-model-catalog.test.ts`, `audio-run-api.test.ts`,
`tts-custom-connections-disabled.test.ts`.

Not tested: Always mode, transformers (non-audio.cpp) TTS models, saved
or cloned voices, Windows, macOS, the desktop app, and audible playback
(checked by HTTP 200 and the WAV payload only).


## Before and after

Two isolated Studio installs (merge base `2fee36ffa` vs this branch),
CPU only, Keep multiple models loaded set to When they fit, with
Qwen3-0.6B Q4_K_M for chat and Kokoro-82M Q8_0 for speech loaded
together.

Audio page: main shows the chat model ("The loaded model is not a TTS
audio model"), this branch shows Kokoro.

![Audio page
header](https://raw.githubusercontent.com/danielhanchen/unsloth-staging-2/pr-media/pr/14191/q_pr14191_pair_00-96bac0369742.png)

Read aloud on a chat reply: main sends no model and gets 400 "No model
loaded.", this branch sends
`model=audio-cpp/audio.cpp-gguf/Kokoro-82M-GGUF` and gets 200.

![Read aloud on a chat
reply](https://raw.githubusercontent.com/danielhanchen/unsloth-staging-2/pr-media/pr/14191/q_pr14191_pair_01-a6404a301ab9.png)

Settings > Voice under Off, after loading Kokoro: the engine option is
now "Unsloth model" (shot before it lost "Studio" for the Desktop
branding contract, so the image still reads "Unsloth Studio model"), the
TTS model row names the loaded model, and a row offers "Keep both
loaded".

![Settings Voice tab under
Off](https://raw.githubusercontent.com/danielhanchen/unsloth-staging-2/pr-media/pr/14191/q_pr14191_pair_02-4b559588f5b1.png)

---------

Co-authored-by: Daniel Han <[email protected]>
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.

[Feature] Auto read-aloud after response completes

1 participant