Use Silero TTS via PyTorch Hub
masterYou can load Silero Text-To-Speech models directly using torch.hub.load. This method automatically handles model downloading and setup. You need to specify the repo_or_dir, the model type (silero_tts), the language, and the speaker (model ID).
# V5
import torch
language = 'ru'
model_id = 'v5_ru'
sample_rate = 48000
speaker = 'xenia'
device = torch.device('cpu')
model, example_text = torch.hub.load(repo_or_dir='snakers4/silero-models',
model='silero_tts',
language=language,
speaker=model_id)
model.to(device) # gpu or cpu
audio = model.apply_tts(text=example_text,
speaker=speaker,
sample_rate=sample_rate)