{"id":6341,"library":"descript-audio-codec","title":"Descript Audio Codec","description":"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.","status":"active","version":"1.0.0","language":"en","source_language":"en","source_url":"https://github.com/descriptinc/descript-audio-codec","tags":["audio","codec","neural network","deep learning","compression","pytorch"],"install":[{"cmd":"pip install descript-audio-codec","lang":"bash","label":"PyPI"}],"dependencies":[],"imports":[{"symbol":"DAC","correct":"import dac\nmodel = dac.DAC.load(...)"},{"note":"Required for handling audio data, automatically installed as a dependency.","symbol":"AudioSignal","correct":"from audiotools import AudioSignal"}],"quickstart":{"code":"import dac\nimport torch\nfrom audiotools import AudioSignal\nimport os\n\n# Instantiate the DAC model. Model weights are automatically downloaded and cached.\n# You can specify model_type='16khz', '24khz', or '44khz'. Default is '44khz'.\ndevice = \"cuda\" if torch.cuda.is_available() else \"cpu\"\nmodel = dac.DAC.load(model_type=\"44khz\").to(device)\n\n# Prepare dummy audio for encoding (e.g., 5 seconds of stereo 44.1kHz noise)\nsample_rate = model.sample_rate # 44100\nduration = 5 # seconds\nchannels = 2 # stereo\naudio_tensor = torch.randn(channels, sample_rate * duration, device=device)\naudio_signal = AudioSignal(audio_tensor, sample_rate)\n\n# Encode the audio to discrete codes and get the reconstructed audio\nwith torch.no_grad():\n    # codes: quantized latent representations (discrete tokens)\n    # latents: continuous latent representations\n    # audio_out: reconstructed audio (audiotools.AudioSignal)\n    codes, latents, audio_out = model.encode(audio_signal, return_audio=True)\n\nprint(f\"Original audio shape: {audio_signal.shape}\")\nprint(f\"Encoded codes shape (batch, num_quantizers, sequence_length): {codes.shape}\")\nprint(f\"Decoded audio shape: {audio_out.shape}\")\n\n# In a real application, you might save `codes` for storage/transmission\n# or `audio_out` to a file.\n# Example (requires audiotools): \n# audio_out.write(\"reconstructed_audio.wav\")\n# Example: torch.save(codes, \"compressed_audio_codes.pt\")","lang":"python","description":"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."},"warnings":[{"fix":"Evaluate model performance carefully for specific non-speech audio domains or complex soundscapes.","message":"Model 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.","severity":"gotcha","affected_versions":"All versions"},{"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.","message":"Model 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.","severity":"gotcha","affected_versions":"All versions"},{"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.","message":"Changes 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.","severity":"gotcha","affected_versions":"< 0.0.4"}],"env_vars":null,"last_verified":"2026-04-15T00:00:00.000Z","next_check":"2026-07-14T00:00:00.000Z"}