Signed-off-by: lishunyang <lishunyang12@163.com> Signed-off-by: xiaohajiayou <923390377@qq.com> Co-authored-by: lishunyang <lishunyang12@163.com>
CosyVoice3
Setup
Install dependencies:
uv pip install -e .
Note: This includes required libraries such as
soundfile,onnxruntime,x-transformers, andeinopsviarequirements/common.txtand platform-specific requirements files.
Download the model snapshot:
from huggingface_hub import snapshot_download
snapshot_download('FunAudioLLM/Fun-CosyVoice3-0.5B-2512', local_dir='pretrained_models/Fun-CosyVoice3-0.5B')
Add config.json in pretrained_models/Fun-CosyVoice3-0.5B/:
{
"model_type": "cosyvoice3",
"architectures": [
"CosyVoice3Model"
]
}
Why
config.jsonis required:AutoConfig.register("cosyvoice3", CosyVoice3Config)only registers a class mapping. The loader still needsmodel_type: "cosyvoice3"fromconfig.jsonto select that class. If noconfig.jsonis present, model type cannot be inferred automatically. If your downloaded checkpoint already includes a validconfig.jsonwithmodel_type: "cosyvoice3", this manual step can be skipped.
Run the offline verification script:
python examples/offline_inference/cosyvoice3/verify_e2e_cosyvoice.py \
--model pretrained_models/Fun-CosyVoice3-0.5B \
--tokenizer pretrained_models/Fun-CosyVoice3-0.5B/CosyVoice-BlankEN
Implementation Overview
CosyVoice3 runs as a 2-stage Omni pipeline.
- Stage 0 (
talker) converts text + prompt audio to speech tokens. - Stage 1 (
code2wav) converts speech tokens + prompt features to waveform via flow matching and HiFiGAN.
Key components live in vllm_omni/model_executor/models/cosyvoice3/cosyvoice3.py.
CosyVoice3MultiModalProcessorbuilds the multimodal inputs:- Tokenizes
promptandprompt_text. - Extracts speech tokens and mel features from the prompt audio.
- Extracts a speaker embedding.
- Tokenizes
CosyVoice3Modelimplements both stages:- Stage 0 uses
CosyVoice3LMand outputs speech tokens + conditioning features. - Stage 1 runs the flow model (DiT-based CFM) and HiFiGAN to synthesize waveform.
- Stage 0 uses
Pipeline topology lives in vllm_omni/model_executor/models/cosyvoice3/pipeline.py;
runtime tunables (batch size, memory limits, sampling) live in
vllm_omni/deploy/cosyvoice3.yaml. The deploy config auto-loads by
HF model_type and defaults to async_chunk: true (shared-memory
streaming). Pass --no-async-chunk on vllm serve to switch to the
legacy sync path where stage 1 runs text2flow over the full
speech-token sequence.
- Stage 0 emits latent speech tokens.
- Stage 1 consumes them via
sync_process_input_func(sync mode) or the shared-memory connector (async-chunk mode) and outputs audio.