Naposledy aktivní 1730823783

Revize fd9f9cc81d7f8f8d2235a610912bf3cc8468ac65

ChatTTS-12.py Raw
1import ChatTTS
2import torch
3import torchaudio
4
5chat = ChatTTS.Chat()
6chat.load(compile=False) # Set to True for better performance
7
8texts = ["PUT YOUR 1st TEXT HERE", "PUT YOUR 2nd TEXT HERE"]
9
10wavs = chat.infer(texts)
11
12for 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)