ChatTTS-12.py
· 565 B · Python
Bruto
import ChatTTS
import torch
import torchaudio
chat = ChatTTS.Chat()
chat.load(compile=False) # Set to True for better performance
texts = ["PUT YOUR 1st TEXT HERE", "PUT YOUR 2nd TEXT HERE"]
wavs = chat.infer(texts)
for i in range(len(wavs)):
"""
In some versions of torchaudio, the first line works but in other versions, so does the second line.
"""
try:
torchaudio.save(f"basic_output{i}.wav", torch.from_numpy(wavs[i]).unsqueeze(0), 24000)
except:
torchaudio.save(f"basic_output{i}.wav", torch.from_numpy(wavs[i]), 24000)
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) |