Text To Speech Highlighted
A terminal-driven text-to-speech reader that speaks text through Piper while a second window tracks the active words in real time so the user stays visually aligned with the audio stream.
A terminal-driven text-to-speech reader that speaks text through Piper while a second window tracks the active words in real time so the user stays visually aligned with the audio stream.
The project combines text normalization, Piper speech generation, audio playback, and a live highlight pane so the spoken output and visible reading position stay linked together.
This came from wanting something more trackable than plain TTS. For longer passages, the missing piece is not just hearing the words, it is being able to see exactly where the reader currently is.
Input and normalization. Raw text is cleaned into an ASCII-safe form so punctuation, symbols, and odd Unicode characters do not break speech synthesis.
Piper synthesis. The script resolves the Piper binary and voices directory, chooses a voice model, and generates short audio spans from the text.
Chunk playback. Each spoken segment is mapped to a word range and played back locally through `pw-play` or `aplay`.
Highlight sync. The active index window is written to a temp file, and the separate pane redraws the text so the current words stay highlighted as playback advances.
Python 3 drives the reader, while `pydub` handles the intermediate audio slicing used to keep the spoken chunks aligned with the highlight spans.
The current public path is Piper-based. The repo removes machine-specific assumptions and lets users rely on `PATH`, `PIPER_BIN`, `PIPER_VOICES_DIR`, or manual path input.
The highlight pane is terminal-native rather than browser-based. It watches the active word index and keeps the reading position centered on screen.
Older Coqui-TTS work is kept in `legacy/` for reference, but the public repo is intentionally centered on the current Piper workflow.
The public repo is packaged as a portable reader rather than a mirror of the original laptop setup. Hard-coded local paths were stripped out, runtime discovery was improved, and users can now provide their own Piper binary and voices directory instead of inheriting one machine’s assumptions.