Closed PSSUN closed 1 month ago
Download ffmpeg and add Path var
or edit the code
torchaudio.save("output1.wav", torch.from_numpy(wavs[0]), 24000, format='wav')
to
soundfile.write("output1.wav", wavs[0], 24000)
已解决! OS: windows 11
创建并激活新的 Conda 环境 conda create -n myenv python=3.9 conda activate myenv
使用 conda 安装 ipython 和 tqdm conda install ipython tqdm
使用 pip 安装其余的包 pip install omegaconf==2.3.0 torch==2.1.0 einops vector_quantize_pytorch transformers==4.41.1 vocos
pip install soudfile
import soundfile import ChatTTS
chat = ChatTTS.Chat() chat.load_models(source='local', local_path='D:\zhanxy\ChatTTS\ChatTTS\model2\chatTTS') texts = ["由于连接方在一段时间后没有正确答复或连接的主机没有反应,连接尝试失败。",]
wavs = chat.infer(texts, use_decoder=True) soundfile.write("output1.wav", wavs[0][0], 24000)
INFO:ChatTTS.core:Load from local: D:\zhanxy\ChatTTS\ChatTTS\model2\chatTTS WARNING:ChatTTS.utils.gpu_utils:No GPU found, use CPU instead INFO:ChatTTS.core:use cpu INFO:ChatTTS.core:vocos loaded. INFO:ChatTTS.core:dvae loaded. INFO:ChatTTS.core:gpt loaded. INFO:ChatTTS.core:decoder loaded. INFO:ChatTTS.core:tokenizer loaded. INFO:ChatTTS.core:All initialized. INFO:ChatTTS.core:All initialized. 11%|█ | 41/384 [00:02<00:22, 15.01it/s] 16%|█▌ | 325/2048 [00:16<01:27, 19.76it/s]
Process finished with exit code 0
重新 git pull
test.py 有点错误,改用 soundfile
2楼不是说了吗,不要使用 torchaudio ,删掉相关代码,使用 soundfile
pip install soundfile
WARNING:ChatTTS.utils.gpu_utils:No GPU found, use CPU instead
INFO:ChatTTS.core:use cpu
INFO:ChatTTS.core:vocos loaded.
INFO:ChatTTS.core:dvae loaded.
INFO:ChatTTS.core:gpt loaded.
INFO:ChatTTS.core:decoder loaded.
INFO:ChatTTS.core:tokenizer loaded.
INFO:ChatTTS.core:All initialized.
INFO:ChatTTS.core:All initialized.
3%|▎ | 12/384 [00:00<00:21, 17.11it/s]
4%|▍ | 83/2048 [00:03<01:15, 25.93it/s]
Traceback (most recent call last):
File "E:\causal\ml\venv\ChatTTS-main\chattts.py", line 17, in
换成soundfile会报这个错
soundfile.write("output1.wav", wavs[0], 24000)
代码需要修正
soundfile.write("output1.wav", wavs[0][0], 24000)
推荐一下我自己 fork 的版本,ChatTTS-Control
感谢楼上 可以了!
2楼不是说了吗,不要使用 torchaudio ,删掉相关代码,使用 soundfile
pip install soundfile
我用你说的第一种方法运行没问题,就是需要安装 ffmpeg
软件
apt update
apt install ffmpeg -y
ffmpeg -version
还是soundflie可靠
OS: windows 11
Error message:
I have installed soundfile and pysoundfile, but still error.