Reputation: 167
Is this code from this repo https://github.com/snakers4/silero-models#pytorch-1 I'd like to output the voice to an audio file, how can I do that?
code:
# V3
import torch
language = 'ru'
model_id = 'ru_v3'
sample_rate = 48000
speaker = 'ksenia'
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
example_text = 'Привет, как делишки?'
audio = model.apply_tts(text=example_text,
speaker=speaker,
sample_rate=sample_rate)
I heard about this, but this don't work with v_2 or v_3
torchaudio.save('test_1.mp3',
audio[0].unsqueeze(0),
sample_rate=16000)
Upvotes: 1
Views: 1659
Reputation: 167
Just remove [0]
so this will be look like this:
torchaudio.save('test_1.mp3',
audio.unsqueeze(0),
sample_rate=16000)
Upvotes: 2