CosyVoice 介绍
CosyVoice 是阿里研发的一个tts大模型
官方项目地址:https://github.com/FunAudioLLM/CosyVoice.git
下载项目(非官方)
git clone --recursive https://github.com/v3ucn/CosyVoice_for_MacOs.git
进入项目
cd CosyVoice_for_MacOs
git submodule update --init --recursive
创建运行环境
conda create -n cosyvoice python=3.8
conda activate cosyvoice
安装依赖
pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/ --trusted-host=mirrors.aliyun.com
# 安装sox
brew install sox
#安装git-lfs(重要,不然下面下载模型能成功,但实际下载不完整,很多人遇到这个坑)
brew install git-lfs
# 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-25Hz.git pretrained_models/CosyVoice-300M-25Hz
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
配置环境变量
export PYTHONPATH=third_party/Matcha-TTS
运行
python3 webui.py --port 50000 --model_dir pretrained_models/CosyVoice-300M
期间可能遇见下面几种问题
1.
There is no such entity as cosyvoice.utils.common.ras_sampling
cosyvoice模型的问题,这个是由于cosyvoice模型部分添加了一个采样器,但 GitHub 上开源的代码中没有包含该采样器。
解决方法
打开项目目录下的models/TTS/CosyVoice-300M/cosyvoice.yaml文件
屏蔽下面这段代码:
sampling: !name:cosyvoice.utils.common.ras_sampling
top_p: 0.8
top_k: 25
win_size: 10
tau_r: 0.1
---------
2.
cannot import name 'cached_download' from 'huggingface_hub'
参考 https://blog.csdn.net/weixin_41492426/article/details/143215577
0.26 及以上的版本不支持 cached_download 了。
该库好像对别的库没有啥影响,所以直接装一个旧版本就行了:
pip install huggingface_hub==0.25.2 -i https://pypi.tuna.tsinghua.edu.cn/simple
3.
onnxruntime.capi.onnxruntime_pybind11_state.InvalidProtobuf: [ONNXRuntimeError] : 7 : INVALID_PROTOBUF : Load model from pretrained_models/CosyVoice-300M/campplus.onnx failed:Protobuf parsing failed.
出现这个主要是没有安装好git-lfs,导致没正确下载完整模型,安装好后重新下载模型即可解决。