A TTS that fits in your CPU (and pocket)
Python
Add a rust version of the CLI based on Gradium's xn-ptts (#383)
Gabriel de Marmiesse28c604373ffc
diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.ymlindex 4575938..90daf4d 100644--- a/.github/workflows/run-tests.yml+++ b/.github/workflows/run-tests.yml@@ -33,6 +33,35 @@ jobs:- name: Run tyrun: uv run -p ${{ matrix.python-version }} ty check+ rust:+ runs-on: ubuntu-latest+ needs: pre-commit+ defaults:+ run:+ working-directory: rust+ steps:+ - uses: actions/checkout@v4+ - uses: dtolnay/rust-toolchain@stable+ with:+ components: rustfmt, clippy+ - uses: Swatinem/rust-cache@v2+ with:+ workspaces: rust+ - name: Check formatting+ run: cargo fmt --check+ - name: Clippy+ run: cargo clippy --release --locked --all-targets -- -D warnings+ - name: Unit tests+ run: cargo test --release --locked+ - name: Generate speech+ run: |+ cargo run --release --locked -- generate --text "Hello world." --output-path hello.wav+ echo "Hello world." | cargo run --release --locked -- generate --text - --output-path - --voice marius -q > stdout.wav+ for f in hello.wav stdout.wav; do+ size=$(stat -c %s "$f")+ if [ "$size" -lt 50000 ]; then echo "::error::$f is only $size bytes"; exit 1; fi+ done+pytest:runs-on: ubuntu-latestneeds: pre-commitdiff --git a/.github/workflows/rust-release.yml b/.github/workflows/rust-release.ymlnew file mode 100644index 0000000..19d8f82--- /dev/null+++ b/.github/workflows/rust-release.yml@@ -0,0 +1,115 @@+name: Rust binaries++# Builds the `pocket-tts` binary of `rust/` for Linux, macOS and Windows on x86 and ARM, and+# attaches the archives to the GitHub release. Pull requests that touch it only build them.++on:+ release:+ types: [published]+ pull_request:+ paths:+ - 'rust/**'+ - 'pocket_tts/config/**'+ - 'pocket_tts/static/**'+ - '.github/workflows/rust-release.yml'+ workflow_dispatch:++permissions:+ contents: read++concurrency:+ group: rust-release-${{ github.ref }}+ cancel-in-progress: ${{ github.event_name == 'pull_request' }}++jobs:+ build:+ name: Build ${{ matrix.target }}+ runs-on: ${{ matrix.runner }}+ timeout-minutes: 60+ strategy:+ fail-fast: false+ matrix:+ include:+ # x86 builds target x86-64-v3 (AVX2, FMA) through rust/.cargo/config.toml.+ - target: x86_64-unknown-linux-gnu+ runner: ubuntu-22.04+ - target: aarch64-unknown-linux-gnu+ runner: ubuntu-22.04-arm+ - target: aarch64-apple-darwin+ runner: macos-15+ rustflags: '-C target-cpu=apple-m1'+ features: accelerate+ - target: x86_64-apple-darwin+ runner: macos-15-intel+ features: accelerate+ # RUSTFLAGS replaces the config's flags, hence the repeated target-cpu.+ - target: x86_64-pc-windows-msvc+ runner: windows-2022+ rustflags: '-C target-cpu=x86-64-v3 -C target-feature=+crt-static'+ env:+ MACOSX_DEPLOYMENT_TARGET: '11.0'+ defaults:+ run:+ shell: bash+ working-directory: rust+ steps:+ - uses: actions/checkout@v4+ - uses: dtolnay/rust-toolchain@stable+ with:+ targets: ${{ matrix.target }}+ - uses: Swatinem/rust-cache@v2+ with:+ workspaces: rust+ key: ${{ matrix.target }}+ - name: Build+ env:+ RUSTFLAGS_OVERRIDE: ${{ matrix.rustflags }}+ run: |+ if [ -n "$RUSTFLAGS_OVERRIDE" ]; then export RUSTFLAGS="$RUSTFLAGS_OVERRIDE"; fi+ features=()+ if [ -n "${{ matrix.features }}" ]; then features=(--features "${{ matrix.features }}"); fi+ cargo build --release --locked --target ${{ matrix.target }} "${features[@]}"+ - name: Package+ id: package+ run: |+ version=$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -1)+ name="pocket-tts-$version-${{ matrix.target }}"+ mkdir -p "dist/$name"+ binary="target/${{ matrix.target }}/release/pocket-tts"+ if [ "$RUNNER_OS" = Windows ]; then binary="$binary.exe"; fi+ cp "$binary" ../LICENSE "dist/$name/"+ "dist/$name/$(basename "$binary")" --version+ "dist/$name/$(basename "$binary")" generate --help > /dev/null+ cd dist+ if [ "$RUNNER_OS" = Windows ]; then+ 7z a "$name.zip" "$name" > /dev/null+ else+ tar czf "$name.tar.gz" "$name"+ fi+ rm -r "$name"+ - uses: actions/upload-artifact@v4+ with:+ name: pocket-tts-${{ matrix.target }}+ path: rust/dist/*+ if-no-files-found: error++ upload:+ name: Attach to the release+ if: github.event_name == 'release'+ needs: build+ runs-on: ubuntu-latest+ permissions:+ contents: write+ steps:+ - uses: actions/download-artifact@v4+ with:+ path: dist+ merge-multiple: true+ - name: Upload the archives and their checksums+ env:+ GH_TOKEN: ${{ github.token }}+ GH_REPO: ${{ github.repository }}+ run: |+ cd dist+ sha256sum * > SHA256SUMS+ gh release upload "${{ github.event.release.tag_name }}" * --clobberdiff --git a/.gitignore b/.gitignoreindex 4f711b5..d00f374 100755--- a/.gitignore+++ b/.gitignore@@ -69,6 +69,9 @@ dataset/*Cargo.tomlCargo.locktarget/+# ...except the Rust CLI, whose lockfile pins the shipped binaries' dependencies.+!/rust/Cargo.toml+!/rust/Cargo.lock# nfs files.nfs*diff --git a/README.md b/README.mdindex 4800360..813dfb7 100644--- a/README.md+++ b/README.md@@ -110,6 +110,15 @@ You can check out the [serve documentation](https://kyutai-labs.github.io/pocketProcessing an audio file (e.g., a .wav or .mp3) for voice cloning is relatively slow, but loading a safetensors file -- a voice embedding converted from an audio file -- is very fast. You can use the `export-voice` command to do this conversion. See the [export-voice documentation](https://kyutai-labs.github.io/pocket-tts/CLI%20Commands/export_voice/) for more details and examples.+### Standalone binaries, without Python++Each [release](https://github.com/kyutai-labs/pocket-tts/releases) comes with a `pocket-tts` binary for Linux and macOS (x86 and ARM) and Windows (x86), which needs neither Python nor PyTorch. It has the same commands and options as the Python CLI, reads the same configs (community models included), voices and exported voice files, and shares the Hugging Face cache with it:+```bash+tar xzf pocket-tts-*-x86_64-unknown-linux-gnu.tar.gz+./pocket-tts-*/pocket-tts generate --text "Hello world." --voice marius+```+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.+## Using it as a Python librarydiff --git a/rust/.cargo/config.toml b/rust/.cargo/config.tomlnew file mode 100644index 0000000..0a5de86--- /dev/null+++ b/rust/.cargo/config.toml@@ -0,0 +1,4 @@+# 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.+[target.'cfg(target_arch = "x86_64")']+rustflags = ["-C", "target-cpu=x86-64-v3"]diff --git a/rust/Cargo.lock b/rust/Cargo.locknew file mode 100644index 0000000..5b8f8ce--- /dev/null+++ b/rust/Cargo.lock@@ -0,0 +1,4689 @@+# This file is automatically @generated by Cargo.+# It is not intended for manual editing.+version = 4++[[package]]+name = "ahash"+version = "0.8.12"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "5a15f179cd60c4584b8a8c596927aadc462e27f2ca70c04e0071964a73ba7a75"+dependencies = [+ "cfg-if",+ "getrandom 0.3.4",+ "once_cell",+ "serde",+ "version_check",+ "zerocopy",+]++[[package]]+name = "aho-corasick"+version = "1.1.5"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "c982642fa9e8606056828ee9a8505737230110bb1099153c79efe865c59d12ba"+dependencies = [+ "memchr",+]++[[package]]+name = "allocator-api2"+version = "0.2.21"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923"++[[package]]+name = "android_system_properties"+version = "0.1.6"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "ae221649c9976a6f6c56ae1facf410f3ddb33cc661c4b7b61020a912d4237fbc"+dependencies = [+ "libc",+]++[[package]]+name = "anstream"+version = "1.0.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "824a212faf96e9acacdbd09febd34438f8f711fb84e09a8916013cd7815ca28d"+dependencies = [+ "anstyle",+ "anstyle-parse",+ "anstyle-query",+ "anstyle-wincon",+ "colorchoice",+ "is_terminal_polyfill",+ "utf8parse",+]++[[package]]+name = "anstyle"+version = "1.0.14"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "940b3a0ca603d1eade50a4846a2afffd5ef57a9feac2c0e2ec2e14f9ead76000"++[[package]]+name = "anstyle-parse"+version = "1.0.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "52ce7f38b242319f7cabaa6813055467063ecdc9d355bbb4ce0c68908cd8130e"+dependencies = [+ "utf8parse",+]++[[package]]+name = "anstyle-query"+version = "1.1.5"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc"+dependencies = [+ "windows-sys 0.61.2",+]++[[package]]+name = "anstyle-wincon"+version = "3.0.11"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747d"+dependencies = [+ "anstyle",+ "once_cell_polyfill",+ "windows-sys 0.61.2",+]++[[package]]+name = "anyhow"+version = "1.0.104"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "330a5ed07fa54e4702c9d6c4174f74427fc0ef6e214bbd677ae50a5099946470"++[[package]]+name = "approx"+version = "0.5.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "cab112f0a86d568ea0e627cc1d6be74a1e9cd55214684db5561995f6dad897c6"+dependencies = [+ "num-traits",+]++[[package]]+name = "arrayvec"+version = "0.7.8"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "d3fb67a6e08acf24fdeccbac2cb6ac4305825bd1f117462e0e6f2f193345ad56"++[[package]]+name = "async-trait"+version = "0.1.92"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "82f6aeea286b8eb4dd3431a1be1b59d290ace00f5bfd8e2a159bc2a05e2c1667"+dependencies = [+ "proc-macro2",+ "quote",+ "syn 3.0.9",+]++[[package]]+name = "atomic-waker"+version = "1.1.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0"++[[package]]+name = "autocfg"+version = "1.5.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53"++[[package]]+name = "aws-lc-rs"+version = "1.18.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "faac5829c2b74c28f830747e7818ccfb684261b5f48a1118b1e2a13d36dfab13"+dependencies = [+ "aws-lc-sys",+ "zeroize",+]++[[package]]+name = "aws-lc-sys"+version = "0.46.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "f1622d8446a2d4b2ce0c7eefc73dd43a99779028d5ee5c2dd8073a658ba8a2bc"+dependencies = [+ "cc",+ "cmake",+ "dunce",+ "fs_extra",+ "pkg-config",+]++[[package]]+name = "axum"+version = "0.8.9"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "31b698c5f9a010f6573133b09e0de5408834d0c82f8d7475a89fc1867a71cd90"+dependencies = [+ "axum-core",+ "bytes",+ "form_urlencoded",+ "futures-util",+ "http",+ "http-body",+ "http-body-util",+ "hyper",+ "hyper-util",+ "itoa",+ "matchit",+ "memchr",+ "mime",+ "multer",+ "percent-encoding",+ "pin-project-lite",+ "serde_core",+ "serde_json",+ "serde_path_to_error",+ "serde_urlencoded",+ "sync_wrapper",+ "tokio",+ "tower",+ "tower-layer",+ "tower-service",+]++[[package]]+name = "axum-core"+version = "0.5.6"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "08c78f31d7b1291f7ee735c1c6780ccde7785daae9a9206026862dab7d8792d1"+dependencies = [+ "bytes",+ "futures-core",+ "http",+ "http-body",+ "http-body-util",+ "mime",+ "pin-project-lite",+ "sync_wrapper",+ "tower-layer",+ "tower-service",+]++[[package]]+name = "base64"+version = "0.13.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8"++[[package]]+name = "base64"+version = "0.22.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6"++[[package]]+name = "base64"+version = "0.23.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "ac07cdecf99051d9a5238b80f35af32cdeba5b336e55d957b318b50137e18da5"++[[package]]+name = "bit-set"+version = "0.8.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "08807e080ed7f9d5433fa9b275196cfc35414f66a0c79d864dc51a0d825231a3"+dependencies = [+ "bit-vec",+]++[[package]]+name = "bit-vec"+version = "0.8.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "5e764a1d40d510daf35e07be9eb06e75770908c27d411ee6c92109c9840eaaf7"++[[package]]+name = "bitflags"+version = "1.3.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"++[[package]]+name = "bitflags"+version = "2.13.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06"++[[package]]+name = "blake3"+version = "1.8.7"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "6d9e454fc11f76977dc803893aff6304ed33d6a26efae8696573bea74baa27ae"+dependencies = [+ "arrayvec",+ "cc",+ "cfg-if",+ "constant_time_eq",+ "cpufeatures 0.3.1",+]++[[package]]+name = "block-buffer"+version = "0.10.4"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71"+dependencies = [+ "generic-array",+]++[[package]]+name = "block-buffer"+version = "0.12.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "d2f6c7dbe95a6ed67ad9f18e57daf93a2f034c524b99fd2b76d18fdfeb6660aa"+dependencies = [+ "hybrid-array",+]++[[package]]+name = "bon"+version = "3.10.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "214f5df094ce551a10a30ffb9c70243d61f121a3d985a6495933e181dee6a7d2"+dependencies = [+ "bon-macros",+]++[[package]]+name = "bon-macros"+version = "3.10.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "2706da6c749998cc555d04184909608956a69ad3f8ab1a076fbc867b4a3c3ce5"+dependencies = [+ "darling 0.24.1",+ "ident_case",+ "prettyplease",+ "proc-macro2",+ "quote",+ "syn 3.0.9",+]++[[package]]+name = "bstr"+version = "1.13.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "6bb31b46c14244e20ee9984b11bf5c992b91fb6939fea616e3512c8baecdbe5f"+dependencies = [+ "memchr",+ "regex-automata",+ "serde_core",+]++[[package]]+name = "bumpalo"+version = "3.20.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "72f5acc6cb2ba439de613abc23857ec3d78374d8ed5ac84e9d11336e87da8649"++[[package]]+name = "bytemuck"+version = "1.25.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "95832e849adfb21180ccb6826a99da14e5d266ae5c2e668e1602cf234f153797"+dependencies = [+ "bytemuck_derive",+]++[[package]]+name = "bytemuck_derive"+version = "1.12.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "6a1f896587b6f2c069c73d2f0913e2d590c3990285cd2f0b6aa02b786b4c679c"+dependencies = [+ "proc-macro2",+ "quote",+ "syn 3.0.9",+]++[[package]]+name = "byteorder"+version = "1.5.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"++[[package]]+name = "bytes"+version = "1.12.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "fc652a48c352aef3ea3aed32080501cf3ef6ed5da78602a020c991775b0aff04"++[[package]]+name = "castaway"+version = "0.2.4"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "dec551ab6e7578819132c713a93c022a05d60159dc86e7a7050223577484c55a"+dependencies = [+ "rustversion",+]++[[package]]+name = "cc"+version = "1.9.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "877bf67ac8e52449eb2f9e98a344ea163beb70dd1f9eebe3cc5357dcfeaee4df"+dependencies = [+ "find-msvc-tools",+ "jobserver",+ "libc",+ "shlex",+]++[[package]]+name = "cfg-if"+version = "1.0.5"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600"++[[package]]+name = "cfg_aliases"+version = "0.2.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "f079e83a288787bcd14a6aea84cee5c87a67c5a3e660c30f557a3d24761b3527"++[[package]]+name = "chacha20"+version = "0.10.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "65c35e4b699c7e15ccbe7ee35c005e4fc0a278d22238a2857e6ce2dadeda1b06"+dependencies = [+ "cfg-if",+ "cpufeatures 0.3.1",+ "rand_core 0.10.1",+]++[[package]]+name = "chrono"+version = "0.4.45"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "1aa79e62e7697b8e29b513a68abacf485adcd1fe8284a4316c5ae868e6633327"+dependencies = [+ "iana-time-zone",+ "js-sys",+ "num-traits",+ "wasm-bindgen",+ "windows-link",+]++[[package]]+name = "clap"+version = "4.6.7"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "aa8876b300ab35ba921adea3dfd70157a46249b33f95c9084ae5709785478946"+dependencies = [+ "clap_builder",+ "clap_derive",+]++[[package]]+name = "clap_builder"+version = "4.6.7"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "ec0797fb7aeb1406c84efac526901f7ec3ead2124f946b494e72879d4b54704d"+dependencies = [+ "anstream",+ "anstyle",+ "clap_lex",+ "strsim",+]++[[package]]+name = "clap_derive"+version = "4.6.7"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "f9c751b79415d4e559e3d1fcf128e09e720eb673a06d26cf6f392d37d75b66e0"+dependencies = [+ "heck",+ "proc-macro2",+ "quote",+ "syn 3.0.9",+]++[[package]]+name = "clap_lex"+version = "1.1.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "1c133bc6a41be0d194c306b5506d15e6feeea7b1d6604bd3f8310dfb2ca96486"++[[package]]+name = "cmake"+version = "0.1.58"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "c0f78a02292a74a88ac736019ab962ece0bc380e3f977bf72e376c5d78ff0678"+dependencies = [+ "cc",+]++[[package]]+name = "colorchoice"+version = "1.0.5"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "1d07550c9036bf2ae0c684c4297d503f838287c83c53686d05370d0e139ae570"++[[package]]+name = "colored"+version = "3.1.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "faf9468729b8cbcea668e36183cb69d317348c2e08e994829fb56ebfdfbaac34"+dependencies = [+ "windows-sys 0.61.2",+]++[[package]]+name = "combine"+version = "4.6.9"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "4356eba6976435498d05a311ee9fc486da3bc81c200d3f0d7dd9703b41913f92"+dependencies = [+ "bytes",+ "memchr",+]++[[package]]+name = "compact_str"+version = "0.9.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "9dfdd1c2274d9aa354115b09dc9a901d6c5576818cdf70d14cae2bdb47df00ab"+dependencies = [+ "castaway",+ "cfg-if",+ "itoa",+ "rustversion",+ "ryu",+ "serde",+ "static_assertions",+]++[[package]]+name = "const-oid"+version = "0.10.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "a6ef517f0926dd24a1582492c791b6a4818a4d94e789a334894aa15b0d12f55c"++[[package]]+name = "const-str"+version = "1.1.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "18f12cc9948ed9604230cdddc7c86e270f9401ccbe3c2e98a4378c5e7632212f"++[[package]]+name = "const_panic"+version = "0.2.17"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "9603f79528ece8163c496f8932121cb36cfe46259e9c907bb3d8205139d7caa3"+dependencies = [+ "typewit",+]++[[package]]+name = "constant_time_eq"+version = "0.4.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "3d52eff69cd5e647efe296129160853a42795992097e8af39800e1060caeea9b"++[[package]]+name = "core-foundation"+version = "0.9.4"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f"+dependencies = [+ "core-foundation-sys",+ "libc",+]++[[package]]+name = "core-foundation"+version = "0.10.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "b2a6cd9ae233e7f62ba4e9353e81a88df7fc8a5987b8d445b4d90c879bd156f6"+dependencies = [+ "core-foundation-sys",+ "libc",+]++[[package]]+name = "core-foundation-sys"+version = "0.8.7"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b"++[[package]]+name = "core_detect"+version = "1.0.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "7f8f80099a98041a3d1622845c271458a2d73e688351bf3cb999266764b81d48"++[[package]]+name = "countio"+version = "0.3.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "b9702aee5d1d744c01d82f6915644f950f898e014903385464c773b96fefdecb"+dependencies = [+ "futures-io",+]++[[package]]+name = "cpufeatures"+version = "0.2.17"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280"+dependencies = [+ "libc",+]++[[package]]+name = "cpufeatures"+version = "0.3.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "5ca28b0ae3115b884660db4118d803791fd6756b6e88f39c0f3f7859060d7566"+dependencies = [+ "libc",+]++[[package]]+name = "crc32fast"+version = "1.5.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "01a7799fd6b852db0e61728dde9a204c423b44d689dbd432522543614b490e78"+dependencies = [+ "cfg-if",+]++[[package]]+name = "crossbeam-channel"+version = "0.5.17"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "98b0cc327b5bc766e7fda9c9260cc0fa81b43a8e240440422dff70788e3f9ef1"+dependencies = [+ "crossbeam-utils",+]++[[package]]+name = "crossbeam-deque"+version = "0.8.8"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "622f3fc73690be383c7214310406f28a90e6edeadc3cea882f9d71e495b9711a"+dependencies = [+ "crossbeam-epoch",+ "crossbeam-utils",+]++[[package]]+name = "crossbeam-epoch"+version = "0.9.21"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "dc74980687109a3b14c72fd458107bf0baa1da1a1a805e178d15501ba9b86d9d"+dependencies = [+ "crossbeam-utils",+]++[[package]]+name = "crossbeam-utils"+version = "0.8.23"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "a31eee39dddec8330830986fcd7625edb5a24ec90ea038215273bbc3adb08ac6"++[[package]]+name = "crunchy"+version = "0.2.4"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5"++[[package]]+name = "crypto-common"+version = "0.1.7"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a"+dependencies = [+ "generic-array",+ "typenum",+]++[[package]]+name = "crypto-common"+version = "0.2.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "ce6e4c961d6cd6c9a86db418387425e8bdeaf05b3c8bc1411e6dca4c252f1453"+dependencies = [+ "hybrid-array",+]++[[package]]+name = "ctor"+version = "1.0.13"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "914a755b7c2d4af2bdcff7ce1739e2db9a1b81a9b07123d8015786ae03c0980d"+dependencies = [+ "link-section",+ "linktime-proc-macro",+]++[[package]]+name = "daachorse"+version = "3.0.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "5614204febbc33cc07a2806aa6440b904ac012b68eecc37f4493ea4a76455a3d"++[[package]]+name = "darling"+version = "0.20.11"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "fc7f46116c46ff9ab3eb1597a45688b6715c6e628b5c133e288e709a29bcb4ee"+dependencies = [+ "darling_core 0.20.11",+ "darling_macro 0.20.11",+]++[[package]]+name = "darling"+version = "0.24.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "ed17f5901b6630b993ca003def43f2f8ef4014fc13b047b57aad617ff32bc2ec"+dependencies = [+ "darling_core 0.24.1",+ "darling_macro 0.24.1",+]++[[package]]+name = "darling_core"+version = "0.20.11"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "0d00b9596d185e565c2207a0b01f8bd1a135483d02d9b7b0a54b11da8d53412e"+dependencies = [+ "fnv",+ "ident_case",+ "proc-macro2",+ "quote",+ "strsim",+ "syn 2.0.119",+]++[[package]]+name = "darling_core"+version = "0.24.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "6837e2cf7485aaae18f86181d2f0e9a7ed297a025e220aeabf63fdebd3a2ddff"+dependencies = [+ "ident_case",+ "proc-macro2",+ "quote",+ "strsim",+ "syn 3.0.9",+]++[[package]]+name = "darling_macro"+version = "0.20.11"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "fc34b93ccb385b40dc71c6fceac4b2ad23662c7eeb248cf10d529b7e055b6ead"+dependencies = [+ "darling_core 0.20.11",+ "quote",+ "syn 2.0.119",+]++[[package]]+name = "darling_macro"+version = "0.24.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "2ac7135c3ef02b2f7833bbeb1be5ba7f966dcde8a87c6b87f65a778d71a02785"+dependencies = [+ "darling_core 0.24.1",+ "quote",+ "syn 3.0.9",+]++[[package]]+name = "dary_heap"+version = "0.3.9"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "8b1e3a325bc115f096c8b77bbf027a7c2592230e70be2d985be950d3d5e60ebe"+dependencies = [+ "serde",+]++[[package]]+name = "dasp_frame"+version = "0.11.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "b2a3937f5fe2135702897535c8d4a5553f8b116f76c1529088797f2eee7c5cd6"+dependencies = [+ "dasp_sample",+]++[[package]]+name = "dasp_sample"+version = "0.11.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "0c87e182de0887fd5361989c677c4e8f5000cd9491d6d563161a8f3a5519fc7f"++[[package]]+name = "deranged"+version = "0.5.9"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "9e9de72ce2ad1f90dc62fa25f0f430ef85eb4b0d8fa0be4f30373bc40a21d28e"++[[package]]+name = "derive_builder"+version = "0.20.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "507dfb09ea8b7fa618fcf76e953f4f5e192547945816d5358edffe39f6f94947"+dependencies = [+ "derive_builder_macro",+]++[[package]]+name = "derive_builder_core"+version = "0.20.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "2d5bcf7b024d6835cfb3d473887cd966994907effbe9227e8c8219824d06c4e8"+dependencies = [+ "darling 0.20.11",+ "proc-macro2",+ "quote",+ "syn 2.0.119",+]++[[package]]+name = "derive_builder_macro"+version = "0.20.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "ab63b0e2bf4d5928aff72e83a7dace85d7bba5fe12dcc3c5a572d78caffd3f3c"+dependencies = [+ "derive_builder_core",+ "syn 2.0.119",+]++[[package]]+name = "digest"+version = "0.10.7"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292"+dependencies = [+ "block-buffer 0.10.4",+ "crypto-common 0.1.7",+]++[[package]]+name = "digest"+version = "0.11.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "f1dd6dbb5841937940781866fa1281a1ff7bd3bf827091440879f9994983d5c2"+dependencies = [+ "block-buffer 0.12.1",+ "const-oid",+ "crypto-common 0.2.2",+]++[[package]]+name = "dirs"+version = "6.0.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "c3e8aa94d75141228480295a7d0e7feb620b1a5ad9f12bc40be62411e38cce4e"+dependencies = [+ "dirs-sys",+]++[[package]]+name = "dirs-sys"+version = "0.5.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "e01a3366d27ee9890022452ee61b2b63a67e6f13f58900b651ff5665f0bb1fab"+dependencies = [+ "libc",+ "option-ext",+ "redox_users",+ "windows-sys 0.61.2",+]++[[package]]+name = "dispatch2"+version = "0.3.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "1e0e367e4e7da84520dedcac1901e4da967309406d1e51017ae1abfb97adbd38"+dependencies = [+ "bitflags 2.13.2",+ "objc2",+]++[[package]]+name = "displaydoc"+version = "0.2.7"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "c6232dd377dcc64799954cbd3a9bb882e9cdc1308ccd87b1c098f1fb2eaf82a8"+dependencies = [+ "proc-macro2",+ "quote",+ "syn 3.0.9",+]++[[package]]+name = "dunce"+version = "1.0.5"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813"++[[package]]+name = "dyn-stack"+version = "0.13.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "1c4713e43e2886ba72b8271aa66c93d722116acf7a75555cce11dcde84388fe8"+dependencies = [+ "bytemuck",+ "dyn-stack-macros",+]++[[package]]+name = "dyn-stack-macros"+version = "0.1.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "e1d926b4d407d372f141f93bb444696142c29d32962ccbd3531117cf3aa0bfa9"++[[package]]+name = "ebur128"+version = "0.1.10"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "e227cc62d64d6fe01abbef48134b9c1f17d470cef1e7a56337ad05b1f81df7f9"+dependencies = [+ "bitflags 1.3.2",+ "dasp_frame",+ "dasp_sample",+ "smallvec",+]++[[package]]+name = "either"+version = "1.19.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "0e9c71c2167ca323c882b99918929403426e2373ea17242ff5653e0d5e1058be"++[[package]]+name = "encoding_rs"+version = "0.8.42"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "8e985e0451871ad22fb8d2b6b076e2028a502a0d3950998c2c5c0a4f9b5d9679"+dependencies = [+ "cfg-if",+ "core_detect",+ "multiversion_no_op",+ "rustversion",+ "scopeguard",+ "simdutf8",+]++[[package]]+name = "enum-as-inner"+version = "0.6.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "a1e6a265c649f3f5979b601d26f1d05ada116434c87741c9493cb56218f76cbc"+dependencies = [+ "heck",+ "proc-macro2",+ "quote",+ "syn 2.0.119",+]++[[package]]+name = "equivalent"+version = "1.0.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "00d174d5400e5e8fd687ad1049e2f578285fa914201b1af7e8b112a4546bd826"++[[package]]+name = "errno"+version = "0.3.14"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb"+dependencies = [+ "libc",+ "windows-sys 0.61.2",+]++[[package]]+name = "esaxx-rs"+version = "0.1.10"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "d817e038c30374a4bcb22f94d0a8a0e216958d4c3dcde369b1439fec4bdda6e6"++[[package]]+name = "extended"+version = "0.1.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "af9673d8203fcb076b19dfd17e38b3d4ae9f44959416ea532ce72415a6020365"++[[package]]+name = "fancy-regex"+version = "0.17.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "72cf461f865c862bb7dc573f643dd6a2b6842f7c30b07882b56bd148cc2761b8"+dependencies = [+ "bit-set",+ "regex-automata",+ "regex-syntax",+]++[[package]]+name = "fastrand"+version = "2.5.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "da7c62ceae207dd37ea5b845da6a0696c799f85e97da1ab5b7910be3c1c80223"++[[package]]+name = "find-msvc-tools"+version = "0.1.15"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "1c66915cc5391097de7a2b0b972e8505aa33c0df401fd3a6811dbdb32881ba48"++[[package]]+name = "fnv"+version = "1.0.7"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"++[[package]]+name = "foldhash"+version = "0.2.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb"++[[package]]+name = "form_urlencoded"+version = "1.2.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "cb4cb245038516f5f85277875cdaa4f7d2c9a0fa0468de06ed190163b1581fcf"+dependencies = [+ "percent-encoding",+]++[[package]]+name = "fs_extra"+version = "1.3.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "42703706b716c37f96a77aea830392ad231f44c9e9a67872fa5548707e11b11c"++[[package]]+name = "futures"+version = "0.3.34"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "9a31d2a3fbaaeb2af2368bbdd904aa8e812d3c04a1ee10d3171f52d556e5d0a3"+dependencies = [+ "futures-channel",+ "futures-core",+ "futures-executor",+ "futures-io",+ "futures-sink",+ "futures-task",+ "futures-util",+]++[[package]]+name = "futures-channel"+version = "0.3.34"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "b1f9e3d69d39e4862ffed03ed071a76f9a13ba1d9109d355b0f0aa6b15e393c4"+dependencies = [+ "futures-core",+ "futures-sink",+]++[[package]]+name = "futures-core"+version = "0.3.34"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "92d699e522242e69e3003b94ecc1f960f3a5e015aa7c5d7486e65ad01dd94f5e"++[[package]]+name = "futures-executor"+version = "0.3.34"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "031b47cf1a3c6cc8bc2fc76cd437f521619387907d469316e7c0bc278f1f5432"+dependencies = [+ "futures-core",+ "futures-task",+ "futures-util",+]++[[package]]+name = "futures-io"+version = "0.3.34"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "53c0fa8157de1303bfffdaa1cc2a673bfffb60102f76b0ef4441659124373fed"++[[package]]+name = "futures-macro"+version = "0.3.34"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "9fb9654ba8355388abeb8dcb4fc62f511300867002afc858860463bdd9fe0c44"+dependencies = [+ "proc-macro2",+ "quote",+ "syn 3.0.9",+]++[[package]]+name = "futures-sink"+version = "0.3.34"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "1944426bf7d03f1d14f708785e4b33efd750b36d48a157b836b3efc15ede8e1d"++[[package]]+name = "futures-task"+version = "0.3.34"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "cd417de3d1d015fc3bfd2b1ea46dfc7bab72ef86f1cc7cc9c78e728b34a6d1fd"++[[package]]+name = "futures-util"+version = "0.3.34"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "0d50a92467f8ba5dd6e3ee5d4bd04d73ab2e4e1c44474a0674821dfce14b79bc"+dependencies = [+ "futures-channel",+ "futures-core",+ "futures-io",+ "futures-macro",+ "futures-sink",+ "futures-task",+ "memchr",+ "pin-project-lite",+ "slab",+]++[[package]]+name = "gearhash"+version = "0.1.4"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "616e8f476a586f1b078d9eece21f7a071f27997e709e2b471f5697deea53bda9"++[[package]]+name = "generic-array"+version = "0.14.7"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a"+dependencies = [+ "typenum",+ "version_check",+]++[[package]]+name = "getrandom"+version = "0.2.17"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0"+dependencies = [+ "cfg-if",+ "js-sys",+ "libc",+ "wasi 0.11.1+wasi-snapshot-preview1",+ "wasm-bindgen",+]++[[package]]+name = "getrandom"+version = "0.3.4"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd"+dependencies = [+ "cfg-if",+ "libc",+ "r-efi 5.3.0",+ "wasip2",+]++[[package]]+name = "getrandom"+version = "0.4.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "300e883d756b2e4ec94e02791f39b04b522276138852cfc41d9fb7e904106099"+dependencies = [+ "cfg-if",+ "js-sys",+ "libc",+ "r-efi 6.0.0",+ "rand_core 0.10.1",+ "wasm-bindgen",+]++[[package]]+name = "git-version"+version = "0.3.9"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "1ad568aa3db0fcbc81f2f116137f263d7304f512a1209b35b85150d3ef88ad19"+dependencies = [+ "git-version-macro",+]++[[package]]+name = "git-version-macro"+version = "0.3.9"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "53010ccb100b96a67bc32c0175f0ed1426b31b655d562898e57325f81c023ac0"+dependencies = [+ "proc-macro2",+ "quote",+ "syn 2.0.119",+]++[[package]]+name = "globset"+version = "0.4.20"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "07c34a9410465b45bd9787443bc7370f37735bad04b0f0cd57ff1a3186c98988"+dependencies = [+ "aho-corasick",+ "bstr",+ "log",+ "regex-automata",+ "regex-syntax",+]++[[package]]+name = "h2"+version = "0.4.20"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "7d29020232d6aa3fb1daca64c1127cf662cf97f254ae16c18c05b8ab635fc118"+dependencies = [+ "atomic-waker",+ "bytes",+ "fnv",+ "futures-core",+ "futures-sink",+ "http",+ "indexmap",+ "slab",+ "tokio",+ "tokio-util",+ "tracing",+]++[[package]]+name = "half"+version = "2.7.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "6ea2d84b969582b4b1864a92dc5d27cd2b77b622a8d79306834f1be5ba20d84b"+dependencies = [+ "bytemuck",+ "cfg-if",+ "crunchy",+ "num-traits",+ "zerocopy",+]++[[package]]+name = "hashbrown"+version = "0.16.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100"+dependencies = [+ "allocator-api2",+ "equivalent",+ "foldhash",+ "serde",+ "serde_core",+]++[[package]]+name = "hashbrown"+version = "0.17.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a"++[[package]]+name = "heapify"+version = "0.2.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "0049b265b7f201ca9ab25475b22b47fe444060126a51abe00f77d986fc5cc52e"++[[package]]+name = "heck"+version = "0.5.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"++[[package]]+name = "hermit-abi"+version = "0.5.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "e17592d60ebacc7d5e169f4663c5f84f9161cc90328abcfe8456f41e4dfcb284"++[[package]]+name = "hf-hub"+version = "1.0.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "e7ccb6bcc85dec15413ef5949879f9a5497ca4568ed702547eb83fac23376e5c"+dependencies = [+ "base64 0.22.1",+ "bon",+ "bytes",+ "futures",+ "getrandom 0.2.17",+ "globset",+ "hf-xet",+ "hyper",+ "pathdiff",+ "percent-encoding",+ "reqwest",+ "serde",+ "serde_json",+ "sha2 0.11.1",+ "thiserror 2.0.21",+ "tokio",+ "tokio-retry",+ "tokio-util",+ "tracing",+ "url",+ "wasm-bindgen-futures",+]++[[package]]+name = "hf-xet"+version = "1.7.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "f24754aef4f6c3d57bc4a0dc2648ca74487050eda01c361b3eefa11feeafd662"+dependencies = [+ "anyhow",+ "async-trait",+ "bytes",+ "http",+ "more-asserts",+ "serde",+ "serde_json",+ "thiserror 2.0.21",+ "tokio",+ "tokio-util",+ "tokio_with_wasm",+ "tracing",+ "uuid",+ "xet-client",+ "xet-core-structures",+ "xet-data",+ "xet-runtime",+]++[[package]]+name = "http"+version = "1.5.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "918d3568bebf352712bc2ef3d46a8bcf1a75b373be6539de198e9105cbbf9ce0"+dependencies = [+ "bytes",+ "itoa",+]++[[package]]+name = "http-body"+version = "1.1.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "ca2a8f2913ee65f60facd6a5905613afaa448497a0230cc41ce022d93290bc2c"+dependencies = [+ "bytes",+ "http",+]++[[package]]+name = "http-body-util"+version = "0.1.5"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "23169fe34a5fbcdd3f3862e78fb9b6fccd5f02a6dc6f732547005d45631ce71c"+dependencies = [+ "bytes",+ "futures-core",+ "http",+ "http-body",+ "pin-project-lite",+]++[[package]]+name = "httparse"+version = "1.10.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87"++[[package]]+name = "httpdate"+version = "1.0.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9"++[[package]]+name = "humantime"+version = "2.4.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "15cdd26707701c53297e2fa6afb323d55fbc1d0810c3aec078ae3ef0424c3c15"++[[package]]+name = "hybrid-array"+version = "0.4.15"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "27f864f10dfb56725ce5ce5472bc52252c8f93a4ab86327122cebf62c5f59a17"+dependencies = [+ "typenum",+]++[[package]]+name = "hyper"+version = "1.12.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "2c3e324da4c95177d6291d4c8730197c0d1822f8a9766814a4a44fa5ab797c9c"+dependencies = [+ "atomic-waker",+ "bytes",+ "futures-channel",+ "futures-core",+ "h2",+ "http",+ "http-body",+ "httparse",+ "httpdate",+ "itoa",+ "pin-project-lite",+ "smallvec",+ "tokio",+ "want",+]++[[package]]+name = "hyper-rustls"+version = "0.27.10"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "dfa8e654703247911e29c23fbeaa261834bd9bb74efba2f9acddc37bfb127f53"+dependencies = [+ "http",+ "hyper",+ "hyper-util",+ "rustls",+ "tokio",+ "tokio-rustls",+ "tower-service",+]++[[package]]+name = "hyper-util"+version = "0.1.21"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "ddc03d96684f9226b8a787cdb71488417b53ab5ea8fdb1dac946cb9431cc8bff"+dependencies = [+ "base64 0.23.1",+ "bytes",+ "futures-channel",+ "futures-util",+ "http",+ "http-body",+ "httparse",+ "hyper",+ "ipnet",+ "libc",+ "percent-encoding",+ "pin-project-lite",+ "socket2",+ "system-configuration",+ "tokio",+ "tower-service",+ "tracing",+ "windows-registry",+]++[[package]]+name = "iana-time-zone"+version = "0.1.65"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "e31bc9ad994ba00e440a8aa5c9ef0ec67d5cb5e5cb0cc7f8b744a35b389cc470"+dependencies = [+ "android_system_properties",+ "core-foundation-sys",+ "iana-time-zone-haiku",+ "js-sys",+ "log",+ "wasm-bindgen",+ "windows-core",+]++[[package]]+name = "iana-time-zone-haiku"+version = "0.1.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f"+dependencies = [+ "cc",+]++[[package]]+name = "icu_collections"+version = "2.3.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "fa68d21081c4a05d5a901a1c62add574c77048b6a1c67be3b50ce0b60d4ca513"+dependencies = [+ "displaydoc",+ "potential_utf",+ "utf8_iter",+ "yoke",+ "zerofrom",+ "zerovec",+]++[[package]]+name = "icu_locale_core"+version = "2.3.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "d56e28588da92eee5c3201a6eff33fabdd49b62269c8938d4ff050ce4d900deb"+dependencies = [+ "displaydoc",+ "litemap",+ "tinystr",+ "writeable",+ "zerovec",+]++[[package]]+name = "icu_normalizer"+version = "2.3.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "12f9cf5f235641ed274641dd81c3f28d870e276763d0797aeeab72317b1c646f"+dependencies = [+ "icu_collections",+ "icu_normalizer_data",+ "icu_properties",+ "icu_provider",+ "smallvec",+ "zerovec",+]++[[package]]+name = "icu_normalizer_data"+version = "2.3.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "1563da1ed3e0b3bf3d74c9b85917ac9c56464d2f57242270c09c9e752f8021a0"++[[package]]+name = "icu_properties"+version = "2.3.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "7e7ca276ad3145661a65914e6daf131ca5120cd3dcee8f8f3214b8875184a148"+dependencies = [+ "displaydoc",+ "icu_collections",+ "icu_locale_core",+ "icu_properties_data",+ "icu_provider",+ "zerotrie",+ "zerovec",+]++[[package]]+name = "icu_properties_data"+version = "2.3.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "e590f038c1464a96894fd6d10127e90a8be4509f56ff7ecef851b15cee0b7caa"++[[package]]+name = "icu_provider"+version = "2.3.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "d27bbb9d3abbefac45d55f647c9de1d44aafcd1186eb91879afef17c396c3e73"+dependencies = [+ "displaydoc",+ "icu_locale_core",+ "writeable",+ "yoke",+ "zerofrom",+ "zerotrie",+ "zerovec",+]++[[package]]+name = "ident_case"+version = "1.0.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39"++[[package]]+name = "idna"+version = "1.1.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "3b0875f23caa03898994f6ddc501886a45c7d3d62d04d2d90788d47be1b1e4de"+dependencies = [+ "idna_adapter",+ "smallvec",+ "utf8_iter",+]++[[package]]+name = "idna_adapter"+version = "1.2.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "cb68373c0d6620ef8105e855e7745e18b0d00d3bdb07fb532e434244cdb9a714"+dependencies = [+ "icu_normalizer",+ "icu_properties",+]++[[package]]+name = "indexmap"+version = "2.14.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "cc4e190f5d26ca7051642629da2c52fc03bde85a03197c99408dcd291734c855"+dependencies = [+ "equivalent",+ "hashbrown 0.17.1",+]++[[package]]+name = "ipnet"+version = "2.12.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "791930b43c0d5973160d90a8f3894509f2b273430f5c5c73b668636d0287c5c0"++[[package]]+name = "is_terminal_polyfill"+version = "1.70.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695"++[[package]]+name = "itertools"+version = "0.14.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "2b192c782037fadd9cfa75548310488aabdbf3d2da73885b31bd0abd03351285"+dependencies = [+ "either",+]++[[package]]+name = "itoa"+version = "1.0.18"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682"++[[package]]+name = "jni"+version = "0.22.4"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "5efd9a482cf3a427f00d6b35f14332adc7902ce91efb778580e180ff90fa3498"+dependencies = [+ "cfg-if",+ "combine",+ "jni-macros",+ "jni-sys",+ "log",+ "simd_cesu8",+ "thiserror 2.0.21",+ "walkdir",+ "windows-link",+]++[[package]]+name = "jni-macros"+version = "0.22.4"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "a00109accc170f0bdb141fed3e393c565b6f5e072365c3bd58f5b062591560a3"+dependencies = [+ "proc-macro2",+ "quote",+ "rustc_version",+ "simd_cesu8",+ "syn 2.0.119",+]++[[package]]+name = "jni-sys"+version = "0.4.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "c6377a88cb3910bee9b0fa88d4f42e1d2da8e79915598f65fb0c7ee14c878af2"+dependencies = [+ "jni-sys-macros",+]++[[package]]+name = "jni-sys-macros"+version = "0.4.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "38c0b942f458fe50cdac086d2f946512305e5631e720728f2a61aabcd47a6264"+dependencies = [+ "quote",+ "syn 2.0.119",+]++[[package]]+name = "jobserver"+version = "0.1.35"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "1c00acbd29eabad4a2392fa0e921c874934dbbf4194312ad20f04a0ed67a3cb3"+dependencies = [+ "getrandom 0.4.3",+ "libc",+]++[[package]]+name = "js-sys"+version = "0.3.106"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "7883d941dae510fb2d978fc3fe018c71c9e2892fd38854de3e8b92c2e5ad9cc5"+dependencies = [+ "cfg-if",+ "futures-util",+ "wasm-bindgen",+]++[[package]]+name = "konst"+version = "0.4.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "f660d5f887e3562f9ab6f4a14988795b694099d66b4f5dedc02d197ba9becb1d"+dependencies = [+ "const_panic",+ "konst_proc_macros",+ "typewit",+]++[[package]]+name = "konst_proc_macros"+version = "0.4.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "e037a2e1d8d5fdbd49b16a4ea09d5d6401c1f29eca5ff29d03d3824dba16256a"++[[package]]+name = "lazy_static"+version = "1.5.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "20870f649af7073d53e38067b2a84312175d56ea15217e1b15bc83506ec50afb"++[[package]]+name = "libc"+version = "0.2.191"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "65cd87c9a6d60536580b316ad985726104730a5151c99845f2490428ef91240a"++[[package]]+name = "libm"+version = "0.2.16"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "b6d2cec3eae94f9f509c767b45932f1ada8350c4bdb85af2fcab4a3c14807981"++[[package]]+name = "libredox"+version = "0.1.25"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "61ff90caf6077a803a240f62fdbe88645a890bbca49ef8174c3cb0404362171d"+dependencies = [+ "libc",+]++[[package]]+name = "link-section"+version = "0.19.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "39c29a617ce3df32c08497bdc1ab6e2376e0b17948ac166a2fbe5977c5954cd9"++[[package]]+name = "linktime-proc-macro"+version = "0.2.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "7e57c38c1e860fd37c604281cdfb1dd2216977fd76a50f85ba2f388ef3219616"++[[package]]+name = "linux-raw-sys"+version = "0.12.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53"++[[package]]+name = "litemap"+version = "0.8.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "47d9d19d1d6efa0109d2f65ff4c85cddd50bd572e5a00127ab10987290bcefae"++[[package]]+name = "log"+version = "0.4.34"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "f9f8bd3e56ce4dfc153cf470fffbfa98c7620958b312ca5c3a4b8d5181fd13c6"++[[package]]+name = "lru-slab"+version = "0.1.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "4050469837a6ff301cd14c1f8f24f88549e6d548f24f64e2148eb0f72cebc51f"++[[package]]+name = "lz4_flex"+version = "0.13.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "7ef0d4ed8669f8f8826eb00dc878084aa8f253506c4fd5e8f58f5bce72ddb97e"+dependencies = [+ "twox-hash",+]++[[package]]+name = "macro_rules_attribute"+version = "0.2.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "b3ae8f6d608c795738406608304d30a2dfbdc8e58e44f7ba43236da5208ded3c"+dependencies = [+ "macro_rules_attribute-proc_macro",+ "pastey",+]++[[package]]+name = "macro_rules_attribute-proc_macro"+version = "0.2.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "fc04a4c58212d57930a24bf47d3fa87485264a3a054e9c10e042eb373573ad3c"++[[package]]+name = "matchers"+version = "0.2.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "d1525a2a28c7f4fa0fc98bb91ae755d1e2d1505079e05539e35bc876b5d65ae9"+dependencies = [+ "regex-automata",+]++[[package]]+name = "matchit"+version = "0.8.4"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "47e1ffaa40ddd1f3ed91f717a33c8c0ee23fff369e3aa8772b9605cc1d22f4c3"++[[package]]+name = "memchr"+version = "2.8.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98"++[[package]]+name = "memmap2"+version = "0.9.11"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "d1219ed1b7f229ee7104d281dd01d6802fe28bb6e95d292942c4daacdeb798c0"+dependencies = [+ "libc",+]++[[package]]+name = "mime"+version = "0.3.17"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a"++[[package]]+name = "mime_guess"+version = "2.0.5"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "f7c44f8e672c00fe5308fa235f821cb4198414e1c77935c1ab6948d3fd78550e"+dependencies = [+ "mime",+ "unicase",+]++[[package]]+name = "minimal-lexical"+version = "0.2.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"++[[package]]+name = "mio"+version = "1.2.4"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "1788edb87fdc09c7e26304471e2f5be8cdefb1b6930d6e3985fc02ff53bf86ee"+dependencies = [+ "libc",+ "wasi 0.11.1+wasi-snapshot-preview1",+ "windows-sys 0.61.2",+]++[[package]]+name = "monostate"+version = "0.1.18"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "3341a273f6c9d5bef1908f17b7267bbab0e95c9bf69a0d4dcf8e9e1b2c76ef67"+dependencies = [+ "monostate-impl",+ "serde",+ "serde_core",+]++[[package]]+name = "monostate-impl"+version = "0.1.18"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "e4db6d5580af57bf992f59068d4ea26fd518574ff48d7639b255a36f9de6e7e9"+dependencies = [+ "proc-macro2",+ "quote",+ "syn 2.0.119",+]++[[package]]+name = "more-asserts"+version = "0.3.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "1fafa6961cabd9c63bcd77a45d7e3b7f3b552b70417831fb0f56db717e72407e"++[[package]]+name = "multer"+version = "3.1.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "83e87776546dc87511aa5ee218730c92b666d7264ab6ed41f9d215af9cd5224b"+dependencies = [+ "bytes",+ "encoding_rs",+ "futures-util",+ "http",+ "httparse",+ "memchr",+ "mime",+ "spin",+ "version_check",+]++[[package]]+name = "multiversion_no_op"+version = "1.0.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "743fb55ba31b18fb1ecef6bdc9aa2743314978ac084044301a7eee33fb99a20d"++[[package]]+name = "nom"+version = "7.1.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a"+dependencies = [+ "memchr",+ "minimal-lexical",+]++[[package]]+name = "ntapi"+version = "0.4.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "c3b335231dfd352ffb0f8017f3b6027a4917f7df785ea2143d8af2adc66980ae"+dependencies = [+ "winapi",+]++[[package]]+name = "nu-ansi-term"+version = "0.50.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5"+dependencies = [+ "windows-sys 0.61.2",+]++[[package]]+name = "num-complex"+version = "0.4.6"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495"+dependencies = [+ "bytemuck",+ "num-traits",+]++[[package]]+name = "num-conv"+version = "0.2.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "521739c6d2bac4aa25192232afe6841231376b2b26d4d9fae5ecf8ca5772e441"++[[package]]+name = "num-derive"+version = "0.4.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202"+dependencies = [+ "proc-macro2",+ "quote",+ "syn 2.0.119",+]++[[package]]+name = "num-integer"+version = "0.1.47"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "7ce2d95d4b3734dc35aa2f45e1aa22cd416814592a4f9d9205e11affd5b8e10b"+dependencies = [+ "num-traits",+]++[[package]]+name = "num-traits"+version = "0.2.19"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841"+dependencies = [+ "autocfg",+ "libm",+]++[[package]]+name = "num_cpus"+version = "1.17.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "91df4bbde75afed763b708b7eee1e8e7651e02d97f6d5dd763e89367e957b23b"+dependencies = [+ "hermit-abi",+ "libc",+]++[[package]]+name = "objc2"+version = "0.6.5"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "08849bbd4767dfae9457696856ae1c84fe4e0281bbe4a7abff2d0e06fb7981f8"+dependencies = [+ "objc2-encode",+]++[[package]]+name = "objc2-core-foundation"+version = "0.3.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "2a180dd8642fa45cdb7dd721cd4c11b1cadd4929ce112ebd8b9f5803cc79d536"+dependencies = [+ "bitflags 2.13.2",+ "dispatch2",+ "objc2",+]++[[package]]+name = "objc2-encode"+version = "4.1.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "ef25abbcd74fb2609453eb695bd2f860d389e457f67dc17cafc8b8cbc89d0c33"++[[package]]+name = "objc2-foundation"+version = "0.3.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "e3e0adef53c21f888deb4fa59fc59f7eb17404926ee8a6f59f5df0fd7f9f3272"+dependencies = [+ "bitflags 2.13.2",+ "objc2",+]++[[package]]+name = "objc2-io-kit"+version = "0.3.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "33fafba39597d6dc1fb709123dfa8289d39406734be322956a69f0931c73bb15"+dependencies = [+ "libc",+ "objc2-core-foundation",+]++[[package]]+name = "objc2-open-directory"+version = "0.3.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "bb82bed227edf5201dfedf072bba4015a33d3d4a98519837295a90f0a23f676d"+dependencies = [+ "objc2",+ "objc2-core-foundation",+ "objc2-foundation",+]++[[package]]+name = "objc2-system-configuration"+version = "0.3.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "7216bd11cbda54ccabcab84d523dc93b858ec75ecfb3a7d89513fa22464da396"+dependencies = [+ "objc2-core-foundation",+]++[[package]]+name = "once_cell"+version = "1.21.4"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"++[[package]]+name = "once_cell_polyfill"+version = "1.70.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe"++[[package]]+name = "oneshot"+version = "0.1.13"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "269bca4c2591a28585d6bf10d9ed0332b7d76900a1b02bec41bdc3a2cdcda107"++[[package]]+name = "openssl-probe"+version = "0.2.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "7c87def4c32ab89d880effc9e097653c8da5d6ef28e6b539d313baaacfbafcbe"++[[package]]+name = "option-ext"+version = "0.2.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d"++[[package]]+name = "os_str_bytes"+version = "6.6.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "e2355d85b9a3786f481747ced0e0ff2ba35213a1f9bd406ed906554d7af805a1"+dependencies = [+ "memchr",+]++[[package]]+name = "paste"+version = "1.0.15"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a"++[[package]]+name = "pastey"+version = "0.2.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "2ee67f1008b1ba2321834326597b8e186293b049a023cdef258527550b9935b4"++[[package]]+name = "pathdiff"+version = "0.2.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "df94ce210e5bc13cb6651479fa48d14f601d9858cfe0467f43ae157023b938d3"++[[package]]+name = "percent-encoding"+version = "2.3.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220"++[[package]]+name = "pin-project"+version = "1.1.13"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "2466b2336ed02bcdca6b294417127b90ec92038d1d5c4fbeac971a922e0e0924"+dependencies = [+ "pin-project-internal",+]++[[package]]+name = "pin-project-internal"+version = "1.1.13"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "c96395f0a926bc13b1c17622aaddda1ecb55d49c8f1bf9777e4d877800a43f8b"+dependencies = [+ "proc-macro2",+ "quote",+ "syn 2.0.119",+]++[[package]]+name = "pin-project-lite"+version = "0.2.17"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd"++[[package]]+name = "pkg-config"+version = "0.3.34"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "f6b464fbc74e149a392436b17d523f769e057cb6877f6a5c4618bc6f11800548"++[[package]]+name = "pocket-tts"+version = "3.3.0"+dependencies = [+ "anyhow",+ "axum",+ "clap",+ "half",+ "hf-hub",+ "log",+ "ptts",+ "rand 0.9.5",+ "rand_distr",+ "reqwest",+ "safetensors",+ "sentencepiece",+ "serde",+ "serde_json",+ "serde_yaml",+ "sha2 0.10.9",+ "symphonia",+ "tempfile",+ "tokenizers",+ "tokio",+ "tokio-stream",+ "tower-http",+ "xn",+]++[[package]]+name = "potential_utf"+version = "0.1.6"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "d83eb9bc6d8e5cf568e7a1101d60ee05e81ed50ea106026f3d18deeb046d7661"+dependencies = [+ "zerovec",+]++[[package]]+name = "powerfmt"+version = "0.2.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "4a6394b9e965e73d0a289ee54f589087e2c676aedf60885baf52c76b771e4958"++[[package]]+name = "ppv-lite86"+version = "0.2.21"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9"+dependencies = [+ "zerocopy",+]++[[package]]+name = "prettyplease"+version = "0.3.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "2bfe0f4c752e450fc2faf62654f1c134747922825d5b04ca717b8874f41a40c0"+dependencies = [+ "proc-macro2",+ "syn 3.0.9",+]++[[package]]+name = "primal-check"+version = "0.3.4"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "dc0d895b311e3af9902528fbb8f928688abbd95872819320517cc24ca6b2bd08"+dependencies = [+ "num-integer",+]++[[package]]+name = "proc-macro2"+version = "1.0.107"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9"+dependencies = [+ "unicode-ident",+]++[[package]]+name = "prost"+version = "0.14.4"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "528ac67416ff8646872a3c02cad9cc4ee5dc9f9540c9b10771855c95cb2e5ae1"+dependencies = [+ "bytes",+ "prost-derive",+]++[[package]]+name = "prost-derive"+version = "0.14.4"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "b570b25f7617e43d59005d0990ccb79e950a423952cea19671b7a876da390adf"+dependencies = [+ "anyhow",+ "itertools",+ "proc-macro2",+ "quote",+ "syn 2.0.119",+]++[[package]]+name = "ptts"+version = "0.4.0-rc.3"+source = "git+https://github.com/gradium-ai/xn-ptts?rev=1bfe079c9a4c778dbe4edd9d4d5bca9df3e46b3f#1bfe079c9a4c778dbe4edd9d4d5bca9df3e46b3f"+dependencies = [+ "ebur128",+ "rand 0.9.5",+ "rand_distr",+ "rubato",+ "safetensors",+ "serde",+ "serde_json",+ "symphonia",+ "thiserror 2.0.21",+ "tokenizers",+ "tracing",+ "tracing-subscriber",+ "xn",+]++[[package]]+name = "pulp"+version = "0.22.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "046aa45b989642ec2e4717c8e72d677b13edd831a4d3b6cf37d9a3e54912496a"+dependencies = [+ "bytemuck",+ "cfg-if",+ "libm",+ "num-complex",+ "paste",+ "pulp-wasm-simd-flag",+ "raw-cpuid",+ "reborrow",+ "version_check",+]++[[package]]+name = "pulp-wasm-simd-flag"+version = "0.1.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "1d8f70e07b9c3962945a74e59ca1c511bba65b6419468acc217c457d93f3c740"++[[package]]+name = "quinn"+version = "0.11.12"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "4051e23e9185c255a7e33ef59cdbca87a22d359052eecd22fc6b901fb37d9d11"+dependencies = [+ "bytes",+ "cfg_aliases",+ "pin-project-lite",+ "quinn-proto",+ "quinn-udp",+ "rustc-hash",+ "rustls",+ "socket2",+ "thiserror 2.0.21",+ "tokio",+ "tracing",+ "web-time",+]++[[package]]+name = "quinn-proto"+version = "0.11.19"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "0e750cca55fe4f0439a15d0bb529da9651e79993e8e72c61a899a36d462befbe"+dependencies = [+ "aws-lc-rs",+ "bytes",+ "getrandom 0.4.3",+ "lru-slab",+ "rand 0.10.3",+ "rand_pcg",+ "ring",+ "rustc-hash",+ "rustls",+ "rustls-pki-types",+ "slab",+ "thiserror 2.0.21",+ "tinyvec",+ "tracing",+ "web-time",+]++[[package]]+name = "quinn-udp"+version = "0.5.16"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "af66907df18639dcf4db56ca65490cabc4b27a97dbadd96f2926cca73298f016"+dependencies = [+ "cfg_aliases",+ "libc",+ "once_cell",+ "socket2",+ "tracing",+ "windows-sys 0.61.2",+]++[[package]]+name = "quote"+version = "1.0.47"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001"+dependencies = [+ "proc-macro2",+]++[[package]]+name = "r-efi"+version = "5.3.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f"++[[package]]+name = "r-efi"+version = "6.0.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf"++[[package]]+name = "rand"+version = "0.9.5"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "b9ef1d0d795eb7d84685bca4f72f3649f064e6641543d3a8c415898726a57b41"+dependencies = [+ "rand_chacha",+ "rand_core 0.9.5",+]++[[package]]+name = "rand"+version = "0.10.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "65c9fb96cbc91e3478eaae79a69fcd3f1ae4ad052e471fe6732fff548984b4af"+dependencies = [+ "chacha20",+ "getrandom 0.4.3",+ "rand_core 0.10.1",+]++[[package]]+name = "rand_chacha"+version = "0.9.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb"+dependencies = [+ "ppv-lite86",+ "rand_core 0.9.5",+]++[[package]]+name = "rand_core"+version = "0.9.5"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "76afc826de14238e6e8c374ddcc1fa19e374fd8dd986b0d2af0d02377261d83c"+dependencies = [+ "getrandom 0.3.4",+]++[[package]]+name = "rand_core"+version = "0.10.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "63b8176103e19a2643978565ca18b50549f6101881c443590420e4dc998a3c69"++[[package]]+name = "rand_distr"+version = "0.5.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "6a8615d50dcf34fa31f7ab52692afec947c4dd0ab803cc87cb3b0b4570ff7463"+dependencies = [+ "num-traits",+ "rand 0.9.5",+]++[[package]]+name = "rand_pcg"+version = "0.10.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "caa0f4137e1c0a72f4c651489402276c8e8e1cf081f3b0ba156d2cbeef09e86a"+dependencies = [+ "rand_core 0.10.1",+]++[[package]]+name = "raw-cpuid"+version = "11.6.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "498cd0dc59d73224351ee52a95fee0f1a617a2eae0e7d9d720cc622c73a54186"+dependencies = [+ "bitflags 2.13.2",+]++[[package]]+name = "rayon"+version = "1.12.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "fb39b166781f92d482534ef4b4b1b2568f42613b53e5b6c160e24cfbfa30926d"+dependencies = [+ "either",+ "rayon-core",+]++[[package]]+name = "rayon-cond"+version = "0.4.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "2964d0cf57a3e7a06e8183d14a8b527195c706b7983549cd5462d5aa3747438f"+dependencies = [+ "either",+ "itertools",+ "rayon",+]++[[package]]+name = "rayon-core"+version = "1.13.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "22e18b0f0062d30d4230b2e85ff77fdfe4326feb054b9783a3460d8435c8ab91"+dependencies = [+ "crossbeam-deque",+ "crossbeam-utils",+]++[[package]]+name = "realfft"+version = "3.5.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "f821338fddb99d089116342c46e9f1fbf3828dba077674613e734e01d6ea8677"+dependencies = [+ "rustfft",+]++[[package]]+name = "reborrow"+version = "0.5.5"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "03251193000f4bd3b042892be858ee50e8b3719f2b08e5833ac4353724632430"++[[package]]+name = "redb"+version = "3.1.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "4ba239c1c1693315d3cc0e601db3b3965543afbf48c41730fdca2f069f510f4a"+dependencies = [+ "libc",+]++[[package]]+name = "redox_users"+version = "0.5.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "60dc65c0ff1a7ae1294b0c67b9f14baf70b644404010370171787bfac1038fc0"+dependencies = [+ "libredox",+ "thiserror 2.0.21",+]++[[package]]+name = "regex"+version = "1.13.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "f020237b6c8eed93db2e2cb53c00c60a8e1bc73da7d073199a1180401450218d"+dependencies = [+ "aho-corasick",+ "memchr",+ "regex-automata",+ "regex-syntax",+]++[[package]]+name = "regex-automata"+version = "0.4.18"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "ad8553b9b26413251cbf30e620595c7a41b3887f03da04579c0e6b0d6a06b4b2"+dependencies = [+ "aho-corasick",+ "memchr",+ "regex-syntax",+]++[[package]]+name = "regex-syntax"+version = "0.8.11"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4"++[[package]]+name = "reqwest"+version = "0.13.5"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "16a1cfa75cc186dd73d5818e510e042e40927bccc9c236b061cea97e1eb08029"+dependencies = [+ "base64 0.23.1",+ "bytes",+ "encoding_rs",+ "futures-channel",+ "futures-core",+ "futures-util",+ "h2",+ "http",+ "http-body",+ "http-body-util",+ "hyper",+ "hyper-rustls",+ "hyper-util",+ "js-sys",+ "log",+ "mime",+ "mime_guess",+ "percent-encoding",+ "pin-project-lite",+ "quinn",+ "rustls",+ "rustls-pki-types",+ "rustls-platform-verifier",+ "serde",+ "serde_json",+ "serde_urlencoded",+ "sync_wrapper",+ "tokio",+ "tokio-rustls",+ "tokio-util",+ "tower",+ "tower-http",+ "tower-service",+ "url",+ "wasm-bindgen",+ "wasm-bindgen-futures",+ "wasm-streams",+ "web-sys",+]++[[package]]+name = "reqwest-middleware"+version = "0.5.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "07bc3f1384cffa4f274dad2d4ddd73aed32fed8f786d96c6be8aa4e5fd3c3b58"+dependencies = [+ "anyhow",+ "async-trait",+ "http",+ "reqwest",+ "thiserror 2.0.21",+ "tower-service",+]++[[package]]+name = "ring"+version = "0.17.14"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7"+dependencies = [+ "cc",+ "cfg-if",+ "getrandom 0.2.17",+ "libc",+ "untrusted",+ "windows-sys 0.52.0",+]++[[package]]+name = "rubato"+version = "0.15.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "b5d18b486e7d29a408ef3f825bc1327d8f87af091c987ca2f5b734625940e234"+dependencies = [+ "num-complex",+ "num-integer",+ "num-traits",+ "realfft",+]++[[package]]+name = "rustc-hash"+version = "2.1.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "6b1e7f9a428571be2dc5bc0505c13fb6bf936822b894ec87abf8a08a4e51742d"++[[package]]+name = "rustc_version"+version = "0.4.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92"+dependencies = [+ "semver",+]++[[package]]+name = "rustfft"+version = "6.4.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "21db5f9893e91f41798c88680037dba611ca6674703c1a18601b01a72c8adb89"+dependencies = [+ "num-complex",+ "num-integer",+ "num-traits",+ "primal-check",+ "strength_reduce",+ "transpose",+]++[[package]]+name = "rustix"+version = "1.1.5"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "891efababe418670775f199f0d233d84843c227a0949a883ce15b37c78d6629d"+dependencies = [+ "bitflags 2.13.2",+ "errno",+ "libc",+ "linux-raw-sys",+ "windows-sys 0.61.2",+]++[[package]]+name = "rustls"+version = "0.23.46"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "48e13bd8c0e9365c43cfa5c9e8f9ad49d3c8444926c9aac819e0e4dc503c8fdf"+dependencies = [+ "aws-lc-rs",+ "once_cell",+ "rustls-pki-types",+ "rustls-webpki",+ "subtle",+ "zeroize",+]++[[package]]+name = "rustls-native-certs"+version = "0.8.5"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "4a073f5dc7469f984c52ad2752b63b0807745133b6de880b7b64c1ac4c48aec4"+dependencies = [+ "openssl-probe",+ "rustls-pki-types",+ "schannel",+ "security-framework",+]++[[package]]+name = "rustls-pki-types"+version = "1.15.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "2f4925028c7eb5d1fcdaf196971378ed9d2c1c4efc7dc5d011256f76c99c0a96"+dependencies = [+ "web-time",+ "zeroize",+]++[[package]]+name = "rustls-platform-verifier"+version = "0.7.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "1167586491e2b18b8bfbb293e8180ec17c201c4f076d7cb3070ca964e7598f98"+dependencies = [+ "core-foundation 0.10.1",+ "core-foundation-sys",+ "jni",+ "log",+ "once_cell",+ "rustls",+ "rustls-native-certs",+ "rustls-platform-verifier-android",+ "rustls-webpki",+ "security-framework",+ "security-framework-sys",+ "webpki-root-certs",+ "windows-sys 0.61.2",+]++[[package]]+name = "rustls-platform-verifier-android"+version = "0.2.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "eec689c0bc40ff2458a5977b6619cb718087084a18e02a131c599b62d05e1a5f"++[[package]]+name = "rustls-webpki"+version = "0.103.15"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "f3c3cf1d8b1e7d4927e2d154c3fcb02979afb9939629c62cd9048d4f07b60ac2"+dependencies = [+ "aws-lc-rs",+ "ring",+ "rustls-pki-types",+ "untrusted",+]++[[package]]+name = "rustversion"+version = "1.0.23"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f"++[[package]]+name = "ryu"+version = "1.0.23"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "9774ba4a74de5f7b1c1451ed6cd5285a32eddb5cccb8cc655a4e50009e06477f"++[[package]]+name = "safe-transmute"+version = "0.11.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "3944826ff8fa8093089aba3acb4ef44b9446a99a16f3bf4e74af3f77d340ab7d"++[[package]]+name = "safetensors"+version = "0.7.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "675656c1eabb620b921efea4f9199f97fc86e36dd6ffd1fbbe48d0f59a4987f5"+dependencies = [+ "hashbrown 0.16.1",+ "serde",+ "serde_json",+]++[[package]]+name = "same-file"+version = "1.0.6"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502"+dependencies = [+ "winapi-util",+]++[[package]]+name = "schannel"+version = "0.1.30"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "9cb23c424d8ee841bb4d813677ca237e2a610067d594fec130f87d6093495ab5"+dependencies = [+ "windows-sys 0.61.2",+]++[[package]]+name = "scopeguard"+version = "1.2.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"++[[package]]+name = "security-framework"+version = "3.7.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "b7f4bc775c73d9a02cde8bf7b2ec4c9d12743edf609006c7facc23998404cd1d"+dependencies = [+ "bitflags 2.13.2",+ "core-foundation 0.10.1",+ "core-foundation-sys",+ "libc",+ "security-framework-sys",+]++[[package]]+name = "security-framework-sys"+version = "2.17.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "6ce2691df843ecc5d231c0b14ece2acc3efb62c0a398c7e1d875f3983ce020e3"+dependencies = [+ "core-foundation-sys",+ "libc",+]++[[package]]+name = "semver"+version = "1.0.28"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "8a7852d02fc848982e0c167ef163aaff9cd91dc640ba85e263cb1ce46fae51cd"++[[package]]+name = "sentencepiece"+version = "0.14.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "199cd424616675812f71a43866e2fb6e4725538dd7cee7d537fea81c0d66c102"+dependencies = [+ "libc",+ "num-derive",+ "num-traits",+ "prost",+ "prost-derive",+ "sentencepiece-sys",+ "thiserror 2.0.21",+]++[[package]]+name = "sentencepiece-sys"+version = "0.14.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "1f4f7b039e2b80f69283f56211f9457ea3f4a8d3045b9ba4282326b446fa3a9a"+dependencies = [+ "cc",+ "cmake",+ "pkg-config",+]++[[package]]+name = "seq-macro"+version = "0.3.6"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "1bc711410fbe7399f390ca1c3b60ad0f53f80e95c5eb935e52268a0e2cd49acc"++[[package]]+name = "serde"+version = "1.0.229"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba"+dependencies = [+ "serde_core",+ "serde_derive",+]++[[package]]+name = "serde_core"+version = "1.0.229"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48"+dependencies = [+ "serde_derive",+]++[[package]]+name = "serde_derive"+version = "1.0.229"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348"+dependencies = [+ "proc-macro2",+ "quote",+ "syn 3.0.9",+]++[[package]]+name = "serde_json"+version = "1.0.154"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "e7e9cc8b1b85264074fbcc02a88680c4096b1e47df8f739dceb03bf482f04bd6"+dependencies = [+ "itoa",+ "memchr",+ "serde",+ "serde_core",+ "zmij",+]++[[package]]+name = "serde_path_to_error"+version = "0.1.20"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "10a9ff822e371bb5403e391ecd83e182e0e77ba7f6fe0160b795797109d1b457"+dependencies = [+ "itoa",+ "serde",+ "serde_core",+]++[[package]]+name = "serde_repr"+version = "0.1.21"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "8d3b1629de253c70a0508c3899572da79ca359fdab27c7920ff00406df418906"+dependencies = [+ "proc-macro2",+ "quote",+ "syn 3.0.9",+]++[[package]]+name = "serde_urlencoded"+version = "0.7.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd"+dependencies = [+ "form_urlencoded",+ "itoa",+ "ryu",+ "serde",+]++[[package]]+name = "serde_yaml"+version = "0.9.34+deprecated"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47"+dependencies = [+ "indexmap",+ "itoa",+ "ryu",+ "serde",+ "unsafe-libyaml",+]++[[package]]+name = "sha2"+version = "0.10.9"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283"+dependencies = [+ "cfg-if",+ "cpufeatures 0.2.17",+ "digest 0.10.7",+]++[[package]]+name = "sha2"+version = "0.11.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "47d7069beb7d6ac7b9acd1039986e73443f24234f41074da099d6f994ac9ad19"+dependencies = [+ "cfg-if",+ "cpufeatures 0.3.1",+ "digest 0.11.3",+]++[[package]]+name = "sharded-slab"+version = "0.1.7"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6"+dependencies = [+ "lazy_static",+]++[[package]]+name = "shellexpand"+version = "3.1.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "32824fab5e16e6c4d86dc1ba84489390419a39f97699852b66480bb87d297ed8"+dependencies = [+ "bstr",+ "dirs",+ "os_str_bytes",+]++[[package]]+name = "shlex"+version = "2.0.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba"++[[package]]+name = "signal-hook-registry"+version = "1.4.8"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "c4db69cba1110affc0e9f7bcd48bbf87b3f4fc7c61fc9155afd4c469eb3d6c1b"+dependencies = [+ "errno",+ "libc",+]++[[package]]+name = "simd_cesu8"+version = "1.2.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "11031e251abf8611c80f460e19dbdeb54a66db918e49c65a7065b46ac7aec520"+dependencies = [+ "rustc_version",+ "simdutf8",+]++[[package]]+name = "simdutf8"+version = "0.1.5"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "e3a9fe34e3e7a50316060351f37187a3f546bce95496156754b601a5fa71b76e"++[[package]]+name = "slab"+version = "0.4.12"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5"++[[package]]+name = "smallvec"+version = "1.16.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "5b3dc8af474f516a851ff4bd12db780f948b9250ad37211e4eec0bccea54e01b"++[[package]]+name = "socket2"+version = "0.6.5"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "c3d1e2c7f27f8d4cb10542a02c49005dbd6e93095799d6f3be745fae9f8fedd4"+dependencies = [+ "libc",+ "windows-sys 0.61.2",+]++[[package]]+name = "spin"+version = "0.9.9"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "3763264f6b73151db08c50ff20d7d8a0b8796e021cdea7ceedad07b80155fa0e"++[[package]]+name = "spm_precompiled"+version = "0.1.4"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "5851699c4033c63636f7ea4cf7b7c1f1bf06d0cc03cfb42e711de5a5c46cf326"+dependencies = [+ "base64 0.13.1",+ "nom",+ "serde",+ "unicode-segmentation",+]++[[package]]+name = "stable_deref_trait"+version = "1.2.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596"++[[package]]+name = "static_assertions"+version = "1.1.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"++[[package]]+name = "statrs"+version = "0.18.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "2a3fe7c28c6512e766b0874335db33c94ad7b8f9054228ae1c2abd47ce7d335e"+dependencies = [+ "approx",+ "num-traits",+]++[[package]]+name = "strength_reduce"+version = "0.2.4"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "fe895eb47f22e2ddd4dabc02bce419d2e643c8e3b585c78158b349195bc24d82"++[[package]]+name = "strsim"+version = "0.11.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"++[[package]]+name = "subtle"+version = "2.6.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292"++[[package]]+name = "symlink"+version = "0.1.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "a7973cce6668464ea31f176d85b13c7ab3bba2cb3b77a2ed26abd7801688010a"++[[package]]+name = "symphonia"+version = "0.5.5"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "5773a4c030a19d9bfaa090f49746ff35c75dfddfa700df7a5939d5e076a57039"+dependencies = [+ "lazy_static",+ "symphonia-bundle-flac",+ "symphonia-bundle-mp3",+ "symphonia-codec-aac",+ "symphonia-codec-adpcm",+ "symphonia-codec-alac",+ "symphonia-codec-pcm",+ "symphonia-codec-vorbis",+ "symphonia-core",+ "symphonia-format-caf",+ "symphonia-format-isomp4",+ "symphonia-format-mkv",+ "symphonia-format-ogg",+ "symphonia-format-riff",+ "symphonia-metadata",+]++[[package]]+name = "symphonia-bundle-flac"+version = "0.5.5"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "c91565e180aea25d9b80a910c546802526ffd0072d0b8974e3ebe59b686c9976"+dependencies = [+ "log",+ "symphonia-core",+ "symphonia-metadata",+ "symphonia-utils-xiph",+]++[[package]]+name = "symphonia-bundle-mp3"+version = "0.5.5"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "4872dd6bb56bf5eac799e3e957aa1981086c3e613b27e0ac23b176054f7c57ed"+dependencies = [+ "lazy_static",+ "log",+ "symphonia-core",+ "symphonia-metadata",+]++[[package]]+name = "symphonia-codec-aac"+version = "0.5.5"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "4c263845aa86881416849c1729a54c7f55164f8b96111dba59de46849e73a790"+dependencies = [+ "lazy_static",+ "log",+ "symphonia-core",+]++[[package]]+name = "symphonia-codec-adpcm"+version = "0.5.5"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "2dddc50e2bbea4cfe027441eece77c46b9f319748605ab8f3443350129ddd07f"+dependencies = [+ "log",+ "symphonia-core",+]++[[package]]+name = "symphonia-codec-alac"+version = "0.5.5"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "8413fa754942ac16a73634c9dfd1500ed5c61430956b33728567f667fdd393ab"+dependencies = [+ "log",+ "symphonia-core",+]++[[package]]+name = "symphonia-codec-pcm"+version = "0.5.5"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "4e89d716c01541ad3ebe7c91ce4c8d38a7cf266a3f7b2f090b108fb0cb031d95"+dependencies = [+ "log",+ "symphonia-core",+]++[[package]]+name = "symphonia-codec-vorbis"+version = "0.5.5"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "f025837c309cd69ffef572750b4a2257b59552c5399a5e49707cc5b1b85d1c73"+dependencies = [+ "log",+ "symphonia-core",+ "symphonia-utils-xiph",+]++[[package]]+name = "symphonia-core"+version = "0.5.5"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "ea00cc4f79b7f6bb7ff87eddc065a1066f3a43fe1875979056672c9ef948c2af"+dependencies = [+ "arrayvec",+ "bitflags 1.3.2",+ "bytemuck",+ "lazy_static",+ "log",+]++[[package]]+name = "symphonia-format-caf"+version = "0.5.5"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "b8faf379316b6b6e6bbc274d00e7a592e0d63ff1a7e182ce8ba25e24edd3d096"+dependencies = [+ "log",+ "symphonia-core",+ "symphonia-metadata",+]++[[package]]+name = "symphonia-format-isomp4"+version = "0.5.5"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "243739585d11f81daf8dac8d9f3d18cc7898f6c09a259675fc364b382c30e0a5"+dependencies = [+ "encoding_rs",+ "log",+ "symphonia-core",+ "symphonia-metadata",+ "symphonia-utils-xiph",+]++[[package]]+name = "symphonia-format-mkv"+version = "0.5.5"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "122d786d2c43a49beb6f397551b4a050d8229eaa54c7ddf9ee4b98899b8742d0"+dependencies = [+ "lazy_static",+ "log",+ "symphonia-core",+ "symphonia-metadata",+ "symphonia-utils-xiph",+]++[[package]]+name = "symphonia-format-ogg"+version = "0.5.5"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "2b4955c67c1ed3aa8ae8428d04ca8397fbef6a19b2b051e73b5da8b1435639cb"+dependencies = [+ "log",+ "symphonia-core",+ "symphonia-metadata",+ "symphonia-utils-xiph",+]++[[package]]+name = "symphonia-format-riff"+version = "0.5.5"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "c2d7c3df0e7d94efb68401d81906eae73c02b40d5ec1a141962c592d0f11a96f"+dependencies = [+ "extended",+ "log",+ "symphonia-core",+ "symphonia-metadata",+]++[[package]]+name = "symphonia-metadata"+version = "0.5.5"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "36306ff42b9ffe6e5afc99d49e121e0bd62fe79b9db7b9681d48e29fa19e6b16"+dependencies = [+ "encoding_rs",+ "lazy_static",+ "log",+ "symphonia-core",+]++[[package]]+name = "symphonia-utils-xiph"+version = "0.5.5"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "ee27c85ab799a338446b68eec77abf42e1a6f1bb490656e121c6e27bfbab9f16"+dependencies = [+ "symphonia-core",+ "symphonia-metadata",+]++[[package]]+name = "syn"+version = "2.0.119"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297"+dependencies = [+ "proc-macro2",+ "quote",+ "unicode-ident",+]++[[package]]+name = "syn"+version = "3.0.9"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "d78c8dee4c7bf0e14673097256fed6142ce9d3b85a408189d07482442145823b"+dependencies = [+ "proc-macro2",+ "quote",+ "unicode-ident",+]++[[package]]+name = "sync_wrapper"+version = "1.0.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263"+dependencies = [+ "futures-core",+]++[[package]]+name = "synstructure"+version = "0.14.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "901704edd0dfe137f1987838ee4f259e4e063c31371bdb423f7ae38ec6f77f02"+dependencies = [+ "proc-macro2",+ "quote",+ "syn 3.0.9",+]++[[package]]+name = "sysctl"+version = "0.6.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "01198a2debb237c62b6826ec7081082d951f46dbb64b0e8c7649a452230d1dfc"+dependencies = [+ "bitflags 2.13.2",+ "byteorder",+ "enum-as-inner",+ "libc",+ "thiserror 1.0.69",+ "walkdir",+]++[[package]]+name = "sysinfo"+version = "0.39.6"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "d2071df9448915b71c4fe6d25deaf1c22f12bd234f01540b77312bb8e41361e6"+dependencies = [+ "libc",+ "memchr",+ "ntapi",+ "objc2-core-foundation",+ "objc2-io-kit",+ "objc2-open-directory",+ "windows",+]++[[package]]+name = "system-configuration"+version = "0.7.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "a13f3d0daba03132c0aa9767f98351b3488edc2c100cda2d2ec2b04f3d8d3c8b"+dependencies = [+ "bitflags 2.13.2",+ "core-foundation 0.9.4",+ "system-configuration-sys",+]++[[package]]+name = "system-configuration-sys"+version = "0.6.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "8e1d1b10ced5ca923a1fcb8d03e96b8d3268065d724548c0211415ff6ac6bac4"+dependencies = [+ "core-foundation-sys",+ "libc",+]++[[package]]+name = "tempfile"+version = "3.27.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd"+dependencies = [+ "fastrand",+ "getrandom 0.4.3",+ "once_cell",+ "rustix",+ "windows-sys 0.61.2",+]++[[package]]+name = "thiserror"+version = "1.0.69"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52"+dependencies = [+ "thiserror-impl 1.0.69",+]++[[package]]+name = "thiserror"+version = "2.0.21"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "09e52cb86a36cede5cb101bf8908837b3e4c6e5e59fe7fd85c23fb56200d189e"+dependencies = [+ "thiserror-impl 2.0.21",+]++[[package]]+name = "thiserror-impl"+version = "1.0.69"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1"+dependencies = [+ "proc-macro2",+ "quote",+ "syn 2.0.119",+]++[[package]]+name = "thiserror-impl"+version = "2.0.21"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "fe5197923287db20a58125f0bc85c062f7f2c892de97b18c356f9efb14b28524"+dependencies = [+ "proc-macro2",+ "quote",+ "syn 3.0.9",+]++[[package]]+name = "thread_local"+version = "1.1.10"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "1ad99c4c6d32803332c548b1af0540b357b3f5fc0be8f6c6bfe8b2e6ae784070"+dependencies = [+ "cfg-if",+]++[[package]]+name = "time"+version = "0.3.55"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "cdb87b95ec50ddfa440816d227a17b2ccbdda963a316a727fda0fc4334f7d134"+dependencies = [+ "deranged",+ "num-conv",+ "powerfmt",+ "serde_core",+ "time-core",+ "time-macros",+]++[[package]]+name = "time-core"+version = "0.1.9"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "9e1c906769ad99c88eaa54e728060edef082f8e358ff32030cb7c7d315e81109"++[[package]]+name = "time-macros"+version = "0.2.32"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "7e689342a48d2ea927c87ea50cabf8594854bf940e9310208848d680d668ed85"+dependencies = [+ "num-conv",+ "time-core",+]++[[package]]+name = "tinystr"+version = "0.8.4"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "b1e27c91459209c2986af3dcf603a5a74a4368754ce37414f59acc971167f643"+dependencies = [+ "displaydoc",+ "zerovec",+]++[[package]]+name = "tinyvec"+version = "1.13.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "fd3ca314f692efd6c868f8408f53fe444634a845f96c028b97d35f6a1f79f0ee"++[[package]]+name = "tokenizers"+version = "0.23.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "7afbf6e88718afcc138bad01d6ccc3051dbbc3b2ce9793d8b8a3aeb610969cfc"+dependencies = [+ "ahash",+ "compact_str",+ "daachorse",+ "dary_heap",+ "derive_builder",+ "esaxx-rs",+ "fancy-regex",+ "getrandom 0.3.4",+ "itertools",+ "log",+ "macro_rules_attribute",+ "monostate",+ "paste",+ "rand 0.9.5",+ "rayon",+ "rayon-cond",+ "regex",+ "regex-syntax",+ "serde",+ "serde_json",+ "spm_precompiled",+ "thiserror 2.0.21",+ "unicode-normalization-alignments",+ "unicode-segmentation",+ "unicode_categories",+]++[[package]]+name = "tokio"+version = "1.53.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "ce3335fa71841cda333a58d7615b03901380ecf09d59b3296d21f8bbac0dde4e"+dependencies = [+ "bytes",+ "libc",+ "mio",+ "pin-project-lite",+ "signal-hook-registry",+ "socket2",+ "tokio-macros",+ "windows-sys 0.61.2",+]++[[package]]+name = "tokio-macros"+version = "2.7.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "78773a2a397f451582ce068015985c33193cf6dea8b74d2a639fe457b2f07b0e"+dependencies = [+ "proc-macro2",+ "quote",+ "syn 3.0.9",+]++[[package]]+name = "tokio-retry"+version = "0.3.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "4a129d95275ebf4c493ec53bf0f8cd95f5ac161bc4f381700809a54f595d4470"+dependencies = [+ "pin-project-lite",+ "rand 0.10.3",+ "tokio",+]++[[package]]+name = "tokio-rustls"+version = "0.26.6"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "c9cc2678c2cdd569ef8215e2afd7954ada2ae20b4fdd2c5fe6139a3b02d105db"+dependencies = [+ "rustls",+ "tokio",+]++[[package]]+name = "tokio-stream"+version = "0.1.19"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "a3d06f0b082ba57c26b79407372e57cf2a1e28124f78e9479fe80322cf53420b"+dependencies = [+ "futures-core",+ "pin-project-lite",+ "tokio",+]++[[package]]+name = "tokio-util"+version = "0.7.20"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "e464cf451ba96ebfc6f9b6542f17ee8b8956e33f1e40d9690624e59d7a7f8a4b"+dependencies = [+ "bytes",+ "futures-core",+ "futures-sink",+ "libc",+ "pin-project-lite",+ "tokio",+]++[[package]]+name = "tokio_with_wasm"+version = "0.8.8"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "34e40fbbbd95441133fe9483f522db15dbfd26dc636164ebd8f2dd28759a6aa6"+dependencies = [+ "js-sys",+ "tokio",+ "tokio_with_wasm_proc",+ "wasm-bindgen",+ "wasm-bindgen-futures",+ "web-sys",+]++[[package]]+name = "tokio_with_wasm_proc"+version = "0.8.8"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "d01145a2c788d6aae4cd653afec1e8332534d7d783d01897cefcafe4428de992"+dependencies = [+ "quote",+ "syn 2.0.119",+]++[[package]]+name = "tower"+version = "0.5.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "ebe5ef63511595f1344e2d5cfa636d973292adc0eec1f0ad45fae9f0851ab1d4"+dependencies = [+ "futures-core",+ "futures-util",+ "pin-project-lite",+ "sync_wrapper",+ "tokio",+ "tower-layer",+ "tower-service",+]++[[package]]+name = "tower-http"+version = "0.6.11"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "4cfcf7e2740e6fc6d4d688b4ef00650406bb94adf4731e43c096c3a19fe40840"+dependencies = [+ "bitflags 2.13.2",+ "bytes",+ "futures-util",+ "http",+ "http-body",+ "pin-project-lite",+ "tower",+ "tower-layer",+ "tower-service",+ "url",+]++[[package]]+name = "tower-layer"+version = "0.3.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e"++[[package]]+name = "tower-service"+version = "0.3.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3"++[[package]]+name = "tracing"+version = "0.1.44"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "63e71662fa4b2a2c3a26f570f037eb95bb1f85397f3cd8076caed2f026a6d100"+dependencies = [+ "pin-project-lite",+ "tracing-attributes",+ "tracing-core",+]++[[package]]+name = "tracing-appender"+version = "0.2.5"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "050686193eb999b4bb3bc2acfa891a13da00f79734704c4b8b4ef1a10b368a3c"+dependencies = [+ "crossbeam-channel",+ "symlink",+ "thiserror 2.0.21",+ "time",+ "tracing-subscriber",+]++[[package]]+name = "tracing-attributes"+version = "0.1.31"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "7490cfa5ec963746568740651ac6781f701c9c5ea257c58e057f3ba8cf69e8da"+dependencies = [+ "proc-macro2",+ "quote",+ "syn 2.0.119",+]++[[package]]+name = "tracing-core"+version = "0.1.36"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "db97caf9d906fbde555dd62fa95ddba9eecfd14cb388e4f491a66d74cd5fb79a"+dependencies = [+ "once_cell",+ "valuable",+]++[[package]]+name = "tracing-log"+version = "0.2.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3"+dependencies = [+ "log",+ "once_cell",+ "tracing-core",+]++[[package]]+name = "tracing-serde"+version = "0.2.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "704b1aeb7be0d0a84fc9828cae51dab5970fee5088f83d1dd7ee6f6246fc6ff1"+dependencies = [+ "serde",+ "tracing-core",+]++[[package]]+name = "tracing-subscriber"+version = "0.3.23"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "cb7f578e5945fb242538965c2d0b04418d38ec25c79d160cd279bf0731c8d319"+dependencies = [+ "matchers",+ "nu-ansi-term",+ "once_cell",+ "regex-automata",+ "serde",+ "serde_json",+ "sharded-slab",+ "smallvec",+ "thread_local",+ "tracing",+ "tracing-core",+ "tracing-log",+ "tracing-serde",+]++[[package]]+name = "transpose"+version = "0.2.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "1ad61aed86bc3faea4300c7aee358b4c6d0c8d6ccc36524c96e4c92ccf26e77e"+dependencies = [+ "num-integer",+ "strength_reduce",+]++[[package]]+name = "try-lock"+version = "0.2.5"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b"++[[package]]+name = "twox-hash"+version = "2.1.5"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "86a801b3cea342a06d468c8710662aa29e5e05e4f5c0d62f00bbb7f2ad7941c2"++[[package]]+name = "typenum"+version = "1.20.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20"++[[package]]+name = "typewit"+version = "1.15.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "214ca0b2191785cbc06209b9ca1861e048e39b5ba33574b3cedd58363d5bb5f6"++[[package]]+name = "unicase"+version = "2.10.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "357cc3acc6a036009fd6c973ed009037c732d60d0b4f6c673e9041497482a28f"++[[package]]+name = "unicode-ident"+version = "1.0.27"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563"++[[package]]+name = "unicode-normalization-alignments"+version = "0.1.12"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "43f613e4fa046e69818dd287fdc4bc78175ff20331479dab6e1b0f98d57062de"+dependencies = [+ "smallvec",+]++[[package]]+name = "unicode-segmentation"+version = "1.13.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "c6f5d3c3b1bf09027a88a6bc961fc00497d651009560b5463668dc81b0fa87a8"++[[package]]+name = "unicode_categories"+version = "0.1.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "39ec24b3121d976906ece63c9daad25b85969647682eee313cb5779fdd69e14e"++[[package]]+name = "unsafe-libyaml"+version = "0.2.11"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "673aac59facbab8a9007c7f6108d11f63b603f7cabff99fabf650fea5c32b861"++[[package]]+name = "untrusted"+version = "0.9.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1"++[[package]]+name = "url"+version = "2.5.8"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "ff67a8a4397373c3ef660812acab3268222035010ab8680ec4215f38ba3d0eed"+dependencies = [+ "form_urlencoded",+ "idna",+ "percent-encoding",+ "serde",+]++[[package]]+name = "urlencoding"+version = "2.1.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "daf8dba3b7eb870caf1ddeed7bc9d2a049f3cfdfae7cb521b087cc33ae4c49da"++[[package]]+name = "utf8_iter"+version = "1.0.4"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be"++[[package]]+name = "utf8parse"+version = "0.2.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"++[[package]]+name = "uuid"+version = "1.28.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "7cc1186384beb7dd8eedea376413fd654937285ea6c9cfbb928dc3043ea4b606"+dependencies = [+ "getrandom 0.4.3",+ "js-sys",+ "wasm-bindgen",+]++[[package]]+name = "valuable"+version = "0.1.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65"++[[package]]+name = "version_check"+version = "0.9.5"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"++[[package]]+name = "walkdir"+version = "2.5.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b"+dependencies = [+ "same-file",+ "winapi-util",+]++[[package]]+name = "want"+version = "0.3.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "ec4cdd0dd910afe868b7ef477227d8d538b46b3075031afee8a9f2acb0a2ed0b"+dependencies = [+ "try-lock",+]++[[package]]+name = "wasi"+version = "0.11.1+wasi-snapshot-preview1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b"++[[package]]+name = "wasi"+version = "0.14.7+wasi-0.2.4"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "883478de20367e224c0090af9cf5f9fa85bed63a95c1abf3afc5c083ebc06e8c"+dependencies = [+ "wasip2",+]++[[package]]+name = "wasip2"+version = "1.0.4+wasi-0.2.12"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "b67efb37e106e55ce722a510d6b5f9c17f083e5fc79afc2badeb12cc313d9487"+dependencies = [+ "wit-bindgen",+]++[[package]]+name = "wasite"+version = "1.0.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "66fe902b4a6b8028a753d5424909b764ccf79b7a209eac9bf97e59cda9f71a42"+dependencies = [+ "wasi 0.14.7+wasi-0.2.4",+]++[[package]]+name = "wasm-bindgen"+version = "0.2.129"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "9bb54f33acc68fd454578d9820b0bde1a1a3d17aa17bb7b6595806d02886d409"+dependencies = [+ "cfg-if",+ "once_cell",+ "rustversion",+ "wasm-bindgen-macro",+ "wasm-bindgen-shared",+]++[[package]]+name = "wasm-bindgen-futures"+version = "0.4.79"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "3cbab34de2d982e9b48e18d216d04c4a6f641066ff19ffb699980f591ee3610e"+dependencies = [+ "js-sys",+ "tokio",+ "wasm-bindgen",+]++[[package]]+name = "wasm-bindgen-macro"+version = "0.2.129"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "2e29d0c35b16e224a7eeb5cd2d25e3e1968fbd65604117b44d3b789d00ee8535"+dependencies = [+ "quote",+ "wasm-bindgen-macro-support",+]++[[package]]+name = "wasm-bindgen-macro-support"+version = "0.2.129"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "6f501a8bc3719dba86ef8ae4728879c08001bea749eb1333ac5b91e040e2a6b7"+dependencies = [+ "bumpalo",+ "proc-macro2",+ "quote",+ "syn 3.0.9",+ "wasm-bindgen-shared",+]++[[package]]+name = "wasm-bindgen-shared"+version = "0.2.129"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "23f0c9c52aa7cd7d77769a4cfe2a9adb1b331f489a41d912ce14513d5ab995c6"+dependencies = [+ "unicode-ident",+]++[[package]]+name = "wasm-streams"+version = "0.5.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "9d1ec4f6517c9e11ae630e200b2b65d193279042e28edd4a2cda233e46670bbb"+dependencies = [+ "futures-util",+ "js-sys",+ "wasm-bindgen",+ "wasm-bindgen-futures",+ "web-sys",+]++[[package]]+name = "web-sys"+version = "0.3.106"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "88261b9deccee56594c11a3460c462c41f58d148598fe70ad77070126a68aba4"+dependencies = [+ "js-sys",+ "wasm-bindgen",+]++[[package]]+name = "web-time"+version = "1.1.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb"+dependencies = [+ "js-sys",+ "wasm-bindgen",+]++[[package]]+name = "webpki-root-certs"+version = "1.0.9"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "b96554aa2acc8ccdb7e1c9a58a7a68dd5d13bccc69cd124cb09406db612a1c9b"+dependencies = [+ "rustls-pki-types",+]++[[package]]+name = "whoami"+version = "2.1.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "626c4bac6755d76ffc12cb01b2eac751db1996b9e0041de9aa02c8c211ddc82c"+dependencies = [+ "libc",+ "libredox",+ "objc2-system-configuration",+ "wasite",+ "web-sys",+]++[[package]]+name = "winapi"+version = "0.3.9"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"+dependencies = [+ "winapi-i686-pc-windows-gnu",+ "winapi-x86_64-pc-windows-gnu",+]++[[package]]+name = "winapi-i686-pc-windows-gnu"+version = "0.4.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"++[[package]]+name = "winapi-util"+version = "0.1.11"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22"+dependencies = [+ "windows-sys 0.61.2",+]++[[package]]+name = "winapi-x86_64-pc-windows-gnu"+version = "0.4.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"++[[package]]+name = "windows"+version = "0.62.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "527fadee13e0c05939a6a05d5bd6eec6cd2e3dbd648b9f8e447c6518133d8580"+dependencies = [+ "windows-collections",+ "windows-core",+ "windows-future",+ "windows-numerics",+]++[[package]]+name = "windows-collections"+version = "0.3.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "23b2d95af1a8a14a3c7367e1ed4fc9c20e0a26e79551b1454d72583c97cc6610"+dependencies = [+ "windows-core",+]++[[package]]+name = "windows-core"+version = "0.62.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "b8e83a14d34d0623b51dce9581199302a221863196a1dde71a7663a4c2be9deb"+dependencies = [+ "windows-implement",+ "windows-interface",+ "windows-link",+ "windows-result",+ "windows-strings",+]++[[package]]+name = "windows-future"+version = "0.3.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "e1d6f90251fe18a279739e78025bd6ddc52a7e22f921070ccdc67dde84c605cb"+dependencies = [+ "windows-core",+ "windows-link",+ "windows-threading",+]++[[package]]+name = "windows-implement"+version = "0.60.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf"+dependencies = [+ "proc-macro2",+ "quote",+ "syn 2.0.119",+]++[[package]]+name = "windows-interface"+version = "0.59.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358"+dependencies = [+ "proc-macro2",+ "quote",+ "syn 2.0.119",+]++[[package]]+name = "windows-link"+version = "0.2.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"++[[package]]+name = "windows-numerics"+version = "0.3.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "6e2e40844ac143cdb44aead537bbf727de9b044e107a0f1220392177d15b0f26"+dependencies = [+ "windows-core",+ "windows-link",+]++[[package]]+name = "windows-registry"+version = "0.6.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "02752bf7fbdcce7f2a27a742f798510f3e5ad88dbe84871e5168e2120c3d5720"+dependencies = [+ "windows-link",+ "windows-result",+ "windows-strings",+]++[[package]]+name = "windows-result"+version = "0.4.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "7781fa89eaf60850ac3d2da7af8e5242a5ea78d1a11c49bf2910bb5a73853eb5"+dependencies = [+ "windows-link",+]++[[package]]+name = "windows-strings"+version = "0.5.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "7837d08f69c77cf6b07689544538e017c1bfcf57e34b4c0ff58e6c2cd3b37091"+dependencies = [+ "windows-link",+]++[[package]]+name = "windows-sys"+version = "0.52.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"+dependencies = [+ "windows-targets",+]++[[package]]+name = "windows-sys"+version = "0.61.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc"+dependencies = [+ "windows-link",+]++[[package]]+name = "windows-targets"+version = "0.52.6"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"+dependencies = [+ "windows_aarch64_gnullvm",+ "windows_aarch64_msvc",+ "windows_i686_gnu",+ "windows_i686_gnullvm",+ "windows_i686_msvc",+ "windows_x86_64_gnu",+ "windows_x86_64_gnullvm",+ "windows_x86_64_msvc",+]++[[package]]+name = "windows-threading"+version = "0.2.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "3949bd5b99cafdf1c7ca86b43ca564028dfe27d66958f2470940f73d86d75b37"+dependencies = [+ "windows-link",+]++[[package]]+name = "windows_aarch64_gnullvm"+version = "0.52.6"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"++[[package]]+name = "windows_aarch64_msvc"+version = "0.52.6"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"++[[package]]+name = "windows_i686_gnu"+version = "0.52.6"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"++[[package]]+name = "windows_i686_gnullvm"+version = "0.52.6"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"++[[package]]+name = "windows_i686_msvc"+version = "0.52.6"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"++[[package]]+name = "windows_x86_64_gnu"+version = "0.52.6"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"++[[package]]+name = "windows_x86_64_gnullvm"+version = "0.52.6"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"++[[package]]+name = "windows_x86_64_msvc"+version = "0.52.6"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"++[[package]]+name = "wit-bindgen"+version = "0.57.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "1ebf944e87a7c253233ad6766e082e3cd714b5d03812acc24c318f549614536e"++[[package]]+name = "writeable"+version = "0.6.4"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "3ad82d2a33cdc9674dc7465672f271e096168fcdbe0f799d9e6db8c5892679dc"++[[package]]+name = "xet-client"+version = "1.7.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "15500e5fc9e17be15224f9e34cb07d41fb2805d9dbbf7bd3507c982fd1eb3efd"+dependencies = [+ "anyhow",+ "async-trait",+ "base64 0.22.1",+ "bytes",+ "chrono",+ "crc32fast",+ "futures",+ "http",+ "hyper",+ "more-asserts",+ "rand 0.10.3",+ "redb",+ "reqwest",+ "reqwest-middleware",+ "serde",+ "serde_json",+ "serde_repr",+ "statrs",+ "tempfile",+ "thiserror 2.0.21",+ "tokio",+ "tokio-retry",+ "tokio_with_wasm",+ "tracing",+ "url",+ "urlencoding",+ "uuid",+ "web-time",+ "xet-core-structures",+ "xet-runtime",+]++[[package]]+name = "xet-core-structures"+version = "1.7.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "5080d5803c8bf15fa56ef934050a46b225801bad3ea4cb8bb3c46c5c37976516"+dependencies = [+ "async-trait",+ "base64 0.22.1",+ "blake3",+ "bytemuck",+ "bytes",+ "countio",+ "futures",+ "futures-util",+ "getrandom 0.4.3",+ "heapify",+ "itertools",+ "lz4_flex",+ "more-asserts",+ "rand 0.10.3",+ "regex",+ "safe-transmute",+ "serde",+ "static_assertions",+ "thiserror 2.0.21",+ "tokio",+ "tokio-util",+ "tracing",+ "uuid",+ "web-time",+ "xet-runtime",+]++[[package]]+name = "xet-data"+version = "1.7.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "1287a1657fb67de846030f6605a9960dcdad401c467b490657e6e909d2e0d1c0"+dependencies = [+ "anyhow",+ "async-trait",+ "bytes",+ "chrono",+ "gearhash",+ "http",+ "itertools",+ "more-asserts",+ "rand 0.10.3",+ "serde",+ "serde_json",+ "sha2 0.11.1",+ "tempfile",+ "thiserror 2.0.21",+ "tokio",+ "tokio-util",+ "tokio_with_wasm",+ "tracing",+ "url",+ "uuid",+ "web-time",+ "xet-client",+ "xet-core-structures",+ "xet-runtime",+]++[[package]]+name = "xet-runtime"+version = "1.7.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "921953c885ce83e02b21e8d26444b75c78c9e83076699ced08d5c6fc1cdb48ac"+dependencies = [+ "anyhow",+ "async-trait",+ "bytes",+ "chrono",+ "colored",+ "const-str",+ "ctor",+ "dirs",+ "futures",+ "git-version",+ "humantime",+ "konst",+ "libc",+ "more-asserts",+ "oneshot",+ "pin-project",+ "rand 0.10.3",+ "reqwest",+ "serde",+ "serde_json",+ "shellexpand",+ "sysinfo",+ "thiserror 2.0.21",+ "tokio",+ "tokio-util",+ "tokio_with_wasm",+ "tracing",+ "tracing-appender",+ "tracing-subscriber",+ "web-time",+ "whoami",+ "winapi",+]++[[package]]+name = "xn"+version = "0.2.12"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "bec55897173439907dd60c759df3d4793aa73af979336cf7f6f999532812d59f"+dependencies = [+ "byteorder",+ "half",+ "libc",+ "libm",+ "memmap2",+ "num-traits",+ "num_cpus",+ "rand 0.9.5",+ "rand_distr",+ "rayon",+ "safetensors",+ "thiserror 2.0.21",+ "tracing",+ "xn-gemm",+ "yoke",+]++[[package]]+name = "xn-gemm"+version = "0.20.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "0f5bcb177032cca83eb7aae3de9d6fa9cc5cbb29a0090bb07ef8880cf82e3c7d"+dependencies = [+ "dyn-stack",+ "num-complex",+ "num-traits",+ "paste",+ "raw-cpuid",+ "seq-macro",+ "xn-gemm-c32",+ "xn-gemm-c64",+ "xn-gemm-common",+ "xn-gemm-f16",+ "xn-gemm-f32",+ "xn-gemm-f64",+]++[[package]]+name = "xn-gemm-c32"+version = "0.20.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "9137ec88a81f5510045a45b1d5fce27b67f9748b8d83400b39163a51ecae6f04"+dependencies = [+ "dyn-stack",+ "num-complex",+ "num-traits",+ "paste",+ "raw-cpuid",+ "seq-macro",+ "xn-gemm-common",+]++[[package]]+name = "xn-gemm-c64"+version = "0.20.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "e9ab9a0de939c339098e4b20da0aa863f66dfbf1a4b0396dff9a13645443d510"+dependencies = [+ "dyn-stack",+ "num-complex",+ "num-traits",+ "paste",+ "raw-cpuid",+ "seq-macro",+ "xn-gemm-common",+]++[[package]]+name = "xn-gemm-common"+version = "0.20.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "c22f986c37636c5cbc0a6b4e120a5315ef8ba25615504c554a075e3b3286f642"+dependencies = [+ "bytemuck",+ "dyn-stack",+ "half",+ "libm",+ "num-complex",+ "num-traits",+ "once_cell",+ "paste",+ "pulp",+ "raw-cpuid",+ "rayon",+ "seq-macro",+ "sysctl",+]++[[package]]+name = "xn-gemm-f16"+version = "0.20.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "c971a82caab9a5960a7c3a6c32bf0c5b6bf5b76492f403997825a4d308b7f233"+dependencies = [+ "dyn-stack",+ "half",+ "num-complex",+ "num-traits",+ "paste",+ "raw-cpuid",+ "rayon",+ "seq-macro",+ "xn-gemm-common",+ "xn-gemm-f32",+]++[[package]]+name = "xn-gemm-f32"+version = "0.20.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "56b8b45a6a11b6d9fedcea8be60bb175c1278170484e7956b29bae507e3c3039"+dependencies = [+ "dyn-stack",+ "num-complex",+ "num-traits",+ "paste",+ "raw-cpuid",+ "seq-macro",+ "xn-gemm-common",+]++[[package]]+name = "xn-gemm-f64"+version = "0.20.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "2be9f43b557116575751164c7ce2c9e1a7a5bde9e944843bf87ca3314da7eb41"+dependencies = [+ "dyn-stack",+ "num-complex",+ "num-traits",+ "paste",+ "raw-cpuid",+ "seq-macro",+ "xn-gemm-common",+]++[[package]]+name = "yoke"+version = "0.8.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "709fe23a0424b6a435d82152b1bd3fdfb0833487d5fa90d05d42762a9891fef5"+dependencies = [+ "stable_deref_trait",+ "yoke-derive",+ "zerofrom",+]++[[package]]+name = "yoke-derive"+version = "0.8.4"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "ec8ebde2db3681e8c9980cc27822030e68752690ddfa9473e739aeb4dbde6d71"+dependencies = [+ "proc-macro2",+ "quote",+ "syn 3.0.9",+ "synstructure",+]++[[package]]+name = "zerocopy"+version = "0.8.63"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "e5fe1f8f1b06191a00962174c61aa5005e0bb391a6d80d07e24d115c01a92ed8"+dependencies = [+ "zerocopy-derive",+]++[[package]]+name = "zerocopy-derive"+version = "0.8.63"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "863ad3ac83293fb4d740aedbfdc9240dd8d1a50c1099acd76ce80ce7c7230c7f"+dependencies = [+ "proc-macro2",+ "quote",+ "syn 2.0.119",+]++[[package]]+name = "zerofrom"+version = "0.1.8"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "0ec05a11813ea801ff6d75110ad09cd0824ddba17dfe17128ea0d5f68e6c5272"+dependencies = [+ "zerofrom-derive",+]++[[package]]+name = "zerofrom-derive"+version = "0.1.8"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "f75b4683f6c7f45248d4d64056a24298c6281e0993356d7d1b4a1a962ef10d4a"+dependencies = [+ "proc-macro2",+ "quote",+ "syn 3.0.9",+ "synstructure",+]++[[package]]+name = "zeroize"+version = "1.9.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "e13084392c5e4bc371903e2935a5eaeed24905a7511356b883835e18a78f6879"++[[package]]+name = "zerotrie"+version = "0.2.5"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "4ea269c3bd32f0a32c321907a2ae912ba6f4649bb0fc764a15627e99a7095a3f"+dependencies = [+ "displaydoc",+ "yoke",+ "zerofrom",+]++[[package]]+name = "zerovec"+version = "0.11.8"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "bb0464e17806c1d976d5cba29399c7f08e516e279e2ba493f63123b5fca67dd8"+dependencies = [+ "yoke",+ "zerofrom",+ "zerovec-derive",+]++[[package]]+name = "zerovec-derive"+version = "0.11.6"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "34df6fc39dbd26ddc9c10e6a2984476e13acce22e64e4487636ef494369225da"+dependencies = [+ "proc-macro2",+ "quote",+ "syn 3.0.9",+]++[[package]]+name = "zmij"+version = "1.0.23"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b"diff --git a/rust/Cargo.toml b/rust/Cargo.tomlnew file mode 100644index 0000000..692c5fc--- /dev/null+++ b/rust/Cargo.toml@@ -0,0 +1,51 @@+[package]+name = "pocket-tts"+# Kept in step with the Python package in ../pyproject.toml.+version = "3.3.0"+edition = "2024"+description = "Kyutai's pocket-sized text-to-speech, as a standalone binary with the CLI of the Python package"+license = "MIT"+repository = "https://github.com/kyutai-labs/pocket-tts"+publish = false++[[bin]]+name = "pocket-tts"+path = "src/main.rs"++[features]+default = []+# Apple's Accelerate framework for the f32 matmuls, for macOS builds.+accelerate = ["ptts/accelerate"]++[dependencies]+# The model itself: https://github.com/gradium-ai/xn-ptts, pinned to a commit since its API is+# still moving between release candidates.+ptts = { git = "https://github.com/gradium-ai/xn-ptts", rev = "1bfe079c9a4c778dbe4edd9d4d5bca9df3e46b3f", default-features = false, features = ["hf", "audio"] }+# Must be the version ptts uses, its tensors cross the boundary.+xn = "0.2.11"++anyhow = "1"+axum = { version = "0.8", default-features = false, features = ["http1", "tokio", "multipart", "query", "json", "form"] }+clap = { version = "4", features = ["derive", "env"] }+half = "2"+hf-hub = { version = "1.0", features = ["blocking"] }+log = "0.4"+rand = { version = "0.9", default-features = false, features = ["std", "std_rng", "os_rng"] }+rand_distr = "0.5"+reqwest = { version = "0.13", features = ["blocking"] }+safetensors = "0.7"+sentencepiece = { version = "0.14", features = ["static"] }+serde = { version = "1", features = ["derive"] }+serde_json = "1"+serde_yaml = "0.9"+sha2 = "0.10"+symphonia = { version = "0.5.3", features = ["all"] }+tempfile = "3"+tokenizers = { version = "0.23.1", default-features = false, features = ["fancy-regex"] }+tokio = { version = "1", features = ["macros", "rt-multi-thread", "signal", "sync", "net"] }+tokio-stream = "0.1"+tower-http = { version = "0.6", features = ["cors"] }++[profile.release]+codegen-units = 1+lto = "thin"diff --git a/rust/README.md b/rust/README.mdnew file mode 100644index 0000000..26860c1--- /dev/null+++ b/rust/README.md@@ -0,0 +1,25 @@+# pocket-tts, the standalone binary++A port of the `pocket-tts` CLI (`generate`, `serve`, `export-voice`) that runs without Python,+built on the [xn-ptts](https://github.com/gradium-ai/xn-ptts) implementation of the model. The+release workflow (`.github/workflows/rust-release.yml`) attaches its builds to every GitHub+release.++```bash+cargo build --release+./target/release/pocket-tts generate --text "Hello world."+```++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`.++## Differences with the Python CLI++- Runs on the CPU only (`--device cpu`), and `--quantize` uses xn's int8 weights.++- `serve --reload` is accepted and ignored. The server answers `/`, `/health` and `/tts` as the+ Python one does, without FastAPI's `/docs`.+- The noise is drawn from a different generator, so the audio differs sample by sample from the+ Python package's, as two runs with different seeds would. The seed is fixed, so a command+ always gives the same audio; `POCKET_TTS_SEED` sets another one.+- The tensor operations use 4 threads by default; set `RAYON_NUM_THREADS` to change it.diff --git a/rust/build.rs b/rust/build.rsnew file mode 100644index 0000000..7487eee--- /dev/null+++ b/rust/build.rs@@ -0,0 +1,46 @@+//! Embeds the model configs and the web page of the Python package, so the binary needs neither+//! a Python install nor a copy of these files.++use std::fmt::Write as _;+use std::path::PathBuf;++fn main() {+ let manifest_dir = PathBuf::from(std::env::var("CARGO_MANIFEST_DIR").unwrap());+ let package_dir = manifest_dir.join("..").join("pocket_tts");+ let configs_dir = package_dir.join("config");+ let index_html = package_dir.join("static").join("index.html");++ println!("cargo:rerun-if-changed={}", configs_dir.display());+ println!("cargo:rerun-if-changed={}", index_html.display());++ let mut configs: Vec<(String, PathBuf)> = std::fs::read_dir(&configs_dir)+ .unwrap_or_else(|e| panic!("cannot list {}: {e}", configs_dir.display()))+ .map(|entry| entry.unwrap().path())+ .filter(|path| path.extension().is_some_and(|ext| ext == "yaml"))+ .map(|path| {+ (+ path.file_stem().unwrap().to_string_lossy().into_owned(),+ path,+ )+ })+ .collect();+ configs.sort();++ let mut out = String::from("/// The configs of `pocket_tts/config`, by language name.\n");+ out.push_str("pub const CONFIGS: &[(&str, &str)] = &[\n");+ for (name, path) in configs.iter() {+ println!("cargo:rerun-if-changed={}", path.display());+ writeln!(out, " ({name:?}, include_str!({:?})),", path).unwrap();+ }+ out.push_str("];\n\n");+ out.push_str("/// The page `serve` answers `/` with.\n");+ writeln!(+ out,+ "pub const INDEX_HTML: &str = include_str!({:?});",+ index_html+ )+ .unwrap();++ let out_path = PathBuf::from(std::env::var("OUT_DIR").unwrap()).join("embedded.rs");+ std::fs::write(out_path, out).unwrap();+}diff --git a/rust/src/audio.rs b/rust/src/audio.rsnew file mode 100644index 0000000..83d76cf--- /dev/null+++ b/rust/src/audio.rs@@ -0,0 +1,327 @@+//! Audio input and output: port of `pocket_tts/data/audio.py` and+//! `pocket_tts/data/audio_utils.py`.++use anyhow::{Context, Result};+use std::io::{Seek, SeekFrom, Write};+use std::path::Path;++/// Reads an audio file as mono samples, averaging the channels, and its sample rate.+///+/// TODO: upstream to xn-ptts: `ptts::audio::decode_file` keeps only the first channel and does not+/// trim the MP3/AAC encoder delay, which libsndfile (the Python package's decoder) does.+pub fn audio_read(path: &Path) -> Result<(Vec<f32>, u32)> {+ use symphonia::core::audio::SampleBuffer;+ use symphonia::core::codecs::DecoderOptions;+ use symphonia::core::errors::Error as SymphoniaError;+ use symphonia::core::formats::FormatOptions;+ use symphonia::core::io::MediaSourceStream;+ use symphonia::core::meta::MetadataOptions;+ use symphonia::core::probe::Hint;++ let file =+ std::fs::File::open(path).with_context(|| format!("cannot open {}", path.display()))?;+ let stream = MediaSourceStream::new(Box::new(file), Default::default());+ let mut hint = Hint::new();+ if let Some(ext) = path.extension().and_then(|ext| ext.to_str()) {+ hint.with_extension(ext);+ }+ // Gapless: the encoder delay and padding of MP3 and AAC are trimmed, as libsndfile (the+ // Python package's decoder) does, rather than heard as a shift.+ let format_options = FormatOptions {+ enable_gapless: true,+ ..Default::default()+ };+ let probed = symphonia::default::get_probe()+ .format(&hint, stream, &format_options, &MetadataOptions::default())+ .with_context(|| format!("unsupported audio format: {}", path.display()))?;+ let mut format = probed.format;+ let track = format+ .default_track()+ .with_context(|| format!("no audio track in {}", path.display()))?;+ let track_id = track.id;+ let mut sample_rate = track.codec_params.sample_rate;+ let mut decoder = symphonia::default::get_codecs()+ .make(&track.codec_params, &DecoderOptions::default())+ .with_context(|| format!("unsupported audio codec in {}", path.display()))?;++ let mut samples = Vec::new();+ loop {+ let packet = match format.next_packet() {+ Ok(packet) => packet,+ Err(SymphoniaError::IoError(e)) if e.kind() == std::io::ErrorKind::UnexpectedEof => {+ break;+ }+ Err(SymphoniaError::ResetRequired) => break,+ Err(e) => return Err(e).with_context(|| format!("cannot read {}", path.display())),+ };+ if packet.track_id() != track_id {+ continue;+ }+ let decoded = match decoder.decode(&packet) {+ Ok(decoded) => decoded,+ // A corrupt packet is skipped, as decoders conventionally do.+ Err(SymphoniaError::DecodeError(_)) => continue,+ Err(e) => return Err(e).with_context(|| format!("cannot decode {}", path.display())),+ };+ let spec = *decoded.spec();+ sample_rate.get_or_insert(spec.rate);+ let channels = spec.channels.count();+ let mut buffer = SampleBuffer::<f32>::new(decoded.capacity() as u64, spec);+ buffer.copy_interleaved_ref(decoded);+ for frame in buffer.samples().chunks_exact(channels) {+ samples.push(frame.iter().sum::<f32>() / channels as f32);+ }+ }+ let sample_rate =+ sample_rate.with_context(|| format!("no sample rate in {}", path.display()))?;+ Ok((samples, sample_rate))+}++/// End a voice prompt on exactly `pause_sec` of silence.+///+/// Training prompts end inside the pause between two words. A prompt that stops on speech makes+/// the model continue that utterance, and one that ends on a long silence delays the onset. The+/// trailing silence (20 ms frames more than `floor_db` below the loudest one) is cut, the last+/// `fade_sec` of what remains is faded out, and `pause_sec` of zeros is appended.+pub fn end_on_pause(wav: &[f32], sample_rate: usize) -> Vec<f32> {+ let (pause_sec, fade_sec, floor_db) = (0.08, 0.02, 35.0f32);+ let frame = ((0.02 * sample_rate as f64) as usize).max(1);+ let n = wav.len() / frame;+ if n == 0 {+ return wav.to_vec();+ }+ let db: Vec<f32> = wav[..n * frame]+ .chunks_exact(frame)+ .map(|chunk| {+ let rms = (chunk.iter().map(|v| v * v).sum::<f32>() / frame as f32).sqrt();+ 20.0 * (rms + 1e-12).log10()+ })+ .collect();+ let max_db = db.iter().copied().fold(f32::NEG_INFINITY, f32::max);+ let last_loud = db.iter().rposition(|&d| d > max_db - floor_db).unwrap_or(0);+ let end = (last_loud + 1) * frame;+ let mut out = wav[..end].to_vec();+ let fade = ((fade_sec * sample_rate as f64) as usize).min(end);+ for i in 0..fade {+ let gain = if fade == 1 {+ 1.0+ } else {+ 1.0 - i as f32 / (fade - 1) as f32+ };+ out[end - fade + i] *= gain;+ }+ out.extend(std::iter::repeat_n(+ 0.0,+ (pause_sec * sample_rate as f64) as usize,+ ));+ out+}++/// Seconds of audio buffered before the first write, from `FIRST_CHUNK_LENGTH_SECONDS`.+fn first_chunk_length_seconds() -> f64 {+ std::env::var("FIRST_CHUNK_LENGTH_SECONDS")+ .ok()+ .and_then(|v| v.parse().ok())+ .unwrap_or(0.0)+}++/// An output a WAV is streamed to: a file, whose header is fixed up at the end, or a pipe.+pub trait WavSink: Write {+ /// Moves back to the start to rewrite the header; `false` when the sink cannot.+ fn rewind(&mut self) -> bool;+}++impl WavSink for std::fs::File {+ fn rewind(&mut self) -> bool {+ self.seek(SeekFrom::Start(0)).is_ok()+ }+}++/// A sink that cannot seek, such as a pipe or an HTTP response.+pub struct Unseekable<W: Write>(pub W);++impl<W: Write> Write for Unseekable<W> {+ fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> {+ self.0.write(buf)+ }++ fn flush(&mut self) -> std::io::Result<()> {+ self.0.flush()+ }+}++impl<W: Write> WavSink for Unseekable<W> {+ fn rewind(&mut self) -> bool {+ false+ }+}++/// Port of `StreamingWAVWriter`: 16-bit mono PCM, written as it is generated.+///+/// An unseekable output gets the header Python's `wave` module writes for it, announcing a+/// billion frames; a file gets its sizes fixed when the stream ends.+pub struct StreamingWavWriter<S: WavSink> {+ sink: S,+ sample_rate: u32,+ seekable: bool,+ data_bytes: u64,+ first_chunk_buffer: Option<Vec<u8>>,+}++const UNSEEKABLE_NFRAMES: u64 = 1_000_000_000;++impl<S: WavSink> StreamingWavWriter<S> {+ pub fn new(sink: S, sample_rate: u32, seekable: bool) -> Self {+ Self {+ sink,+ sample_rate,+ seekable,+ data_bytes: 0,+ first_chunk_buffer: Some(Vec::new()),+ }+ }++ fn write_header(&mut self, data_bytes: u64) -> std::io::Result<()> {+ let data_bytes = data_bytes.min(u32::MAX as u64 - 36) as u32;+ let mut header = Vec::with_capacity(44);+ header.extend_from_slice(b"RIFF");+ header.extend_from_slice(&(36 + data_bytes).to_le_bytes());+ header.extend_from_slice(b"WAVEfmt ");+ header.extend_from_slice(&16u32.to_le_bytes());+ header.extend_from_slice(&1u16.to_le_bytes()); // PCM+ header.extend_from_slice(&1u16.to_le_bytes()); // mono+ header.extend_from_slice(&self.sample_rate.to_le_bytes());+ header.extend_from_slice(&(self.sample_rate * 2).to_le_bytes());+ header.extend_from_slice(&2u16.to_le_bytes());+ header.extend_from_slice(&16u16.to_le_bytes());+ header.extend_from_slice(b"data");+ header.extend_from_slice(&data_bytes.to_le_bytes());+ self.sink.write_all(&header)+ }++ pub fn write_header_initial(&mut self) -> std::io::Result<()> {+ let initial = if self.seekable {+ 0+ } else {+ UNSEEKABLE_NFRAMES * 2+ };+ self.write_header(initial)+ }++ fn write_raw(&mut self, bytes: &[u8]) -> std::io::Result<()> {+ self.data_bytes += bytes.len() as u64;+ self.sink.write_all(bytes)?;+ self.sink.flush()+ }++ pub fn write_pcm(&mut self, audio: &[f32]) -> std::io::Result<()> {+ let bytes: Vec<u8> = audio+ .iter()+ .flat_map(|&v| ((v.clamp(-1.0, 1.0) * 32767.0) as i16).to_le_bytes())+ .collect();+ if let Some(buffer) = self.first_chunk_buffer.as_mut() {+ buffer.extend_from_slice(&bytes);+ let target = (self.sample_rate as f64 * first_chunk_length_seconds()) as usize * 2;+ if buffer.len() < target {+ return Ok(());+ }+ return self.flush_first_chunk();+ }+ self.write_raw(&bytes)+ }++ fn flush_first_chunk(&mut self) -> std::io::Result<()> {+ if let Some(buffer) = self.first_chunk_buffer.take() {+ self.write_raw(&buffer)?;+ }+ Ok(())+ }++ /// Writes 200 ms of silence, to ensure proper playback, and fixes up the header.+ pub fn finalize(mut self) -> std::io::Result<S> {+ self.flush_first_chunk()?;+ let silence = vec![0u8; (self.sample_rate as f64 * 0.2) as usize * 2];+ self.write_raw(&silence)?;+ if self.seekable && self.sink.rewind() {+ self.write_header(self.data_bytes)?;+ }+ self.sink.flush()?;+ Ok(self.sink)+ }+}++/// Opens `path` for a WAV, `-` being stdout. Returns whether the output can be seeked, which a+/// stdout redirected to a file can.+pub fn open_output(path: &str) -> Result<(Box<dyn WavSinkBox>, bool)> {+ if path == "-" {+ let stdout = stdout_file()?;+ let seekable = stdout.is_some_and(|mut f| f.stream_position().is_ok());+ match stdout_file()? {+ Some(file) if seekable => Ok((Box::new(file), true)),+ _ => Ok((Box::new(Unseekable(std::io::stdout())), false)),+ }+ } else {+ let file = std::fs::File::create(path).with_context(|| format!("cannot create {path}"))?;+ Ok((Box::new(file), true))+ }+}++pub trait WavSinkBox: WavSink + Send {}+impl<T: WavSink + Send> WavSinkBox for T {}++impl WavSink for Box<dyn WavSinkBox> {+ fn rewind(&mut self) -> bool {+ (**self).rewind()+ }+}++/// A handle on stdout as a file, to seek it when it is redirected to one.+#[cfg(unix)]+fn stdout_file() -> Result<Option<std::fs::File>> {+ use std::os::fd::AsFd;+ let fd = std::io::stdout().as_fd().try_clone_to_owned()?;+ Ok(Some(std::fs::File::from(fd)))+}++#[cfg(windows)]+fn stdout_file() -> Result<Option<std::fs::File>> {+ use std::os::windows::io::AsHandle;+ let handle = std::io::stdout().as_handle().try_clone_to_owned()?;+ Ok(Some(std::fs::File::from(handle)))+}++#[cfg(not(any(unix, windows)))]+fn stdout_file() -> Result<Option<std::fs::File>> {+ Ok(None)+}++#[cfg(test)]+mod tests {+ use super::*;++ #[test]+ fn end_on_pause_trims_silence_and_appends_a_pause() {+ let sr = 1000;+ let mut wav = vec![0.5f32; 500];+ wav.extend(vec![0.0f32; 500]);+ let out = end_on_pause(&wav, sr);+ assert_eq!(out.len(), 500 + 80);+ assert_eq!(out[0], 0.5);+ assert_eq!(out[499], 0.0);+ assert!(out[500..].iter().all(|&v| v == 0.0));+ }++ #[test]+ fn unseekable_header_announces_a_billion_frames() {+ let mut out = Vec::new();+ {+ let mut writer = StreamingWavWriter::new(Unseekable(&mut out), 24000, false);+ writer.write_header_initial().unwrap();+ writer.write_pcm(&[0.5, -2.0]).unwrap();+ writer.finalize().unwrap();+ }+ assert_eq!(&out[40..44], &2_000_000_000u32.to_le_bytes());+ assert_eq!(&out[44..48], &[0xff, 0x3f, 0x01, 0x80]);+ assert_eq!(out.len(), 44 + 4 + 24000 / 5 * 2);+ }+}diff --git a/rust/src/config.rs b/rust/src/config.rsnew file mode 100644index 0000000..b1e43d4--- /dev/null+++ b/rust/src/config.rs@@ -0,0 +1,392 @@+//! The YAML model configs of `pocket_tts/utils/config.py`, and their translation to the+//! `config.json` schema of xn-ptts.+//!+//! The configs of the Python package are embedded in the binary; any other YAML file, local or+//! remote, is read with the same schema, unknown fields being an error as with pydantic.++use anyhow::{Context, Result, bail};+use serde::Deserialize;+use std::collections::BTreeMap;++include!(concat!(env!("OUT_DIR"), "/embedded.rs"));++#[derive(Debug, Clone, Deserialize)]+#[serde(deny_unknown_fields)]+pub struct FlowConfig {+ pub dim: usize,+ pub depth: usize,+ #[serde(rename = "type", default = "default_flow_type")]+ pub kind: String,+}++fn default_flow_type() -> String {+ "lsd".to_string()+}++#[derive(Debug, Clone, Deserialize)]+#[serde(deny_unknown_fields)]+pub struct FlowLMTransformerConfig {+ pub hidden_scale: usize,+ pub max_period: f64,+ pub d_model: usize,+ pub num_heads: usize,+ pub num_layers: usize,+}++#[derive(Debug, Clone, Deserialize)]+#[serde(deny_unknown_fields)]+pub struct LookupTable {+ pub dim: usize,+ pub n_bins: usize,+ pub tokenizer: String,+ pub tokenizer_path: String,+}++#[derive(Debug, Clone, Deserialize)]+#[serde(deny_unknown_fields)]+pub struct FlowLMConfig {+ /// Unused: the model always runs in float32 (or int8 with `--quantize`).+ #[allow(dead_code)]+ pub dtype: String,+ pub flow: FlowConfig,+ pub transformer: FlowLMTransformerConfig,+ pub lookup_table: LookupTable,+ #[serde(default)]+ pub weights_path: Option<String>,+ #[serde(default)]+ pub insert_bos_before_voice: bool,+}++#[derive(Debug, Clone, Deserialize)]+#[serde(deny_unknown_fields)]+pub struct SEANetConfig {+ pub dimension: usize,+ pub channels: usize,+ pub n_filters: usize,+ pub n_residual_layers: usize,+ pub ratios: Vec<usize>,+ pub kernel_size: usize,+ pub residual_kernel_size: usize,+ pub last_kernel_size: usize,+ pub dilation_base: usize,+ pub pad_mode: String,+ pub compress: usize,+}++#[derive(Debug, Clone, Deserialize)]+#[serde(deny_unknown_fields)]+pub struct MimiTransformerConfig {+ pub d_model: usize,+ pub input_dimension: usize,+ pub output_dimensions: Vec<usize>,+ pub num_heads: usize,+ pub num_layers: usize,+ pub layer_scale: f64,+ pub context: usize,+ #[serde(default = "default_max_period")]+ pub max_period: f64,+ pub dim_feedforward: usize,+}++fn default_max_period() -> f64 {+ 10000.0+}++#[derive(Debug, Clone, Deserialize)]+#[serde(deny_unknown_fields)]+pub struct QuantizerConfig {+ pub dimension: usize,+ pub output_dimension: usize,+}++#[derive(Debug, Clone, Deserialize)]+#[serde(deny_unknown_fields)]+pub struct MimiConfig {+ /// Unused: Mimi always runs in float32.+ #[allow(dead_code)]+ pub dtype: String,+ pub sample_rate: usize,+ pub channels: usize,+ pub frame_rate: f64,+ pub seanet: SEANetConfig,+ pub transformer: MimiTransformerConfig,+ pub quantizer: QuantizerConfig,+ #[serde(default)]+ pub weights_path: Option<String>,+ #[serde(default)]+ pub inner_dim: Option<usize>,+ #[serde(default)]+ pub outer_dim: Option<usize>,+}++#[derive(Debug, Clone, Deserialize)]+#[serde(deny_unknown_fields)]+pub struct Config {+ pub flow_lm: FlowLMConfig,+ pub mimi: MimiConfig,+ #[serde(default)]+ pub weights_path: Option<String>,+ #[serde(default)]+ pub weights_path_without_voice_cloning: Option<String>,+ #[serde(default)]+ pub pad_with_spaces_for_short_inputs: bool,+ #[serde(default)]+ pub remove_semicolons: bool,+ #[serde(default = "default_true")]+ pub append_terminal_punctuation: bool,+ #[serde(default = "default_true")]+ pub capitalize_first_letter: bool,+ /// Per-character rewrites applied before tokenization, `None` or "" deletes.+ #[serde(default)]+ pub replace_characters: BTreeMap<String, Option<String>>,+ #[serde(default)]+ pub model_recommended_frames_after_eos: Option<usize>,+ #[serde(default = "default_temperature")]+ pub default_temperature: f32,+}++fn default_true() -> bool {+ true+}++fn default_temperature() -> f32 {+ 0.3+}++/// The sampler head of the flow LM, from the config's `flow.type`.+#[derive(Debug, Clone, Copy, PartialEq, Eq)]+pub enum FlowType {+ /// Lagrangian Self Distillation: two time conditions.+ Lsd,+ /// Optimal-transport flow matching: one time condition, Euler integration.+ FlowMatching,+ /// No time condition, the head maps the noise to a sample in one step.+ Drifting,+}++/// Where a config came from.+#[derive(Debug, Clone, PartialEq, Eq)]+pub enum Origin {+ /// One of the embedded configs, which can use the predefined voices.+ Language(String),+ /// A local path or a URL.+ Custom(String),+}++impl Origin {+ /// What the Python package's `TTSModel.origin` prints as, which picks the default text of+ /// the web page.+ pub fn display_path(&self) -> String {+ match self {+ Self::Language(language) => format!("pocket_tts/config/{language}.yaml"),+ Self::Custom(path) => path.clone(),+ }+ }+}++pub fn available_languages() -> Vec<&'static str> {+ CONFIGS.iter().map(|(name, _)| *name).collect()+}++impl Config {+ pub fn parse(yaml: &str) -> Result<Self> {+ let config: Self = serde_yaml::from_str(yaml)?;+ config.validate()?;+ Ok(config)+ }++ /// Reads the config of `language`, or the YAML file at `config` (local, `https://` or+ /// `hf://`), defaulting to English.+ pub fn load(language: Option<&str>, config: Option<&str>) -> Result<(Self, Origin)> {+ if config.is_some() && language.is_some() {+ bail!("Cannot specify both config and language, please choose one or the other.")+ }+ let (yaml, origin) = match config {+ None => {+ let language = language.unwrap_or(crate::defaults::DEFAULT_LANGUAGE);+ let Some((_, yaml)) = CONFIGS.iter().find(|(name, _)| *name == language) else {+ bail!(+ "Config file not found: pocket_tts/config/{language}.yaml. Did you make a typo? Available languages: {:?}",+ available_languages()+ )+ };+ log::info!("Loading model from config at {language}.yaml...");+ (yaml.to_string(), Origin::Language(language.to_string()))+ }+ Some(path) => {+ // hf:// paths may carry a "@revision" suffix, strip it before checking the extension.+ let suffix_source = if path.starts_with("hf://") {+ path.split('@').next().unwrap()+ } else {+ path+ };+ if !(suffix_source.ends_with(".yaml") || suffix_source.ends_with(".yml")) {+ bail!("Config should be a path to a YAML file ending with .yaml")+ }+ let local = crate::download::download_if_necessary(path)?;+ if !local.exists() {+ bail!(+ "Config file not found: {}. Did you make a typo?",+ local.display()+ )+ }+ log::info!("Loading model from config at {path}...");+ let yaml = std::fs::read_to_string(&local)+ .with_context(|| format!("cannot read {}", local.display()))?;+ (yaml, Origin::Custom(path.to_string()))+ }+ };+ let config = Self::parse(&yaml).with_context(|| format!("invalid config {origin:?}"))?;+ Ok((config, origin))+ }++ pub fn flow_type(&self) -> Result<FlowType> {+ match self.flow_lm.flow.kind.as_str() {+ "lsd" => Ok(FlowType::Lsd),+ "flow_matching" => Ok(FlowType::FlowMatching),+ "drifting" => Ok(FlowType::Drifting),+ other => bail!("Unknown flow type: {other}"),+ }+ }++ /// The width of the speaker latents, which the Mimi encoder's downsampling produces.+ pub fn speaker_latent_dim(&self) -> usize {+ self.mimi.inner_dim.unwrap_or(self.mimi.seanet.dimension)+ }++ /// The configuration is checked up front against what xn-ptts can run, so that a model it+ /// cannot represent fails with an explanation rather than a shape mismatch.+ fn validate(&self) -> Result<()> {+ self.flow_type()?;+ let mimi = &self.mimi;+ let dimension = mimi.seanet.dimension;+ // TODO: upstream to xn-ptts. Its Mimi decoder upsamples from `dimension` channels; an+ // `outer_dim` (the `in_dimension` of `ConvTrUpsample1d`) other than that needs support+ // in `MimiConfig`.+ if mimi+ .outer_dim+ .is_some_and(|outer_dim| outer_dim != dimension)+ {+ bail!("mimi.outer_dim different from mimi.seanet.dimension is not supported")+ }+ // TODO: upstream to xn-ptts. Its SEANet always pads with zeros.+ if mimi.seanet.pad_mode != "constant" {+ bail!(+ "mimi.seanet.pad_mode {:?} is not supported",+ mimi.seanet.pad_mode+ )+ }+ if mimi.transformer.input_dimension != dimension+ || mimi.transformer.output_dimensions != [dimension]+ {+ bail!("the Mimi transformer must map mimi.seanet.dimension to itself")+ }+ if mimi.channels != 1 || mimi.seanet.channels != 1 {+ bail!("only mono Mimi models are supported")+ }+ for key in self.replace_characters.keys() {+ if key.chars().count() != 1 {+ bail!("string keys in translate table must be of length 1, got {key:?}")+ }+ }+ Ok(())+ }++ /// The `config.json` of xn-ptts that describes the same model.+ pub fn to_ptts(+ &self,+ sampler_decode_steps: usize,+ eos_threshold: f32,+ ) -> Result<ptts::tts_model::TTSConfig> {+ let flow_lm = &self.flow_lm;+ let mimi = &self.mimi;+ let mut config = serde_json::json!({+ "flow_lm": {+ "d_model": flow_lm.transformer.d_model,+ "num_heads": flow_lm.transformer.num_heads,+ "num_layers": flow_lm.transformer.num_layers,+ "dim_feedforward": flow_lm.transformer.d_model * flow_lm.transformer.hidden_scale,+ "max_period": flow_lm.transformer.max_period,+ "n_bins": flow_lm.lookup_table.n_bins,+ "lut_dim": flow_lm.lookup_table.dim,+ "flow_dim": flow_lm.flow.dim,+ "flow_depth": flow_lm.flow.depth,+ "ldim": mimi.quantizer.dimension,+ },+ "mimi": {+ "channels": mimi.channels,+ "sample_rate": mimi.sample_rate,+ "frame_rate": mimi.frame_rate,+ "dimension": mimi.seanet.dimension,+ "quantizer_dimension": mimi.quantizer.dimension,+ "quantizer_output_dimension": mimi.quantizer.output_dimension,+ "n_filters": mimi.seanet.n_filters,+ "n_residual_layers": mimi.seanet.n_residual_layers,+ "ratios": mimi.seanet.ratios,+ "kernel_size": mimi.seanet.kernel_size,+ "last_kernel_size": mimi.seanet.last_kernel_size,+ "residual_kernel_size": mimi.seanet.residual_kernel_size,+ "dilation_base": mimi.seanet.dilation_base,+ "compress": mimi.seanet.compress,+ "transformer_d_model": mimi.transformer.d_model,+ "transformer_num_heads": mimi.transformer.num_heads,+ "transformer_num_layers": mimi.transformer.num_layers,+ "transformer_layer_scale": mimi.transformer.layer_scale,+ // TODO: upstream to xn-ptts. Its Mimi attention reaches `context` positions back,+ // which is `context + 1` keys with the current one, where pocket-tts (and moshi)+ // attend to `context` keys in all. One less gives the same window.+ "transformer_context": mimi.transformer.context.saturating_sub(1),+ "transformer_max_period": mimi.transformer.max_period,+ "transformer_dim_feedforward": mimi.transformer.dim_feedforward,+ "downsample_channel_wise": false,+ },+ "lsd_decode_steps": sampler_decode_steps,+ "eos_threshold": eos_threshold,+ "model_id": null,+ });+ if flow_lm.insert_bos_before_voice {+ // pocket-tts prepends `bos_before_voice` to the voice embedding, which is what a+ // `speaker_wavs` prefix sink does in xn-ptts: `[empty text, sink, voice]`. The check+ // that comes with sinks wants the CFG null branch to have no audio, which pocket-tts+ // never runs anyway.+ config["prefix_sinks"] = serde_json::json!({ "speaker_wavs": {} });+ config["cfg_null_audio_empty"] = serde_json::json!(true);+ }+ Ok(serde_json::from_value(config)?)+ }+}++#[cfg(test)]+mod tests {+ use super::*;++ #[test]+ fn every_embedded_config_parses_and_translates() {+ for (name, yaml) in CONFIGS {+ let config = Config::parse(yaml).unwrap_or_else(|e| panic!("{name}: {e:#}"));+ config+ .to_ptts(1, -4.0)+ .unwrap_or_else(|e| panic!("{name}: {e:#}"));+ }+ assert!(available_languages().contains(&"english"));+ }++ #[test]+ fn unknown_fields_are_rejected() {+ let (_, yaml) = CONFIGS.iter().find(|(name, _)| *name == "english").unwrap();+ let yaml = format!("{yaml}\nnot_a_field: 1\n");+ assert!(Config::parse(&yaml).is_err());+ }++ #[test]+ fn drifting_config_is_recognized() {+ let (_, yaml) = CONFIGS+ .iter()+ .find(|(name, _)| *name == "english_drifting_26-09")+ .unwrap();+ assert_eq!(+ Config::parse(yaml).unwrap().flow_type().unwrap(),+ FlowType::Drifting+ );+ }+}diff --git a/rust/src/defaults.rs b/rust/src/defaults.rsnew file mode 100644index 0000000..ce811c0--- /dev/null+++ b/rust/src/defaults.rs@@ -0,0 +1,210 @@+//! Port of `pocket_tts/default_parameters.py` and of the voice catalog in `pocket_tts/utils/utils.py`.++pub const DEFAULT_LANGUAGE: &str = "english";+pub const DEFAULT_SAMPLER_DECODE_STEPS: usize = 1;+pub const DEFAULT_EOS_THRESHOLD: f32 = -4.0;+pub const MAX_TOKEN_PER_CHUNK: usize = 50;++const DEFAULT_TEXT_FOR_LANGUAGE: &[(&str, &str)] = &[+ (+ "english",+ "Hello world. I am Kyutai's Pocket TTS. I'm fast enough to run on small CPUs. I hope you'll like me.",+ ),+ (+ "french",+ "Bonjour le monde. Je suis le TTS de poche de Kyutai. Je suis assez rapide pour fonctionner sur de petits CPU. J'espère que vous m'aimerez.",+ ),+ (+ "german",+ "Hallo Welt. Ich bin Pocket TTS von Kyutai. Ich bin schnell genug, um auch auf kleinen CPUs zu laufen. Ich hoffe, ich gefalle dir.",+ ),+ (+ "portuguese",+ "Olá mundo. Eu sou o Pocket TTS da Kyutai. Sou rápido o suficiente para rodar em CPUs pequenas. Espero que você goste de mim.",+ ),+ (+ "italian",+ "Ciao mondo. Sono il Pocket TTS di Kyutai. Sono abbastanza veloce da funzionare su piccole CPU. Spero che ti piacerò.",+ ),+ (+ "dutch",+ "Hallo wereld. Ik ben Pocket TTS van Kyutai. Ik ben snel genoeg om op kleine CPU's te draaien. Ik hoop dat je me leuk vindt.",+ ),+ (+ "spanish",+ "Hola mundo. Soy el Pocket TTS de Kyutai. Soy lo suficientemente rápido para funcionar en pequeñas CPU. Espero que te guste.",+ ),+];++const DEFAULT_VOICE_FOR_LANGUAGE: &[(&str, &str)] = &[+ ("italian", "giovanni"),+ ("spanish", "lola"),+ ("german", "juergen"),+ ("portuguese", "rafael"),+ ("french", "estelle"),+ ("dutch", "daan"),+];+const DEFAULT_VOICE_FALLBACK: &str = "alba";++/// The audio each predefined voice was computed from.+pub const ORIGINS_OF_PREDEFINED_VOICES: &[(&str, &str)] = &[+ (+ "cosette",+ "hf://kyutai/tts-voices/expresso/ex04-ex02_confused_001_channel1_499s.wav",+ ),+ (+ "marius",+ "hf://kyutai/tts-voices/voice-donations/Selfie.wav",+ ),+ (+ "javert",+ "hf://kyutai/tts-voices/voice-donations/Butter.wav",+ ),+ ("alba", "hf://kyutai/tts-voices/alba-mackenna/casual.wav"),+ (+ "jean",+ "hf://kyutai/tts-voices/ears/p010/freeform_speech_01_enhanced.wav",+ ),+ ("anna", "hf://kyutai/tts-voices/vctk/p228_023_enhanced.wav"),+ ("vera", "hf://kyutai/tts-voices/vctk/p229_023_enhanced.wav"),+ (+ "fantine",+ "hf://kyutai/tts-voices/vctk/p244_023_enhanced.wav",+ ),+ (+ "charles",+ "hf://kyutai/tts-voices/vctk/p254_023_enhanced.wav",+ ),+ ("paul", "hf://kyutai/tts-voices/vctk/p259_023_enhanced.wav"),+ (+ "eponine",+ "hf://kyutai/tts-voices/vctk/p262_023_enhanced.wav",+ ),+ (+ "azelma",+ "hf://kyutai/tts-voices/vctk/p303_023_enhanced.wav",+ ),+ (+ "george",+ "hf://kyutai/tts-voices/vctk/p315_023_enhanced.wav",+ ),+ ("mary", "hf://kyutai/tts-voices/vctk/p333_023_enhanced.wav"),+ ("jane", "hf://kyutai/tts-voices/vctk/p339_023_enhanced.wav"),+ (+ "michael",+ "hf://kyutai/tts-voices/vctk/p360_023_enhanced.wav",+ ),+ ("eve", "hf://kyutai/tts-voices/vctk/p361_023_enhanced.wav"),+ (+ "bill_boerst",+ "hf://kyutai/tts-voices/voice-zero/bill_boerst.wav",+ ),+ (+ "peter_yearsley",+ "hf://kyutai/tts-voices/voice-zero/peter_yearsley.wav",+ ),+ (+ "stuart_bell",+ "hf://kyutai/tts-voices/voice-zero/stuart_bell.wav",+ ),+ (+ "caro_davy",+ "hf://kyutai/tts-voices/voice-zero/caro_davy.wav",+ ),+ (+ "giovanni",+ "hf://kyutai/pocket-tts/common_voice_it_36520747-enhanced-v2.mp3@64ab7d24c479d736a83b8cc666c4a776fca30fda",+ ),+ (+ "lola",+ "hf://kyutai/pocket-tts/common_voice_es_19762977-enhanced-v2.mp3@64ab7d24c479d736a83b8cc666c4a776fca30fda",+ ),+ (+ "juergen",+ "hf://kyutai/pocket-tts/de-DE-juergen.mp3@64ab7d24c479d736a83b8cc666c4a776fca30fda",+ ),+ (+ "rafael",+ "hf://kyutai/pocket-tts/g-Vi8PgmSY0-enhanced-v2.wav@64ab7d24c479d736a83b8cc666c4a776fca30fda",+ ),+ (+ "daan",+ "hf://kyutai/pocket-tts/cml_tts_nl_11290_9412_000030_0001.flac@2dd944b099d06bb9edbd221fef138685711d9bf0",+ ),+ (+ "estelle",+ "hf://kyutai/tts-voices/unmute-prod-website/developpeuse-3.wav@1fc7395b7e012e2bbebfca14b942a4ef62ccc899",+ ),+];++pub fn is_predefined_voice(name: &str) -> bool {+ ORIGINS_OF_PREDEFINED_VOICES+ .iter()+ .any(|(voice, _)| *voice == name)+}++pub fn predefined_voice_names() -> Vec<&'static str> {+ ORIGINS_OF_PREDEFINED_VOICES+ .iter()+ .map(|(name, _)| *name)+ .collect()+}++/// The state of a predefined voice, precomputed with the released weights of `language`.+pub fn get_predefined_voice(language: &str, name: &str) -> String {+ format!(+ "hf://kyutai/pocket-tts-without-voice-cloning/languages/{language}/embeddings/{name}.safetensors@ab248779e0718743c013e20b2d812ace7c8f4bf7"+ )+}++pub fn get_default_text_for_language(language: Option<&str>) -> &'static str {+ for (key, text) in DEFAULT_TEXT_FOR_LANGUAGE {+ if language.is_some_and(|language| language.contains(key)) {+ return text;+ }+ }+ DEFAULT_TEXT_FOR_LANGUAGE[0].1+}++/// The voice to use when the user didn't pick one.+///+/// `config` and `checkpoint` both mean custom weights, which cannot use the predefined voices,+/// hence the audio file instead of the voice name.+pub fn get_default_voice_for_language(language: Option<&str>, custom_weights: bool) -> String {+ if custom_weights {+ return ORIGINS_OF_PREDEFINED_VOICES+ .iter()+ .find(|(name, _)| *name == DEFAULT_VOICE_FALLBACK)+ .map(|(_, origin)| origin.to_string())+ .unwrap();+ }+ for (key, voice) in DEFAULT_VOICE_FOR_LANGUAGE {+ if language.is_some_and(|language| language.contains(key)) {+ return voice.to_string();+ }+ }+ DEFAULT_VOICE_FALLBACK.to_string()+}++#[cfg(test)]+mod tests {+ use super::*;++ #[test]+ fn defaults_follow_the_language_substring() {+ assert!(get_default_text_for_language(Some("french_24l")).starts_with("Bonjour"));+ assert!(get_default_text_for_language(None).starts_with("Hello"));+ assert_eq!(+ get_default_voice_for_language(Some("italian_24l"), false),+ "giovanni"+ );+ assert_eq!(+ get_default_voice_for_language(Some("english_2026-04"), false),+ "alba"+ );+ assert_eq!(+ get_default_voice_for_language(Some("italian"), true),+ "hf://kyutai/tts-voices/alba-mackenna/casual.wav"+ );+ }+}diff --git a/rust/src/download.rs b/rust/src/download.rsnew file mode 100644index 0000000..4829ea7--- /dev/null+++ b/rust/src/download.rs@@ -0,0 +1,100 @@+//! Port of `download_if_necessary` from `pocket_tts/utils/utils.py`: `hf://` paths go through the+//! Hugging Face cache, shared with the Python package, and `http(s)://` URLs through+//! `~/.cache/pocket_tts`.++use anyhow::{Context, Result, bail};+use sha2::{Digest, Sha256};+use std::path::{Path, PathBuf};++pub fn download_if_necessary(file_path: &str) -> Result<PathBuf> {+ if file_path.starts_with("http://") || file_path.starts_with("https://") {+ download_url(file_path)+ } else if let Some(rest) = file_path.strip_prefix("hf://") {+ let (repo_id, filename, revision) = split_hf_path(rest)?;+ download_hf(repo_id, &filename, revision)+ .with_context(|| format!("cannot download {file_path}"))+ } else {+ Ok(PathBuf::from(file_path))+ }+}++/// `owner/name/path/in/repo[@revision]` into its parts.+fn split_hf_path(path: &str) -> Result<(&str, String, Option<&str>)> {+ let parts: Vec<&str> = path.split('/').collect();+ if parts.len() < 3 {+ bail!("`hf://{path}` should look like hf://<owner>/<repo>/<file>[@revision]")+ }+ let repo_end = parts[0].len() + 1 + parts[1].len();+ let repo_id = &path[..repo_end];+ let filename = &path[repo_end + 1..];+ match filename.split_once('@') {+ Some((filename, revision)) => Ok((repo_id, filename.to_string(), Some(revision))),+ None => Ok((repo_id, filename.to_string(), None)),+ }+}++/// The client reads `HF_TOKEN`, `HF_ENDPOINT`, `HF_HOME` and the token `hf auth login` stores.+fn download_hf(repo_id: &str, filename: &str, revision: Option<&str>) -> Result<PathBuf> {+ let client = hf_hub::HFClientSync::new()?;+ let (owner, name) = hf_hub::split_id(repo_id);+ let path = client+ .model(owner, name)+ .download_file()+ .filename(filename)+ .maybe_revision(revision.map(str::to_string))+ .send()?;+ Ok(path)+}++pub fn cache_directory() -> Result<PathBuf> {+ let home = std::env::home_dir().context("cannot locate the home directory")?;+ let dir = home.join(".cache").join("pocket_tts");+ std::fs::create_dir_all(&dir).with_context(|| format!("cannot create {}", dir.display()))?;+ Ok(dir)+}++fn download_url(url: &str) -> Result<PathBuf> {+ let url_path = url.split(['?', '#']).next().unwrap_or(url);+ let url_path = url_path.splitn(4, '/').nth(3).unwrap_or("");+ let suffix = Path::new(url_path)+ .extension()+ .map(|ext| format!(".{}", ext.to_string_lossy()))+ .unwrap_or_default();+ let digest = Sha256::digest(url.as_bytes());+ let hex: String = digest.iter().map(|b| format!("{b:02x}")).collect();+ let cached_file = cache_directory()?.join(format!("{hex}{suffix}"));+ if !cached_file.exists() {+ let response = reqwest::blocking::get(url)+ .and_then(|r| r.error_for_status())+ .with_context(|| format!("cannot download {url}"))?;+ let bytes = response+ .bytes()+ .with_context(|| format!("cannot download {url}"))?;+ let partial = cached_file.with_extension("partial");+ std::fs::write(&partial, &bytes)?;+ std::fs::rename(&partial, &cached_file)?;+ }+ Ok(cached_file)+}++#[cfg(test)]+mod tests {+ use super::*;++ #[test]+ fn hf_paths_split_like_python() {+ assert_eq!(+ split_hf_path("kyutai/pocket-tts/languages/english/model.safetensors@abc").unwrap(),+ (+ "kyutai/pocket-tts",+ "languages/english/model.safetensors".to_string(),+ Some("abc")+ )+ );+ assert_eq!(+ split_hf_path("user/repo/config.yaml").unwrap(),+ ("user/repo", "config.yaml".to_string(), None)+ );+ assert!(split_hf_path("user/repo").is_err());+ }+}diff --git a/rust/src/logging.rs b/rust/src/logging.rsnew file mode 100644index 0000000..e1c5ca9--- /dev/null+++ b/rust/src/logging.rs@@ -0,0 +1,38 @@+//! Logs as the Python package prints them: `LEVEL: message` on stderr, for this crate only.++struct Logger {+ level: log::LevelFilter,+}++impl log::Log for Logger {+ fn enabled(&self, metadata: &log::Metadata) -> bool {+ metadata.level() <= self.level && metadata.target().starts_with("pocket_tts")+ }++ fn log(&self, record: &log::Record) {+ if !self.enabled(record.metadata()) {+ return;+ }+ let level = match record.level() {+ log::Level::Error => "ERROR",+ log::Level::Warn => "WARNING",+ log::Level::Info => "INFO",+ log::Level::Debug => "DEBUG",+ log::Level::Trace => "TRACE",+ };+ eprintln!("{level}: {}", record.args());+ }++ fn flush(&self) {}+}++/// `quiet` keeps the errors only.+pub fn init(quiet: bool) {+ let level = if quiet {+ log::LevelFilter::Error+ } else {+ log::LevelFilter::Info+ };+ let _ = log::set_boxed_logger(Box::new(Logger { level }));+ log::set_max_level(level);+}diff --git a/rust/src/main.rs b/rust/src/main.rsnew file mode 100644index 0000000..401c372--- /dev/null+++ b/rust/src/main.rs@@ -0,0 +1,321 @@+//! `pocket-tts` without Python: the `generate`, `serve` and `export-voice` commands of the+//! Python package's CLI (`pocket_tts/main.py`), with the same options and defaults.++mod audio;+mod config;+mod defaults;+mod download;+mod logging;+mod model;+mod rng;+mod server;+mod text;+mod tokenizer;+mod weights;++use anyhow::{Context, Result, bail};+use clap::{Args, Parser, Subcommand};+use config::Config;+use model::CpuBackend;+use model::{LoadOptions, TtsModel, VoiceState};+use std::process::ExitCode;+use std::sync::atomic::AtomicBool;++const LANGUAGE_HELP: &str = "Language for the TTS model. 'english_2026-01', 'english_2026-04', 'english_2026-09', 'english_2026-09_2', 'english_drifting_26-09', 'english', 'french', 'french_24l', 'german', 'german_24l', 'portuguese', 'portuguese_24l', 'italian', 'italian_24l', 'spanish', 'spanish_24l', 'dutch', 'dutch_24l'. Incompatible with the config argument. Default is 'english', which is the same model as 'english_2026-09_2'.";+const CONFIG_HELP: &str = "Path to a model config .yaml file: a local path, an https:// URL, or an hf:// path. Incompatible with the language argument. If not provided, will use the default English model.";++#[derive(Parser)]+#[command(+ name = "pocket-tts",+ version,+ about = "Kyutai Pocket TTS - Text-to-Speech generation tool"+)]+struct Cli {+ #[command(subcommand)]+ command: Command,+}++#[derive(Subcommand)]+enum Command {+ /// Start the server, with a web interface to try voices and prompts.+ Serve(ServeArgs),+ /// Generate speech using Kyutai Pocket TTS.+ Generate(GenerateArgs),+ /// Convert and save audio to .safetensors file+ ExportVoice(ExportVoiceArgs),+}++/// `--quantize / --no-quantize`.+#[derive(Args)]+struct QuantizeFlag {+ /// Apply int8 quantization to reduce memory usage+ #[arg(long, overrides_with = "no_quantize")]+ quantize: bool,+ #[arg(long, overrides_with = "quantize", hide = true)]+ no_quantize: bool,+}++#[derive(Args)]+struct ServeArgs {+ /// Host to bind to+ #[arg(long, default_value = "localhost")]+ host: String,+ /// Port to bind to+ #[arg(long, default_value_t = 8000)]+ port: u16,+ /// Enable auto-reload (a development feature of the Python server, ignored here)+ #[arg(long, overrides_with = "no_reload")]+ reload: bool,+ #[arg(long, overrides_with = "reload", hide = true)]+ no_reload: bool,+ #[arg(long, help = LANGUAGE_HELP)]+ language: Option<String>,+ #[arg(long, help = CONFIG_HELP)]+ config: Option<String>,+ /// Voice used by requests that don't ask for one: a built-in voice name, a local path to an+ /// audio file or to a .safetensors voice, an https:// URL, or an hf:// path. Defaults to the+ /// built-in voice of the language.+ #[arg(long)]+ default_voice: Option<String>,+ #[command(flatten)]+ quantize: QuantizeFlag,+}++#[derive(Args)]+struct GenerateArgs {+ /// Text to generate+ #[arg(long)]+ text: Option<String>,+ /// Path to audio conditioning file (voice to clone). Defaults to a built-in voice chosen from+ /// the language: 'giovanni' for italian, 'lola' for spanish, 'juergen' for german, 'rafael'+ /// for portuguese, 'estelle' for french, 'alba' otherwise. With the config or checkpoint+ /// argument, defaults to alba's audio file, which any model can clone.+ #[arg(long)]+ voice: Option<String>,+ /// Disable logging output+ #[arg(short, long)]+ quiet: bool,+ #[arg(long, help = format!("{LANGUAGE_HELP} The '24l' variants are bigger models, not distilled yet and here only as preview. They're not the final models for those languages."))]+ language: Option<String>,+ #[arg(long, help = CONFIG_HELP)]+ config: Option<String>,+ /// Training checkpoint (.pt) to load instead of the config's weights (not supported by this+ /// binary)+ #[arg(long)]+ checkpoint: Option<String>,+ /// Number of generation steps+ #[arg(long, default_value_t = defaults::DEFAULT_SAMPLER_DECODE_STEPS)]+ sampler_decode_steps: usize,+ /// Deprecated: use --sampler-decode-steps+ #[arg(long, hide = true)]+ lsd_decode_steps: Option<usize>,+ /// Temperature for generation. Defaults to the model's recommended value from its config+ /// (0.3).+ #[arg(long, allow_negative_numbers = true)]+ temperature: Option<f32>,+ /// Noise clamp value+ #[arg(long, allow_negative_numbers = true)]+ noise_clamp: Option<f32>,+ /// EOS threshold+ #[arg(long, default_value_t = defaults::DEFAULT_EOS_THRESHOLD, allow_negative_numbers = true)]+ eos_threshold: f32,+ /// Number of frames to generate after EOS+ #[arg(long)]+ frames_after_eos: Option<usize>,+ /// Output path for generated audio+ #[arg(long, default_value = "./tts_output.wav")]+ output_path: String,+ /// Device to use+ #[arg(long, default_value = "cpu")]+ device: String,+ /// Maximum number of tokens per chunk.+ #[arg(long, default_value_t = defaults::MAX_TOKEN_PER_CHUNK)]+ max_tokens: usize,+ #[command(flatten)]+ quantize: QuantizeFlag,+}++#[derive(Args)]+struct ExportVoiceArgs {+ /// Audio file or directory to convert and export+ audio_path: String,+ /// Output file or directory+ export_path: String,+ /// Disable logging output+ #[arg(short, long)]+ quiet: bool,+ #[arg(long, help = format!("{LANGUAGE_HELP} The '24l' variants are bigger models, not distilled yet and here only as preview."))]+ language: Option<String>,+ #[arg(long, help = CONFIG_HELP)]+ config: Option<String>,+}++/// Threads for the tensor operations unless `RAYON_NUM_THREADS` says otherwise. The model is+/// small enough that more threads cost more to dispatch than they save: four were fastest on+/// the machines measured, ahead of both two and eight.+const DEFAULT_NUM_THREADS: usize = 4;++fn main() -> ExitCode {+ let cli = Cli::parse();+ if std::env::var_os("RAYON_NUM_THREADS").is_none() {+ let cpus = std::thread::available_parallelism().map_or(1, |n| n.get());+ xn::set_num_threads(DEFAULT_NUM_THREADS.min(cpus));+ }+ let result = match cli.command {+ Command::Serve(args) => serve(args),+ Command::Generate(args) => generate(args),+ Command::ExportVoice(args) => export_voice(args),+ };+ match result {+ Ok(code) => code,+ Err(e) => {+ log::error!("{e:#}");+ ExitCode::FAILURE+ }+ }+}++/// Runs `$body` with `$q` bound to the f32 or the int8 backend.+macro_rules! with_backend {+ ($quantize:expr, $q:ident => $body:expr) => {+ if $quantize {+ type $q = xn::quantized::Q80F32;+ $body+ } else {+ type $q = xn::Unquantized<f32, xn::CpuDevice>;+ $body+ }+ };+}++fn load_model<Q: CpuBackend>(+ language: Option<&str>,+ config: Option<&str>,+ options: &LoadOptions,+) -> Result<TtsModel<Q>> {+ let (config, origin) = Config::load(language, config)?;+ TtsModel::load(config, origin, options)+}++fn generate(args: GenerateArgs) -> Result<ExitCode> {+ logging::init(args.quiet);+ let mut sampler_decode_steps = args.sampler_decode_steps;+ if let Some(steps) = args.lsd_decode_steps {+ log::warn!("--lsd-decode-steps is deprecated, use --sampler-decode-steps");+ sampler_decode_steps = steps;+ }+ let mut text = args.text.clone().unwrap_or_else(|| {+ defaults::get_default_text_for_language(args.language.as_deref()).into()+ });+ if text == "-" {+ text = std::io::read_to_string(std::io::stdin()).context("cannot read stdin")?;+ }+ if text.trim().is_empty() {+ log::error!("No input received from stdin.");+ return Ok(ExitCode::FAILURE);+ }+ if args.checkpoint.is_some() {+ bail!(+ "--checkpoint is not supported by this binary: training checkpoints (.pt) need the Python package"+ )+ }+ if args.device != "cpu" {+ bail!(+ "this binary runs on the cpu only, got --device {}",+ args.device+ )+ }+ let options = LoadOptions {+ temperature: args.temperature,+ sampler_decode_steps,+ noise_clamp: args.noise_clamp,+ eos_threshold: args.eos_threshold,+ };+ with_backend!(args.quantize.quantize, Q => generate_with::<Q>(&args, &text, &options))?;+ if args.output_path != "-" {+ log::info!("Results written in {}", args.output_path);+ }+ log::info!("{}", "-".repeat(20));+ log::info!("If you want to try multiple voices and prompts quickly, try the `serve` command.");+ log::info!(+ "If you like Kyutai projects, comment, like, subscribe at https://x.com/kyutai_labs"+ );+ Ok(ExitCode::SUCCESS)+}++fn generate_with<Q: CpuBackend>(+ args: &GenerateArgs,+ text: &str,+ options: &LoadOptions,+) -> Result<()> {+ let model: TtsModel<Q> = load_model(args.language.as_deref(), args.config.as_deref(), options)?;+ let voice = args.voice.clone().unwrap_or_else(|| {+ defaults::get_default_voice_for_language(+ args.language.as_deref(),+ args.config.is_some() || args.checkpoint.is_some(),+ )+ });+ let voice = model.get_state_for_audio_prompt(&voice, false)?;++ // Stream audio generation directly to the file or stdout.+ let (sink, seekable) = audio::open_output(&args.output_path)?;+ let mut writer = audio::StreamingWavWriter::new(sink, model.sample_rate() as u32, seekable);+ writer.write_header_initial()?;+ {+ let mut on_chunk = |pcm: &[f32]| -> Result<()> { Ok(writer.write_pcm(pcm)?) };+ model.generate_audio_stream(+ &voice,+ text,+ args.max_tokens,+ args.frames_after_eos,+ &AtomicBool::new(false),+ &mut on_chunk,+ )?;+ }+ writer.finalize()?;+ Ok(())+}++fn serve(args: ServeArgs) -> Result<ExitCode> {+ logging::init(false);+ if args.reload {+ log::warn!("--reload is a development feature of the Python server, it is ignored");+ }+ let _ = args.no_reload;+ with_backend!(args.quantize.quantize, Q => serve_with::<Q>(&args))?;+ Ok(ExitCode::SUCCESS)+}++fn serve_with<Q: CpuBackend>(args: &ServeArgs) -> Result<()>+where+ TtsModel<Q>: Send + Sync,+ VoiceState<Q>: Send + Sync,+{+ let model: TtsModel<Q> = load_model(+ args.language.as_deref(),+ args.config.as_deref(),+ &LoadOptions::default(),+ )?;+ let default_voice = args.default_voice.clone().unwrap_or_else(|| {+ defaults::get_default_voice_for_language(args.language.as_deref(), args.config.is_some())+ });+ // Resolved before serving: a voice that cannot be loaded fails at startup instead of on the+ // first request.+ let default_voice = model.get_state_for_audio_prompt(&default_voice, false)?;+ let runtime = tokio::runtime::Builder::new_multi_thread()+ .enable_all()+ .build()?;+ runtime.block_on(server::serve(model, default_voice, &args.host, args.port))+}++fn export_voice(args: ExportVoiceArgs) -> Result<ExitCode> {+ logging::init(args.quiet);+ let model: TtsModel<xn::Unquantized<f32, xn::CpuDevice>> = load_model(+ args.language.as_deref(),+ args.config.as_deref(),+ &LoadOptions::default(),+ )?;+ let voice = model.get_state_for_audio_prompt(&args.audio_path, true)?;+ voice.export(std::path::Path::new(&args.export_path))?;+ Ok(ExitCode::SUCCESS)+}diff --git a/rust/src/model.rs b/rust/src/model.rsnew file mode 100644index 0000000..72d22b6--- /dev/null+++ b/rust/src/model.rs@@ -0,0 +1,613 @@+//! Port of `TTSModel` from `pocket_tts/models/tts_model.py`, on the streaming primitives of+//! xn-ptts: loading a config's weights, conditioning on a voice, and generating audio chunk by+//! chunk while a second thread decodes it.++use crate::config::{Config, FlowType, Origin};+use crate::defaults;+use crate::rng::NoiseRng;+use crate::text::{TextOptions, prepare_text_prompt, split_into_best_sentences};+use crate::tokenizer::{SharedTokenizer, Tokenizer};+use crate::weights::SafetensorsFile;+use anyhow::{Context, Result, bail};+use ptts::flow_lm::{FlowLMState, StepInput};+use ptts::transformer::{LayerAttentionState, StreamingMHAState, StreamingTransformerState};+use ptts::tts_model::{MimiEnc, TTSModel, TTSState};+use std::collections::HashMap;+use std::path::Path;+use std::sync::atomic::{AtomicBool, Ordering};+use std::sync::mpsc::TryRecvError;+use std::sync::{Arc, Mutex};+use std::time::Instant;+use xn::{BackendQ, Tensor, WithDTypeF};++/// The backends this binary runs on: the CPU, with f32 or int8 weights.+pub trait CpuBackend: BackendQ<B = xn::CpuDevice> {}+impl<Q: BackendQ<B = xn::CpuDevice>> CpuBackend for Q {}++const TOKENS_PER_SECOND_ESTIMATE: f64 = 3.0;+const GEN_SECONDS_PADDING: f64 = 2.0;+/// EOS is ignored on the first frames: before speech starts, the EOS logit of some voices can+/// cross the threshold, and a short text then ends before the word is spoken.+const MIN_FRAMES_BEFORE_EOS: usize = 6;++pub fn voice_cloning_unsupported() -> String {+ format!(+ "We could not download the weights for the model with voice cloning, but you're trying to use voice cloning. Without voice cloning, you can use our catalog of voices {:?}. If you want access to the model with voice cloning, go to https://huggingface.co/kyutai/pocket-tts and accept the terms, then make sure you're logged in locally with `uvx hf auth login`.",+ defaults::predefined_voice_names()+ )+}++/// What `load_model` takes besides the config.+#[derive(Debug, Clone)]+pub struct LoadOptions {+ pub temperature: Option<f32>,+ pub sampler_decode_steps: usize,+ pub noise_clamp: Option<f32>,+ pub eos_threshold: f32,+}++impl Default for LoadOptions {+ fn default() -> Self {+ Self {+ temperature: None,+ sampler_decode_steps: defaults::DEFAULT_SAMPLER_DECODE_STEPS,+ noise_clamp: None,+ eos_threshold: defaults::DEFAULT_EOS_THRESHOLD,+ }+ }+}++/// The flow LM state after a voice prompt, which every generation starts from.+pub struct VoiceState<Q: CpuBackend> {+ transformer_state: StreamingTransformerState<Q::T, Q::B>,+}++impl<Q: CpuBackend> VoiceState<Q> {+ /// Positions the prompt fills.+ pub fn len(&self) -> usize {+ match self.transformer_state.layer_states.first() {+ Some(LayerAttentionState::FlowLm(state)) => state.current_end,+ _ => 0,+ }+ }++ /// Writes the state as the Python package's `export_model_state` does: per attention layer,+ /// `{module}/cache` of shape `[2, batch, time, heads, dim]` and `{module}/offset`.+ pub fn export(&self, path: &Path) -> Result<()> {+ let mut tensors: Vec<(String, safetensors::Dtype, Vec<usize>, Vec<u8>)> = Vec::new();+ for (i, layer) in self.transformer_state.layer_states.iter().enumerate() {+ let LayerAttentionState::FlowLm(state) = layer else {+ bail!("layer {i} has no flow LM attention state")+ };+ let (b, _, h, d) = state.k_cache.dims4()?;+ let t = state.current_end;+ let mut bytes = Vec::with_capacity(2 * b * t * h * d * 4);+ for cache in [&state.k_cache, &state.v_cache] {+ let values = cache.narrow(1, 0..t)?.contiguous()?.to_vec()?;+ bytes.extend(values.iter().flat_map(|v| v.to_f32().to_le_bytes()));+ }+ let module = format!("transformer.layers.{i}.self_attn");+ tensors.push((+ format!("{module}/cache"),+ safetensors::Dtype::F32,+ vec![2, b, t, h, d],+ bytes,+ ));+ let offset: Vec<u8> = (0..b).flat_map(|_| (t as i64).to_le_bytes()).collect();+ tensors.push((+ format!("{module}/offset"),+ safetensors::Dtype::I64,+ vec![b],+ offset,+ ));+ }+ let views = tensors+ .iter()+ .map(|(name, dtype, shape, bytes)| {+ Ok((+ name.clone(),+ safetensors::tensor::TensorView::new(*dtype, shape.clone(), bytes)?,+ ))+ })+ .collect::<Result<Vec<_>, safetensors::SafeTensorError>>()?;+ safetensors::tensor::serialize_to_file(views, None, path)+ .with_context(|| format!("cannot write {}", path.display()))?;+ Ok(())+ }+}++pub struct TtsModel<Q: CpuBackend> {+ pub config: Config,+ pub origin: Origin,+ model: TTSModel<Q>,+ encoder: Option<MimiEnc<Q>>,+ tokenizer: Arc<Tokenizer>,+ text_options: TextOptions,+ has_voice_cloning: bool,+ flow_type: FlowType,+ rng: Mutex<NoiseRng>,+ num_layers: usize,+ num_heads: usize,+ d_model: usize,+}++impl<Q: CpuBackend> TtsModel<Q> {+ /// Port of `TTSModel.load_model`, for the config already read.+ pub fn load(config: Config, origin: Origin, options: &LoadOptions) -> Result<Self> {+ let flow_type = config.flow_type()?;+ // TODO: the separate FlowLM and Mimi checkpoints of training runs (weight-normed Mimi,+ // un-renamed FlowLM keys) are not converted; export a single `weights_path` instead.+ if config.flow_lm.weights_path.is_some() || config.mimi.weights_path.is_some() {+ bail!(+ "flow_lm.weights_path and mimi.weights_path are not supported by this binary, use a config with a single weights_path"+ )+ }+ let Some(weights_path) = config.weights_path.as_deref() else {+ bail!("No weights_path specified for the TTSModel, the model would be uninitialized")+ };+ log::info!("Loading TTSModel weights from {weights_path}");+ let mut has_voice_cloning = true;+ let weights_file = match crate::download::download_if_necessary(weights_path) {+ Ok(path) => path,+ Err(e) => {+ let Some(fallback) = config.weights_path_without_voice_cloning.as_deref() else {+ return Err(e);+ };+ log::debug!("falling back to the weights without voice cloning: {e:#}");+ has_voice_cloning = false;+ crate::download::download_if_necessary(fallback)?+ }+ };++ let lookup_table = &config.flow_lm.lookup_table;+ let tokenizer = Arc::new(Tokenizer::load(+ lookup_table.n_bins,+ &lookup_table.tokenizer_path,+ &lookup_table.tokenizer,+ )?);++ // The drifting head maps the noise in one step, whatever the number of steps asked.+ let decode_steps = match flow_type {+ FlowType::Drifting => 1,+ _ => options.sampler_decode_steps,+ };+ if decode_steps == 0 {+ bail!("the number of sampler decode steps must be positive")+ }+ let ptts_config = config.to_ptts(decode_steps, options.eos_threshold)?;+ let weights = crate::weights::load(&weights_file, &config)?;+ let model = TTSModel::<Q>::load(+ &weights.vb,+ Box::new(SharedTokenizer(tokenizer.clone())),+ &ptts_config,+ &HashMap::new(),+ )?;+ let has_encoder = weights.vb.contains("mimi.encoder.model.0.conv.weight")+ && weights.vb.contains(ptts::loader::SPEAKER_PROJ_WEIGHT);+ let encoder = if has_encoder {+ Some(MimiEnc::<Q>::load(&weights.vb, &ptts_config)?)+ } else {+ None+ };+ drop(weights);++ let temperature = options.temperature.unwrap_or(config.default_temperature);+ let transformer = &config.flow_lm.transformer;+ Ok(Self {+ num_layers: transformer.num_layers,+ num_heads: transformer.num_heads,+ d_model: transformer.d_model,+ text_options: TextOptions::from_config(&config),+ rng: Mutex::new(NoiseRng::new(temperature, options.noise_clamp)?),+ config,+ origin,+ model,+ encoder,+ tokenizer,+ has_voice_cloning,+ flow_type,+ })+ }++ pub fn sample_rate(&self) -> usize {+ self.config.mimi.sample_rate+ }++ /// Port of `get_state_for_audio_prompt`: `source` is a predefined voice name, an audio file+ /// or a `.safetensors` state, as a local path, an `http(s)://` URL or an `hf://` path.+ /// `truncate` keeps the first 30 seconds of an audio file.+ pub fn get_state_for_audio_prompt(+ &self,+ source: &str,+ truncate: bool,+ ) -> Result<VoiceState<Q>> {+ if is_safetensors_source(source) {+ let path = crate::download::download_if_necessary(source)?;+ return self.import_state(&path);+ }+ if defaults::is_predefined_voice(source) {+ let Origin::Language(language) = &self.origin else {+ bail!(+ "Cannot use predefined voices when the model is not loaded from a config associated with a language.Here the origin is {}",+ self.origin.display_path()+ )+ };+ let voice = defaults::get_predefined_voice(language, source);+ let path = crate::download::download_if_necessary(&voice)?;+ return self.import_state(&path);+ }+ if !self.has_voice_cloning || self.encoder.is_none() {+ bail!(voice_cloning_unsupported())+ }++ let path = crate::download::download_if_necessary(source)?;+ let (mut audio, sample_rate) = crate::audio::audio_read(&path)?;+ if truncate {+ let max_samples = 30 * sample_rate as usize;+ if audio.len() > max_samples {+ audio.truncate(max_samples);+ log::info!("Audio truncated to first 30 seconds ({max_samples} samples)");+ }+ }+ let audio = ptts::audio::resample(audio, sample_rate as usize, self.sample_rate())?;+ let audio = crate::audio::end_on_pause(&audio, self.sample_rate());+ self.state_for_audio(&audio)+ }++ /// Encodes mono audio at the model's sample rate and prompts the flow LM with it.+ fn state_for_audio(&self, audio: &[f32]) -> Result<VoiceState<Q>> {+ let encoder = self+ .encoder+ .as_ref()+ .with_context(voice_cloning_unsupported)?;+ let start = Instant::now();+ let data = audio.iter().map(|&v| Q::T::from_f32(v)).collect();+ let audio = Tensor::from_vec(data, (1, 1, audio.len()), self.model.device())?;+ let conditioning = encoder.encode_audio(&audio)?;+ log::info!(+ "Encoding audio prompt took {} ms",+ start.elapsed().as_millis()+ );++ let start = Instant::now();+ let frames = conditioning.dim(1usize)?;+ let mut state = self+ .model+ .init_flow_lm_state(1, self.model.voice_prompt_len(frames))?;+ self.model.prompt_audio(&mut state, &conditioning)?;+ log::info!("Prompting audio took {} ms", start.elapsed().as_millis());+ let voice = VoiceState {+ transformer_state: state.flow_lm_state.transformer_state,+ };+ let size = 2 * self.num_layers * voice.len() * self.d_model * std::mem::size_of::<f32>();+ log::info!(+ "Size of the model state for audio prompt: {} MB",+ size / 1_000_000+ );+ Ok(voice)+ }++ /// Reads a state written by `export-voice`, from this binary or the Python package.+ fn import_state(&self, path: &Path) -> Result<VoiceState<Q>> {+ let file = SafetensorsFile::open(path)?;+ let dim_per_head = self.d_model / self.num_heads;+ let mut layer_states = Vec::with_capacity(self.num_layers);+ for i in 0..self.num_layers {+ let module = format!("transformer.layers.{i}.self_attn");+ let cache_name = format!("{module}/cache");+ if !file.tensors.contains_key(&cache_name) {+ bail!(+ "{} is not a voice state of this model: it has no {cache_name}",+ path.display()+ )+ }+ let (cache, shape) = file.read_f32(&cache_name)?;+ let [2, b, capacity, h, d] = shape[..] else {+ bail!("{cache_name} has shape {shape:?}, expected [2, batch, time, heads, dim]")+ };+ if b != 1 || h != self.num_heads || d != dim_per_head {+ bail!(+ "{cache_name} has shape {shape:?}, this model needs [2, 1, _, {}, {dim_per_head}]",+ self.num_heads+ )+ }+ // States written before the offset was stored hold the position in the length of+ // `current_end`.+ let offset_name = format!("{module}/offset");+ let current_end_name = format!("{module}/current_end");+ let used = if file.tensors.contains_key(&offset_name) {+ file.read_i64(&offset_name)?.first().copied().unwrap_or(0) as usize+ } else if let Some(info) = file.tensors.get(¤t_end_name) {+ info.shape.first().copied().unwrap_or(0)+ } else {+ capacity+ };+ if used > capacity {+ bail!("{offset_name} is {used}, past the {capacity} cached positions")+ }+ let per_position = h * d;+ let plane = capacity * per_position;+ let take = |start: usize| -> Result<Tensor<Q::T, Q::B>> {+ let data = cache[start..start + used * per_position]+ .iter()+ .map(|&v| Q::T::from_f32(v))+ .collect();+ Ok(Tensor::from_vec(+ data,+ (1, used, h, d),+ self.model.device(),+ )?)+ };+ layer_states.push(LayerAttentionState::FlowLm(StreamingMHAState {+ k_cache: take(0)?,+ v_cache: take(plane)?,+ current_end: used,+ }));+ }+ Ok(VoiceState {+ transformer_state: StreamingTransformerState { layer_states },+ })+ }++ fn estimate_max_gen_len(&self, token_count: usize) -> usize {+ let gen_len_sec = token_count as f64 / TOKENS_PER_SECOND_ESTIMATE + GEN_SECONDS_PADDING;+ (gen_len_sec * self.config.mimi.frame_rate).ceil() as usize+ }++ /// Port of `generate_audio_stream`: splits the text into chunks and generates them one after+ /// the other from the voice state, calling `on_chunk` with the audio as it is decoded.+ /// Setting `stop` ends the generation early.+ pub fn generate_audio_stream(+ &self,+ voice: &VoiceState<Q>,+ text_to_generate: &str,+ max_tokens: usize,+ frames_after_eos: Option<usize>,+ stop: &AtomicBool,+ on_chunk: &mut (dyn FnMut(&[f32]) -> Result<()> + Send),+ ) -> Result<()> {+ let frames_after_eos = frames_after_eos.or(self.config.model_recommended_frames_after_eos);+ // This is a very simplistic way of handling long texts, as in the Python package.+ let chunks = split_into_best_sentences(+ self.tokenizer.as_ref(),+ text_to_generate,+ max_tokens,+ &self.text_options,+ )?;+ for chunk in chunks {+ if stop.load(Ordering::Relaxed) {+ break;+ }+ let (text, frames_after_eos_guess) = prepare_text_prompt(&chunk, &self.text_options)?;+ let frames = frames_after_eos.unwrap_or(frames_after_eos_guess + 2);+ self.generate_short_text(voice, &text, frames, stop, on_chunk)?;+ }+ Ok(())+ }++ fn generate_short_text(+ &self,+ voice: &VoiceState<Q>,+ text: &str,+ frames_after_eos: usize,+ stop: &AtomicBool,+ on_chunk: &mut (dyn FnMut(&[f32]) -> Result<()> + Send),+ ) -> Result<()> {+ let tokens = self.tokenizer.encode(text)?;+ let max_gen_len = self.estimate_max_gen_len(tokens.len());+ let seq_budget = voice.len() + tokens.len() + max_gen_len;+ let transformer_state = voice.transformer_state.with_seq_budget(seq_budget)?;+ let mut state = TTSState {+ flow_lm_state: FlowLMState {+ transformer_state,+ conditions: None,+ },+ };++ let t_generating = Instant::now();+ let start = Instant::now();+ self.model.prompt_text(&mut state, &tokens)?;+ log::info!("Prompting text took {} ms", start.elapsed().as_millis());++ let sample_rate = self.sample_rate();+ let (latent_tx, latent_rx) = std::sync::mpsc::channel::<Option<Tensor<Q::T, Q::B>>>();+ let (generated, decoded) = std::thread::scope(|s| {+ let decoder = s.spawn(move || self.decode_worker(latent_rx, on_chunk));+ let generated = self.autoregressive_generation(+ &mut state,+ max_gen_len,+ frames_after_eos,+ &latent_tx,+ stop,+ );+ // Closes the stream, also on error, so that the decoder finishes.+ let _ = latent_tx.send(None);+ let decoded = decoder+ .join()+ .unwrap_or_else(|_| Err(anyhow::anyhow!("the decoder panicked")));+ (generated, decoded)+ });+ generated?;+ let total_samples = decoded?;++ let audio_ms = total_samples * 1000 / sample_rate;+ let generation_ms = t_generating.elapsed().as_millis().max(1) as usize;+ log::info!(+ "Generated: {audio_ms} ms of audio in {generation_ms} ms so {:.2}x faster than real-time",+ audio_ms as f64 / generation_ms as f64+ );+ Ok(())+ }++ fn autoregressive_generation(+ &self,+ state: &mut TTSState<Q>,+ max_gen_len: usize,+ frames_after_eos: usize,+ latent_tx: &std::sync::mpsc::Sender<Option<Tensor<Q::T, Q::B>>>,+ stop: &AtomicBool,+ ) -> Result<()> {+ let mut previous: Option<Tensor<Q::T, Q::B>> = None;+ let mut eos_step = None;+ let mut step_times = Vec::new();+ let mut reached_max_len = true;+ for generation_step in 0..max_gen_len {+ if stop.load(Ordering::Relaxed) {+ reached_max_len = false;+ break;+ }+ let start = Instant::now();+ let input = match &previous {+ None => StepInput::Bos { batch: 1 },+ Some(latent) => StepInput::Latent(latent),+ };+ let (latent, is_eos) = {+ let mut rng = self.rng.lock().unwrap_or_else(|e| e.into_inner());+ rng.take_drawn();+ let (latent, is_eos) = self.model.generate_step(state, input, &mut *rng)?;+ let latent = match self.flow_type {+ FlowType::Drifting => self.subtract_noise(&latent, &rng.take_drawn())?,+ FlowType::Lsd | FlowType::FlowMatching => latent,+ };+ (latent, is_eos)+ };+ if is_eos && eos_step.is_none() && generation_step >= MIN_FRAMES_BEFORE_EOS {+ eos_step = Some(generation_step);+ }+ if eos_step.is_some_and(|eos_step| generation_step >= eos_step + frames_after_eos) {+ reached_max_len = false;+ break;+ }+ // A closed channel means the decoder stopped on an error, which it reports.+ if latent_tx.send(Some(latent.clone())).is_err() {+ reached_max_len = false;+ break;+ }+ previous = Some(latent);+ step_times.push(start.elapsed().as_millis());+ }+ if reached_max_len {+ if std::env::var("KPOCKET_TTS_ERROR_WITHOUT_EOS").is_ok_and(|v| v == "1") {+ bail!("Generation reached maximum length without EOS!")+ }+ log::warn!(+ "Maximum generation length reached without EOS, this very often indicates an error."+ );+ }+ if !step_times.is_empty() {+ let mean = step_times.iter().sum::<u128>() / step_times.len() as u128;+ log::info!("Average generation step time: {mean} ms");+ }+ Ok(())+ }++ // TODO: upstream to xn-ptts. Without a drifting sampler there, the head runs as one LSD step+ // with zeroed time embeddings (see `weights.rs`), which returns `noise + head(noise)`; the+ // drifting sample is `head(noise)`.+ fn subtract_noise(+ &self,+ latent: &Tensor<Q::T, Q::B>,+ noise: &[f32],+ ) -> Result<Tensor<Q::T, Q::B>> {+ let values = latent.to_vec()?;+ if values.len() != noise.len() {+ bail!(+ "drew {} noise values for a latent of {}",+ noise.len(),+ values.len()+ )+ }+ let data = values+ .iter()+ .zip(noise)+ .map(|(v, n)| Q::T::from_f32(v.to_f32() - n))+ .collect();+ Ok(Tensor::from_vec(+ data,+ latent.dims().to_vec(),+ self.model.device(),+ )?)+ }++ /// Decodes the latents as they come, as many as are queued in one call, and hands the audio+ /// to `on_chunk`. Returns the number of samples decoded.+ fn decode_worker(+ &self,+ latent_rx: std::sync::mpsc::Receiver<Option<Tensor<Q::T, Q::B>>>,+ on_chunk: &mut (dyn FnMut(&[f32]) -> Result<()> + Send),+ ) -> Result<usize> {+ let mut mimi_state = self.model.init_mimi_state(1)?;+ // A fresh Mimi decoder state puts a small step in its first samples, heard as a click at+ // the start of every chunk: fade the first 5 ms in.+ let fade_len = self.sample_rate() / 200;+ let mut fade_in = true;+ let mut total = 0;+ while let Ok(Some(latent)) = latent_rx.recv() {+ let mut latents = vec![latent];+ let mut finished = false;+ loop {+ match latent_rx.try_recv() {+ Ok(Some(latent)) => latents.push(latent),+ Ok(None) | Err(TryRecvError::Disconnected) => {+ finished = true;+ break;+ }+ Err(TryRecvError::Empty) => break,+ }+ }+ let refs: Vec<&Tensor<Q::T, Q::B>> = latents.iter().collect();+ let batch = Tensor::cat(&refs, 1)?;+ let audio = self.model.decode_latent(&batch, &mut mimi_state)?;+ let mut pcm = audio.to_vec()?;+ if fade_in {+ let n = fade_len.min(pcm.len());+ for (i, sample) in pcm[..n].iter_mut().enumerate() {+ *sample *= if fade_len > 1 {+ i as f32 / (fade_len - 1) as f32+ } else {+ 0.0+ };+ }+ fade_in = false;+ }+ total += pcm.len();+ on_chunk(&pcm)?;+ if finished {+ break;+ }+ }+ Ok(total)+ }+}++/// Whether a voice source names a `.safetensors` state rather than audio.+pub fn is_safetensors_source(source: &str) -> bool {+ let path = if source.starts_with("http://") || source.starts_with("https://") {+ let rest = source.split(['?', '#']).next().unwrap_or(source);+ rest.splitn(4, '/').nth(3).unwrap_or("").to_string()+ } else if source.starts_with("hf://") {+ source+ .rsplit_once('@')+ .map_or(source, |(path, _)| path)+ .to_string()+ } else {+ source.to_string()+ };+ path.ends_with(".safetensors")+}++#[cfg(test)]+mod tests {+ use super::*;++ #[test]+ fn safetensors_sources_are_recognized() {+ assert!(is_safetensors_source("voice.safetensors"));+ assert!(is_safetensors_source(+ "https://example.com/v.safetensors?download=1"+ ));+ assert!(is_safetensors_source("hf://a/b/v.safetensors@main"));+ assert!(!is_safetensors_source("hf://a/b/v.wav"));+ assert!(!is_safetensors_source("alba"));+ }+}diff --git a/rust/src/rng.rs b/rust/src/rng.rsnew file mode 100644index 0000000..f9137df--- /dev/null+++ b/rust/src/rng.rs@@ -0,0 +1,92 @@+//! The noise the flow head starts from: Gaussian with standard deviation `sqrt(temperature)`,+//! truncated to `[-noise_clamp, noise_clamp]` when a clamp is set (`torch.nn.init.trunc_normal_`+//! in the Python package).++use rand::SeedableRng;+use rand_distr::{Distribution, Normal};++/// Like PyTorch's default generator, the seed is fixed, so a given command gives the same audio+/// every time it is run. `POCKET_TTS_SEED` picks another one.+const SEED: u64 = 42;++fn seed() -> u64 {+ std::env::var("POCKET_TTS_SEED")+ .ok()+ .and_then(|s| s.parse().ok())+ .unwrap_or(SEED)+}++pub struct NoiseRng {+ rng: rand::rngs::StdRng,+ normal: Normal<f32>,+ clamp: Option<f32>,+ /// What was drawn since the last [`Self::take_drawn`].+ drawn: Vec<f32>,+}++impl NoiseRng {+ pub fn new(temperature: f32, noise_clamp: Option<f32>) -> anyhow::Result<Self> {+ let normal = Normal::new(0.0, temperature.max(0.0).sqrt())?;+ Ok(Self {+ rng: rand::rngs::StdRng::seed_from_u64(seed()),+ normal,+ clamp: noise_clamp,+ drawn: Vec::new(),+ })+ }++ /// The values drawn since the previous call, in order.+ pub fn take_drawn(&mut self) -> Vec<f32> {+ std::mem::take(&mut self.drawn)+ }++ fn draw(&mut self) -> f32 {+ let Some(clamp) = self.clamp else {+ return self.normal.sample(&mut self.rng);+ };+ if clamp <= 0.0 || self.normal.std_dev() == 0.0 {+ return 0.0;+ }+ // Rejection sampling: exact for a truncated normal, and fast unless the clamp is a tiny+ // fraction of the standard deviation, where a bounded number of tries falls back to a+ // uniform draw, which a normal truncated that tightly is close to.+ for _ in 0..10_000 {+ let value = self.normal.sample(&mut self.rng);+ if value.abs() <= clamp {+ return value;+ }+ }+ rand::Rng::random_range(&mut self.rng, -clamp..=clamp)+ }+}++impl ptts::flow_lm::Rng for NoiseRng {+ fn sample(&mut self) -> f32 {+ let value = self.draw();+ self.drawn.push(value);+ value+ }+}++#[cfg(test)]+mod tests {+ use super::*;+ use ptts::flow_lm::Rng as _;++ #[test]+ fn clamped_noise_stays_in_range() {+ let mut rng = NoiseRng::new(1.0, Some(0.5)).unwrap();+ let values: Vec<f32> = (0..1000).map(|_| rng.sample()).collect();+ assert!(values.iter().all(|v| v.abs() <= 0.5));+ assert_eq!(rng.take_drawn(), values);+ assert!(rng.take_drawn().is_empty());+ }++ #[test]+ fn std_is_the_square_root_of_the_temperature() {+ let mut rng = NoiseRng::new(0.25, None).unwrap();+ let n = 20000;+ let var = (0..n).map(|_| rng.sample().powi(2)).sum::<f32>() / n as f32;+ assert!((var - 0.25).abs() < 0.02, "{var}");+ }+}diff --git a/rust/src/server.rs b/rust/src/server.rsnew file mode 100644index 0000000..96c7b49--- /dev/null+++ b/rust/src/server.rs@@ -0,0 +1,325 @@+//! Port of the FastAPI app of `pocket_tts/main.py`: the web page, `/health` and `/tts`, which+//! streams a WAV as it is generated.++// The errors are HTTP responses, built once per failed request.+#![allow(clippy::result_large_err)]++use crate::model::CpuBackend;+use crate::model::{TtsModel, VoiceState};+use anyhow::Result;+use axum::Router;+use axum::body::{Body, Bytes};+use axum::extract::{FromRequest, Multipart, Request, State};+use axum::http::{HeaderValue, StatusCode, header};+use axum::response::{Html, IntoResponse, Response};+use axum::routing::{get, post};+use std::collections::VecDeque;+use std::sync::atomic::{AtomicBool, Ordering};+use std::sync::{Arc, Mutex};++/// Voices requested by URL keep their state, as `lru_cache(maxsize=2)` does in Python.+const VOICE_CACHE_SIZE: usize = 2;++struct App<Q: CpuBackend> {+ model: TtsModel<Q>,+ default_voice: Arc<VoiceState<Q>>,+ voice_cache: Mutex<VecDeque<(String, Arc<VoiceState<Q>>)>>,+ /// Generations run one at a time, as with the Python server.+ generation: Mutex<()>,+}++type Shared<Q> = Arc<App<Q>>;++pub async fn serve<Q: CpuBackend>(+ model: TtsModel<Q>,+ default_voice: VoiceState<Q>,+ host: &str,+ port: u16,+) -> Result<()>+where+ TtsModel<Q>: Send + Sync,+ VoiceState<Q>: Send + Sync,+{+ let app: Shared<Q> = Arc::new(App {+ model,+ default_voice: Arc::new(default_voice),+ voice_cache: Mutex::new(VecDeque::new()),+ generation: Mutex::new(()),+ });+ let cors = tower_http::cors::CorsLayer::new()+ .allow_origin(+ [+ "http://localhost:3000",+ "https://pod1-10007.internal.kyutai.org",+ "https://kyutai.org",+ ]+ .map(HeaderValue::from_static),+ )+ .allow_credentials(true)+ .allow_methods(tower_http::cors::AllowMethods::mirror_request())+ .allow_headers(tower_http::cors::AllowHeaders::mirror_request());+ let router = Router::new()+ .route("/", get(root::<Q>))+ .route("/health", get(health))+ .route("/tts", post(text_to_speech::<Q>))+ .layer(cors)+ .with_state(app);++ let listener = tokio::net::TcpListener::bind((host, port)).await?;+ log::info!("Started server process [{}]", std::process::id());+ let address = listener.local_addr()?;+ let shown = if address.ip().is_loopback() && host == "localhost" {+ format!("http://localhost:{}", address.port())+ } else {+ format!("http://{address}")+ };+ log::info!("Server running on {shown} (Press CTRL+C to quit)");+ axum::serve(listener, router)+ .with_graceful_shutdown(async {+ let _ = tokio::signal::ctrl_c().await;+ log::info!("Shutting down");+ })+ .await?;+ Ok(())+}++async fn root<Q: CpuBackend>(State(app): State<Shared<Q>>) -> Html<String>+where+ TtsModel<Q>: Send + Sync,+ VoiceState<Q>: Send + Sync,+{+ let origin = app.model.origin.display_path();+ let text = crate::defaults::get_default_text_for_language(Some(&origin));+ Html(crate::config::INDEX_HTML.replace("DEFAULT_TEXT_PROMPT", text))+}++async fn health() -> impl IntoResponse {+ axum::Json(serde_json::json!({ "status": "healthy" }))+}++fn http_error(status: StatusCode, detail: impl Into<String>) -> Response {+ (+ status,+ axum::Json(serde_json::json!({ "detail": detail.into() })),+ )+ .into_response()+}++/// The form fields of `/tts`, sent as multipart (as the web page does) or urlencoded.+#[derive(Default)]+struct TtsForm {+ text: Option<String>,+ voice_url: Option<String>,+ voice_wav: Option<(Option<String>, Bytes)>,+}++async fn read_form(request: Request) -> Result<TtsForm, Response> {+ let content_type = request+ .headers()+ .get(header::CONTENT_TYPE)+ .and_then(|v| v.to_str().ok())+ .unwrap_or("")+ .to_string();+ let mut form = TtsForm::default();+ if content_type.starts_with("multipart/form-data") {+ let mut multipart = Multipart::from_request(request, &())+ .await+ .map_err(|e| http_error(StatusCode::BAD_REQUEST, e.body_text()))?;+ while let Some(field) = multipart+ .next_field()+ .await+ .map_err(|e| http_error(StatusCode::BAD_REQUEST, e.body_text()))?+ {+ let name = field.name().unwrap_or("").to_string();+ let file_name = field.file_name().map(str::to_string);+ let data = field+ .bytes()+ .await+ .map_err(|e| http_error(StatusCode::BAD_REQUEST, e.body_text()))?;+ match name.as_str() {+ "text" => form.text = Some(String::from_utf8_lossy(&data).into_owned()),+ "voice_url" => form.voice_url = Some(String::from_utf8_lossy(&data).into_owned()),+ "voice_wav" => form.voice_wav = Some((file_name, data)),+ _ => {}+ }+ }+ } else {+ let axum::Form(fields) = axum::Form::<Vec<(String, String)>>::from_request(request, &())+ .await+ .map_err(|e| http_error(StatusCode::UNPROCESSABLE_ENTITY, e.body_text()))?;+ for (name, value) in fields {+ match name.as_str() {+ "text" => form.text = Some(value),+ "voice_url" => form.voice_url = Some(value),+ _ => {}+ }+ }+ }+ Ok(form)+}++async fn text_to_speech<Q: CpuBackend>(State(app): State<Shared<Q>>, request: Request) -> Response+where+ TtsModel<Q>: Send + Sync,+ VoiceState<Q>: Send + Sync,+{+ let form = match read_form(request).await {+ Ok(form) => form,+ Err(response) => return response,+ };+ let Some(text) = form.text else {+ return (+ StatusCode::UNPROCESSABLE_ENTITY,+ axum::Json(serde_json::json!({ "detail": [{+ "type": "missing", "loc": ["body", "text"], "msg": "Field required", "input": null+ }]})),+ )+ .into_response();+ };+ if text.trim().is_empty() {+ return http_error(StatusCode::BAD_REQUEST, "Text cannot be empty");+ }+ if form.voice_url.is_some() && form.voice_wav.is_some() {+ return http_error(+ StatusCode::BAD_REQUEST,+ "Cannot provide both voice_url and voice_wav",+ );+ }++ let voice_app = app.clone();+ let voice = tokio::task::spawn_blocking(move || -> Result<Arc<VoiceState<Q>>, Response> {+ let app = voice_app;+ if let Some(voice_url) = form.voice_url {+ let allowed = voice_url.starts_with("http://")+ || voice_url.starts_with("https://")+ || voice_url.starts_with("hf://")+ || crate::defaults::is_predefined_voice(&voice_url);+ if !allowed {+ return Err(http_error(+ StatusCode::BAD_REQUEST,+ "voice_url must start with http://, https://, or hf://",+ ));+ }+ let voice = cached_voice(&app, &voice_url).map_err(internal_error)?;+ log::warn!("Using voice from URL: {voice_url}");+ Ok(voice)+ } else if let Some((file_name, data)) = form.voice_wav {+ // Keep the extension, the audio decoder goes by it.+ let suffix = file_name+ .as_deref()+ .and_then(|name| std::path::Path::new(name).extension())+ .map(|ext| format!(".{}", ext.to_string_lossy()))+ .unwrap_or_else(|| ".wav".to_string());+ let file = tempfile::Builder::new()+ .suffix(&suffix)+ .tempfile()+ .map_err(internal_error)?;+ std::fs::write(file.path(), &data).map_err(internal_error)?;+ let path = file.path().to_string_lossy().into_owned();+ let voice = app+ .model+ .get_state_for_audio_prompt(&path, true)+ .map_err(internal_error)?;+ Ok(Arc::new(voice))+ } else {+ Ok(app.default_voice.clone())+ }+ })+ .await;+ let voice = match voice {+ Ok(Ok(voice)) => voice,+ Ok(Err(response)) => return response,+ Err(e) => return internal_error(e),+ };++ let (tx, rx) = tokio::sync::mpsc::channel::<Result<Bytes, std::io::Error>>(64);+ std::thread::spawn(move || {+ let _guard = app.generation.lock().unwrap_or_else(|e| e.into_inner());+ let stop = AtomicBool::new(false);+ let sink = crate::audio::Unseekable(ChannelWriter {+ tx: tx.clone(),+ stop: &stop,+ });+ let mut writer =+ crate::audio::StreamingWavWriter::new(sink, app.model.sample_rate() as u32, false);+ let result = (|| -> Result<()> {+ writer.write_header_initial()?;+ let mut on_chunk = |pcm: &[f32]| -> Result<()> { Ok(writer.write_pcm(pcm)?) };+ app.model.generate_audio_stream(+ &voice,+ &text,+ crate::defaults::MAX_TOKEN_PER_CHUNK,+ None,+ &stop,+ &mut on_chunk,+ )?;+ writer.finalize()?;+ Ok(())+ })();+ if let Err(e) = result+ && !stop.load(Ordering::Relaxed)+ {+ log::error!("Error in generation: {e:#}");+ let _ = tx.blocking_send(Err(std::io::Error::other(format!("{e:#}"))));+ }+ });++ let body = Body::from_stream(tokio_stream::wrappers::ReceiverStream::new(rx));+ Response::builder()+ .header(header::CONTENT_TYPE, "audio/wav")+ .header(+ header::CONTENT_DISPOSITION,+ "attachment; filename=generated_speech.wav",+ )+ .body(body)+ .unwrap()+}++/// Sends the WAV bytes to the response. When the client has gone, raises `stop`, so that the+/// generation ends instead of finishing for nobody.+struct ChannelWriter<'a> {+ tx: tokio::sync::mpsc::Sender<Result<Bytes, std::io::Error>>,+ stop: &'a AtomicBool,+}++impl std::io::Write for ChannelWriter<'_> {+ fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> {+ if self+ .tx+ .blocking_send(Ok(Bytes::copy_from_slice(buf)))+ .is_err()+ {+ self.stop.store(true, Ordering::Relaxed);+ return Err(std::io::Error::new(+ std::io::ErrorKind::BrokenPipe,+ "client disconnected",+ ));+ }+ Ok(buf.len())+ }++ fn flush(&mut self) -> std::io::Result<()> {+ Ok(())+ }+}++fn cached_voice<Q: CpuBackend>(app: &App<Q>, voice_url: &str) -> Result<Arc<VoiceState<Q>>> {+ {+ let cache = app.voice_cache.lock().unwrap_or_else(|e| e.into_inner());+ if let Some((_, voice)) = cache.iter().find(|(url, _)| url == voice_url) {+ return Ok(voice.clone());+ }+ }+ let voice = Arc::new(app.model.get_state_for_audio_prompt(voice_url, false)?);+ let mut cache = app.voice_cache.lock().unwrap_or_else(|e| e.into_inner());+ if cache.len() >= VOICE_CACHE_SIZE {+ cache.pop_front();+ }+ cache.push_back((voice_url.to_string(), voice.clone()));+ Ok(voice)+}++fn internal_error(e: impl std::fmt::Display) -> Response {+ log::error!("{e:#}");+ (StatusCode::INTERNAL_SERVER_ERROR, "Internal Server Error").into_response()+}diff --git a/rust/src/text.rs b/rust/src/text.rsnew file mode 100644index 0000000..b2b30f7--- /dev/null+++ b/rust/src/text.rs@@ -0,0 +1,384 @@+//! Port of `pocket_tts/models/text_chunking.py`: turning a text prompt into the chunks the model+//! generates one at a time.+//!+//! The model is trained on single sentences, so long inputs are split on sentence boundaries and+//! regrouped into chunks that fit `max_tokens`.++use anyhow::{Result, bail};+use std::collections::{BTreeMap, HashSet};++pub trait TextTokenizer {+ fn encode(&self, text: &str) -> Result<Vec<u32>>;+ fn decode(&self, tokens: &[u32]) -> Result<String>;+}++impl TextTokenizer for crate::tokenizer::Tokenizer {+ fn encode(&self, text: &str) -> Result<Vec<u32>> {+ crate::tokenizer::Tokenizer::encode(self, text)+ }++ fn decode(&self, tokens: &[u32]) -> Result<String> {+ crate::tokenizer::Tokenizer::decode(self, tokens)+ }+}++/// The text options of a model config.+#[derive(Debug, Clone)]+pub struct TextOptions {+ pub pad_with_spaces_for_short_inputs: bool,+ pub remove_semicolons: bool,+ pub append_terminal_punctuation: bool,+ pub capitalize_first_letter: bool,+ pub replace_characters: BTreeMap<char, String>,+}++impl TextOptions {+ pub fn from_config(config: &crate::config::Config) -> Self {+ let replace_characters = config+ .replace_characters+ .iter()+ .map(|(key, value)| {+ (+ key.chars().next().unwrap(),+ value.clone().unwrap_or_default(),+ )+ })+ .collect();+ Self {+ pad_with_spaces_for_short_inputs: config.pad_with_spaces_for_short_inputs,+ remove_semicolons: config.remove_semicolons,+ append_terminal_punctuation: config.append_terminal_punctuation,+ capitalize_first_letter: config.capitalize_first_letter,+ replace_characters,+ }+ }+}++/// Python's `" ".join(text.split())`.+fn collapse_whitespace(text: &str) -> String {+ text.split_whitespace().collect::<Vec<_>>().join(" ")+}++/// Python's `re.sub(r"([.!?…])\s*[,;:]", r"\1", text)`: deleted quotes leave+/// '"Hi?", she said' as 'Hi?, she said', which reads as a sentence end followed by a stray comma;+/// keep the sentence mark only.+fn drop_punctuation_after_sentence_end(text: &str) -> String {+ let chars: Vec<char> = text.chars().collect();+ let mut out = String::with_capacity(text.len());+ let mut i = 0;+ while i < chars.len() {+ let c = chars[i];+ out.push(c);+ i += 1;+ if matches!(c, '.' | '!' | '?' | '\u{2026}') {+ let mut j = i;+ while j < chars.len() && chars[j].is_whitespace() {+ j += 1;+ }+ if j < chars.len() && matches!(chars[j], ',' | ';' | ':') {+ i = j + 1;+ }+ }+ }+ out+}++/// Returns the prepared text and a guess of the frames to generate after the end of speech.+pub fn prepare_text_prompt(text: &str, options: &TextOptions) -> Result<(String, usize)> {+ let mut text = text.trim().to_string();+ if !options.replace_characters.is_empty() {+ let translated: String = text+ .chars()+ .map(|c| match options.replace_characters.get(&c) {+ Some(replacement) => replacement.clone(),+ None => c.to_string(),+ })+ .collect();+ text = drop_punctuation_after_sentence_end(&collapse_whitespace(&translated));+ }+ if text.is_empty() {+ bail!("Text prompt cannot be empty")+ }+ text = text.replace(['\n', '\r'], " ").replace(" ", " ");+ if options.remove_semicolons {+ text = text.replace(';', ",");+ }+ let number_of_words = text.split_whitespace().count();+ let frames_after_eos_guess = if number_of_words <= 4 { 3 } else { 1 };++ // Make sure it starts with an uppercase letter. Only meaningful for orthographies that have+ // case; see the config's capitalize_first_letter.+ if options.capitalize_first_letter {+ let mut chars = text.chars();+ let first = chars.next().unwrap();+ if !first.is_uppercase() {+ text = first.to_uppercase().chain(chars).collect();+ }+ }++ if options.append_terminal_punctuation {+ text = ensure_terminal_punctuation(&text);+ }++ // The model does not perform well when there are very few tokens, so we can add empty spaces+ // at the beginning to increase the token count.+ if options.pad_with_spaces_for_short_inputs && text.split_whitespace().count() < 5 {+ text = format!("{}{text}", " ".repeat(8));+ }++ Ok((text, frames_after_eos_guess))+}++const TERMINAL_PUNCTUATION: &str = ".!?\u{2026}";+const WEAK_PUNCTUATION: &str = ",;:-\u{2013}\u{2014}";+const CLOSERS: &str = "\"'\u{201d}\u{2019})]\u{bb}";++/// Make sure the prompt ends with sentence-final punctuation.+///+/// The model is trained on sentences that end with a period, a question mark or an exclamation+/// mark. Without one, the last word is often mispronounced or repeated. Text that already ends+/// with one, possibly followed by closing quotes or brackets, is left alone. A trailing comma,+/// colon or dash is replaced by a period. Anything else gets a period appended after the closing+/// quote or bracket.+fn ensure_terminal_punctuation(text: &str) -> String {+ let core = text.trim_end_matches(|c| CLOSERS.contains(c) || c == ' ');+ let closers = text[core.len()..].trim();+ match core.chars().last() {+ None => text.to_string(),+ Some(last) if TERMINAL_PUNCTUATION.contains(last) => text.to_string(),+ Some(last) if WEAK_PUNCTUATION.contains(last) => {+ let core = core.trim_end_matches(|c| WEAK_PUNCTUATION.contains(c) || c == ' ');+ format!("{core}.{closers}")+ }+ Some(_) => format!("{text}."),+ }+}++/// Whether `segment_start_idx` begins right after a decimal period.+fn is_decimal_period_boundary(+ tokens: &[u32],+ segment_start_idx: usize,+ tokenizer: &dyn TextTokenizer,+) -> Result<bool> {+ let prefix: Vec<char> = tokenizer+ .decode(&tokens[..segment_start_idx])?+ .chars()+ .collect();+ let suffix = tokenizer.decode(&tokens[segment_start_idx..])?;+ Ok(prefix.len() >= 2+ && prefix[prefix.len() - 1] == '.'+ && prefix[prefix.len() - 2].is_numeric()+ && suffix.chars().next().is_some_and(char::is_numeric))+}++/// Token indices where the text should be split. Each consecutive pair of the result delimits a+/// segment, the first is always 0 and the last `tokens.len()`.+fn find_boundary_indices(+ tokens: &[u32],+ boundary_tokens: &[u32],+ decimal_tokenizer: Option<&dyn TextTokenizer>,+) -> Result<Vec<usize>> {+ let boundary_set: HashSet<u32> = boundary_tokens.iter().copied().collect();+ let mut indices = vec![0];+ let mut previous_was_boundary = false;+ for (idx, token) in tokens.iter().enumerate() {+ if boundary_set.contains(token) {+ previous_was_boundary = true;+ continue;+ }+ if previous_was_boundary {+ let is_decimal = match decimal_tokenizer {+ Some(tokenizer) => is_decimal_period_boundary(tokens, idx, tokenizer)?,+ None => false,+ };+ if !is_decimal {+ indices.push(idx);+ }+ }+ previous_was_boundary = false;+ }+ indices.push(tokens.len());+ Ok(indices)+}++fn segments_from_boundaries(+ tokens: &[u32],+ boundaries: &[usize],+ tokenizer: &dyn TextTokenizer,+) -> Result<Vec<(usize, String)>> {+ boundaries+ .windows(2)+ .map(|w| Ok((w[1] - w[0], tokenizer.decode(&tokens[w[0]..w[1]])?)))+ .collect()+}++/// The tokens of `text` without the first one, which carries the leading space marker.+fn marker_tokens(tokenizer: &dyn TextTokenizer, text: &str) -> Result<Vec<u32>> {+ Ok(tokenizer.encode(text)?.into_iter().skip(1).collect())+}++pub fn split_into_best_sentences(+ tokenizer: &dyn TextTokenizer,+ text_to_generate: &str,+ max_tokens: usize,+ options: &TextOptions,+) -> Result<Vec<String>> {+ let (text, _) = prepare_text_prompt(text_to_generate, options)?;+ let text = text.trim();+ let tokens = tokenizer.encode(text)?;++ let end_of_sentence_tokens = marker_tokens(tokenizer, ".!...?")?;+ let sentence_boundaries =+ find_boundary_indices(&tokens, &end_of_sentence_tokens, Some(tokenizer))?;+ let sentences = segments_from_boundaries(&tokens, &sentence_boundaries, tokenizer)?;++ // Sub-split oversized sentences on commas, semicolons, and colons to prevent skipped words.+ let fallback_tokens = marker_tokens(tokenizer, ",;:")?;+ let mut refined_segments = Vec::new();+ for (nb_tokens, sentence) in sentences {+ if nb_tokens <= max_tokens {+ refined_segments.push((nb_tokens, sentence));+ continue;+ }+ let sub_tokens = tokenizer.encode(sentence.trim())?;+ let sub_boundaries = find_boundary_indices(&sub_tokens, &fallback_tokens, None)?;+ let sub_segments = segments_from_boundaries(&sub_tokens, &sub_boundaries, tokenizer)?;+ if sub_segments.len() > 1 {+ refined_segments.extend(sub_segments);+ } else {+ refined_segments.push((nb_tokens, sentence));+ }+ }++ let mut chunks = Vec::new();+ let mut current_chunk = String::new();+ let mut current_nb_of_tokens = 0;+ for (nb_tokens, sentence) in refined_segments {+ if current_chunk.is_empty() {+ current_chunk = sentence;+ current_nb_of_tokens = nb_tokens;+ continue;+ }+ if current_nb_of_tokens + nb_tokens > max_tokens {+ chunks.push(current_chunk.trim().to_string());+ current_chunk = sentence;+ current_nb_of_tokens = nb_tokens;+ } else {+ current_chunk.push(' ');+ current_chunk.push_str(&sentence);+ current_nb_of_tokens += nb_tokens;+ }+ }+ if !current_chunk.is_empty() {+ chunks.push(current_chunk.trim().to_string());+ }++ for chunk in chunks.iter() {+ let nb_tokens = tokenizer.encode(chunk.trim())?.len();+ if nb_tokens > max_tokens {+ let preview: String = chunk.chars().take(50).collect();+ log::warn!(+ "Chunk has {nb_tokens} tokens (max {max_tokens}), generation may skip words: '{preview}...'"+ );+ }+ }+ Ok(chunks)+}++#[cfg(test)]+mod tests {+ use super::*;++ /// One token per character, with a leading space marker like SentencePiece.+ struct CharTokenizer;++ impl TextTokenizer for CharTokenizer {+ fn encode(&self, text: &str) -> Result<Vec<u32>> {+ Ok(std::iter::once(0)+ .chain(text.chars().map(|c| c as u32))+ .collect())+ }++ fn decode(&self, tokens: &[u32]) -> Result<String> {+ Ok(tokens+ .iter()+ .filter(|&&t| t != 0)+ .map(|&t| char::from_u32(t).unwrap())+ .collect())+ }+ }++ fn options() -> TextOptions {+ TextOptions {+ pad_with_spaces_for_short_inputs: false,+ remove_semicolons: false,+ append_terminal_punctuation: true,+ capitalize_first_letter: true,+ replace_characters: BTreeMap::new(),+ }+ }++ #[test]+ fn prompts_are_prepared_like_python() {+ let o = options();+ assert_eq!(+ prepare_text_prompt("hello world", &o).unwrap(),+ ("Hello world.".into(), 3)+ );+ assert_eq!(+ prepare_text_prompt(" one two three four five ", &o).unwrap(),+ ("One two three four five.".into(), 1)+ );+ assert_eq!(prepare_text_prompt("Wait,", &o).unwrap().0, "Wait.");+ assert_eq!(+ prepare_text_prompt("He said \"hi\"", &o).unwrap().0,+ "He said \"hi\"."+ );+ assert_eq!(+ prepare_text_prompt("Is it \"so?\"", &o).unwrap().0,+ "Is it \"so?\""+ );+ assert_eq!(prepare_text_prompt("über", &o).unwrap().0, "Über.");+ assert_eq!(prepare_text_prompt("a\nb c", &o).unwrap().0, "A b c.");+ assert!(prepare_text_prompt(" ", &o).is_err());++ let mut o = options();+ o.pad_with_spaces_for_short_inputs = true;+ o.remove_semicolons = true;+ assert_eq!(prepare_text_prompt("a; b", &o).unwrap().0, " A, b.");++ let mut o = options();+ o.replace_characters = [('"', String::new()), ('«', String::new())].into();+ assert_eq!(+ prepare_text_prompt("\"Hi?\", she said", &o).unwrap().0,+ "Hi? she said."+ );+ }++ // The expected values are what the Python implementation returns with the same tokenizer,+ // whose decoded segments keep their leading space (hence the double spaces).+ #[test]+ fn sentences_are_grouped_up_to_max_tokens() {+ let o = options();+ let text = "First one. Second one! Third one?";+ let chunks = split_into_best_sentences(&CharTokenizer, text, 25, &o).unwrap();+ assert_eq!(chunks, ["First one. Second one!", "Third one?"]);+ let chunks = split_into_best_sentences(&CharTokenizer, text, 1000, &o).unwrap();+ assert_eq!(chunks, ["First one. Second one! Third one?"]);+ }++ #[test]+ fn decimal_periods_do_not_split() {+ let chunks =+ split_into_best_sentences(&CharTokenizer, "It costs 3.5 euros. Yes.", 5, &options())+ .unwrap();+ assert_eq!(chunks, ["It costs 3.5 euros.", "Yes."]);+ }++ #[test]+ fn long_sentences_split_on_commas() {+ let chunks =+ split_into_best_sentences(&CharTokenizer, "aaaa, bbbb, cccc.", 8, &options()).unwrap();+ assert_eq!(chunks, ["Aaaa,", "bbbb,", "cccc."]);+ }+}diff --git a/rust/src/tokenizer.rs b/rust/src/tokenizer.rsnew file mode 100644index 0000000..4b49f59--- /dev/null+++ b/rust/src/tokenizer.rs@@ -0,0 +1,77 @@+//! Port of `pocket_tts/modules/text_conditioner.py`: a SentencePiece `.model` or a Hugging Face+//! `tokenizer.json`, picked from the config's `tokenizer` field or the file's suffix.++use anyhow::{Context, Result, bail};+use std::sync::Arc;++pub enum Tokenizer {+ SentencePiece(sentencepiece::SentencePieceProcessor),+ Json(Box<tokenizers::Tokenizer>),+}++impl Tokenizer {+ pub fn load(n_bins: usize, tokenizer_path: &str, kind: &str) -> Result<Self> {+ let is_json = kind == "tokenizers"+ || kind == "json"+ || tokenizer_path.split('@').next().unwrap().ends_with(".json");+ let local_path = crate::download::download_if_necessary(tokenizer_path)?;+ if is_json {+ log::info!("Loading tokenizers json from {tokenizer_path}");+ let tokenizer = tokenizers::Tokenizer::from_file(&local_path)+ .map_err(|e| anyhow::anyhow!("{e}"))+ .with_context(|| format!("cannot load {}", local_path.display()))?;+ let vocab_size = tokenizer.get_vocab_size(true);+ if vocab_size != n_bins {+ bail!("tokenizer has vocab size={vocab_size} but nbins={n_bins} was specified")+ }+ Ok(Self::Json(Box::new(tokenizer)))+ } else {+ log::info!("Loading sentencepiece tokenizer from {tokenizer_path}");+ let sp = sentencepiece::SentencePieceProcessor::open(&local_path)+ .with_context(|| format!("cannot load {}", local_path.display()))?;+ if sp.len() != n_bins {+ bail!(+ "sentencepiece tokenizer has vocab size={} but nbins={n_bins} was specified",+ sp.len()+ )+ }+ Ok(Self::SentencePiece(sp))+ }+ }++ pub fn encode(&self, text: &str) -> Result<Vec<u32>> {+ match self {+ Self::SentencePiece(sp) => Ok(sp.encode(text)?.into_iter().map(|p| p.id).collect()),+ // `add_special_tokens` as in Python's `Tokenizer.encode` default.+ Self::Json(tok) => Ok(tok+ .encode(text, true)+ .map_err(|e| anyhow::anyhow!("{e}"))?+ .get_ids()+ .to_vec()),+ }+ }++ pub fn decode(&self, ids: &[u32]) -> Result<String> {+ match self {+ Self::SentencePiece(sp) => Ok(sp.decode_piece_ids(ids)?),+ Self::Json(tok) => tok.decode(ids, true).map_err(|e| anyhow::anyhow!("{e}")),+ }+ }+}++/// The tokenizer as xn-ptts's flow LM holds it, shared with the text chunking.+pub struct SharedTokenizer(pub Arc<Tokenizer>);++impl ptts::Tokenizer for SharedTokenizer {+ fn encode(&self, text: &str) -> xn::Result<Vec<u32>> {+ self.0+ .encode(text)+ .map_err(|e| xn::Error::msg(format!("{e:#}")))+ }++ fn decode(&self, tokens: &[u32]) -> xn::Result<String> {+ self.0+ .decode(tokens)+ .map_err(|e| xn::Error::msg(format!("{e:#}")))+ }+}diff --git a/rust/src/weights.rs b/rust/src/weights.rsnew file mode 100644index 0000000..af6edf4--- /dev/null+++ b/rust/src/weights.rs@@ -0,0 +1,337 @@+//! Loading pocket-tts safetensors weights into xn-ptts.+//!+//! The checkpoint keys are renamed with xn-ptts's own key map, and the few tensors xn-ptts cannot+//! take as they are get rewritten into equivalent ones, written to a small side file loaded after+//! the checkpoint. Each rewrite is exact: it only adds zeros, or scales by a power of two. They+//! are stopgaps, marked TODO, for features xn-ptts does not have yet.++use crate::config::{Config, FlowType};+use anyhow::{Context, Result, bail};+use std::collections::{HashMap, HashSet};+use std::io::{Read, Seek, SeekFrom};+use std::path::{Path, PathBuf};++/// Names of the rewritten tensors in the side file, before the prefix is stripped.+const PATCH_PREFIX: &str = "pocket_tts_patch.";+const SPEAKER_SINK: &str = "flow_lm.condition_provider.conditioners.speaker_wavs.sink";+const DOWNSAMPLE_WEIGHT: &str = "mimi.downsample.conv.conv.weight";++/// Where a tensor sits in a safetensors file.+#[derive(Debug, Clone)]+pub struct TensorInfo {+ pub dtype: String,+ pub shape: Vec<usize>,+ start: u64,+ end: u64,+}++/// The header of a safetensors file, read without loading the tensors.+pub struct SafetensorsFile {+ path: PathBuf,+ data_start: u64,+ pub tensors: HashMap<String, TensorInfo>,+}++impl SafetensorsFile {+ pub fn open(path: &Path) -> Result<Self> {+ let mut file =+ std::fs::File::open(path).with_context(|| format!("cannot open {}", path.display()))?;+ let mut len = [0u8; 8];+ file.read_exact(&mut len)?;+ let len = u64::from_le_bytes(len);+ let mut header = vec![0u8; len as usize];+ file.read_exact(&mut header)?;+ let header: HashMap<String, serde_json::Value> = serde_json::from_slice(&header)+ .with_context(|| format!("{} is not a safetensors file", path.display()))?;+ let mut tensors = HashMap::new();+ for (name, value) in header {+ if name == "__metadata__" {+ continue;+ }+ let info = (|| {+ let dtype = value.get("dtype")?.as_str()?.to_string();+ let shape = value+ .get("shape")?+ .as_array()?+ .iter()+ .map(|d| d.as_u64().map(|d| d as usize))+ .collect::<Option<Vec<_>>>()?;+ let offsets = value.get("data_offsets")?.as_array()?;+ Some(TensorInfo {+ dtype,+ shape,+ start: offsets.first()?.as_u64()?,+ end: offsets.get(1)?.as_u64()?,+ })+ })()+ .with_context(|| format!("bad entry {name} in {}", path.display()))?;+ tensors.insert(name, info);+ }+ Ok(Self {+ path: path.to_path_buf(),+ data_start: 8 + len,+ tensors,+ })+ }++ fn read_bytes(&self, info: &TensorInfo) -> Result<Vec<u8>> {+ let mut file = std::fs::File::open(&self.path)?;+ file.seek(SeekFrom::Start(self.data_start + info.start))?;+ let mut bytes = vec![0u8; (info.end - info.start) as usize];+ file.read_exact(&mut bytes)?;+ Ok(bytes)+ }++ /// A floating point tensor, converted to f32.+ pub fn read_f32(&self, name: &str) -> Result<(Vec<f32>, Vec<usize>)> {+ let info = self+ .tensors+ .get(name)+ .with_context(|| format!("no tensor {name}"))?;+ let bytes = self.read_bytes(info)?;+ Ok((bytes_to_f32(&info.dtype, &bytes)?, info.shape.clone()))+ }++ /// An integer tensor, converted to i64.+ pub fn read_i64(&self, name: &str) -> Result<Vec<i64>> {+ let info = self+ .tensors+ .get(name)+ .with_context(|| format!("no tensor {name}"))?;+ let bytes = self.read_bytes(info)?;+ Ok(match info.dtype.as_str() {+ "I64" => bytes+ .as_chunks::<8>()+ .0+ .iter()+ .map(|b| i64::from_le_bytes(*b))+ .collect(),+ "I32" => bytes+ .as_chunks::<4>()+ .0+ .iter()+ .map(|b| i32::from_le_bytes(*b) as i64)+ .collect(),+ other => bail!("tensor {name} has dtype {other}, expected an integer"),+ })+ }+}++pub fn bytes_to_f32(dtype: &str, bytes: &[u8]) -> Result<Vec<f32>> {+ Ok(match dtype {+ "F32" => bytes+ .as_chunks::<4>()+ .0+ .iter()+ .map(|b| f32::from_le_bytes(*b))+ .collect(),+ "BF16" => bytes+ .as_chunks::<2>()+ .0+ .iter()+ .map(|b| f32::from_bits((u16::from_le_bytes([b[0], b[1]]) as u32) << 16))+ .collect(),+ "F16" => bytes+ .as_chunks::<2>()+ .0+ .iter()+ .map(|b| half::f16::from_le_bytes([b[0], b[1]]).to_f32())+ .collect(),+ other => bail!("unsupported dtype {other}, expected a float"),+ })+}++/// pocket-tts key names to xn-ptts ones.+fn remap_key(name: &str) -> Option<String> {+ let name = ptts::loader::remap_key(name)?;+ // pocket-tts prepends `bos_before_voice` to the voice prompt, which xn-ptts models as the+ // sink of the `speaker_wavs` conditioning, see `Config::to_ptts`.+ if name == "flow_lm.bos_before_voice" {+ return Some(SPEAKER_SINK.to_string());+ }+ Some(name)+}++/// A rewritten tensor, f32 whatever the checkpoint's dtype.+struct Patch {+ name: String,+ shape: Vec<usize>,+ data: Vec<f32>,+}++/// Zero-pads dimension `dim` of a row-major tensor to `new_size`.+fn zero_pad(data: &[f32], shape: &[usize], dim: usize, new_size: usize) -> (Vec<f32>, Vec<usize>) {+ let outer: usize = shape[..dim].iter().product();+ let inner: usize = shape[dim + 1..].iter().product();+ let old_block = shape[dim] * inner;+ let new_block = new_size * inner;+ let mut out = vec![0.0; outer * new_block];+ for o in 0..outer {+ out[o * new_block..o * new_block + old_block]+ .copy_from_slice(&data[o * old_block..(o + 1) * old_block]);+ }+ let mut new_shape = shape.to_vec();+ new_shape[dim] = new_size;+ (out, new_shape)+}++/// The patches `config` needs on top of the checkpoint `file`.+fn patches(config: &Config, file: &SafetensorsFile) -> Result<Vec<Patch>> {+ let mut patches = Vec::new();+ let dimension = config.mimi.seanet.dimension;+ let latent_dim = config.speaker_latent_dim();++ // TODO: upstream to xn-ptts. Its Mimi encoder downsamples to `dimension` channels and its+ // speaker projection reads `dimension` of them, where pocket-tts models since 2026-04 have+ // `inner_dim: 32`. Padding the downsampling with zero filters and the projection with zero+ // columns gives the same voice embedding.+ if latent_dim != dimension {+ if file.tensors.contains_key(DOWNSAMPLE_WEIGHT) {+ let (data, shape) = file.read_f32(DOWNSAMPLE_WEIGHT)?;+ if shape.len() != 3 || shape[0] != latent_dim {+ bail!("{DOWNSAMPLE_WEIGHT} has shape {shape:?}, expected [{latent_dim}, ...]")+ }+ let (data, shape) = zero_pad(&data, &shape, 0, dimension);+ patches.push(Patch {+ name: DOWNSAMPLE_WEIGHT.to_string(),+ shape,+ data,+ });+ }+ let speaker_proj = ptts::loader::SPEAKER_PROJ_WEIGHT;+ if file.tensors.contains_key(speaker_proj) {+ let (data, shape) = file.read_f32(speaker_proj)?;+ if shape.len() != 2 || shape[1] != latent_dim {+ bail!("{speaker_proj} has shape {shape:?}, expected [_, {latent_dim}]")+ }+ let (data, shape) = zero_pad(&data, &shape, 1, dimension);+ patches.push(Patch {+ name: speaker_proj.to_string(),+ shape,+ data,+ });+ }+ }++ // TODO: upstream to xn-ptts. Its flow head always has two time embedders whose outputs it+ // averages, as LSD needs. Until it supports the other samplers, they are expressed as LSD:+ // - flow_matching has one embedder, fed the step's start time `i / n`, which is what LSD+ // feeds the first one. Doubling the first one's output (its final norm's scale) and adding+ // a second one that outputs zeros keeps the average equal to it, and both samplers then+ // take the same Euler steps.+ // - drifting has no time embedder, so both get zero ones; the noise is then subtracted from+ // the one-step LSD output, see `model.rs`.+ let flow_dim = config.flow_lm.flow.dim;+ let time_embed = |i: usize| format!("flow_lm.flow_net.time_embed.{i}");+ let zero_time_embedder = |i: usize| {+ let prefix = time_embed(i);+ [+ ("mlp.0.weight", vec![flow_dim, 256]),+ ("mlp.0.bias", vec![flow_dim]),+ ("mlp.2.weight", vec![flow_dim, flow_dim]),+ ("mlp.2.bias", vec![flow_dim]),+ ("mlp.3.alpha", vec![flow_dim]),+ ("freqs", vec![128]),+ ]+ .into_iter()+ .map(|(name, shape)| Patch {+ name: format!("{prefix}.{name}"),+ data: vec![0.0; shape.iter().product()],+ shape,+ })+ .collect::<Vec<_>>()+ };+ match config.flow_type()? {+ FlowType::Lsd => {}+ FlowType::FlowMatching => {+ let alpha = format!("{}.mlp.3.alpha", time_embed(0));+ let (data, shape) = file.read_f32(&alpha)?;+ patches.push(Patch {+ name: alpha,+ shape,+ data: data.iter().map(|v| v * 2.0).collect(),+ });+ patches.extend(zero_time_embedder(1));+ }+ FlowType::Drifting => {+ patches.extend(zero_time_embedder(0));+ patches.extend(zero_time_embedder(1));+ }+ }+ Ok(patches)+}++/// The weights as xn-ptts loads them, with the side file of rewritten tensors, which must+/// outlive them.+pub struct Weights {+ pub vb: xn::nn::Path<xn::CpuDevice>,+ _patch_dir: Option<tempfile::TempDir>,+}++/// Memory-maps the checkpoint at `path`, with the rewrites `config` needs.+pub fn load(path: &Path, config: &Config) -> Result<Weights> {+ let file = SafetensorsFile::open(path)?;+ let patches = patches(config, &file)?;+ let mut files = vec![path.to_path_buf()];+ let mut patch_dir = None;+ let patched: HashSet<String> = patches.iter().map(|p| p.name.clone()).collect();+ if !patches.is_empty() {+ let dir = tempfile::tempdir()?;+ let patch_path = dir.path().join("patch.safetensors");+ let bytes: Vec<(String, Vec<u8>, Vec<usize>)> = patches+ .iter()+ .map(|p| {+ let bytes = p.data.iter().flat_map(|v| v.to_le_bytes()).collect();+ (format!("{PATCH_PREFIX}{}", p.name), bytes, p.shape.clone())+ })+ .collect();+ let views = bytes+ .iter()+ .map(|(name, bytes, shape)| {+ let view = safetensors::tensor::TensorView::new(+ safetensors::Dtype::F32,+ shape.clone(),+ bytes,+ )?;+ Ok((name.clone(), view))+ })+ .collect::<Result<Vec<_>, safetensors::SafeTensorError>>()?;+ safetensors::tensor::serialize_to_file(views, None, &patch_path)?;+ files.push(patch_path);+ patch_dir = Some(dir);+ }+ let key_map = move |name: &str| -> Option<String> {+ if let Some(name) = name.strip_prefix(PATCH_PREFIX) {+ return Some(name.to_string());+ }+ let name = remap_key(name)?;+ if patched.contains(&name) {+ None+ } else {+ Some(name)+ }+ };+ let vb = xn::nn::VB::load_with_key_map(&files, xn::CPU, key_map)+ .with_context(|| format!("cannot load the weights in {}", path.display()))?;+ Ok(Weights {+ vb: vb.root(),+ _patch_dir: patch_dir,+ })+}++#[cfg(test)]+mod tests {+ use super::*;++ #[test]+ fn zero_pad_keeps_values_in_place() {+ // [2, 2] padded to [2, 3] on the last dim.+ let (data, shape) = zero_pad(&[1.0, 2.0, 3.0, 4.0], &[2, 2], 1, 3);+ assert_eq!(shape, [2, 3]);+ assert_eq!(data, [1.0, 2.0, 0.0, 3.0, 4.0, 0.0]);+ // [1, 2, 2] padded to [2, 2, 2] on the first dim.+ let (data, shape) = zero_pad(&[1.0, 2.0, 3.0, 4.0], &[1, 2, 2], 0, 2);+ assert_eq!(shape, [2, 2, 2]);+ assert_eq!(data, [1.0, 2.0, 3.0, 4.0, 0.0, 0.0, 0.0, 0.0]);+ }+}