Views
No views yet
git clone https://github.com/2noise/ChatTTS.git1# Import necessary libraries and configure settings
2import torch
3import torchaudio
4torch._dynamo.config.cache_size_limit = 64
5torch._dynamo.config.suppress_errors = True
6torch.set_float32_matmul_precision('high')
7
8import ChatTTS
9from IPython.display import Audio
10
11# Initialize and load the model:
12chat = ChatTTS.Chat()
13chat.load_models(compile=False) # Set to True for better performance
14
15# Define the text input for inference (Support Batching)
16texts = [
17 "So we found being competitive and collaborative was a huge way of staying motivated towards our goals, so one person to call when you fall off, one person who gets you back on then one person to actually do the activity with.",
18 ]
19
20# Perform inference and play the generated audio
21wavs = chat.infer(texts)
22Audio(wavs[0], rate=24_000, autoplay=True)
23
24# Save the generated audio
25torchaudio.save("output.wav", torch.from_numpy(wavs[0]), 24000)