Skip to content

fix: bundle espeak-ng-data inside binary (fixes #59)#60

Merged
pszymkowiak merged 3 commits into
mainfrom
fix/piper-espeak-data
May 14, 2026
Merged

fix: bundle espeak-ng-data inside binary (fixes #59)#60
pszymkowiak merged 3 commits into
mainfrom
fix/piper-espeak-data

Conversation

@pszymkowiak

Copy link
Copy Markdown
Contributor

Summary

Piper TTS failed on fresh installs (vox setup → test piper backend) with No such file or directory, as reported in #59.

Root cause

The espeak-ng C library that piper-rs links statically has its data directory path baked in at compile time — the path of the CI runner that built the release binary. On end-user machines that path does not exist, so espeak_Initialize aborts with No such file or directory for every language.

Confirmed by strings on the released vox-aarch64-apple-darwin binary:

/Users/runner/work/vox/vox/target/aarch64-apple-darwin/release/build/espeak-rs-sys-<hash>/out/share/espeak-ng-data

espeak-rs does provide a fallback search path (env var PIPER_ESPEAKNG_DATA_DIRECTORY, then CWD, then exe dir), but the release tarball only contains the vox binary — no data files — so none of those resolve.

Fix

Embed the compiled espeak-ng-data into the binary and extract it on first piper use:

  1. build.rs — locates espeak-ng-data in espeak-rs-sys's OUT_DIR (cargo guarantees dep build scripts have already run) and stages it into vox's OUT_DIR.
  2. piper.rs — embeds the staged directory via include_dir!("$OUT_DIR/espeak-ng-data"), extracts it once to ~/.config/vox/piper/espeak-ng-data (with a sentinel file), then sets PIPER_ESPEAKNG_DATA_DIRECTORY before any Piper::new / model.create() call.

Binary size grows by ~15 MB (the size of espeak-ng-data). No network access required, no install-script changes needed — fresh installs just work.

Test plan

  • CI builds green on macOS, Linux, Windows
  • Manual: fresh install on M-series Mac, vox setup → test piper (en) → audio plays
  • Manual: same, switch to French in TUI → audio plays
  • Manual: second run is fast (sentinel file short-circuits re-extract)

Piper TTS failed on fresh installs with "No such file or directory"
because the espeak-ng C library statically linked into vox has the
build-machine data path hard-coded, and the release tarball never
shipped the espeak-ng-data files.

Embed the espeak-ng-data directory at build time via include_dir!
(staged from espeak-rs-sys's OUT_DIR by a new build.rs), extract it
once to ~/.config/vox/piper/espeak-ng-data on first piper call, and
set PIPER_ESPEAKNG_DATA_DIRECTORY so espeak-rs can locate it.
@pszymkowiak pszymkowiak merged commit b251c3c into main May 14, 2026
5 of 8 checks passed
@pszymkowiak pszymkowiak deleted the fix/piper-espeak-data branch May 14, 2026 10:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant