MODEL TYPE
What Is a Neural Audio Codec?
A neural audio codec turns a sound wave into a short sequence of discrete tokens, and back again, using a neural network instead of a fixed math formula. Those tokens are what let a transformer generate or understand audio the same way it generates or understands text: by predicting the next one.
Compressing sound into tokens, not just smaller sound
A traditional codec like MP3 compresses audio by throwing away detail a human ear is unlikely to notice, using a fixed, hand-designed formula. A neural audio codec does something different: it learns, from data, how to compress a waveform into a short sequence of discrete tokens, then reconstruct audio that sounds close to the original from just those tokens.
Discrete means each token is one of a fixed, finite set of symbols, like a word from a vocabulary, rather than a continuous number. That's the detail that matters most: once sound is represented as discrete tokens, it looks structurally like text to a transformer, a sequence of symbols from a fixed vocabulary, which is exactly the format a language model already knows how to predict.
Encoder, quantizer, decoder
Models like SoundStream and EnCodec follow the same three-stage shape. An encoder, a stack of convolutional layers, compresses the raw waveform into a shorter sequence of continuous vectors. A quantizer then snaps each vector to the nearest entry in a learned codebook, a fixed list of reference vectors, and what gets kept is just the index of that entry: a discrete token. A decoder, mirroring the encoder, takes the token sequence and reconstructs a waveform.
The whole system is trained end-to-end so the reconstructed audio matches the original as closely as possible, with the codebook itself learned during training rather than designed by hand.
Residual vector quantization: layering codebooks to raise quality
Snapping a vector to one codebook entry loses information, the gap between the vector and its nearest codebook match. Residual vector quantization (RVQ), the technique both SoundStream and EnCodec use, fixes this by chaining several codebooks: the first quantizes the vector, a second codebook then quantizes just the leftover error from the first, a third quantizes what's still left after that, and so on.
Each added codebook token buys a bit more fidelity at a bit more storage cost, so a single trained codec can serve several bitrates by simply using more or fewer of its codebooks, without retraining. This is also the direct reason audio tokens can vary in count per second of sound: more codebooks per timestep means more tokens, higher bitrate, and (up to a point) better reconstructed quality.
Why this is the building block behind modern audio AI
Once audio is a token sequence, the exact same next-token training approach behind text LLMs applies: a transformer can be trained to predict the next audio token, generating new sound, or trained on a mixed sequence of audio and text tokens, learning to move between the two modalities in one model. That's the mechanism behind native speech-to-speech systems, and the reason audio generation research increasingly looks like language modeling research with a different vocabulary.
It also means a codec's quality sets a ceiling: a downstream model can only generate audio as good as what its codec's decoder can reconstruct from tokens, so codec fidelity, bitrate, and token rate are active research targets in their own right, not settled infrastructure.
FAQ
- Is a neural audio codec the same thing as a vocoder?
- They overlap but solve different problems. A vocoder (like HiFi-GAN) turns a spectrogram into a waveform for text-to-speech and doesn't need to produce a small, fixed vocabulary of discrete tokens. A neural audio codec's decoder does a similar waveform-reconstruction job, but the discrete, small-vocabulary token output is the point, because that's what lets a transformer predict it as a token sequence.
- Why not just feed raw audio samples straight into a transformer?
- A single second of audio can be tens of thousands of raw samples, far too long a sequence for a transformer to handle efficiently. A neural audio codec compresses that same second into a much shorter sequence of discrete tokens, which is what makes transformer-based audio generation computationally practical at all.
- Do different neural audio codecs produce compatible tokens?
- No. Each codec learns its own codebooks during training, so tokens from one codec are meaningless to a model or decoder built around a different codec. A generative model is trained against one specific codec's tokenization and can't swap to another without retraining.
Sources
Related
Last updated 2026-09-16