Registry / ai-ml / descript-audio-codec

descript-audio-codec

JSON →
library1.0.0pypypiunverified

Descript Audio Codec (DAC) is a high-fidelity, general neural audio codec, currently at version 1.0.0. It enables compression of audio (supporting 16kHz, 24kHz, and 44.1kHz sampling rates) into discrete codes at very low bitrates, achieving approximately 90x compression for 44.1 kHz audio at 8 kbps while maintaining exceptional fidelity. It is designed to be universal, working across various audio domains including speech, music, and environmental sounds, and can serve as a drop-in replacement for codecs like EnCodec in audio language modeling applications. The library maintains an active development pace with regular updates.

pip install descript-audio-codec
INSTALL
IMPORT
SIG · DESCRIPT-AUDIO-COD
D
descript-audio-codec
ai-mlpythonv1.0.0
Install
94.6s avg
Import
7263ms
Disk
5504MB
Pass rate
4/ 10
Env Coverage4 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.0.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
glibc
py 3.10
✕ build_error
✓ 102.08s
py 3.11
✕ build_error
✓ 98.18s
py 3.12
✕ build_error
✓ 94.53s
py 3.13
✕ build_error
✓ 83.7s
py 3.9
✕ build_error
✕ timeout
5504MB installed
● package 5504MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

DAC
import dac model = dac.DAC.load(...)
AudioSignal
from audiotools import AudioSignal
Required for handling audio data, automatically installed as a dependency.

This quickstart demonstrates how to initialize the Descript Audio Codec, generate a dummy audio signal using `audiotools`, and then encode and decode it using the model. Model weights are automatically managed and downloaded on the first run. The output includes the shape of the original audio, the compressed discrete codes, and the reconstructed audio.

import dac import torch from audiotools import AudioSignal import os # Instantiate the DAC model. Model weights are automatically downloaded and cached. # You can specify model_type='16khz', '24khz', or '44khz'. Default is '44khz'. device = "cuda" if torch.cuda.is_available() else "cpu" model = dac.DAC.load(model_type="44khz").to(device) # Prepare dummy audio for encoding (e.g., 5 seconds of stereo 44.1kHz noise) sample_rate = model.sample_rate # 44100 duration = 5 # seconds channels = 2 # stereo audio_tensor = torch.randn(channels, sample_rate * duration, device=device) audio_signal = AudioSignal(audio_tensor, sample_rate) # Encode the audio to discrete codes and get the reconstructed audio with torch.no_grad(): # codes: quantized latent representations (discrete tokens) # latents: continuous latent representations # audio_out: reconstructed audio (audiotools.AudioSignal) codes, latents, audio_out = model.encode(audio_signal, return_audio=True) print(f"Original audio shape: {audio_signal.shape}") print(f"Encoded codes shape (batch, num_quantizers, sequence_length): {codes.shape}") print(f"Decoded audio shape: {audio_out.shape}") # In a real application, you might save `codes` for storage/transmission # or `audio_out` to a file. # Example (requires audiotools): # audio_out.write("reconstructed_audio.wav") # Example: torch.save(codes, "compressed_audio_codes.pt")
Debug
Known issues
gotchaModel limitations exist for certain audio types; it performs best on speech and may have difficulty reconstructing some musical instruments (e.g., glockenspiel) or complex environmental sounds perfectly.
fix
Evaluate model performance carefully for specific non-speech audio domains or complex soundscapes.
affects: All versions
gotchaModel weights are automatically downloaded from the internet on the first use of `dac.DAC.load()` or `dac.utils.download()`. This requires an active internet connection for initial setup.
fix
To pre-cache models or manage downloads explicitly, use `python3 -m dac download --model_type <type>` (e.g., '44khz') to download weights before inference or in a controlled environment.
affects: All versions
gotchaChanges in early `0.x` versions (e.g., between 0.0.3 and 0.0.4) modified the storage format of discrete codes to `uint16`. If you saved codes with very old `0.x` versions, they might not be compatible with newer versions of the library.
fix
Re-encode audio with the current library version if using previously saved codes from versions prior to 0.0.4. For new projects, ensure you are using the latest stable version.
affects: < 0.0.4
Upgrade
Version history
1.0.0latest on PyPI · released Jul 20, 2023
Audit
Dependencies

No dependency data recorded yet.

Agent activity
27 hits · last 30 days
node
24
Perplexity
1
OpenAI (training)
1
Resources
descript-audio-codec — pip install descript-audio-codec · libregistry