Skip to content
ModelListedExternal
Download

CosyVoice 300M ONNX

| Field | Value | | Upstream model | FunAudioLLM/CosyVoice-300M | | Upstream source revision | 24c40509c3c5ea6fe06b5f8790ff99e3714a6bee | | Export tool/script | Community torch.onnx export (CPU PyTorch 2.12, verified...

KindOtherBase modelFunAudioLLM/CosyVoice-300MVersionRevision 1dc153e

Model source

Kind
Other
File size
100 KB–1.16 GB
Base model
FunAudioLLM/CosyVoice-300M
Version
vRevision 1dc153e
Updated
Sep 13, 2026
Downloads
636
Source
Hugging Face

Source description

CosyVoice-300M ONNX

Source

FieldValue
Upstream modelFunAudioLLM/CosyVoice-300M
Upstream source revision24c40509c3c5ea6fe06b5f8790ff99e3714a6bee
Export tool/scriptCommunity torch.onnx export (CPU PyTorch 2.12, verified with onnxruntime 1.26)
Quantization recipeFP32 ONNX component graphs under llm/, flow/, hift/

Precision and Packaging

Export tooling, precision, and quantization are recorded in the Source table above. This packaging mirror does not publish independent parity benchmarks; validate on your target execution provider before production use.

Intended Uses

  • Cross-platform TTS deployment without a PyTorch dependency
  • Edge/embedded inference via ONNX Runtime on CPU, GPU, or NPU
  • Lower-latency serving with execution-provider acceleration (validate before relying on it)
  • Research on TTS model optimization and format conversion

Safety and Responsible Use

CosyVoice-300M is a zero-shot voice-cloning model capable of producing realistic speech that closely matches a target speaker from a short reference clip.

  • Do not use to impersonate real individuals without their explicit consent.
  • Do not generate synthetic speech intended to deceive listeners about a speaker's identity.
  • Disclose AI-generated audio where listeners would reasonably expect a human voice.
  • Users are responsible for compliance with applicable laws governing synthetic media and voice cloning in their jurisdiction.

Limitations & Biases

  1. Autoregressive decoding: The token generator is exported in teacher-forced mode; step-by-step decoding with KV-cache requires custom ONNX graphs or runtime loops
  2. STFT approximation: The vocoder uses DFT matrix multiplication instead of FFT, introducing minor numerical differences (max 1.98 absolute)
  3. Frontend models: campplus.onnx (speaker encoder) and speech_tokenizer_v1.onnx (speech tokenizer) are from the original repo, not part of this conversion
  4. No training data: This is a format conversion, not a trained model — no new training was performed

What's in this repo

ONNX Models (ready for inference)

FileDescriptionInputOutput
llm/text_encoder.onnxText tokenizer + Conformer encoder. Encodes text tokens into hidden representations.text_tokens (B, L) int64, text_lengths (B,) int64encoder_out (B, L, 1024) float32
llm/token_generator.onnxLLM decoder (Transformer encoder + linear head). Predicts speech token logits.lm_input (B, T, 1024) float32, lm_input_len (B,) int64logits (B, T, 4097) float32
flow/encoder.onnxFlow encoder (Conformer + projection). Encodes speech tokens into flow latent space.token (B, T, 512) float32, token_len (B,) int64encoder_out (B, T, 80) float32
hift/source.onnxHiFT source module. Generates harmonic + noise excitation from F0.f0 (B, T, 1) float32sine_source, noise_source, uv (B, T, 1) float32
hift/vocoder.onnxHiFT neural vocoder (decoder). Converts mel spectrogram + source to waveform.speech_feat (B, 80, T_mel) float32, source_signal (B, 1, T_mel*256) float32speech (B, T_audio) float32
hift/f0_predictor.onnxConvRNN F0 predictor. Estimates pitch from mel spectrogram.mel (B, 80, T) float32f0 (B, T) float32

Pre-existing ONNX (from original CosyVoice repo)

FileDescription
campplus.onnxCAM++ speaker embedding model
speech_tokenizer_v1.onnxSpeech tokenizer (encodes audio to discrete tokens)
flow.decoder.estimator.fp32.onnxFlow matching decoder estimator (UNet-style)

PyTorch weights

FileDescription
llm.ptLLM state dict (text encoder + transformer decoder)
flow.ptFlow model state dict (encoder + decoder + CFM)
hift.ptHiFT generator state dict (source + vocoder)

Config

FileDescription
cosyvoice.yamlFull model configuration (architecture, hyperparameters)

Usage

import numpy as np
import onnxruntime as ort

# Load models
text_encoder = ort.InferenceSession("llm/text_encoder.onnx")
token_generator = ort.InferenceSession("llm/token_generator.onnx")
flow_encoder = ort.InferenceSession("flow/encoder.onnx")
hift_source = ort.InferenceSession("hift/source.onnx")
hift_vocoder = ort.InferenceSession("hift/vocoder.onnx")

# Example: encode text tokens
text_tokens = np.array([[101, 2023, 3042, 102]], dtype=np.int64)  # tokenized input
text_lengths = np.array([4], dtype=np.int64)
encoded = text_encoder.run(None, {"text_tokens": text_tokens, "text_lengths": text_lengths})[0]
# encoded shape: (1, 4, 1024)

Benchmarks

[!NOTE] All figures below were measured by the repository maintainer on a single NVIDIA RTX 5070 machine (PyTorch 2.12, onnxruntime 1.26). They are illustrative, not guaranteed, and were not independently reproduced. Re-measure on your own hardware and execution provider before relying on them. Numbers describe latency/throughput, not output quality.

Inference Latency (NVIDIA RTX 5070)

All latencies report mean (p50, p95) in milliseconds.

ComponentInputCPU (ms)GPU (ms)TRT RTX (ms)GPU SpeedupTRT/CUDA
LLM Text Encoder5 tokens20.59.21.02.2x9.0x
LLM Text Encoder50 tokens59.57.61.57.8x5.0x
LLM Text Encoder200 tokens141.76.73.021.0x2.2x
LLM Text Encoder500 tokens447.49.07.549.5x1.2x
LLM Token Generator5 steps37.514.12.02.7x7.0x
LLM Token Generator50 steps84.014.63.45.8x4.3x
LLM Token Generator200 steps352.116.56.821.4x2.4x
Flow Encoder8 tokens6.57.20.60.9x12.2x
Flow Encoder50 tokens18.68.50.62.2x14.3x
Flow Encoder200 tokens42.76.11.17.0x5.5x
HiFT Source100 frames0.68.50.40.1x23.6x
HiFT Vocoder50 mel136.519.8144.56.9x0.1x
HiFT Vocoder200 mel486.430.1505.416.2x0.06x
F0 Predictor100 mel2.50.90.32.7x3.4x
F0 Predictor500 mel12.80.80.416.0x2.2x

Notes (maintainer measurements, single machine):

  • Max observed GPU speedup vs CPU: 59.5x (Text Encoder, seq=500)
  • Max observed TRT RTX speedup over CUDA: 14.3x (Flow Encoder, T=50)
  • CUDA outperformed TRT RTX on the vocoder (STFT ops) in this run
  • All components achieved RTF < 1.0 on both CPU and GPU in this run

PyTorch vs ONNX Runtime (GPU)

ComponentInputPyTorch (ms)ONNX (ms)Speedup
LLM Text Encoder5 tokens11.35.82.0x
LLM Text Encoder100 tokens12.26.02.0x
LLM Text Encoder500 tokens14.310.61.3x
LLM Token Generator5 steps60.818.13.4x
LLM Token Generator50 steps27.215.01.8x
LLM Token Generator200 steps31.918.41.7x
Flow Encoder8 tokens13.86.02.3x
Flow Encoder100 tokens18.47.82.4x
Flow Encoder200 tokens19.49.62.0x

Numerical verification (maintainer-run)

ONNX exports were checked against PyTorch reference outputs by the maintainer:

ComponentMax Absolute DiffStatus
LLM Text Encoder2.15PASS (rtol=1e-3)
LLM Token Generator0.0045PASS (rtol=1e-2)
Flow Encoder0.12PASS (rtol=1e-2)
HiFT SourceShapes matchPASS
HiFT Vocoder1.98 (DFT approximation)PASS (self-consistent)
F0 Predictor0.03PASS (rtol=1e-3)

Model Sizes

FileSize
llm/text_encoder.onnx459 MB
llm/token_generator.onnx789 MB
flow/encoder.onnx100 MB
hift/source.onnx101 KB
hift/vocoder.onnx66 MB
hift/f0_predictor.onnx13 KB
Total (6 files)~1.41 GB

Model Architecture

CosyVoice-300M uses a three-stage pipeline:

  1. LLM (TransformerLM): ConformerEncoder text encoder (6 blocks, in=512, out=1024) + TransformerEncoder language model (14 blocks, dim=1024) + linear decoder (-> 4097 speech tokens)
  2. Flow (MaskedDiffWithXvec): ConformerEncoder (6 blocks, out=512) + InterpolateRegulator (length expansion) + ConditionalCFM decoder with ConditionalDecoder estimator (channels=[256,256], 4 blocks, 12 mid_blocks)
  3. HiFT (HiFTGenerator): SourceModuleHnNSF (harmonic + noise excitation) + ConvRNNF0Predictor + convolutional decoder with upsampling (2 stages, 8x each) + ISTFT

Notes

  • All ONNX models were exported with CPU-only PyTorch 2.12 and verified with onnxruntime 1.26.
  • The vocoder uses a DFT-matrix-based ISTFT (instead of FFT) for ONNX compatibility. Results are numerically close but not bit-identical to the PyTorch version.
  • The hift/vocoder.onnx file has an accompanying hift/vocoder.onnx.data external data file (~51 MB).

Citation

@article{du2024cosyvoice,
  title={Cosyvoice: A scalable multilingual zero-shot text-to-speech synthesizer based on supervised semantic tokens},
  author={Du, Zhihao and Chen, Qian and Zhang, Shiliang and Hu, Kai and Lu, Heng and others},
  journal={arXiv preprint arXiv:2407.05407},
  year={2024}
}

Disclaimer

This is an unofficial ONNX conversion. The original model and architecture are by Alibaba's FunAudioLLM team. For the official implementation, see github.com/FunAudioLLM/CosyVoice.

Sources

1 source
Hugging FacePrimaryVersion 1dc153e98d3ef267fc2d71dac0feab9ee35bdb03
huggingface.co/tonythethompson/CosyVoice-300M-ONNX/tree/1dc153e98d3ef267fc2d71dac0feab9ee35bdb03

Verified Sep 13

Model artifacts

27 artifacts

campplus.onnx

onnx · 27.0 MB · SHA-256 a6ac6a639977…4d73 · Hugging Face

Download

flow.decoder.estimator.fp32.onnx

onnx · 313 MB · SHA-256 8c02bc651f59…c947 · Hugging Face

Download

flow.pt

pt · 400 MB · SHA-256 fd80b089444a…6b55 · Hugging Face

Download

flow/encoder.onnx

onnx · 99.0 MB · SHA-256 f83cab679c02…3ae4 · Hugging Face

Download

hift.pt

pt · 78.1 MB · SHA-256 91e679b6ca1e…6012 · Hugging Face

Download

hift/f0_predictor.onnx

onnx · 12.5 MB · SHA-256 efeb8eb58cfa…52e3 · Hugging Face

Download

hift/source.onnx

onnx · 100 KB · SHA-256 857034db801f…bb4b · Hugging Face

Download

hift/vocoder.onnx

onnx · 65.8 MB · SHA-256 63af48b4bf27…dae7 · Hugging Face

Download

llm.pt

pt · 1.16 GB · SHA-256 59f7eb172d2f…f976 · Hugging Face

Download

llm/text_encoder.onnx

onnx · 459 MB · SHA-256 6c4c6d05ade8…9d4c · Hugging Face

Download

llm/token_generator.onnx

onnx · 788 MB · SHA-256 48efe45da92f…52e4 · Hugging Face

Download

onnx_quantized_modelopt/flow/encoder.int4.onnx

onnx · 30.5 MB · SHA-256 54cb8308d8ca…96d5 · Hugging Face

Download

onnx_quantized_modelopt/flow/encoder.int8.onnx

onnx · 50.0 MB · SHA-256 9bc76f75ddff…d1d5 · Hugging Face

Download

onnx_quantized_modelopt/hift/f0_predictor.int4.onnx

onnx · 12.5 MB · SHA-256 b6737e346e37…5949 · Hugging Face

Download

onnx_quantized_modelopt/hift/f0_predictor.int8.onnx

onnx · 6.27 MB · SHA-256 e4231b466705…0fa3 · Hugging Face

Download

onnx_quantized_modelopt/hift/source.int4.onnx

onnx · 143 KB · SHA-256 11c5bd232c71…f0f2 · Hugging Face

Download

onnx_quantized_modelopt/hift/source.int8.onnx

onnx · 167 KB · SHA-256 06b4d2409cad…eaee · Hugging Face

Download

onnx_quantized_modelopt/llm/text_encoder.int4.onnx

onnx · 183 MB · SHA-256 a47658b3b8e0…190a · Hugging Face

Download

onnx_quantized_modelopt/llm/text_encoder.int8.onnx

onnx · 230 MB · SHA-256 6de581588909…d573 · Hugging Face

Download

onnx_quantized_modelopt/llm/token_generator.int4.onnx

onnx · 140 MB · SHA-256 56255202e247…b762 · Hugging Face

Download

onnx_quantized_modelopt/llm/token_generator.int8.onnx

onnx · 396 MB · SHA-256 e1173fcbaa30…6012 · Hugging Face

Download

onnx_quantized/flow/encoder.int8.onnx

onnx · 39.8 MB · SHA-256 70896af52744…8be7 · Hugging Face

Download

onnx_quantized/hift/f0_predictor.int8.onnx

onnx · 3.14 MB · SHA-256 5fef1066b899…c495 · Hugging Face

Download

onnx_quantized/hift/source.int8.onnx

onnx · 144 KB · SHA-256 7f591cf36be9…5cf2 · Hugging Face

Download

onnx_quantized/llm/text_encoder.int8.onnx

onnx · 145 MB · SHA-256 e9c1a40af007…f77e · Hugging Face

Download

onnx_quantized/llm/token_generator.int8.onnx

onnx · 228 MB · SHA-256 7bc448639169…9b5a · Hugging Face

Download

speech_tokenizer_v1.onnx

onnx · 498 MB · SHA-256 23b5a723ed91…bb1e · Hugging Face

Download

Source excerpts

2 excerpts

--- license: apache-2.0 base_model: FunAudioLLM/CosyVoice-300M base_model_relation: quantized language: - zh - en - fr - es - ja - ko - it - ru - de pipeline_tag: text-to-speech library_name: cosyvoice tags: - cosyvoice - tts - text-to-speech - onnx - voice-cloning - zero-shot - multilingual --- # CosyVoice-300M ONNX ## Source | Field | Value | |---|---| | Upstream model | [FunAudioLLM/CosyVoice-300M](https://huggingface.co/FunAudioLLM/CosyVoice-300M) | | Upstream source revision | `24c40509c3c5ea6fe06b5f8790ff99e3714a6bee` | | Export tool/script | Community `torch.onnx` export (CPU PyTorch 2.12, verified with onnxruntime 1.26) | | Quantization recipe | FP32 ONNX component graphs under `llm/`, `flow/`, `hift/` | ## Precision and Packaging Export tooling, precision, and quantization are recorded in the **Source** table above. This packaging mirror does not publish independent parity benchmarks; validate on your target execution provider before production use. ## Intended Uses - Cross-platform TTS deployment without a PyTorch dependency - Edge/embedded inference via ONNX Runtime on CPU, GPU, or NPU - Lower-latency serving with execution-provider acceleration (validate before relying on it) - Research on TTS model optimization and format conversion ## Safety and Responsible Use CosyVoice-300M is a zero-shot voice-cloning model capable of producing realistic speech that closely matches a target speaker from a short reference clip. - Do not use to impersonate real individuals without their explicit consent. - Do not generate synthetic speech intended to deceive listeners about a speaker's identity. - Disclose AI-generated audio where listeners would reasonably expect a human voice. - Users are responsible for compliance with applicable laws governing synthetic media and voice cloning in their jurisdiction. ## Limitations & Biases 1. **Autoregressive decoding**: The token generator is exported in teacher-forced mode; step-by-step decoding with KV-cache requires custom ONNX graphs or runtime loops 2. **STFT approximation**: The vocoder uses DFT matrix multiplication instead of FFT, introducing minor numerical differences (max 1.98 absolute) 3. **Frontend models**: `campplus.onnx` (speaker encoder) and `speech_tokenizer_v1.onnx` (speech tokenizer) are from the original repo, not part of this conversion 4. **No tr...

Source context: 636 downloads · 1 likes · Pipeline text-to-speech · Library cosyvoice · Repo tonythethompson/CosyVoice-300M-ONNX