Skip to content

feat(web): read any chat message aloud in one click - #532

Merged
adeelahmad merged 2 commits into
mainfrom
claude/project-thread-lzpr5p
Oct 18, 2026
Merged

adeelahmad merged 2 commits into
mainfrom
claude/project-thread-lzpr5p

Conversation

@adeelahmad

Copy link
Copy Markdown
Owner

Requested by Adeel · project thread

Description

Before: only voice mode read answers aloud; a message already in a conversation could not be played.

After: every question and answer in the web chat has a speaker button. One click reads it aloud by the speech model and the voice picked in Settings → AI assistant → Voice (else the browser's own speech); another click stops it. One message plays at a time (starting another stops the first, and so does leaving the conversation). Long answers go in pieces of at most 1,500 characters, cut after a sentence, under every provider's limit, and the next piece is asked for while one plays. Each piece's audio is kept in the page (32 most recent), so playing a message again doesn't call the speech model again.

How: useReadAloud() in lib/voice.ts sits beside useVoice() and uses the same POST /voice/speak, speakable() text cleaning and GET /voice server check, so the provider layer, the voice picker's choice and the model.speech row in the activity ledger are voice mode's; no backend change. ReadAloud (components/chat/read-aloud.tsx) is the button, in Answer's action row and UserBubble's hover buttons.

Motivation and Context

Adeel: "Allow playing audio via tts model of any message in chat interface".

Types of changes

  • New feature (non-breaking change which adds functionality)

Checklist:

  • The title is a Conventional Commit.
  • My code follows the code style of this project (make hooks checks it on commit).
  • I added or updated tests (__tests__/chat-read-aloud.test.tsx, 7 tests; chat.test.tsx mocks next-auth now that UserBubble reaches the API client).
  • My change requires documentation updates, and I have updated docs/ accordingly (docs/assistant.md "Read a message aloud", docs/requirements.md row, README, DEVLOG).
  • Users need more than the title to understand it, so I wrote it under ## Unreleased in CHANGELOG.md.

Local CI (ci/local-ci.sh --jobs frontend,pre-commit,title): all three pass; mkdocs build --strict clean; make requirements passes.

Done questions (AGENTS.md)

  • Goal: any message, one click, through the configured TTS model; merged on green.
  • Agents: n/a for the button itself; agents already have POST /voice/speak with {text, voice?}, which this uses unchanged.
  • Zero setup: nothing new to install or configure; works with whatever speech provider is set, else the browser.
  • Fewest clicks: one click plays, one stops; no dialog.
  • Configurable: uses the existing Settings → AI assistant → Voice provider and voice picker; no new setting.
  • Light: frontend only; audio kept in the browser page, nothing on the server.
  • Private and secure: n/a, no new surface; the text goes to the already-configured speech provider as voice mode does, and nothing is stored.
  • Cost: audio cached per piece in the page so replays are free; every call is a model.speech ledger row via speech.speak, under budgets as before.
  • User decides: nothing plays until clicked; no existing default changed.
  • Upgrades: n/a, no stored-data change.
  • Honest: listed as built in README and docs/requirements.md with its checks.
  • Tests, docs and generated files updated (no OpenAPI change).
  • Open standards: Web Audio / Web Speech APIs; no new dependency.
  • Reported in the thread with evidence; refine-later items in DEVLOG (audio across reloads, pause/resume, button in an asset's Chat tab, forget audio when the voice changes).
  • Reuse: speech.py provider layer, /voice/speak, speakable(), askServer(), IconButton; no new code where existing fit.

Generated by Claude Code

A speaker button on every question and answer reads it through POST /voice/speak, the configured speech model and the
voice picked in Settings, else the browser's speech. One message at a time, long answers in pieces under every
provider's limit with the next prefetched, audio kept in the page so replays cost nothing. Each call is a model.speech
row in the activity ledger.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0113pz5KMp2GDme1G4WqJbAo
@adeelahmad adeelahmad self-assigned this Oct 17, 2026
@adeelahmad
adeelahmad merged commit b9e9d93 into main Oct 18, 2026
10 checks passed
@adeelahmad
adeelahmad deleted the claude/project-thread-lzpr5p branch October 18, 2026 01:25
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.

2 participants