Abstract
We introduce a state-of-the-art real-time, high-fidelity, audio codec leveraging neural networks. It consists in a streaming encoder-decoder architecture with quantized latent space trained in an end-to-end fashion. We simplify and speed-up the training by using a single multiscale spectrogram adversary that efficiently reduces artifacts and produce high-quality samples. We introduce a novel loss balancer mechanism to stabilize training: the weight of a loss now defines the fraction of the overall gradient it should represent, thus decoupling the choice of this hyper-parameter from the typical scale of the loss. Finally, we study how lightweight Transformer models can be used to further compress the obtained representation by up to 40%, while staying faster than real time.
Introduction
As audio and video streaming dominate global internet traffic, the demand for efficient compression is critical. Traditional lossy codecs like Opus or EVS rely on hand-engineered psychoacoustic models to remove "inaudible" data. However, these methods often struggle at extremely low bitrates, introducing metallic artifacts or muffled sound. Neural audio codecs have emerged as a promising alternative but face challenges in generalization across diverse audio types, training stability, and real-time efficiency on consumer hardware.
Architecture and Methods
The proposed system, EnCodec, utilizes a convolutional encoder-decoder architecture designed for streaming.
Encoder and Decoder
The model converts raw audio into a latent representation via a 1D-convolutional backbone, followed by LSTM layers for temporal sequence modeling. This structure allows for low-latency processing, essential for real-time applications.
Residual Vector Quantization (RVQ)
To achieve compression, EnCodec employs Residual Vector Quantization. This technique projects the encoder's output onto multiple layers of codebooks. A key advantage of RVQ is its support for variable bitrates (e.g., 1.5, 3, 6, 12 kbps) within a single model instance, allowing for flexible bandwidth management.
Multi-Scale STFT Discriminator (MS-STFTD)
Training is guided by a novel multiscale spectrogram adversary. Instead of complex time-domain discriminators, MS-STFTD operates on spectrograms at different scales, effectively reducing artifacts across the frequency spectrum while simplifying the training pipeline.
The Loss Balancer
A significant technical contribution is the loss balancer. Traditional GAN training requires manual tuning of loss weights ($\lambda$). EnCodec instead defines these weights as the fraction of the overall gradient a specific loss should represent. This decoupling from the raw loss scales significantly stabilizes training and simplifies hyperparameter optimization.
Data and Training
The model was trained on a massive, diverse collection of audio to ensure it doesn't overfit to specific sounds, including speech (DNS Challenge 4, Common Voice), general audio (AudioSet, FSD50K), and music (Jamendo). An "on-the-fly" mixing strategy was used to create complex acoustic environments, forcing the model to handle overlapping speech, music, and noise.
Results and Evaluation
Subjective quality was assessed using MUSHRA (MUltiple Stimuli with Hidden Reference and Anchor) tests, where human listeners rate audio quality.
Key findings include:
- Low Bitrate Superiority: EnCodec at 3 kbps outperformed Lyra-v2 at 6 kbps and Opus at 12 kbps.
- High Fidelity: For 48 kHz stereo music, EnCodec at 24 kbps achieved quality nearly indistinguishable from the original for many listeners.
- Efficiency: The 24 kHz model achieves a latency of 13.3ms and runs approximately 10 times faster than real-time on a single CPU thread (2019 MacBook Pro).
- Transformer Entropy Coding: By applying a lightweight Transformer to predict quantized units, bitrates can be further reduced by 25–40% without quality loss.
Conclusion
EnCodec represents a major step forward in neural audio compression, offering state-of-the-art fidelity at low bitrates while maintaining real-time performance. The introduction of the loss balancer and MS-STFTD provides a robust framework for training high-quality generative audio models. Future work will focus on reducing the compute overhead compared to traditional codecs and further lowering latency for high-fidelity stereo streaming.
Summary updated