Feature Extraction
Transformers
Safetensors
PyTorch
liquid_codec
audio
audio-codec
bfloat16
custom_code
Instructions to use LiquidAI/Liquid-Codec with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use LiquidAI/Liquid-Codec with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("feature-extraction", model="LiquidAI/Liquid-Codec", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("LiquidAI/Liquid-Codec", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
|
Download README.md from LiquidAI/Liquid-Codec: direct link, hf CLI and curl.
- Browser
- Download file 1.44 kB
-
https://huggingface.co/LiquidAI/Liquid-Codec/resolve/main/README.md
- Command line
-
hf download hf://LiquidAI/Liquid-Codec/README.md
-
curl -L -o README.md https://huggingface.co/LiquidAI/Liquid-Codec/resolve/main/README.md
1.44 kB
| library_name: transformers | |
| license: other | |
| tags: | |
| - audio | |
| - audio-codec | |
| - pytorch | |
| - bfloat16 | |
| # Liquid Codec BF16 | |
| ## Remote-code loading | |
| The repository includes the codec configuration and model implementation, so it can be loaded with `AutoModel`: | |
| ```python | |
| import torch | |
| from transformers import AutoModel | |
| codec = AutoModel.from_pretrained( | |
| "LiquidAI/Liquid-Codec", | |
| trust_remote_code=True, | |
| dtype=torch.bfloat16, | |
| device_map="cuda", | |
| ) | |
| waveform = torch.randn(1, 24_000 * 3, device="cuda") # 24 kHz | |
| codes = codec.encode(waveform).audio_codes | |
| reconstructed = codec.decode(codes).audio_values | |
| ``` | |
| ## Native loading and streaming | |
| ```python | |
| import torch | |
| from transformers import LiquidCodecModel, LiquidCodecStreamingCache | |
| codec = LiquidCodecModel.from_pretrained("LiquidAI/Liquid-Codec", dtype=torch.bfloat16, device_map="cuda") | |
| waveform = torch.randn(1, 24_000 * 3, device="cuda") # 24 kHz | |
| codes = codec.encode(waveform).audio_codes # (1, 12, 38) | |
| reconstructed = codec.decode(codes).audio_values # (1, 38 * 1920), float32 | |
| # streaming synthesis: every chunk returns the samples that no later frame changes any more | |
| cache = LiquidCodecStreamingCache(codec.config) | |
| chunks = [codec.decode(codes[..., i : i + 1], cache, finalize=False).audio_values for i in range(codes.shape[-1])] | |
| chunks.append(codec.decode(codes[..., :0], cache, finalize=True).audio_values) | |
| streamed = torch.cat(chunks, dim=-1) | |
| ``` | |