A TTS that fits in your CPU (and pocket)
Python
Release x86-64-v2 binaries for CPUs without AVX2 (#430)
Gabriel de Marmiesseee2ebc89aba9
diff --git a/.github/workflows/rust-release.yml b/.github/workflows/rust-release.ymlindex 19d8f82..f86e210 100644--- a/.github/workflows/rust-release.yml+++ b/.github/workflows/rust-release.yml@@ -23,7 +23,7 @@ concurrency:jobs:build:- name: Build ${{ matrix.target }}+ name: Build ${{ matrix.target }}${{ matrix.suffix }}runs-on: ${{ matrix.runner }}timeout-minutes: 60strategy:@@ -33,6 +33,13 @@ jobs:# x86 builds target x86-64-v3 (AVX2, FMA) through rust/.cargo/config.toml.- target: x86_64-unknown-linux-gnurunner: ubuntu-22.04+ # The `-v2` archives are for x86 CPUs without AVX2 (x86-64-v2: SSE4.2). They are separate+ # builds since xn picks its int8 kernels at compile time: at this level `--quantize` is+ # up to 2.6x slower, while the f32 matmuls, dispatched at runtime, keep their speed.+ - target: x86_64-unknown-linux-gnu+ runner: ubuntu-22.04+ suffix: -v2+ rustflags: '-C target-cpu=x86-64-v2'- target: aarch64-unknown-linux-gnurunner: ubuntu-22.04-arm- target: aarch64-apple-darwin@@ -46,6 +53,10 @@ jobs:- target: x86_64-pc-windows-msvcrunner: windows-2022rustflags: '-C target-cpu=x86-64-v3 -C target-feature=+crt-static'+ - target: x86_64-pc-windows-msvc+ runner: windows-2022+ suffix: -v2+ rustflags: '-C target-cpu=x86-64-v2 -C target-feature=+crt-static'env:MACOSX_DEPLOYMENT_TARGET: '11.0'defaults:@@ -60,7 +71,7 @@ jobs:- uses: Swatinem/rust-cache@v2with:workspaces: rust- key: ${{ matrix.target }}+ key: ${{ matrix.target }}${{ matrix.suffix }}- name: Buildenv:RUSTFLAGS_OVERRIDE: ${{ matrix.rustflags }}@@ -73,7 +84,7 @@ jobs:id: packagerun: |version=$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -1)- name="pocket-tts-$version-${{ matrix.target }}"+ name="pocket-tts-$version-${{ matrix.target }}${{ matrix.suffix }}"mkdir -p "dist/$name"binary="target/${{ matrix.target }}/release/pocket-tts"if [ "$RUNNER_OS" = Windows ]; then binary="$binary.exe"; fi@@ -89,7 +100,7 @@ jobs:rm -r "$name"- uses: actions/upload-artifact@v4with:- name: pocket-tts-${{ matrix.target }}+ name: pocket-tts-${{ matrix.target }}${{ matrix.suffix }}path: rust/dist/*if-no-files-found: errordiff --git a/README.md b/README.mdindex 80c794f..cbb84b6 100644--- a/README.md+++ b/README.md@@ -116,6 +116,8 @@ Each [release](https://github.com/kyutai-labs/pocket-tts/releases) comes with atar xzf pocket-tts-*-x86_64-unknown-linux-gnu.tar.gz./pocket-tts-*/pocket-tts generate --text "Hello world." --voice marius```+The x86 binaries need a CPU with AVX2 (Intel Haswell, AMD Zen, or newer). For older CPUs, the Linux and Windows releases also have a `-v2` archive (e.g. `pocket-tts-*-x86_64-unknown-linux-gnu-v2.tar.gz`), which only needs SSE4.2: it is as fast in the default mode, but slower with `--quantize`, so prefer the regular one when your CPU supports it.+It is a Rust port built on [xn-ptts](https://github.com/gradium-ai/xn-ptts), whose sources are in [`rust/`](rust/). It runs on the CPU only, cannot load training checkpoints (`--checkpoint`), and its audio is not bit-identical to the Python package's, as the sampling noise differs.diff --git a/rust/.cargo/config.toml b/rust/.cargo/config.tomlindex 0a5de86..961ce59 100644--- a/rust/.cargo/config.toml+++ b/rust/.cargo/config.toml@@ -1,4 +1,6 @@-# xn picks its SIMD kernels at compile time. x86-64-v3 (AVX2, FMA: Intel Haswell and AMD Zen-# onwards) is the baseline the released x86 binaries are built for; aarch64 always has NEON.+# xn picks its int8 SIMD kernels at compile time (the f32 matmuls are dispatched at runtime).+# x86-64-v3 (AVX2, FMA: Intel Haswell and AMD Zen onwards) is the baseline the released x86+# binaries are built for; aarch64 always has NEON. The release workflow also builds `-v2`+# archives (x86-64-v2) for older CPUs, by overriding these flags with RUSTFLAGS.[target.'cfg(target_arch = "x86_64")']rustflags = ["-C", "target-cpu=x86-64-v3"]diff --git a/rust/README.md b/rust/README.mdindex 14ce77e..929c290 100644--- a/rust/README.md+++ b/rust/README.md@@ -12,7 +12,10 @@ cargo build --release```Building needs CMake and a C++ compiler, for the SentencePiece tokenizer that most community-models use. x86 builds target x86-64-v3 (AVX2), see `.cargo/config.toml`.+models use. x86 builds target x86-64-v3 (AVX2), see `.cargo/config.toml`. For a CPU without AVX2,+build with `RUSTFLAGS="-C target-cpu=x86-64-v2"`, as the `-v2` archives of the releases are:+`--quantize` is slower there (xn picks its int8 kernels at compile time), the default f32 mode is+not.## Differences with the Python CLI