200.2. piper-1.8.0
Piper: neural text to speech on the CPU, with the voice model on the disk and nothing sent anywhere
| Version | 1.8.0, release 2 |
| Shelf | accessibility — Screen readers, speech, braille and alternative input |
| Phase | 42_graphics (Graphics Stack), 42 of 189 in build order |
| Licence | GPL-3.0-or-later |
| Homepage | https://github.com/OHF-Voice/piper1-gpl |
| Build time | 0.9 SBU |
| Installed size | 44.0 MiB in 429 files |
| Recipe | ports/core/accessibility/piper/kpkgbuild |
About
Piper is a neural text-to-speech engine that runs on the processor through onnxruntime, with the voice model as a file on the disk: the text it speaks is sent nowhere. A voice is an .onnx model with an .onnx.json beside it, passed with -m. Three parts of the program reach the network: the piper.download_voices module, which fetches voices; the piper.http_server module’s voice list and download routes; and a voice whose phoneme type is pinyin (Mandarin), which fetches the g2pW model from Hugging Face into g2pW under the current directory whenever g2pW/g2pw.onnx is not already there. The package installs the piper Python package and a piper command, and with none of -f, -d and --output-raw the piper command speaks through PipeWire.
Sources
piper-1.8.0.tar.gz(23.6 MiB)
sha2560a22987a6157f14e2fb7cf4aa702b547467fd0448bea9f233abd503c3ff4a0e1
upstream: https://github.com/OHF-Voice/piper1-gpl/archive/refs/tags/v1.8.0.tar.gz
archive copy: sources-1/accessibility--piper-1.8.0.tar.gzespeak-ng-724808c5a83f9ef95fdd0db886ba7ba537ff224a.tar.gz(17.8 MiB)
sha2567d8ebd78201923a443245362a928999977d1721c3eeba596eafc6ea8db7e243c
upstream: https://github.com/espeak-ng/espeak-ng/archive/724808c5a83f9ef95fdd0db886ba7ba537ff224a.tar.gz
archive copy: sources-1/accessibility--espeak-ng-724808c5a83f9ef95fdd0db886ba7ba537ff224a.tar.gz
Dependencies
Depends on: cmake, ninja, patch, python3, numpy, onnxruntime, python3-pathvalidate, pipewire.
Required by: no port names it.
Patches
build.sh applies these; kpkg applies nothing by itself.
espeak-ng-local-archive.patch— Makes upstream’s ExternalProject build espeak-ng from the archive named byPIPER_ESPEAKNG_ARCHIVEinstead of cloning it from GitHub at a pinned commit, since the build has no network; the archive is the recipe’s second source, at the commit_espeaknames. It puts the tree’s$CFLAGSand$CXXFLAGSin front of the flags upstream passes to that build, which otherwise replace them, so the static espeak-ng library is compiled with the tree’s flags. It also passes placeholderSONIC_LIBandSONIC_INCvalues: espeak-ng’s CMake clones the sonic library whenever it finds no installed copy, even withUSE_LIBSONICoff, and nothing reads the two while that option is off.pw-play-playback.patch— Plays the synthesised audio through PipeWire’spw-play, as raw 16-bit mono at the voice’s sample rate, instead offfplay, and makes the check for a player look forpw-play. The ffmpeg port builds noffplay, and without a player every plainpiperrun would writeoutput.wavinto the current directory instead of speaking.
Installation
From the repository root, inside the build container, this is the line kdosbuild runs for the port:
script/chroot/exec.sh bash -c 'source script/phases/42_graphics/phase.env && kpkg install piper'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/accessibility/piper.
1. Verify every declared source. Each file a sha256 = line names, found in the port directory or in /var/cache/kpkg/sources, must hash to its line; a mismatch stops the build before anything is unpacked.
cd /ports/core/accessibility/piper
echo '0a22987a6157f14e2fb7cf4aa702b547467fd0448bea9f233abd503c3ff4a0e1 piper-1.8.0.tar.gz' | sha256sum -c -
echo '7d8ebd78201923a443245362a928999977d1721c3eeba596eafc6ea8db7e243c espeak-ng-724808c5a83f9ef95fdd0db886ba7ba537ff224a.tar.gz' | sha256sum -c -
2. Unpack. The work directory is emptied and the first source is unpacked into $SRC with its top directory stripped; any later tarball lands unstripped beside it in $SRC_ROOT, and a file that is not a tarball is copied into $SRC.
SRC_ROOT=/var/cache/kpkg/work/piper
SRC=$SRC_ROOT/piper-1.8.0
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf piper-1.8.0.tar.gz -C "$SRC" --strip-components=1
tar --no-same-permissions --warning=no-unknown-keyword -xf espeak-ng-724808c5a83f9ef95fdd0db886ba7ba537ff224a.tar.gz -C "$SRC_ROOT"
Every config.guess and config.sub older than automake’s is then replaced with automake’s, so a configure script recognises the musl target.
3. Build. build.sh is sourced in a subshell under set -e, from $SRC, with name, version, release and the recipe’s helpers _espeak and the five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:
patch -p1 -i "$PORT_SRC/espeak-ng-local-archive.patch"
patch -p1 -i "$PORT_SRC/pw-play-playback.patch"
_espeak_tar=espeak-ng-$_espeak.tar.gz
for d in "$PORT_SRC" "$SOURCE_DIR"; do
[ -f "$d/$_espeak_tar" ] && break
done
[ -f "$d/$_espeak_tar" ] || { echo "piper: $_espeak_tar is missing" >&2; exit 1; }
cmake -S . -B build -G Ninja \
-DCMAKE_POLICY_VERSION_MINIMUM=3.5 \
-DCMAKE_BUILD_TYPE=Release \
-DPIPER_ESPEAKNG_ARCHIVE="$d/$_espeak_tar"
cmake --build build
_site=$(python3 -c 'import sys, sysconfig; print(sysconfig.get_path("purelib", vars={"base": sys.argv[1]}))' "$PKG/usr")
install -d "$_site"
cp -r src/piper "$_site/piper"
rm -rf "$_site/piper/train" "$_site/piper/espeakbridge.c"
cmake --install build --prefix "$_site/piper"
[ -f "$_site/piper/espeak-ng-data/phontab" ] ||
{ echo "piper: espeak-ng-data was not built" >&2; exit 1; }
ls "$_site"/piper/espeakbridge*.so >/dev/null ||
{ echo "piper: the espeakbridge module was not built" >&2; exit 1; }
python3 -m compileall -q -s "$PKG" -p / "$_site/piper"
install -d "$PKG/usr/bin"
cat > "$PKG/usr/bin/piper" <<'SCRIPT'
#!/usr/bin/python3
import sys
from piper.__main__ import main
sys.exit(main())
SCRIPT
chmod 755 "$PKG/usr/bin/piper"
The switches, and why each is set:
-DPIPER_ESPEAKNG_ARCHIVE="$d/$_espeak_tar"— A cache variable thatespeak-ng-local-archive.patchadds: the espeak-ng source archive CMake’s ExternalProject builds, in place of the git clone upstream’sCMakeLists.txtmakes.$dis whichever of the port directory and kpkg’s source directory holds the second source, and the build stops when neither does.
The common switches of each build system are explained in the Flag glossary.
4. Package. kpkg removes libtool archives, the info directory index, mimeinfo.cache and every fonts.dir from $PKG, copies the source’s licence files into /usr/share/licenses/piper, prunes what the image does not ship, lints the tree and rolls it reproducibly:
tar --sort=name --format=gnu --numeric-owner --owner=0 --group=0 \
--mtime=@$SOURCE_DATE_EPOCH \
--use-compress-program='xz -9 -T0 --block-size=32MiB --no-adjust' \
-cf piper-1.8.0-2.tar.xz -C "$PKG" .
5. Adopt. kpkgadd installs the package’s files over the root, refusing a path another package owns, records the file list in /var/lib/kpkg/db/piper, and runs the triggers its paths call for.
Contents
Installed programs: piper.
Installed directories: /usr/lib/python3.14/site-packages/piper, /usr/share/licenses/piper.
Notes
Piper phonemises through a function, espeak_TextToPhonemesWithTerminator, that no espeak-ng release has, so upstream builds a static espeak-ng from a pinned commit and links it into its Python extension. The recipe’s _espeak helper names that commit; a bump of piper keeps it at or past the commit the new release pins in its CMakeLists.txt. espeak-ng’s compiled espeak-ng-data is installed inside the package directory, where piper looks for it, and build.sh stops if phontab or the espeakbridge extension is missing.
Upstream builds its Python package with scikit-build, the setuptools-based skbuild, which is not a port (scikit-build-core, a different backend, is). build.sh does what that build does by hand: it runs the project’s CMake, which compiles the espeakbridge extension and espeak-ng’s data and copies the data into src/piper; copies src/piper into site-packages without the training code and the extension’s C source; installs the CMake output into it; byte-compiles it; and writes the piper console script that the package’s entry point would have made.