跳到主要内容
CosyVoice · prolist
返回项目库查看仓库原始简介 Multi-lingual large voice generation model, providing inference, training and deployment full-stack ability.
来自项目 README 项目解读 README
项目解读由 AI 根据历史资料整理,尚未经人工复核。仓库资料更新于 2026-09-08,与历史解读分开保留。
项目概览 CosyVoice 是阿里巴巴达摩院 FunAudioLLM 团队开发的多语种大语音生成模型,提供推理、训练和部署的全栈能力。其核心能力包括仅需 3 秒参考音频即可实现零样本声音克隆,覆盖 9 种常见语言和 18 种以上中文方言,并支持跨语种克隆。模型采用 LLM 生成语义 Token 与 Flow Matching 渲染声波的双阶段架构,CosyVoice 2.0 起支持双向流式合成,延迟低至 150ms。CosyVoice 3.0 引入多任务 Tokenizer 和可微分奖励模型后训练,训练数据扩展至 100 万小时。项目采用 Apache-2.0 许可证,支持本地部署,提供 Docker、FastAPI、gRPC、vLLM、TensorRT-LLM 等多种部署方式。
解决什么问题 在 CosyVoice 出现之前,TTS 领域面临多个痛点。传统声音克隆需要数十分钟甚至数小时的录音数据,还需专业设备和安静环境,门槛高。多语种支持碎片化,跨语种合成几乎不可能,企业需集成多个引擎,维护成本高。流式延迟高,传统模型需先生成完整音频再播放,延迟通常在 500ms 以上。早期模型语音不自然,语调平淡、节奏僵硬。文本归一化依赖外部模块,增加系统复杂度和出错概率。云端依赖带来隐私风险,音频数据需上传第三方服务器,对医疗、金融、法律等敏感行业不可接受。
工作方式 CosyVoice 采用双阶段生成架构。第一阶段,LLM 根据文本和参考音频的声纹特征生成语音语义 Token 序列;第二阶段,Flow Matching 模型将语义 Token 逐步渲染成高保真声波。语音 Tokenizer 将连续声波压缩成离散 Token 序列,使语音可被 LLM 处理。CosyVoice 2.0 使用有限标量量化(FSQ)解决码本坍塌问题,并引入 Chunk-aware 因果 Flow Matching,实现流式与非流式统一模型。CosyVoice 3.0 的 Tokenizer 同时训练 ASR、情感识别、语种识别、音频事件检测、说话人分析五个任务,并引入可微分奖励模型,使用 GRPO 强化学习进行后训练。推理时,3 秒参考音频通过说话人编码器提取声纹嵌入,作为条件信号注入 LLM。
核心能力
秒零样本声音克隆,无需微调
支持 9 种语言和 18 种以上中文方言
跨语种克隆,音色保持一致
双向流式合成,延迟低至 150ms
自然语言指令控制语言、方言、情感、语速、音量
发音修复(Inpainting),支持拼音和 CMU 音素级精确控制
全量本地部署,无需联网
支持 vLLM、TensorRT-LLM 加速
提供 Docker、FastAPI、gRPC 部署方式
Apache-2.0 许可证,商业友好
使用前需要了解
AI 整理 · 本地测试,未经人工复核;依据历史报告节选,不代表当前产品状态。
报告指出,CosyVoice 存在若干局限。GPU 要求较高,最低 8GB VRAM,推荐 24GB+,不适合纯 CPU 环境。模型体积大,单个模型 0.5B-1.5B,加上预训练资源超过 10GB。中文优化优先,中文和方言效果明显优于其他语言。超长文本(超过 5 分钟)可能出现韵律漂移或重复。推理速度相比轻量级 TTS 实时率较高。不支持音乐或歌唱合成。在消费级 GPU 上难以做到实时率小于 1 的实时生成。指令跟随的情感控制是粗粒度的,无法精确到句子级别。多说话人场景中可能出现音色混淆。报告还提示,3 秒克隆并非完美复制,音色相似度约 75-78%。首次使用需下载模型(10GB+),之后才能完全离线运行。声音克隆技术存在伦理和法律风险,使用他人声音需获得授权,应遵守当地法律法规和 Apache-2.0 许可证条款。
简体中文 · AI 译文 原文
AI 中文译文,非官方翻译;安装命令与技术细节请对照原文。
SVG Banners(请在原文查看)
👉🏻 CosyVoice 👈🏻
Fun-CosyVoice 3.0 : 演示 ; 论文 ; ModelScope ; Hugging Face ; CV3-Eval
CosyVoice 2.0 : 演示 ; 论文 ; ModelScope ; Hugging Face
CosyVoice 1.0 : 演示 ; 论文 ; ModelScope ; Hugging Face
亮点🔥
Fun-CosyVoice 3.0 是一个基于大语言模型(LLM)的先进文本转语音(TTS)系统,在内容一致性、说话人相似度和韵律自然度方面超越了其前代产品(CosyVoice 2.0)。它专为野外零样本多语言语音合成而设计。
主要特性
语言覆盖 :覆盖 9 种常用语言(中文、英语、日语、韩语、德语、西班牙语、法语、意大利语、俄语),18 种以上的中文方言/口音(广东、闽南、四川、东北、陕西、山西、上海、天津、山东、宁夏、甘肃等),同时支持多语言/跨语言零样本声音克隆。
内容一致性与自然度 :在内容一致性、说话人相似度和韵律自然度方面达到最先进水平。
发音修复 :支持中文拼音和英文 CMU 音素的发音修复,提供更强的可控性,适合生产环境使用。
文本规范化 :无需传统前端模块即可支持数字、特殊符号和各种文本格式的朗读。
双流式 :支持文本输入流式和音频输出流式,在保持高质量音频输出的同时,延迟可低至 150 毫秒。
指令支持 :支持多种指令,如语言、方言、情感、语速、音量等。
路线图
评测
安装
克隆并安装
克隆仓库
git clone --recursive https://github.com/FunAudioLLM/CosyVoice.git
# If you failed to clone the submodule due to network failures, please run the following command until success
cd CosyVoice
git submodule update --init --recursive
安装 Conda:请参阅 https://docs.conda.io/en/latest/miniconda.html
创建 Conda 环境:
conda create -n cosyvoice -y python=3.10
conda activate cosyvoice
pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/ --trusted-host=mirrors.aliyun.com
# If you encounter sox compatibility issues
# ubuntu
sudo apt-get install sox libsox-dev
# centos
sudo yum install sox sox-devel
模型下载 我们强烈建议您下载我们预训练的 Fun-CosyVoice3-0.5B CosyVoice2-0.5B CosyVoice-300M CosyVoice-300M-SFT CosyVoice-300M-Instruct 模型和 CosyVoice-ttsfrd 资源。
# modelscope SDK model download
from modelscope import snapshot_download
snapshot_download('FunAudioLLM/Fun-CosyVoice3-0.5B-2512', local_dir='pretrained_models/Fun-CosyVoice3-0.5B')
snapshot_download('iic/CosyVoice2-0.5B', local_dir='pretrained_models/CosyVoice2-0.5B')
snapshot_download('iic/CosyVoice-300M', local_dir='pretrained_models/CosyVoice-300M')
snapshot_download('iic/CosyVoice-300M-SFT', local_dir='pretrained_models/CosyVoice-300M-SFT')
snapshot_download('iic/CosyVoice-300M-Instruct', local_dir='pretrained_models/CosyVoice-300M-Instruct')
snapshot_download('iic/CosyVoice-ttsfrd', local_dir='pretrained_models/CosyVoice-ttsfrd')
# for oversea users, huggingface SDK model download
from huggingface_hub import snapshot_download
snapshot_download('FunAudioLLM/Fun-CosyVoice3-0.5B-2512', local_dir='pretrained_models/Fun-CosyVoice3-0.5B')
snapshot_download('FunAudioLLM/CosyVoice2-0.5B', local_dir='pretrained_models/CosyVoice2-0.5B')
snapshot_download('FunAudioLLM/CosyVoice-300M', local_dir='pretrained_models/CosyVoice-300M')
snapshot_download('FunAudioLLM/CosyVoice-300M-SFT', local_dir='pretrained_models/CosyVoice-300M-SFT')
snapshot_download('FunAudioLLM/CosyVoice-300M-Instruct', local_dir='pretrained_models/CosyVoice-300M-Instruct')
snapshot_download('FunAudioLLM/CosyVoice-ttsfrd', local_dir='pretrained_models/CosyVoice-ttsfrd')
可选地,您可以解压 ttsfrd 资源并安装 ttsfrd 包以获得更好的文本规范化性能。
请注意,此步骤并非必需。如果您不安装 ttsfrd 包,我们将默认使用 wetext。
cd pretrained_models/CosyVoice-ttsfrd/
unzip resource.zip -d .
pip install ttsfrd_dependency-0.1-py3-none-any.whl
pip install ttsfrd-0.4.2-cp310-cp310-linux_x86_64.whl
基本用法 我们强烈建议使用 Fun-CosyVoice3-0.5B 以获得更好的性能。
请遵循 example.py 中的代码以了解每个模型的详细用法。
vLLM 用法 CosyVoice2/3 现在支持 vLLM 0.11.x+ (V1 引擎) 和 vLLM 0.9.0 (旧版) 。
旧版 vllm 版本(<0.9.0) do not support CosyVoice inference, and versions in between (e.g., 0.10.x) are not tested.
Notice that vllm has a lot of specific requirements. You can create a new env to in case your hardward do not support vllm and old env is corrupted.
conda create -n cosyvoice_vllm --clone cosyvoice
conda activate cosyvoice_vllm
# for vllm==0.9.0
pip install vllm==v0.9.0 transformers==4.51.3 numpy==1.26.4 -i https://mirrors.aliyun.com/pypi/simple/ --trusted-host=mirrors.aliyun.com
# for vllm>=0.11.0
pip install vllm==v0.11.0 transformers==4.57.1 numpy==1.26.4 -i https://mirrors.aliyun.com/pypi/simple/ --trusted-host=mirrors.aliyun.com
python vllm_example.py
Start web demo You can use our web demo page to get familiar with CosyVoice quickly.
Please see the demo website for details.
# change iic/CosyVoice-300M-SFT for sft inference, or iic/CosyVoice-300M-Instruct for instruct inference
python3 webui.py --port 50000 --model_dir pretrained_models/CosyVoice-300M
Advanced Usage For advanced users, we have provided training and inference scripts in examples/libritts.
Build for deployment Optionally, if you want service deployment,
You can run the following steps.
cd runtime/python
docker build -t cosyvoice:v1.0 .
# change iic/CosyVoice-300M to iic/CosyVoice-300M-Instruct if you want to use instruct inference
# for grpc usage
docker run -d --runtime=nvidia -p 50000:50000 cosyvoice:v1.0 /bin/bash -c "cd /opt/CosyVoice/CosyVoice/runtime/python/grpc && python3 server.py --port 50000 --max_conc 4 --model_dir iic/CosyVoice-300M && sleep infinity"
cd grpc && python3 client.py --port 50000 --mode <sft|zero_shot|cross_lingual|instruct>
# for fastapi usage
docker run -d --runtime=nvidia -p 50000:50000 cosyvoice:v1.0 /bin/bash -c "cd /opt/CosyVoice/CosyVoice/runtime/python/fastapi && python3 server.py --port 50000 --model_dir iic/CosyVoice-300M && sleep infinity"
cd fastapi && python3 client.py --port 50000 --mode <sft|zero_shot|cross_lingual|instruct>
Using Nvidia TensorRT-LLM for deployment Using TensorRT-LLM to accelerate cosyvoice2 llm could give 4x acceleration comparing with huggingface transformers implementation.
To quick start:
cd runtime/triton_trtllm
docker compose up -d
For more details, you could check here
Discussion & Communication You can also scan the QR code to join our official Dingding chat group.
Acknowledge
We borrowed a lot of code from FunASR .
We borrowed a lot of code from FunCodec .
We borrowed a lot of code from Matcha-TTS .
We borrowed a lot of code from AcademiCodec .
We borrowed a lot of code from WeNet .
Citations @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 Yang, Yexin and Hu, Hangrui and Zheng, Siqi and Gu, Yue and Ma, Ziyang and others},
journal={arXiv preprint arXiv:2407.05407},
year={2024}
}
@article{du2024cosyvoice,
title={Cosyvoice 2: Scalable streaming speech synthesis with large language models},
author={Du, Zhihao and Wang, Yuxuan and Chen, Qian and Shi, Xian and Lv, Xiang and Zhao, Tianyu and Gao, Zhifu and Yang, Yexin and Gao, Changfeng and Wang, Hui and others},
journal={arXiv preprint arXiv:2412.10117},
year={2024}
}
@article{du2025cosyvoice,
title={CosyVoice 3: Towards In-the-wild Speech Generation via Scaling-up and Post-training},
author={Du, Zhihao and Gao, Changfeng and Wang, Yuxuan and Yu, Fan and Zhao, Tianyu and Wang, Hao and Lv, Xiang and Wang, Hui and Shi, Xian and An, Keyu and others},
journal={arXiv preprint arXiv:2505.17589},
year={2025}
}
@inproceedings{lyu2025build,
title={Build LLM-Based Zero-Shot Streaming TTS System with Cosyvoice},
author={Lyu, Xiang and Wang, Yuxuan and Zhao, Tianyu and Wang, Hao and Liu, Huadai and Du, Zhihao},
booktitle={ICASSP 2025-2025 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP)},
pages={1--2},
year={2025},
organization={IEEE}
}
生态系统 CosyVoice 是 FunAudioLLM 家族的一部分——一个完整的语音 AI 工具包:
免责声明 以上内容仅供学术目的使用,旨在展示技术能力。部分示例来源于互联网。如果任何内容侵犯了您的权利,请联系我们请求删除。