模型部署arrowPic CosyVoice 模型部署教程
CosyVoice 模型部署教程
发布时间:2025-02-13 10:10:33

一 介绍

CosyVoice 是一个开源的超强 TTS(‌文本转语音)‌模型,‌它支持多种生成模式,‌具有极强的语音自然可控性。‌

具有以下特点

  • 语音合成 :能够将文本转换为自然流畅的语音输出。
  • 多语种支持:支持多种语言的语音合成,例如英语、中文等。
  • 个性化调整:可能支持音色、语速等参数的调整,以实现个性化的语音输出。

可应用于多个场景,如

  • 辅助技术 :可用于语音助手、自动电话系统、无障碍辅助等场景,帮助用户更便捷地获取信息。
  • 创意内容创作 :艺术家、内容创作者可以利用其生成独特的声音效果。
  • 教育和培训 :用于创建教育内容或培训材料的语音配音。

二 部署流程

1.克隆并安装

  • 克隆仓库
git clone --recursive https://github.com/FunAudioLLM/CosyVoice.git
# If you failed to clone submodule due to network failures, please run following command until success
cd CosyVoice
git submodule update --init --recursive
conda create -n cosyvoice python=3.8
conda activate cosyvoice
# pynini is required by WeTextProcessing, use conda to install it as it can be executed on all platform.
conda install -y -c conda-forge pynini==2.1.5
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

2.模型下载

下载预训练 CosyVoice-300M CosyVoice-300M-SFT CosyVoice-300M-Instruct 模型和 CosyVoice-ttsfrd 资源。

# git模型下载,请确保已安装git lfs
mkdir -p pretrained_models
git clone https://www.modelscope.cn/iic/CosyVoice-300M.git pretrained_models/CosyVoice-300M
git clone https://www.modelscope.cn/iic/CosyVoice-300M-SFT.git pretrained_models/CosyVoice-300M-SFT
git clone https://www.modelscope.cn/iic/CosyVoice-300M-Instruct.git pretrained_models/CosyVoice-300M-Instruct
git clone https://www.modelscope.cn/iic/CosyVoice-ttsfrd.git pretrained_models/CosyVoice-ttsfrd

或者,可以解压缩 ttsfrd 资源并安装 ttsfrd 包以获得更好的文本规范化性能。

注意,这一步不是必须的,如果你没有安装 ttsfrd,默认使用 WeTextProcessing。

cd pretrained_models/CosyVoice-ttsfrd/
unzip resource.zip -d .
pip install ttsfrd-0.3.6-cp38-cp38-linux_x86_64.whl

三 网页演示

# 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

image.png

进入webui页面如下:

image.png

点击此处,立即体验CosyVoice!

bg-circle
算力加速·赋能科研
2026闲时计算资源公益助研活动进行中
2026年1月1日-2026年12月31
立即申请
新人好礼
客服中心