Repository navigation
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. |
This branch has not been deployed
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, mirrored to the fork as feat: paint highlight ranges behind the rendered text (upstream #1218) enriched-markdown#17.apps/mobile/depsuses a tarball of that branch.deps/README.mdsays this.Setting: "Highlight words" is on by default, with strings in all locales.
This PR does not change the local-model stack, OpenRouter or xAI.
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.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