onWordHighlight

Registers a callback invoked on the main thread each time the TTS engine starts speaking a new word or text range.

For calls made with speak\(text\) or speakAndAwait\(text\), the WordHighlight.start and WordHighlight.end positions are mapped back to the original text so they can be used directly for UI highlighting.

When speech finishes, a final WordHighlight with start = -1 and end = -1 is emitted to signal that highlighting should be cleared.

For DSL-based calls, positions refer to the generated SSML string and may not map to any single source string.

Return

This instance for chaining.

Parameters

callback

Receives a WordHighlight with the currently spoken range.

See also