Model reference · open weights

xcodec2

Audio HKUSTAudio Audio→audio 1 build Non-commercial 1k dl/mo

xcodec2 is an open-weight audio or speech model from HKUSTAudio. xcodec2 (FP32) weighs 1.6 GB; the smallest configuration that runs it is RTX 3060 12 GB.

For self-hosting, compare this build's requirements below with the GPU you plan to rent.

  • xcodec2 is an audio-to-audio speech tokenizer developed by HKUSTAudio with 823M parameters.
  • It features single vector quantization, processes audio at 50 tokens per second, and supports multilingual speech semantic support alongside high-quality speech reconstruction.
  • The model is released under the cc-by-nc-4.0 licence.

Summary of the HKUSTAudio/xcodec2 model card, 2026-10-01

What it is

Released byHKUSTAudio
Released2025-01-07
Parameters823M
VRAM1.6 GB for the weights

What it runs on

Memory and cards for xcodec2 (FP32)

1.6 GBweights, file size
1.6 GBruntime overhead
CardOne streamMemory
RTX 3060 12 GBfits11.6 GB
RTX 4060 Ti 16 GBfits15.4 GB
RTX 3090 24 GBfits23.4 GB
RTX 4090 24 GBfits23.4 GB
RTX 5090 32 GBfits31.0 GB
L40S 48 GBfits44.0 GB
A100 80 GBfits78.2 GB
H100 80 GBfits78.1 GB
RTX PRO 6000 Blackwell 96 GBfits93.8 GB
DGX Spark (GB10) 128 GB unifiedfits107 GB
H200 141 GBfits138 GB
B200 180 GBfits176 GB

From the model card

What HKUSTAudio says about xcodec2

Read the model card

Update (2026-06-25): A Transformers-native version of Xcodec2 has been released here!

Update (2025-02-13): Add Llasa finetune instruction.

Update (2025-02-07): Our paper has been released!

Paper

LLaSA: Scaling Train Time and Inference Time Compute for LLaMA based Speech Synthesis

Codec Does Matter: Exploring the Semantic Shortcoming of Codec for Audio Language Model (AAAI 2025, xcodec 1.0)

Getting Started with XCodec2 on Hugging Face

XCodec2 is a speech tokenizer that offers the following key features:

  1. Single Vector Quantization
  2. 50 Tokens per Second
  3. Multilingual Speech Semantic Support and High-Quality Speech Reconstruction

To use xcodec2, ensure you have it installed. You can install it using the following command:

conda create -n xcodec2 python=3.9
conda activate xcodec2
pip install xcodec2  (Use `xcodec2==0.1.5` for codec inference and llasa fine-tuning. I’ve removed unnecessary dependencies, and it works fine in my testing. However,  I’m not sure if other problems may arise. If you prefer more stability, I recommend using `xcodec2==0.1.3` which accurately aligns during my codec training.)

Then,

import torch
import soundfile as sf
from transformers import AutoConfig

from xcodec2.modeling_xcodec2 import XCodec2Model

model_path = "HKUSTAudio/xcodec2"

model = XCodec2Model.from_pretrained(model_path)
model.eval().cuda()

wav, sr = sf.read("test.wav")
wav_tensor = torch.from_numpy(wav).float().unsqueeze(0)  # Shape: (1, T)

with torch.no_grad():
   # Only 16khz speech
   # Only supports single input. For batch inference, please refer to the link below.
    vq_code = model.encode_code(input_waveform=wav_tensor)
    print("Code:", vq_code )

    recon_wav = model.decode_code(vq_code).cpu()       # Shape: (1, 1, T')

sf.write("reconstructed.wav", recon_wav[0, 0, :].numpy(), sr)
print("Done! Check reconstructed.wav")

If you want to train your own xcodec2, batch inference, or large-scale code extraction, the code is released here.

Quoted from the model card on Hugging Face. The full card is behind the Hugging Face link above.

© 2026 AxForge · EU-hosted AI infrastructure Pricing Docs Trust Privacy Terms