How to use EnCodec: choose a model and bitrate for your audio
Install EnCodec, choose its 24 kHz mono or 48 kHz stereo model, and compress a short WAV from the CLI. Learn supported bitrates, decompression, entropy coding, long-file memory limits, and how to preserve the original.
How to use EnCodec: compress audio with a suitable model and bitrate
EnCodec is an open-source neural codec that compresses audio into learned discrete codes and reconstructs it. For a quick trial, install the package, encode a WAV to an EnCodec .ecdc file with the CLI, then decode it to WAV. First check whether your input is 24 kHz mono speech or 48 kHz stereo audio, then choose a supported bitrate. Encoding and decoding must use compatible model configurations.
Choose the model and bitrate
The project provides two main configurations:
| Input or goal | Model option | Supported bitrates |
|---|---|---|
| 24 kHz mono, such as speech | Default model | 1.5, 3, 6, 12, 24 kbps |
| 48 kHz stereo, such as music | --hq | 3, 6, 12, 24 kbps |
A lower bitrate creates a smaller code stream but may reduce audible detail. At 6 kbps, the ideal raw data rate is about 45 kB per minute: 6,000 bits/s × 60 ÷ 8. Actual file size also depends on the container and any side information or entropy coding, so check the file produced by your workflow.
The 48 kHz model is a separate stereo configuration, not merely a higher sample-rate switch. Without --hq, the default 24 kHz mono model may be selected. If input sample rate or channels do not match, the CLI can resample or reduce channels automatically. Keep an untouched copy of the source and listen for changes caused by conversion.
Install and try a short file
The official repository README, checked on 2026-11-19, lists Python 3.8 and PyTorch 1.11.0 as its stated requirements/recommendation. It officially supports macOS and recent mainstream Linux distributions; Windows support is best-effort, while iOS, Android, and onboard ARM are not supported. These version notes may lag current packages, so check Python, PyTorch, and torchaudio compatibility for your environment before installing. A virtual environment helps isolate dependencies.
python -m venv .venv
# macOS / Linux
source .venv/bin/activate
# Windows PowerShell
.\.venv\Scripts\Activate.ps1
python -m pip install --upgrade pip
python -m pip install -U encodecAssume speech.wav is a short speech recording. The model may download through Torch Hub on first use, so allow network access and disk space for the weights.
# Default 24 kHz mono model, target 6 kbps
encodec -b 6 speech.wav speech.ecdc
# Decode the compressed file to WAV
encodec speech.ecdc speech-restored.wav
# Use the 48 kHz stereo model for music
encodec --hq -b 6 music-stereo.wav music-stereo.ecdc
# Compress and immediately decode for a quick preview
encodec -b 6 speech.wav speech-preview.wavGive the output a different name so the source is not overwritten. The CLI's -f option forcibly overwrites an existing file; use it only intentionally. If the decoded result clips, the -r decoding option rescales its level. Rescaling changes amplitude; it does not restore lost information.
Options and validation
-b sets the target bandwidth in kbps; the default is 6. The 24 kHz model supports 1.5, 3, 6, 12, and 24 kbps; the 48 kHz model supports 3, 6, 12, and 24 kbps.
--hq selects the 48 kHz stereo model. The repository documents 1-second chunks with 1% overlap and per-chunk scale normalization for this model.
--lm enables a pretrained language model and entropy coding. It may further compress the code representation but is much slower; the paper also reports added initial latency from entropy coding. Compare its real delay with the default mode before using it for live conversation.
An .ecdc file is EnCodec-compressed data, not a regular WAV. Decoding requires a compatible implementation and model. For archiving, keep the source, compressed file, package/model version, and encoding options together.
After decoding, level-match the source and reconstruction and compare sections by listening for consonants, background noise, reverberation, stereo image, and clipping. Do not assume that a setting that works for one song or recording will work equally well for another domain. For an important use, compare several representative signals at the same sample rate, channel layout, and bitrate; record first-output latency and file size too.
Long files and recovery
The repository FAQ warns that long inputs are applied to the model as a whole rather than intelligently split, which can use substantial memory and terminate the process. Start with a short copy. If memory runs out, consider smaller segments, but listen for audible joins after decoding and combining them. Keep the original and write to a separate output so a failed attempt is recoverable.
If something goes wrong:
If the encodec command is missing, activate the same virtual environment where the package was installed.
If model weights cannot download, check the network and Torch Hub storage, then retry.
For memory errors, reproduce with a short clip; if segmenting a long input, inspect the boundaries.
If the CLI converted channels or sample rate unexpectedly, inspect the source and choose the appropriate 24 kHz mono or 48 kHz stereo configuration.
Restore an overwritten source from backup. Avoid adding -f casually to automated commands.
Quality and real-time figures in the EnCodec paper are tied to its test data, hardware, and setup. Neither the paper's scores nor the word “real-time” establishes that the implementation will meet your own device or service requirements.
References
[Official EnCodec README: installation, CLI, supported bandwidths, and FAQ](https://github.com/facebookresearch/encodec/blob/main/README.md) (checked 2026-11-19)
[Défossez et al. (2022), High Fidelity Neural Audio Compression](https://arxiv.org/abs/2210.13438)