Add real-time speaking highlight for sentence analysis#6
Open
Conversation
Use Web Speech API boundary events to track speaking progress and highlight the current token with a glowing pulse animation in both the token flow chips and the detail table. https://claude.ai/code/session_018ANiNAw1R6prwWozJwmxxh
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.
Summary
This PR adds visual feedback that highlights which token is currently being spoken when using the text-to-speech feature in the sentence analysis panel. As the speech synthesis engine processes the sentence, the corresponding token is highlighted with an animated glow effect in both the token flow view and the token details table.
Key Changes
Speech tracking with Web Speech API boundary events: Implemented
speak_with_tracking()function that uses theonboundaryevent to track character positions during speech synthesis and dispatch custom events to the Rust component.Character-to-token mapping: Added
char_index_to_token()andbuild_char_offset_ranges()functions to accurately map character indices from the Web Speech API to token indices, accounting for multi-byte UTF-8 characters in Japanese text.Real-time state updates: Integrated a polling mechanism that listens for boundary events and updates the
speaking_token_idxsignal to track which token is currently being spoken.Visual highlighting animations: Added three new CSS animations:
speaking-glow: Pulsing glow effect for token chips with color shift and scale transformspeaking-row-flash: Subtle background flash for table rowsbtn-pulse: Pulse animation for the active speak buttonDynamic class binding: Updated both token chip and table row rendering to conditionally apply the
speakingclass based on the current speaking token index.Enhanced speak button: Replaced the simple
SpeakButtoncomponent call with a custom button that usesspeak_with_tracking()and shows active state during speech.Implementation Details
kumou-boundaryevent dispatched from JavaScripthttps://claude.ai/code/session_018ANiNAw1R6prwWozJwmxxh