Repository navigation
feat(read-aloud): highlight the paragraph and word being read - #39836
Merged
Yash-Singh1 merged 31 commits intoNov 25, 2026
Merged
Yash-Singh1 merged 31 commits into
Yash-Singh1 merged 31 commits into
Conversation
readAloudSpeech returns the spoken text with the markdown offset of each character and the spoken and source range of each block, so a client can find the word being read in the rendered message. readAloudText and splitReadAloudText keep their behaviour. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The synthesis catalog says where a provider's word timings come from, a new endpoint reads the timings of a started synthesis by its token, and a highlightWords setting turns follow-along highlighting off. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ElevenLabs now streams from its with-timestamps endpoint. Its character alignment becomes words, moved to each piece's place in the request text and to where that piece's audio starts, counted from MP3 frame headers. Synthesis jobs keep the words and the audio length, and /api/voice/synthesis/timings long-polls them by the stream token. The MP3 stream is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The read-aloud controller keeps the speech's map back to the markdown and publishes the current block and word, as markdown ranges plus text cues, on a separate subscription so only the message being read re-renders. Playbacks report words. Environment audio uses createTimedWords, which follows the environment's word timings on the media clock with one timer per word, and estimates them from the audio length when the provider has none. System voices use boundary events on web and mobile. startSpeechSynthesis also returns the stream token for the timings. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Rendered block elements carry their markdown range. While a reply is read, the block and word are found in that element's text and painted with the CSS Custom Highlight API, so the DOM and copied text stay unchanged. The colours are theme tokens for light and dark. The timeline scrolls to keep the word in view until the user scrolls away, and follows again once the word is back in view. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Highlight words sits in Settings → Voice → Read aloud on web and mobile, on by default, with every locale translated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… view useReadAloudHighlight returns the block and word being read in a message. The native view cannot draw ranges yet, so the assistant message marks where to pass it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A real browser renders a reply and checks that the block range survives the markdown pipeline, that the repeated word painted is the one being read, and that stopping clears both highlights. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The fork adds highlights, onRenderedTextChange and onHighlightLayout so read aloud can tint the paragraph and word it reads. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Native markdown views report the text they show, not where it came from in the markdown. readAloudShownText matches the reply's spoken words to the shown words in order and returns the paragraph and word ranges to tint. A word without a safe match is left unhighlighted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Replies pass the native markdown view the paragraph and word being read as ranges of the text it shows, tinted with the web's light and dark read-aloud colours. Code blocks and tables are tinted whole. The feed keeps the word in view, pausing after the user scrolls until they bring it back. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s from Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Author
|
@Yash-Singh1 nice work with the TTS PR. I had my own version with an additional highlight the paragraphs and follow along with each word as it reads aloud. So I've made a PR for it here. Let me know if you have any questions. |
Contributor
|
This PR conflicts with See the conflict window. |
The base branch moved chat Markdown from react-markdown to Words, so the speech offsets now tag the hast in the chat Markdown renderer. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Also rebuilds the Enriched Markdown tarball so it keeps the fork's iOS tall code block and blockquote lift fixes next to the highlight ranges. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Words writes data-sourcepos only on list items, so paragraphs, headings and table rows had no speech offsets and the highlighter found no block to paint. Fall back to the innermost block whose text holds the block's first and last words. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Packs pingdotgg/enriched-markdown#17 at edfcf852 with the fork's iOS fixes (commit 35a9c280). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Read aloud always started at the top of a reply. `start` now takes a markdown offset and makes speech only from the first block that ends after it, so the highlight keeps the reply's own offsets. `jump` reads the reply being read again from a new place with the same settings, and `readAloudSourceAtShown` maps a place in a renderer's own text back to the markdown. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
While a reply is read aloud, a plain click on one of its paragraphs, headings, list items, or table rows reads from that block. Links, controls, code blocks, math, and clicks that select text keep their behavior. The assistant selection toolbar also offers "Read from here", which starts reading at the selection. Words writes source positions only on list items, so other blocks are found by matching their words to the reply. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
While a reply is read aloud, tapping one of its paragraphs reads from that paragraph. The tap handler is set only while the reply is read, so taps on other replies keep their native behavior. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…r cancel The controller now marks a reading as started once it plays audio. `readAloudButtonMode` uses this: a reply that plays or waits for its next chunk can pause and offers a separate Stop; only the first speech generation cancels. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
While a reply plays, its read-aloud button pauses it at the current word, and pressing it again resumes from there. A small stop button shows next to it while the reply plays or is paused. While the first speech is made, the button still cancels. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The reply's read-aloud button pauses and resumes like on the web, and a stop button shows next to it while the reply plays or is paused. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 25, 2026
Merged
The archive came from a personal branch on the old upstream base. It now comes from pingdotgg/enriched-markdown t3/mobile-tarball (11817aa2): upstream main plus one commit per carried change, with highlight ranges squashed from software-mansion/enriched-markdown#1218. The highlight API read aloud uses is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…op button" This reverts commit 65b6be2. # Conflicts: # apps/mobile/src/i18n/translations/de.json # apps/mobile/src/i18n/translations/en.json # apps/mobile/src/i18n/translations/es.json # apps/mobile/src/i18n/translations/fr.json # apps/mobile/src/i18n/translations/ja.json # apps/mobile/src/i18n/translations/ko.json # apps/mobile/src/i18n/translations/pt-BR.json # apps/mobile/src/i18n/translations/ru.json # apps/mobile/src/i18n/translations/sv.json # apps/mobile/src/i18n/translations/zh.json
…button" This reverts commit e1ef1f7. # Conflicts: # apps/web/src/i18n/translations/de.json # apps/web/src/i18n/translations/en.json # apps/web/src/i18n/translations/es.json # apps/web/src/i18n/translations/fr.json # apps/web/src/i18n/translations/ja.json # apps/web/src/i18n/translations/ko.json # apps/web/src/i18n/translations/pt-BR.json # apps/web/src/i18n/translations/ru.json # apps/web/src/i18n/translations/sv.json # apps/web/src/i18n/translations/zh.json
…resume or cancel" This reverts commit 3ca1159.
ReadAloudMarkdownText subscribes to the controller and asks whether its reply is being read, which the mock did not provide, so nine preview tests failed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Highlighting is how read aloud shows its place, so it is always on. The Highlight words setting, its saved field and its strings are removed; settings saved with the field still decode. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Yash-Singh1
merged commit Nov 25, 2026
6024593
into
pingdotgg:feat/read-aloud-providers
34 of 35 checks passed
This was referenced Nov 25, 2026
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When read aloud plays a long reply, the user cannot see which part is being read. If the user scrolls or looks away, the place is lost.
Change
This PR is stacked on #35910. Its base is
feat/read-aloud-providers, so the diff shows only this work. While read aloud plays, the app tints the current paragraph and the current word. It also scrolls to follow them. This works on web, desktop and mobile.Timing source: each provider in the catalog has an optional
wordTimings:provider: timestamps from the provider's API. ElevenLabs now uses/stream/with-timestamps.boundary: boundary events from system voices.estimated: an estimate from the text length and the audio duration.Clients do not branch on provider names.
Server:
SynthesisBackendgets an optionalalignedAudiopath. Words in later 1000-character pieces are shifted by text position and by audio time. The audio time comes from the MP3 frame headers. The timings go on a separate endpoint,POST /api/voice/synthesis/timings, with the same token. The MP3 stream does not change.Shared:
readAloudSpeechmaps the spoken text back to markdown offsets.readAloudTextkeeps its output.Client runtime: words follow the media clock. The highlight has its own subscription, so only the message that is read re-renders.
Web: the CSS Custom Highlight API with light and dark tokens. Follow-scroll stops when the user scrolls away, and starts again when the word is back in view.
Mobile: the app gives ranges to
EnrichedMarkdownText.highlightsprop is new, from feat: paint highlight ranges behind the rendered text software-mansion/enriched-markdown#1218.apps/mobile/depsuses the tarball of the fork'st3/mobile-tarballbranch (1.2.0-t3.19,11817aa2): upstreammainplus one commit per carried change, with Fix Codex provider banner for custom overrides #1218 squashed into one.deps/README.mdsays this.No setting: highlighting is always on.
This PR does not change the local-model stack, OpenRouter or xAI.
Reading controls
These controls bring back what an earlier version of this work had:
ReadAloudController.start()now takes an optional markdown offset. Speech is made only from that block onward, and the highlight offsets still match the whole reply.Scope
This is a feature on top of #35910, not a bug fix. No maintainer asked for it, so I understand it can be closed. It depends on #35910, so I made it a follow-up and did not add it to that PR.
Verification
i18n:checkpass.vp run check:changed origin/feat/read-aloud-providerspasses (format, lint, knip, typecheck of 44 packages, 447 tests in 18 files, React Compiler). Settings saved withhighlightWordsstill decode.ChatMarkdown.permissions.browser.test.tsxhas 2 failing tests (Shift+F10 menu). They fail the same way on feat(read-aloud): add optional speech playback across clients #35910's head without this PR.Demo video (desktop and iOS, ElevenLabs):
t3code-read-aloud-highlight-narrated.mp4
Model and harness: Claude Opus 5.5 in Claude Code.
🤖 Generated with Claude Code