-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Description
If I run Sample Provided code:
`import ChatTTS
import torch
import torchaudio
chat = ChatTTS.Chat()
chat.load(compile=True) # 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)`
The error is:
`RuntimeError Traceback (most recent call last)
/tmp/ipython-input-3696949750.py in <cell line: 0>()
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)):
7 frames
/usr/local/lib/python3.12/dist-packages/ChatTTS/model/gpt.py in _prepare_generation_inputs(self, input_ids, past_key_values, attention_mask, inputs_embeds, cache_position, position_ids, use_cache)
228 and cache_length + input_ids.shape[1] > max_cache_length
229 ):
--> 230 attention_mask = attention_mask.narrow(
231 1, -max_cache_length, max_cache_length
232 )
RuntimeError: narrow(): length must be non-negative.`