最后活跃于 1730823783

knox 修订了这个 Gist 1730823783. 跳至此修订

1 file changed, 19 insertions

ChatTTS-12.py(file created)

@@ -0,0 +1,19 @@
1 + import ChatTTS
2 + import torch
3 + import torchaudio
4 +
5 + chat = ChatTTS.Chat()
6 + chat.load(compile=False) # Set to True for better performance
7 +
8 + texts = ["PUT YOUR 1st TEXT HERE", "PUT YOUR 2nd TEXT HERE"]
9 +
10 + wavs = chat.infer(texts)
11 +
12 + for i in range(len(wavs)):
13 + """
14 + In some versions of torchaudio, the first line works but in other versions, so does the second line.
15 + """
16 + try:
17 + torchaudio.save(f"basic_output{i}.wav", torch.from_numpy(wavs[i]).unsqueeze(0), 24000)
18 + except:
19 + torchaudio.save(f"basic_output{i}.wav", torch.from_numpy(wavs[i]), 24000)
更新 更早