[2noise/ChatTTS]运行wavs = chat.infer(texts, use_decoder=True)出现以下错误

2024-06-06 953 views
5

ARNING:ChatTTS.core:vocos not initialized. WARNING:ChatTTS.core:gpt not initialized. WARNING:ChatTTS.core:tokenizer not initialized. WARNING:ChatTTS.core:decoder not initialized.

AssertionError Traceback (most recent call last) in <cell line: 1>() ----> 1 wavs = chat.infer(texts, use_decoder=True)

/usr/local/lib/python3.10/dist-packages/ChatTTS/core.py in infer(self, text, skip_refine_text, params_refine_text, params_infer_code, use_decoder) 93 94 def infer(self, text, skip_refine_text=False, params_refine_text={}, params_infer_code={}, use_decoder=False): ---> 95 assert self.check_model(use_decoder=use_decoder) 96 if not skip_refine_text: 97 text_tokens = refine_text(self.pretrain_models, text, **params_refine_text)['ids']

回答

3

更新一下transformers库就解决了

3

更新transformers库至4.41.2,并不能解决问题,依然报错:

(chatTTS) D:\AI\chatTTS>python untitled.py
WARNING:ChatTTS.utils.gpu_utils:No GPU found, use CPU instead
INFO:ChatTTS.core:use cpu
WARNING:ChatTTS.core:vocos not initialized.
WARNING:ChatTTS.core:gpt not initialized.
WARNING:ChatTTS.core:tokenizer not initialized.
WARNING:ChatTTS.core:dvae not initialized.
========texts========: ['今天天气不错,适合去钓鱼']
========chat.pretrain_models========: {}
WARNING:ChatTTS.core:vocos not initialized.
WARNING:ChatTTS.core:gpt not initialized.
WARNING:ChatTTS.core:tokenizer not initialized.
WARNING:ChatTTS.core:decoder not initialized.
Traceback (most recent call last):
  File "D:\Learn\chatTTS\untitled.py", line 16, in <module>
    wavs = chat.infer(texts, use_decoder=True, )
  File "D:\ProgramData\miniconda3\envs\chatTTS\lib\site-packages\ChatTTS\core.py", line 95, in infer
    assert self.check_model(use_decoder=use_decoder)
AssertionError
通过debug发现,chat.pretrain_models是空的,没有被初始化

摸索了好久,才发chatTTS正确的打开方式:

首先,

不要使用pip安装chatTTS,一定要使用chatTTS官方代码仓库, 其次huggingface的模型下载不下来的话,就去modelscope下载:
git clone https://www.modelscope.cn/mirror013/ChatTTS.git

代码仓库里有一个example.ipynb文件,可以直接运行这个。但是如果自己手动下载了模型文件,需要修改代码:

chat = ChatTTS.Chat()
chat.load_models(source='local', local_path='./ChatTTS', compile=False) 

快来试试吧,效果真的炸裂!