* feat(tts): read aloud with Speech Dispatcher voices on Linux
Read Aloud on Linux can now use the voices installed in Speech
Dispatcher (eSpeak NG, or Piper through a module) under System TTS.
The native-tts plugin speaks SSIP over the daemon's Unix socket with
no speech library linked, so the AppImage uses the host daemon and the
Flatpak needs --filesystem=xdg-run/speech-dispatcher:ro
(docs/linux-system-tts.md). Each reader window gets its own
connection, closed when the window is destroyed. If the daemon or its
voices are unavailable, the other engines remain.
- Voices keep their Speech Dispatcher names; eSpeak NG's per-variant
copies ("English (America)+Annie") are dropped, so English lists 9
voices instead of 945. The module is appended only when two modules
list voices.
- Pause stops the sentence and Play reads it again, as on Android. A
speechd PAUSE holds back the restarted SPEAK, and RESUME then
cancels it, so Play skipped the paused sentence.
- A closing window cancels its speech: speechd finishes a disconnected
client's message.
- Events that arrive before the speak reply are kept, and an aborted
utterance is canceled by ID so a late reply cannot stop its
replacement. Rates go to speechd as given, without the mobile
exponent.
Tests that fail without the change:
- Rust (plugin): pause_cancels_so_the_restarted_sentence_is_not_held_back
(left "PAUSE SELF\r\n", right "CANCEL SELF\r\n");
lists_each_espeak_voice_once_rather_than_once_per_variant (4 voices,
expected 2); closing_a_reader_window_silences_its_speech (left "",
right "CANCEL SELF\r\n").
- TS: 8 tests in native-tts-client.test.ts and tts-controller.test.ts
fail against the old NativeTTSClient/TTSController, 7 on assertions
(e.g. "expected [] to deeply equal [ 'boundary', 'end' ]",
"expected null not to be null" for the Linux system voices) and one
on its 5 s timeout (overlapping speak replies).
Real use, Linux CEF dev build, isolated HOME, host speech-dispatcher
0.12.1 with its eSpeak NG module:
- Pause/Play 3 of 3 re-read the paused sentence with no "Speech
interrupted"; before the fix 3 of 3 skipped it.
- Speak on a selection while paused speaks (before: silent).
- Picker lists 9 System TTS voices; choosing another voice and pressing
Play reads on in that voice.
- Speed: 2.7 s per sentence at 1.5x, 5.2 s at 0.95x.
- Closing the book at +1.4 s into a sentence: speech ends 1 s later;
without the cancel it ran 3.6 s to the sentence's end.
- SPEECHD_ADDRESS at a missing socket: "System TTS unavailable" is
logged and Read Aloud falls back to Edge TTS.
Checks: plugin cargo test (36 passed), pnpm test:rust (204 passed),
the two TS suites (171 passed), pnpm lint, pnpm fmt:check, pnpm
clippy:check, cargo check of the plugin for x86_64-pc-windows-gnu and
aarch64-linux-android.
Not run: the AppImage and Flatpak packages, two reader windows reading
at once, light/dark/e-ink (no UI changed). Chinese books get no System
TTS voice: eSpeak NG labels them cmn/yue and language matching expects
zh.
Closes #6805
Reported by ell1e on GitHub.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(tts): keep a slow Speech Dispatcher voice list from disabling System TTS
Every command waited at most 3 s, and a timeout closes the connection
because a late reply would answer the next command. eSpeak NG sends
about 15k voice rows for LIST SYNTHESIS_VOICES: 0.4 s here, warm or
cold, so a slow machine or module could run past 3 s. voices() then
took the dead connection for a module without voices and failed with
"Speech Dispatcher has no installed voices".
The voice list now gets 10 s, under the reader's 15 s engine init
limit. A lost connection ends the listing with its cause ("Speech
Dispatcher did not answer in time while listing piper voices"); a
module that answers with an error is still skipped.
Raised by CodeRabbit on #7314.
Tests that fail without the change:
- waits_for_a_slow_voice_list: the reply comes 3.5 s after the request;
fails at "a voice list slower than one command must still arrive".
- a_lost_connection_while_listing_voices_reports_the_cause: left
Some("Speech Dispatcher has no installed voices"), right
Some("Speech Dispatcher disconnected while listing espeak-ng voices").
Checks: plugin cargo test --lib (38 passed), pnpm test:rust (204
passed), pnpm fmt:check, pnpm clippy:check, cargo fmt --check in the
plugin. Real daemon (speech-dispatcher 0.12.1, eSpeak NG): init()
lists 141 voices in 0.43 s.
Not run: a real slow module (the delay is simulated in the test), and
the Tauri app after this change.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(tts): give every reader speed its own Speech Dispatcher rate
The reader offers 0.5x to 3x (the speed ruler and RSVP's rate list),
but the Linux bridge sent (rate - 1) * 100 clamped to SSIP's -100..100,
so 2x, 2.5x and 3x all became 100 and sounded the same, and 0.5x only
reached -50. 0.5x-1x now spreads over -100..0 and 1x-3x over 0..100.
Raised by CodeRabbit on #7314.
Test that fails without the change:
every_reader_speed_has_its_own_ssip_rate, left
[-50, -25, 0, 50, 100, 100, 100], right [-100, -50, 0, 25, 50, 75, 100]
for 0.5, 0.75, 1, 1.5, 2, 2.5, 3.
Real daemon (speech-dispatcher 0.12.1, eSpeak NG), one sentence spoken
through SpeechDispatcher at each speed, begin to end: 0.5x 12.17 s,
1x 5.57 s, 1.5x 3.91 s, 2x 2.97 s, 2.5x 2.29 s, 3x 1.82 s (0.46x,
1.42x, 1.88x, 2.44x, 3.05x of 1x).
Checks: plugin cargo test --lib (39 passed), pnpm test:rust (204
passed), pnpm fmt:check, pnpm clippy:check, cargo fmt --check in the
plugin.
Not run: the speed ruler in the Tauri app after this change; the
mapping from the ruler to set_rate is unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2.5 KiB
Linux system voices
Read Aloud can use the voices installed in Speech Dispatcher. Text goes to the local daemon over its Unix socket; the selected Speech Dispatcher module controls synthesis. Install a local module such as eSpeak NG or configure Piper through a Speech Dispatcher module (for example with Pied) to read offline.
On Debian and Ubuntu:
sudo apt install speech-dispatcher speech-dispatcher-espeak-ng
spd-say --wait --language en 'Local speech is ready.'
Open a book, start Read Aloud, and choose a voice under System TTS in the voice picker. Voices keep their Speech Dispatcher names ("English (America)"), and eSpeak NG voices are listed once, without their per-variant copies; when more than one module has voices, each name also shows its module. Voice selection, speed, sentence highlighting, and stopping use the existing player controls. Pause stops the sentence and Play reads it again from its start, as on Android. There are no word timings or downloadable audio for these voices. Speech Dispatcher rates are engine-relative, so the audible speed depends on the installed module.
Readest connects at $XDG_RUNTIME_DIR/speech-dispatcher/speechd.sock (falling back
to $XDG_CACHE_HOME, then ~/.cache). A custom local socket can be selected with
SPEECHD_ADDRESS=unix_socket:/absolute/path/to/speechd.sock. Outside Flatpak, Readest
tries speech-dispatcher --spawn if the daemon is not running. Custom socket paths
must match the daemon's configuration for autospawn to succeed. SPEECHD_CMD can
select a different daemon executable. If the daemon or voices are unavailable,
the other Read Aloud engines remain available.
AppImage
Install Speech Dispatcher and a voice module on the host. The AppImage connects to the host daemon without bundling a speech library, engine, or models.
Flatpak
The host must have Speech Dispatcher running with at least one voice module. The
Flatpak manifest needs this entry in finish-args:
- --filesystem=xdg-run/speech-dispatcher:ro
The manifest is maintained separately in flathub/com.bilingify.readest. For a package whose manifest has not yet added the permission:
flatpak override --user --filesystem=xdg-run/speech-dispatcher:ro com.bilingify.readest
The read-only directory mount allows connecting to the socket. Readest does not start a second daemon inside the sandbox. A custom socket outside this directory also needs explicit Flatpak filesystem access.