Multi-Scale Neural Audio Codec for audio compression, supporting 24 kHz, 32 kHz, and 44 kHz sampling rates. This is a PyTorch-based library for encoding audio into discrete codes (suitable for language modeling) and decoding back to waveform. Current version 1.2.1 has a stable API with `encode` and `decode` methods.
pip install snacVerified import paths — ran on the pinned version, not inferred.
Load a pretrained model, encode audio to discrete codes, and decode back to audio.
Upgrade to >=1.2.0 or use `codes = model.encode(audio)` and handle list.
Upgrade to 1.2.1 or use a Hugging Face model ID.
Resample input audio to match the model's sample rate before encoding.
Use only v1.x models and upgrade to latest version.
Ensure you installed the correct package: `pip install snac`. Check that you are not shadowing the package with a local file named snac.py.
Move the model and input to the same device: `model = model.to('cuda'); audio = audio.to('cuda')`.Use a valid Hugging Face model ID (e.g., 'hubertsiuzdak/snac_24khz', 'hubertsiuzdak/snac_32khz', 'hubertsiuzdak/snac_44khz') or ensure your network can access huggingface.co.