Views
No views yet
k=100.pip install speechbrain transformers1import torch
2import torchaudio
3from speechbrain.inference.ST import EncoderDecoderS2UT
4from speechbrain.inference.vocoders import UnitHIFIGAN
5
6# Intialize S2UT (Transformer) and Vocoder (HiFIGAN Unit)
7s2ut = EncoderDecoderS2UT.from_hparams(source="speechbrain/s2st-transformer-fr-en-hubert-l6-k100-cvss", savedir="tmpdir_s2ut")
8hifi_gan_unit = UnitHIFIGAN.from_hparams(source="speechbrain/tts-hifigan-unit-hubert-l6-k100-ljspeech", savedir="tmpdir_vocoder")
9
10# Running the S2UT model
11codes = s2ut.translate_file("speechbrain/s2st-transformer-fr-en-hubert-l6-k100-cvss/example-fr.wav")
12codes = torch.IntTensor(codes)
13
14# Running Vocoder (units-to-waveform)
15waveforms = hifi_gan_unit.decode_unit(codes)
16
17# Save the waverform
18torchaudio.save('example.wav',waveforms.squeeze(1), 16000)run_opts={"device":"cuda"} when calling the from_hparams method.@misc{SB2021,
author = {Ravanelli, Mirco and Parcollet, Titouan and Rouhe, Aku and Plantinga, Peter and Rastorgueva, Elena and Lugosch, Loren and Dawalatabad, Nauman and Ju-Chieh, Chou and Heba, Abdel and Grondin, Francois and Aris, William and Liao, Chien-Feng and Cornell, Samuele and Yeh, Sung-Lin and Na, Hwidong and Gao, Yan and Fu, Szu-Wei and Subakan, Cem and De Mori, Renato and Bengio, Yoshua },
title = {SpeechBrain},
year = {2021},
publisher = {GitHub},
journal = {GitHub repository},
howpublished = {\\\\url{https://github.com/speechbrain/speechbrain}},
}