--- license: mit tags: - audio --- # SNAC 🍿 Multi-**S**cale **N**eural **A**udio **C**odec (SNAC) compressess audio into discrete codes at a low bitrate. See GitHub repository: https://github.com/hubertsiuzdak/snac/ ## Overview SNAC encodes audio into hierarchical tokens similarly to SoundStream, EnCodec, and DAC. However, SNAC introduces a simple change where coarse tokens are sampled less frequently, covering a broader time span. This model compresses 44 kHz audio into discrete codes at a 2.6 kbps bitrate. It uses 4 RVQ levels with token rates of 14, 29, 57, and 115 Hz. ## Usage Install it using: ```bash pip install snac ``` To encode (and reconstruct) audio with SNAC in Python, use the following code: ```python import torch from snac import SNAC model = SNAC.from_pretrained("hubertsiuzdak/snac_44khz").eval().cuda() audio = torch.randn(1, 1, 44100).cuda() # B, 1, T with torch.inference_mode(): audio_hat, _, codes, _, _ = model(audio) ``` ⚠️ Note that `codes` is a list of token sequences of variable lengths, each corresponding to a different temporal resolution. ``` >>> [code.shape[1] for code in codes] [16, 32, 64, 128] ``` ## Acknowledgements Module definitions are adapted from the [Descript Audio Codec](https://github.com/descriptinc/descript-audio-codec).