Downloads · 30 days
332
6% of all-time downloads
OpenMOSS-Team/XY_Tokenizer_TTSD_V0_hf
XY_Tokenizer_TTSD_V0_hf is a machine learning model from OpenMOSS-Team. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as apache-2.0.
XY-Tokenizer is a speech codec that simultaneously models both semantic and acoustic aspects of speech, converting audio into discrete tokens and decoding them back to high-quality audio. It achieves efficient speech…
Downloads · 30 days
332
6% of all-time downloads
All-time downloads
5.3K
Public
Repo size
4.3 GB
Likes
1
Public
Click a slice to open those files.
.bin2.1 GB · 100%
From the Hugging Face model README
XY-Tokenizer is a speech codec that simultaneously models both semantic and acoustic aspects of speech, converting audio into discrete tokens and decoding them back to high-quality audio. It achieves efficient speech representation at only 1kbps with RVQ8 quantization at 12.5Hz frame rate.
XY-Tokenizer serves as the underlying neural codec for MOSS-TTSD, our 1.7B Audio Language Model.
Explore MOSS-TTSD for advanced text-to-speech and other audio generation tasks on GitHub, Blog, 博客, and Space Demo.
Here's how to use XY-Tokenizer with transformers to encode an audio file into discrete tokens and decode it back into a waveform.
import torchaudio
from transformers import AutoFeatureExtractor, AutoModel
# 1. Load the feature extractor and the codec model
model_id = "OpenMOSS-Team/XY_Tokenizer_TTSD_V0_hf"
feature_extractor = AutoFeatureExtractor.from_pretrained(model_id, trust_remote_code=True)
codec = AutoModel.from_pretrained(model_id, trust_remote_code=True).eval().to("cuda")
# 2. Load and preprocess the audio
# The model expects a 16kHz sample rate.
wav_form, sampling_rate = torchaudio.load("examples/m1.wav")
if sampling_rate != 16000:
wav_form = torchaudio.functional.resample(wav_form, orig_freq=sampling_rate, new_freq=16000)
# 3. Encode the audio into discrete codes
input_features = feature_extractor(wav_form, sampling_rate=16000, return_attention_mask=True, return_tensors="pt")
# The 'code' dictionary contains the discrete audio codes
code = codec.encode(input_features)
# 4. Decode the codes back to an audio waveform
# The output is high-quality 24kHz audio.
output_wav = codec.decode(code["audio_codes"], overlap_seconds=10)
# 5. Save the reconstructed audio
for i, audio in enumerate(output_wav["audio_values"]):
torchaudio.save(f"audio_{i}.wav", audio.cpu(), 24000)