github地址:https://github.com/netease-youdao/EmotiVoice

1.环境安装

#拉取代码
git clone https://github.com/netease-youdao/EmotiVoice

#进入根目录安装虚拟环境
cd EmotiVoice

#安装Anaconda创建环境
conda create -n EmotiVoice python=3.10.12 -y
conda activate EmotiVoice

#安装Pytorch
pip3 install torch torchvision torchaudio -i https://pypi.tuna.tsinghua.edu.cn/simple/

#安装环境
pip install numpy numba scipy transformers soundfile yacs g2p_en jieba pypinyin pypinyin_dict fastapi pyrubberband
-i https://pypi.tuna.tsinghua.edu.cn/simple/

#安装包
pip install -r requirements.openaiapi.txt -i https://pypi.tuna.tsinghua.edu.cn/simple/

pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple/

#安装
pip install scrapy

#在 Conda 环境中安装 CFFI
conda install cffi

MAC ffmpeg安装方式

#在Mac上安装FFmpeg,你可以使用Homebrew包管理器。如果你还没有安装Homebrew,请先在终端中运行以下命令来安装它:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

#安装Homebrew后,运行以下命令来安装FFmpeg:
brew install ffmpeg

#安装完成后,你可以通过运行以下命令来检查FFmpeg是否正确安装并且可用:
#如果安装成功,这个命令会输出FFmpeg的版本信息。
ffmpeg -version

2.准备模型文件

在根目录下载需要的两个模型

#下载outputs
git clone https://www.modelscope.cn/syq163/outputs.git

#安装lfs
brew install git-lfs

#下载WangZeJun
git lfs clone https://huggingface.co/WangZeJun/simbert-base-chinese WangZeJun/simbert-base-chinese

#拷贝已经训练好的模型
#将两个文件夹放入项目文件夹内
\\192.168.99.53\Public\xinba\TTS\data
\\192.168.99.53\Public\xinba\TTS\exp

#修改代码
修改openaiapi.py文件

MAC 部署EmotiVoiceApi_Public

#安装libsndfile
brew install libsndfile

#如果报错
pip uninstall -y cffi pycparser SoundFile//卸载soundfile
 
pip install soundfile//安装soundfile

#启动
uvicorn openaiapi:app --reload --port 6006 --host 0.0.0.0