Descript Audio Codec (.dac): High-Fidelity Audio Compression with Improved RVQGAN
This repository is a wrapper around the original Descript Audio Codec model, a high fidelity general neural audio codec, introduced in the paper titled High-Fidelity Audio Compression with Improved RVQGAN.
It is designed to be used as a drop-in replacement of the transformers implementation of Encodec, so that architectures that use Encodec can also be trained with DAC instead.
The Parler-TTS library is an example of how to use DAC to train high-quality TTS models. We released Parler-TTS Mini v0.1, a first iteration model trained using 10k hours of narrated audiobooks. It generates high-quality speech with features that can be controlled using a simple text prompt (e.g. gender, background noise, speaking rate, pitch and reverberation)
To use this checkpoint, you first need to install the Parler-TTS library with (to do once):
👉 With Descript Audio Codec, you can compress 44.1 KHz audio into discrete codes at a low 8 kbps bitrate.
🤌 That's approximately 90x compression while maintaining exceptional fidelity and minimizing artifacts.
💪 Descript universal model works on all domains (speech, environment, music, etc.), making it widely applicable to generative modeling of all audio.
👌 It can be used as a drop-in replacement for EnCodec for all audio language modeling applications (such as AudioLMs, MusicLMs, MusicGen, etc.)
Weights are released as part of this repo under MIT license.
We release weights for models that can natively support 16 kHz, 24kHz, and 44.1kHz sampling rates.
Weights are automatically downloaded when you first run encode or decode command. You can cache them using one of the following commands
bash
1python3 -m dac download # downloads the default 44kHz variant2python3 -m dac download --model_type 44khz # downloads the 44kHz variant3python3 -m dac download --model_type 24khz # downloads the 24kHz variant4python3 -m dac download --model_type 16khz # downloads the 16kHz variant
We provide a Dockerfile that installs all required dependencies for encoding and decoding. The build process caches the default model weights inside the image. This allows the image to be used without an internet connection. Please refer to instructions below.
This command will create .dac files with the same name as the input files.
It will also preserve the directory structure relative to input root and
re-create it in the output directory. Please use python -m dac encode --help
for more options.
This command will create .wav files with the same name as the input files.
It will also preserve the directory structure relative to input root and
re-create it in the output directory. Please use python -m dac decode --help
for more options.
Programmatic Usage
py
1import dac
2from audiotools import AudioSignal
34# Download a model5model_path = dac.utils.download(model_type="44khz")6model = dac.DAC.load(model_path)78model.to('cuda')910# Load audio signal file11signal = AudioSignal('input.wav')1213# Encode audio signal as one long file14# (may run out of GPU memory on long files)15signal.to(model.device)1617x = model.preprocess(signal.audio_data, signal.sample_rate)18z, codes, latents, _, _ = model.encode(x)1920# Decode audio signal21y = model.decode(z)2223# Alternatively, use the `compress` and `decompress` functions24# to compress long files.2526signal = signal.cpu()27x = model.compress(signal)2829# Save and load to and from disk30x.save("compressed.dac")31x = dac.DACFile.load("compressed.dac")3233# Decompress it back to an AudioSignal34y = model.decompress(x)3536# Write to file37y.write('output.wav')