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:
Single Vector Quantization
50 Tokens per Second
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 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.
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:
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.