按照conda create -n chattts conda activate chattts pip install -r requirements.txt pip install ChatTTS配置环境之后运行示例代码
import ChatTTS
import torch
import torchaudio
chat = ChatTTS.Chat()
chat.load(compile=False) # Set to True for better performance
texts = ["你好啊,你吃早饭了嘛", "你真讨厌啊!"]
wavs = chat.infer(texts)
for i in range(len(wavs)):
torchaudio.save(f"basic_output{i}.wav", torch.from_numpy(wavs[i]).unsqueeze(0), 24000)
显示bug
(chattts) mcshao@node17:/home/work_nfs13/mcshao/workspace/chattts/ChatTTS$ python /home/work_nfs13/mcshao/workspace/chattts/example.py
use default LlamaModel for importing TELlamaModel error: No module named 'transformer_engine'
text: 0%| | 0/384(max) [00:00, ?it/s]We detected that you are passing `past_key_values` as a tuple and this is deprecated and will be removed in v4.43. Please use an appropriate `Cache` class (https://huggingface.co/docs/transformers/v4.41.3/en/internal/generation_utils#transformers.Cache)
text: 80%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████ | 308/384(max) [00:12, 24.14it/s]
code: 58%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████ | 1198/2048(max) [00:46, 25.87it/s]
Traceback (most recent call last):
File "/home/work_nfs13/mcshao/workspace/chattts/example.py", line 13, in <module>
torchaudio.save(f"basic_output{i}.wav", torch.from_numpy(wavs[i]).unsqueeze(0), 24000)
File "/home/environment2/mcshao/miniconda3/lib/python3.11/site-packages/torchaudio/_backend/utils.py", line 313, in save
return backend.save(
^^^^^^^^^^^^^
File "/home/environment2/mcshao/miniconda3/lib/python3.11/site-packages/torchaudio/_backend/sox.py", line 72, in save
sox_ext.save_audio_file(
File "/home/environment2/mcshao/miniconda3/lib/python3.11/site-packages/torch/_ops.py", line 854, in __call__
return self_._op(*args, **(kwargs or {}))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: Input tensor has to be 2D.
并且我的环境pip list显示已有transformer_engine 0.0.0 为啥依然有 error: No module named 'transformer_engine'