This is a powerful interactive text-to-speech system that reads text aloud while highlighting each word in real time. It turns any editable text area into a live reading experience where speech and visual tracking are fully synchronised.
Users can select voices, adjust speed, pitch, and volume, and choose how the text is processed before it is spoken. The system also supports pausing, resuming, and restarting without losing reading position.
It is designed to feel like a smart reading assistant that helps you listen, follow, and interact with written content naturally, whether you're studying, reviewing notes, or consuming long-form text.
The system is built on the Web Speech API and uses a multi-layer architecture combining speech synthesis, DOM traversal, and runtime state management.
Text is split into sentence-based chunks using regex segmentation, stored in a chunks[] array, and executed sequentially through a recursive speakChunk(index) engine.
In keep-as-is mode, the system walks the DOM tree and injects data-word-idx spans into existing text nodes, preserving original formatting while enabling global word indexing across the document.
A dual indexing system maps: chunk index → sentence → word offset → global word index, allowing precise synchronisation between speech events and visual highlighting via onboundary events.
Speech behaviour is dynamically extended by overriding window.speakChunk, enabling runtime injection of features such as: voice rotation, sentence delay control, and playback modification without altering core execution logic.
User preferences (voice, rate, pitch, volume, shortcuts, scroll behaviour) are persisted locally using localStorage, creating a fully client-side state system that restores session behaviour automatically on reload.
Scroll synchronisation includes interruption detection, allowing the system to pause or adapt auto-scrolling when user movement is detected. Keyboard bindings provide direct control over playback (play/pause/reset) without UI interaction.
Copyright © - My Digital Book | Unique-Functions | NR