TL;DR
SoundStream is a neural audio codec. A convolutional encoder turns a waveform into a short sequence of embeddings, a residual vector quantizer turns each embedding into a few small integer codes, and a decoder rebuilds the waveform from those codes. All three parts are trained together with adversarial and reconstruction losses. In listening tests at 3 kbps it beat Opus at 12 kbps and approached EVS at 9.6 kbps, and one model covers bitrates from 3 to 18 kbps.
Builds on: Vector Quantization, Residual Vector Quantization, Generative Adversarial Network, Dilated Convolution, Causal Convolution · Leads to: EnCodec, a later neural codec built on the same ideas
Why it mattered
Speech and music are sent over the internet at low bitrates by traditional codecs such as Opus and EVS. These are carefully engineered signal-processing systems. The paper notes that Opus runs inside applications such as WebRTC services, and that it is one of the main codecs used for streaming on YouTube. Any gain in rate-quality trade-off therefore lands on very large volumes of traffic.
SoundStream's central result is the size of that gain. At 3 kbps, listeners preferred it to Opus at 12 kbps, and to match its quality EVS needed at least 9.6 kbps and Opus at least 12 kbps. That is 3.2 to 4 times the bits. The authors also claim it is the first neural codec shown to beat both Opus and EVS over this broad bitrate range. The model runs in real time on one CPU thread of a smartphone.
The design also changed how neural codecs are built. Earlier learned codecs were trained for one bitrate, were limited to speech, or fixed the features and learned only a decoder. SoundStream trains every part end-to-end and uses one set of weights for every bitrate.
The problem
Waveform codecs keep audio faithful at medium and high bitrates, but at low bitrates they produce coding artefacts. Parametric codecs handle low bitrates by assuming a source model, usually speech, so they struggle with music and general audio. A codec that is good at both low rate and general content has to learn the representation from data.
A learned codec needs a bottleneck that can be trained by gradient descent and that stays small. Vector quantization offers that, but it has a cost problem. At 6 kbps with 75 frames per second, each frame gets 80 bits. A plain quantizer for 80 bits would need a codebook of vectors, which cannot be stored or searched. The paper therefore needs a quantizer whose size grows with the number of bits in a practical way.
A codec also has to serve many bitrates without retraining, and it has to run on a phone with little delay. The paper's answer to both is in the structure of the model, not in extra training data.
How it works
The codec is a pipeline with a learned encoder, a quantizer and a decoder, and a set of discriminators that are used only during training.
flowchart LR A["24 kHz waveform"] --> B["Causal conv encoder, strides 2 4 5 8"] B --> C["Embedding every 320 samples"] C --> D["Residual VQ: N_q stages of 1024 codes"] D --> E["Sum of selected codes"] E --> F["Transposed-conv decoder"] F --> G["Reconstructed waveform"]
- Frame the waveform. At 24 kHz, the product of the encoder strides is , so one embedding covers 320 samples. Check: embeddings per second.
- Encode with causal convolutions. The encoder is a stack of blocks. Each block has three residual units with dilated convolutions, dilation rates 1, 3 and 9, followed by a strided convolution that down-samples. The channel count doubles at each down-sampling step. Every convolution is causal, so padding is applied only to the past. Check: a sample's embedding never waits for future audio, so the latency comes only from the frame length.
- Quantize residually. The first codebook replaces the embedding with its nearest code. The leftover, the residual, is quantized by a second codebook, and so on for stages. The reconstruction is the sum of the chosen codes. With 1024 codes per stage, each stage costs 10 bits. Check: 8 stages give 80 bits per frame, and bits per second, which is 6 kbps.
- Decode. The summed embedding goes through a convolution and then mirrored blocks. Each block up-samples with a transposed convolution and then runs the same three residual units, with the strides in reverse order. A final one-filter convolution produces the waveform. Check: the strides multiply back to 320, so the output has the same length as the input.
- Score the output during training. Three waveform discriminators work at three resolutions, and one spectrogram discriminator works on the complex short-time Fourier transform with a window of 1024 and a hop of 256. The generator is trained with an adversarial loss, a feature-matching loss from inside the discriminators, and a multi-scale spectral loss. Check: the feature weight is 100, the other two weights are 1.
- Choose a bitrate at run time. During training, the number of stages is drawn at random from 1 to for each example, so the decoder learns to work from any prefix of the stages. At run time, sets the bitrate. Check: at 3 kbps, , since bits per second.
The math
Let be the waveform, the encoder, the residual quantizer and the decoder. The generator is , and the reconstruction is .
Step 3 in symbols: residual quantization
Start with , where is an embedding. For stage with codebook , choose the nearest code to and update the residual:
The quantized embedding is . If each codebook has entries, the stage costs bits, so stages cost bits per frame. At frames per second, the bitrate is . With this is bits per second.
Step 1 in symbols: the frame rate
With input samples and stride product , the encoder outputs embeddings, a rate of per second. At Hz this is 75.
Step 5 in symbols: the losses
The discriminator uses a hinge loss, averaged over time . The paper also averages over its discriminators, and the formulas below show one discriminator for brevity:
The adversarial loss for the generator is . The feature loss compares the intermediate activations of the discriminator on real and decoded audio:
The spectral loss sums over window lengths an term on mel spectra and a log term weighted by . The generator loss is
Step 6 in symbols: quantizer dropout
For each training example, sample uniformly from and use only the first quantizers. The embedding dimension does not change with , so the same encoder and decoder serve every bitrate.
Joint enhancement in symbols
The denoising switch enters through FiLM layers, which scale and shift an activation by values and computed from a one-hot mode signal: .
Worked examples
1. Tiny: bits and bitrate
- Frames per second: 75. Check: from the stride product 320 at 24 kHz.
- Bits per frame with 8 stages of 1024 codes: . Check: .
- Bitrate: bits per second, which is 6 kbps.
- Interpretation: halving the stages to 4 gives 3 kbps, and doubling them to 16 gives 12 kbps. The codebook stays the same size at every bitrate, and only the number of stages changes.
2. Standard: residual quantization on a number line
Take the embedding . Stage 1 has codes , stage 2 has codes , and stage 3 has codes .
- Stage 1: nearest code to 2.7 is 2, since and . Residual: .
- Stage 2: nearest code to 0.7 is 0.5, since and . Residual: .
- Stage 3: nearest code to 0.2 is 0.25, since . Residual: .
- Reconstruction: . Check: the error is , which equals the last residual exactly.
- Interpretation: each stage removes most of what the stages before it left, so a few small codes reach a precise value. This is why residual stages make a large effective codebook from small ones.
3. Realistic: the learned encoder at half the bitrate
The paper's ablation at 6 kbps compares a learned encoder with a fixed mel-filterbank encoder. The ViSQOL quality score is 3.96 for the learned encoder and 3.33 for the mel encoder. The learned encoder at 3 kbps scores 3.76.
- Quality gap at 6 kbps: points.
- Relative size of that gap: percent of the learned score.
- Learned encoder at 3 kbps against mel encoder at 6 kbps: points. Check: the learned model at half the bitrate still scores higher than the mel model at full bitrate.
- Interpretation: the learned encoder buys more than a bitrate doubling does. The paper's wording is that the extra complexity of a learnable encoder gives a very significant improvement in the rate-quality trade-off.
- Try it: how much above the mel model's 6 kbps score is the learned model's 3 kbps score, as a percentage of 3.33?
Answer: , so about 12.9 percent higher.
Common mistakes and tradeoffs
- It is tempting to think a neural codec wins by being a better speech model. In fact the paper's gains hold across speech, noisy speech and music, and it calls the 3 kbps music result the first time a codec operates on diverse content at such a low bitrate.
- It is tempting to think more quantizer stages always help. In fact at a fixed bitrate, fewer stages with larger codebooks are the more efficient choice, at a higher computational cost. The paper's table shows 8 stages of 1024 codes at 4.01 and 80 stages of 2 codes at 3.92.
- It is tempting to think a longer frame gives better quality for the same bits. In fact the paper's latency study finds the three stride settings equally good in quality, while longer frames, which mean more latency, raise the real-time factor (the audio duration divided by the processing time, so a value above 1 means faster than real time).
- It is tempting to think the same stride and stage settings carry over to a new sampling rate. In fact the stride product fixes the frame in samples, so the frame duration and the bit budget per frame both change, and the model should be retrained at the new rate; the paper trains at 24 kHz.
| Design choice | Benefit | Cost |
|---|---|---|
| Learned encoder | Much better rate-quality trade-off | More compute than mel features |
| Residual VQ | Large effective codebook from small codes | More stages to run |
| Quantizer dropout | One model for many bitrates | Slight loss at the very lowest rate versus a model trained for it |
| Causal convolutions | Streaming with low latency | No look-ahead, so less context per frame |
Results
| Result | Number in the paper |
|---|---|
| 3 kbps against Opus | Opus needs 12 kbps or more to match, so 4 times the bits |
| 3 kbps against EVS | EVS needs at least 9.6 kbps to match, so about 3.2 times the bits |
| Medium bitrate, 6 kbps | EVS and Opus need 2.2 to 2.6 times as many bits |
| High bitrate, 12 kbps | EVS and Opus need 1.3 to 1.6 times as many bits |
| Music at 3 kbps | Better than Opus at 12 kbps and EVS at 5.9 kbps |
| ViSQOL across 3 to 18 kbps | Stays above 3.7 even at 3 kbps |
| Entropy coding on top | Potential saving of 7 to 20 percent |
| Learned vs mel encoder at 6 kbps | ViSQOL 3.96 vs 3.33 |
| Quantizer depth at 6 kbps | 8 stages of 1024 give 4.01; 80 stages of 2 give 3.92 |
| Real-time factor, default model | Above 2.3 on one CPU thread of a Pixel 4 |
| Architectural latency, default | 320 samples, about 13 ms per frame at 24 kHz |
Bitrate scalability. The single model trained with quantizer dropout matches models trained for one bitrate at 6 and 12 kbps, and is slightly worse at 3 kbps. Without dropout, a model trained at 18 kbps degrades when run at lower bitrates, and the gap grows as the bitrate falls.
Joint compression and enhancement. A conditioning signal turns background-noise suppression on or off at run time, with no extra latency. The paper reports that adding the conditioning at the encoder or at the decoder both work.
Limits. The main listening test used 200 clips of 2 to 4 seconds, each rated 20 times by crowd raters, so it measures perceived quality in short clips. ViSQOL was chosen for model selection because it correlates with listening results and is freely available, and PESQ and POLQA were set aside because of licensing restrictions. The encoder is a real cost: the paper's table shows that lighter encoders run much faster with little quality loss, and that a lighter decoder hurts more. The constant-bitrate model does not exploit the 7 to 20 percent entropy-coding saving in its main results.
Reading guide
- Section I, Introduction. Read Autoencoder for the idea of a compressed code learned from data, and Vector Quantization for the bottleneck.
- Section II, Related work. WaveNet is the autoregressive decoder that earlier neural codecs used, and Generative Adversarial Network is the family that SoundStream's decoder and losses come from.
- Section III-A and III-B, Encoder and decoder. The encoder's layers are Causal Convolution and Dilated Convolution. The decoder's up-sampling is Transposed Convolution, inside a Convolutional Neural Network.
- Section III-C, Residual vector quantizer. Read Residual Vector Quantization first. The codebook initialisation uses K-Means Clustering, and the codebook updates use an Exponential Moving Average. The mel-spectrogram baseline that the ablations compare against is Mel Spectrogram, tested in Section V-D.
- Section III-D and III-E, Discriminators and losses. The feature loss is Feature Matching Loss, and the spectrogram discriminator uses the Fourier Transform.
- Section V, Results. Section IV-B describes the quality measure ViSQOL, and the later codec High Fidelity Neural Audio Compression uses the same overall recipe.
Check yourself
QuestionWhat is quantizer dropout, and what does it let one model do?Show answer
QuestionA codec uses 16 quantizer stages with 1024 codes each, at 75 frames per second. What is its bitrate?Show answer
QuestionWhy does a plain vector quantizer fail at 80 bits per frame, and how does the residual version avoid the problem?Show answer
QuestionA team wants to run a SoundStream-style codec at 16 kHz with a 40 ms latency budget and a 6 kbps target. What should they check?Show answer
Sources
- Zeghidour N, Luebs A, Omran A, Skoglund J, Tagliasacchi M (2021). SoundStream: An End-to-End Neural Audio Codec. arXiv. https://arxiv.org/abs/2107.03312
- DOI for the arXiv preprint: https://doi.org/10.48550/arXiv.2107.03312