Skip to main content

Module audio_tokens

Module audio_tokens 

Source
Expand description

RVQ / FSQ discrete audio token codec (quantizer ABI). Re-exports only (AU-GEN).

The quantizer structure is pure Rust and real now: rvq_quantize/rvq_dequantize implement a residual vector quantizer over caller-owned codebooks, and fsq_quantize/fsq_dequantize implement finite scalar quantization. The neural encoder/decoder that produces the latents and codebooks is NeedsWeights (out of scope).

Re-exports§

pub use fsq::fsq_dequantize;
pub use fsq::fsq_quantize;
pub use rvq::rvq_dequantize;
pub use rvq::rvq_quantize;

Modules§

fsq
Finite Scalar Quantization (FSQ) — the codebook-free discrete token structure from “Finite Scalar Quantization: VQ-VAE Made Simple” (Mentzer et al., 2023). Each latent dimension is independently rounded to one of L evenly-spaced levels spanning a bounded range [lo, hi]; the implicit codebook is the Cartesian product of the per-dim level grids, so no codebook needs to be stored or learned. This is pure quantizer math — real and buildable now. The neural encoder that produces the (bounded) latents is a separate, NeedsWeights concern.
rvq
Residual Vector Quantizer (RVQ) — the codec structure used by discrete audio token models (EnCodec / SoundStream / DAC family). This is pure codebook math: no learned weights are required, so it is real and buildable now. The caller supplies the codebooks (each stage a [n_centroids × dim] row-major block); the neural encoder/decoder that produces those codebooks and the latent vectors is a separate, NeedsWeights concern (out of scope here).