一、项目地址进行克隆
官方GitHub地址:https://github.com/2noise/ChatTTS
二、注意事项
python版本要求使用3.8以上,刚开始我使用3.7安装依赖时报错,后来将python版本换成3.8.8。(使用环境Windows10)
三、模型下载
因为项目启动默认到hugging face下载模型。所以使用modelscope下载模型
from modelscope import snapshot_download
model_dir = snapshot_download('pzc163/chatTTS',cache_dir="XXXXXX")
注意:cache_dir填写你想要模型下载的绝对路径。不指定cache_dir模型默认下载到:C:\Users\Administrator.cache\modelscope\hub\pzc163。
四、webui启动
在webui界面中还需安装gradio:
pip install gradio
修改webui中部分代码:
parser.add_argument('--local_path', type=str, default=None, help='the local_path if need')
将模型地址改为自己下载的模型地址,default=“模型地址”。
到这一步我已经成功启动webui界面,但是点击Generate生成语音报错:UnboundLocalError: local variable ‘Normalizer’ referenced before assignment。
去官方GitHub地址搜寻问题,看到了大佬们发的解决办法。
修改webui中代码
if refine_text_flag:
text = chat.infer(text,
skip_refine_text=False,
refine_text_only=True,
params_refine_text=params_refine_text,
params_infer_code=params_infer_code
)
wav = chat.infer(text,
skip_refine_text=True,
params_refine_text=params_refine_text,
params_infer_code=params_infer_code
)
在上述代码的infer中都要加入"do_text_normalization=False"。
修改后代码:
if refine_text_flag:
text = chat.infer(text,
skip_refine_text=False,
refine_text_only=True,
params_refine_text=params_refine_text,
params_infer_code=params_infer_code,
do_text_normalization=False
)
wav = chat.infer(text,
skip_refine_text=True,
params_refine_text=params_refine_text,
params_infer_code=params_infer_code,
do_text_normalization=False
)
五、结语
至此项目已成功运行并生成语音。
代码运行中出现问题可以去官方地址搜寻:https://github.com/2noise/ChatTTS/issues