
Cosyvoice本地安装
参考资料
官方网站: CosyVoice | Multilingual TTS Model
官方文档: CosyVoice 2: Scalable Streaming Speech Synthesis with Large Language Models
博客1: CosyVoice2-0.5B在Windows下本地完全部署、最小化部署
博客2: CosyVoice2实现音色保存及推理
本地安装步骤 (Win11)
环境依赖
版本控制工具 Git , 参考: https://git-scm.com/
Git 扩展程序 Git-lfs , 参考: https://git-lfs.com/
[可选] 终端工具 Windows Terminal , 参考: https://learn.microsoft.com/zh-cn/windows/terminal/install
[可选] 文本编辑器 Visual Studio Code
安装 Conda
Conda 是一个开源的包管理和环境管理工具, 提供了一个简单的方式来安装、更新和管理软件包,同时允许用户创建独立的虚拟环境,以避免包依赖冲突
访问 Anaconda Documentation , 下载 Miniconda 安装程序(Anaconda Installer 包含了一个 ui 客户端和大量依赖库,推荐轻量级的 Miniconda)
2. 执行 Miniconda Installer 安装程序,使用默认配置完成安装(注意选择空间余量充足的磁盘)
3. 按 Win+Q 搜索 `Anaconda Prompt`, 打开专用命令行终端 (建议预先安装 Windows Terminal 程序,Miniconda Installer 会自动添加进去,而后使用 WinTerminal 访问)
4. 添加 channels 镜像源(清华镜像)
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/
5. 查看并确认 channel 添加成功
conda config --get channels
! 注意:后续步骤均在 Conda 终端中执行
下载程序与模型
克隆代码仓库
cd ${Your Base Path}
git clone --recursive https://github.com/FunAudioLLM/CosyVoice.git
2. 创建并激活 Conda 环境
conda create -n cosyvoice -y python=3.10
conda activate cosyvoice
3. 安装程序依赖
cd CosyVoice
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
4. 使用 git-lfs 下载模型
本文仅使用 2.0 模型,如果需要使用 1.0 模型,参考官方文档
官方提供的可选工具 CosyVoice-ttsfrd ,在 Windows 环境中无法运行,所以也忽略
mkdir -p pretrained_models
git clone https://www.modelscope.cn/iic/CosyVoice2-0.5B.git pretrained_models/CosyVoice2-0.5B
通过 Web 客户端使用程序
启动服务
如果遇到 Module Not Found 问题,使用 pip install 命令安装即可
python webui.py --port 50000 --model_dir pretrained_models/CosyVoice2-0.5B.git
2. 打开浏览器,访问 `http://localhost:50000`
3. [选择推理模式],选中 [3s极速复刻]
4. 选择并上传 prompt 音频源文件(声音样本)
5. [输入prompt文本] 录入与音频源文件对应的文字内容(声音样本的文本)
6. [输入合成文本] 录入希望合成的目标文本
7. 点击 [生成音频] 按钮,等待完成(如果生成的音频无法打开,重新生成即可)