HKUSTAudio / xcodec2

huggingface.co
Total runs: 20.5K
24-hour runs: 0
7-day runs: -504
30-day runs: -41.4K
Model's Last Updated: February 24 2025
audio-to-audio

Introduction of xcodec2

Model Details of xcodec2

Paper

LLaSA: Scaling Train Time and Test Time Compute for LLaMA based Speech Synthesis (Comming soon)

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==0.1.3 (Fix the bug in the previous version to achieve better sound quality)

Then,

import torch
import soundfile as sf
from transformers import AutoConfig

 
from xcodec2.modeling_xcodec2 import XCodec2Model
 
model_path = "HKUST-Audio/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 .

Runs of HKUSTAudio xcodec2 on huggingface.co

20.5K
Total runs
0
24-hour runs
-412
3-day runs
-504
7-day runs
-41.4K
30-day runs

More Information About xcodec2 huggingface.co Model

xcodec2 huggingface.co

xcodec2 huggingface.co is an AI model on huggingface.co that provides xcodec2's model effect (), which can be used instantly with this HKUSTAudio xcodec2 model. huggingface.co supports a free trial of the xcodec2 model, and also provides paid use of the xcodec2. Support call xcodec2 model through api, including Node.js, Python, http.

HKUSTAudio xcodec2 online free

xcodec2 huggingface.co is an online trial and call api platform, which integrates xcodec2's modeling effects, including api services, and provides a free online trial of xcodec2, you can try xcodec2 online for free by clicking the link below.

HKUSTAudio xcodec2 online free url in huggingface.co:

https://huggingface.co/HKUSTAudio/xcodec2

xcodec2 install

xcodec2 is an open source model from GitHub that offers a free installation service, and any user can find xcodec2 on GitHub to install. At the same time, huggingface.co provides the effect of xcodec2 install, users can directly use xcodec2 installed effect in huggingface.co for debugging and trial. It also supports api for free installation.

xcodec2 install url in huggingface.co:

https://huggingface.co/HKUSTAudio/xcodec2

Url of xcodec2

Provider of xcodec2 huggingface.co

HKUSTAudio
ORGANIZATIONS

Other API from HKUSTAudio

huggingface.co

Total runs: 12.0K
Run Growth: 3.9K
Growth Rate: 31.86%
Updated:May 10 2025
huggingface.co

Total runs: 551
Run Growth: 212
Growth Rate: 37.39%
Updated:February 18 2026
huggingface.co

Total runs: 291
Run Growth: 159
Growth Rate: 54.64%
Updated:March 09 2025
huggingface.co

Total runs: 173
Run Growth: -309
Growth Rate: -188.41%
Updated:May 10 2025
huggingface.co

Total runs: 108
Run Growth: 46
Growth Rate: 42.59%
Updated:May 09 2025
huggingface.co

Total runs: 0
Run Growth: 0
Growth Rate: 0.00%
Updated:February 10 2026