Pytorch TTS 如何将输出添加到音频文件?

Pytorch TTS how to add output to audio file?

这段代码来自这个 repo https://github.com/snakers4/silero-models#pytorch-1 我想将语音输出到音频文件,我该怎么做?

代码:

# 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)

我听说过这个,但这不适用于 v_2 或 v_3

torchaudio.save('test_1.mp3',
                  audio[0].unsqueeze(0),
                  sample_rate=16000)

只需删除 [0]

所以这看起来像这样:

torchaudio.save('test_1.mp3',
                  audio.unsqueeze(0),
                  sample_rate=16000)