{"id":24608,"library":"snac","title":"SNAC","description":"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.","status":"active","version":"1.2.1","language":"python","source_language":"en","source_url":"https://github.com/hubertsiuzdak/snac","tags":["audio","neural-codec","pytorch","compression","llm"],"install":[{"cmd":"pip install snac","lang":"bash","label":"Latest PyPI"}],"dependencies":[{"reason":"Required for tensor operations and model inference.","package":"torch","optional":false}],"imports":[{"note":"","wrong":"","symbol":"SNAC","correct":"from snac import SNAC"}],"quickstart":{"code":"import torch\nfrom snac import SNAC\n\nmodel = SNAC.from_pretrained(\"hubertsiuzdak/snac_24khz\")\naudio = torch.randn(1, 1, 24000)  # 1 second of 24 kHz audio\ncodes = model.encode(audio)\nprint(\"Codes shape:\", codes.shape)\nreconstructed = model.decode(codes)\nprint(\"Audio shape:\", reconstructed.shape)","lang":"python","description":"Load a pretrained model, encode audio to discrete codes, and decode back to audio."},"warnings":[{"fix":"Upgrade to >=1.2.0 or use `codes = model.encode(audio)` and handle list.","message":"The `encode` method returns a list of tensors (one per layer) in version <1.2.0, but returns a single stacked tensor in 1.2.0+. Check your version and adjust code accordingly.","severity":"gotcha","affected_versions":"<1.2.0"},{"fix":"Upgrade to 1.2.1 or use a Hugging Face model ID.","message":"Loading models from a local filepath was broken in 1.2.0 and fixed in 1.2.1. If you use `SNAC.from_pretrained('./local_model')`, ensure version >=1.2.1.","severity":"deprecated","affected_versions":"1.2.0"},{"fix":"Resample input audio to match the model's sample rate before encoding.","message":"The model expects audio resampled to the model's sample rate (24kHz, 32kHz, or 44kHz). Failure to resample will produce garbled output.","severity":"gotcha","affected_versions":"all"},{"fix":"Use only v1.x models and upgrade to latest version.","message":"Version 1.0.0 introduced a completely new architecture and model zoo. Models from v0.x (if they existed) are incompatible.","severity":"breaking","affected_versions":"<1.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Ensure you installed the correct package: `pip install snac`. Check that you are not shadowing the package with a local file named snac.py.","cause":"SNAC was not installed correctly or an incompatible version is installed.","error":"ImportError: cannot import name 'SNAC' from 'snac'"},{"fix":"Move the model and input to the same device: `model = model.to('cuda'); audio = audio.to('cuda')`.","cause":"The model is on one device, but the input tensor is on another.","error":"RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cpu and cuda:0!"},{"fix":"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.","cause":"The model name is incorrect or the model is not publicly accessible.","error":"OSError: Can't load tokenizer for 'hubertsiuzdak/snac_24khz'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}