MOSS-Audio-Tokenizer
Introduction
This is the code for MOSS-Audio-Tokenizer presented in the MOSS-Audio-Tokenizer: Scaling Audio Tokenizers for Future Audio Foundation Models. MOSS-Audio-Tokenizer is a unified discrete audio tokenizer based on the Cat (Causal Audio Tokenizer with Transformer) architecture. Scaling to 1.6 billion parameters, it functions as a unified discrete interface, delivering both lossless-quality reconstruction and high-level semantic alignment.
Key Features:
- Extreme Compression & Variable Bitrate: It compresses 24kHz raw audio into a remarkably low frame rate of 12.5Hz. Utilizing a 32-layer Residual Vector Quantizer (RVQ), it supports high-fidelity reconstruction across a wide range of bitrates, from 0.125kbps to 4kbps.
- Pure Transformer Architecture: The model features a "CNN-free" homogeneous architecture built entirely from Causal Transformer blocks. With 1.6B combined parameters (Encoder + Decoder), it ensures exceptional scalability and supports low-latency streaming inference.
- Large-Scale General Audio Training: Trained on 3 million hours of diverse audio data, the model excels at encoding and reconstructing all audio domains, including speech, sound effects, and music.
- Unified Semantic-Acoustic Representation: While achieving state-of-the-art reconstruction quality, Cat produces discrete tokens that are "semantic-rich," making them ideal for downstream tasks like speech understanding (ASR) and generation (TTS).
- Fully Trained From Scratch: Cat does not rely on any pretrained encoders (such as HuBERT or Whisper) or distillation from teacher models. All representations are learned autonomously from raw data.
- End-to-End Joint Optimization: All components—including the encoder, quantizer, decoder, discriminator, and a decoder-only LLM for semantic alignment—are optimized jointly in a single unified training pipeline.
Summary:
By combining a simple, scalable architecture with massive-scale data, the Cat architecture overcomes the bottlenecks of traditional audio tokenizers. It provides a robust, high-fidelity, and semantically grounded interface for the next generation of native audio foundation models.
This repository is the official implementation of MOSS-Audio-Tokenizer.
Architecture of MOSS-Audio-Tokenizer
Quick Link
Release
- [2026/6/16] 📊 Released MOSS-Audio-Tokenizer-Eval, an objective reconstruction evaluation toolkit for audio tokenizers, neural codecs, audio VAEs, and vocoders. It supports MOSS-Audio-Tokenizer, MOSS-Audio-Tokenizer-v2, and MOSS-Audio-Tokenizer-Nano evaluation with configurable RVQ layers and standard reconstruction metrics. See the MOSS-Audio-Tokenizer-Eval GitHub repository for details.
- [2026/6/7] 🚀 Released MOSS-Audio-Tokenizer-v2, the 48kHz stereo audio tokenizer used by the MOSS-TTS-Local-Transformer-v1.5 model. The model is available on Hugging Face, and ModelScope.
- [2026/5/6] 🎉 Added MLX Audio support for MOSS-TTS and MOSS-Audio-Tokenizer. Visit the MLX Audio GitHub repository for details.
- [2026/4/27] 📊 Released the evaluation results for MOSS-Audio-Tokenizer-Nano. For details, please see the MOSS-TTS-Nano evaluation metrics.
- [2026/4/13] 🚀 Released MOSS-Audio-Tokenizer-Nano, an ultra-lightweight ~20M-parameter audio tokenizer with native 48kHz stereo input and output. The model is available on Hugging Face. For more details, please refer to the MOSS-TTS-Nano GitHub repository.
- [2026/3/4] 🚀 Added ONNX Runtime and TensorRT inference backends for MOSS-Audio-Tokenizer, enabling high-performance deployment without PyTorch dependency. See
onnx/ and trt/ directories for details. We also provide conversion scripts (onnx/export_onnx.py) for community reference.
- [2026/2/12] 🌟 We released the technical report: MOSS-Audio-Tokenizer: Scaling Audio Tokenizers for Future Audio Foundation Models. Read the paper.
- [2026/2/10] 🎉 Released MOSS-TTS Family. Please refer to our blog for details; models and docs can be found in the MOSS-TTS GitHub repository.
- [2026/2/9] 🔥 We released code and checkpoints of MOSS-Audio-Tokenizer. Check out the GitHub repository, Hugging Face weights, and ModelScope weights.
Model List
For MOSS‑TTS Family models and docs, visit the GitHub repos: https://github.com/OpenMOSS/MOSS-TTS and https://github.com/OpenMOSS/MOSS-TTS-Nano
MOSS-Audio-Tokenizer
| Model |
Sampling Rate |
Channels |
Hugging Face |
ModelScope |
| MOSS-Audio-Tokenizer |
24kHz |
1 channel (mono) |
|
|
| MOSS-Audio-Tokenizer (ONNX Runtime) |
24kHz |
1 channel (mono) |
|
|
| MOSS-Audio-Tokenizer-v2 |
48kHz |
2 channels (stereo) |
|
|
| MOSS-Audio-Tokenizer-Nano |
48kHz |
2 channels (stereo) |
|
|
MOSS-TTS Family
| Model |
Hugging Face |
ModelScope |
| MOSS-TTS |
|
|
| MOSS-TTS-v1.5 |
|
|
| MOSS-TTS-Nano |
|
|
| MOSS-TTS-Local-Transformer |
|
|
| MOSS-TTS-Local-Transformer-v1.5 |
|
|
| MOSS-TTSD |
|
|
| MOSS-TTS-Realtime |
|
|
| MOSS-VoiceGenerator |
|
|
| MOSS-SoundEffect |
|
|
| MOSS-SoundEffect-v2.0 |
|
|
HuggingFace (PyTorch)
Installation
# Clone the repository
git clone https://github.com/OpenMOSS/MOSS-Audio-Tokenizer.git
cd MOSS-Audio-Tokenizer
# Install dependencies
conda create -n moss-audio-tokenizer python=3.10 -y
conda activate moss-audio-tokenizer
pip install -r requirements.txt
Usage
Reconstruction
import torch
from transformers import AutoModel
import torchaudio
repo_id = "OpenMOSS-Team/MOSS-Audio-Tokenizer"
model = AutoModel.from_pretrained(repo_id, trust_remote_code=True).eval()
wav, sr = torchaudio.load('demo/demo_gt.wav')
if sr != model.sampling_rate:
wav = torchaudio.functional.resample(wav, sr, model.sampling_rate)
wav = wav.unsqueeze(0)
enc = model.encode(wav, return_dict=True)
print(f"enc.audio_codes.shape: {enc.audio_codes.shape}")
dec = model.decode(enc.audio_codes, return_dict=True)
print(f"dec.audio.shape: {dec.audio.shape}")
wav = dec.audio.squeeze(0)
torchaudio.save("demo/demo_rec.wav", wav, sample_rate=model.sampling_rate)
# Decode using only the first 8 layers of the RVQ
dec_rvq8 = model.decode(enc.audio_codes[:8], return_dict=True)
wav_rvq8 = dec_rvq8.audio.squeeze(0)
torchaudio.save("demo/demo_rec_rvq8.wav", wav_rvq8, sample_rate=model.sampling_rate)
MOSS-Audio-Tokenizer-v2 or MOSS-Audio-Tokenizer-Nano Reconstruction (48kHz Stereo)
import torch
from transformers import AutoModel
import torchaudio
repo_id = "OpenMOSS-Team/MOSS-Audio-Tokenizer-v2"
# repo_id = "OpenMOSS-Team/MOSS-Audio-Tokenizer-Nano"
device = "cuda" if torch.cuda.is_available() else "cpu"
model = AutoModel.from_pretrained(repo_id, trust_remote_code=True).to(device).eval()
wav, sr = torchaudio.load("demo/demo_gt.wav")
if sr != model.sampling_rate:
wav = torchaudio.functional.resample(wav, sr, model.sampling_rate)
if wav.shape[0] == 1:
wav = wav.repeat(model.config.number_channels, 1)
elif wav.shape[0] > model.config.number_channels:
wav = wav[: model.config.number_channels]
input_length = wav.shape[-1]
with torch.inference_mode():
enc = model.encode(wav.unsqueeze(0).to(device), return_dict=True)
dec = model.decode(enc.audio_codes, return_dict=True)
audio = dec.audio[..., :input_length]
torchaudio.save("demo/demo_rec_v2.wav", audio.squeeze(0).cpu(), sample_rate=model.sampling_rate)
print(f"enc.audio_codes.shape: {enc.audio_codes.shape}")
Streaming
MossAudioTokenizerModel.encode and MossAudioTokenizerModel.decode support simple streaming via a chunk_duration argument.
chunk_duration is expressed in seconds.
- It must be <=
MossAudioTokenizerConfig.causal_transformer_context_duration.
chunk_duration * MossAudioTokenizerConfig.sampling_rate must be divisible by MossAudioTokenizerConfig.downsample_rate.
- Streaming chunking only supports
batch_size=1.
import torch
from transformers import AutoModel
repo_id = "OpenMOSS-Team/MOSS-Audio-Tokenizer"
model = AutoModel.from_pretrained(repo_id, trust_remote_code=True).eval()
audio = torch.randn(1, 1, 3200) # dummy waveform
# 0.08s @ 24kHz = 1920 samples, divisible by downsample_rate=1920
enc = model.encode(audio, return_dict=True, chunk_duration=0.08)
dec = model.decode(enc.audio_codes, return_dict=True, chunk_duration=0.08)
For MOSS-Audio-Tokenizer-v2 or MOSS-Audio-Tokenizer-Nano, use 48kHz stereo input and output:
import torch
from transformers import AutoModel
repo_id = "OpenMOSS-Team/MOSS-Audio-Tokenizer-v2"
# repo_id = "OpenMOSS-Team/MOSS-Audio-Tokenizer-Nano"
device = "cuda" if torch.cuda.is_available() else "cpu"
model = AutoModel.from_pretrained(repo_id, trust_remote_code=True).to(device).eval()
audio = torch.randn(1, 2, 48000 * 6, device=device)
with torch.inference_mode():
enc = model.encode(audio, return_dict=True, chunk_duration=0.08)
dec = model.decode(enc.audio_codes, return_dict=True, chunk_duration=0.08)
ONNX Runtime
Installation
# From repository root
mkdir weights
cd weights
git clone https://huggingface.co/OpenMOSS-Team/MOSS-Audio-Tokenizer-ONNX
cd -
# CPU version
pip install onnxruntime librosa soundfile
# GPU version (CUDA/TensorRT)
pip install onnxruntime-gpu librosa soundfile
Usage