Downloads · 30 days
32
8% of all-time downloads
hance-ai/descript-audio-codec-24khz
descript-audio-codec-24khz is a machine learning model from hance-ai. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as mit.
DAC is the state-of-the-art audio tokenizer with improvement upon the previous tokenizers like SoundStream and EnCodec.
Downloads · 30 days
32
8% of all-time downloads
All-time downloads
406
Public
Parameters
74.7M
606 MB on disk
Likes
3
Public
Click a slice to open those files.
.safetensors299 MB · 100%
From the Hugging Face model README
DAC is the state-of-the-art audio tokenizer with improvement upon the previous tokenizers like SoundStream and EnCodec.
This model card provides an easy-to-use API for a pretrained DAC [1] for 24khz audio whose backbone and pretrained weights are from its original reposotiry. With this API, you can encode and decode by a single line of code either using CPU or GPU. Furhtermore, it supports chunk-based processing for memory-efficient processing, especially important for GPU processing.
There are three types of model depending on an input audio sampling rate.
| Model | Input audio sampling rate [khz] |
|---|---|
hance-ai/descript-audio-codec-44khz | 44.1khz |
hance-ai/descript-audio-codec-24khz | 24khz |
hance-ai/descript-audio-codec-16khz | 16khz |
See requirements.txt.
from transformers import AutoModel
# device setting
device = 'cpu' # or 'cuda:0'
# load
model = AutoModel.from_pretrained('hance-ai/descript-audio-codec-24khz', trust_remote_code=True)
model.to(device)
audio_filename = 'path/example_audio.wav'
zq, s = model.encode(audio_filename)
zq is discrete embeddings with dimension of (1, num_RVQ_codebooks, token_length) and s is a token sequence with dimension of (1, num_RVQ_codebooks, token_length).
# decoding from `zq`
waveform = model.decode(zq=zq) # (1, 1, audio_length); the output has a mono channel.
# decoding from `s`
waveform = model.decode(s=s) # (1, 1, audio_length); the output has a mono channel.
model.waveform_to_audiofile(waveform, 'out.wav')
model.save_tensor(s, 'tokens.pt')
loaded_s = model.load_tensor('tokens.pt')
[1] Kumar, Rithesh, et al. "High-fidelity audio compression with improved rvqgan." Advances in Neural Information Processing Systems 36 (2024).
<!-- contributions - chunk processing - add device parameter in the test notebook -->