记录ChatTTS使用

一、项目地址进行克隆

官方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

  • 3
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值