Views
No views yet
1git clone https://github.com/speechbrain/speechbrain.git
2cd speechbrain
3pip install -r requirements.txt
4pip install --editable . 1import torchaudio
2from speechbrain.inference.TTS import FastSpeech2InternalAlignment
3from speechbrain.inference.vocoders import HIFIGAN
4
5# Intialize TTS (tacotron2) and Vocoder (HiFIGAN)
6fastspeech2 = FastSpeech2InternalAlignment.from_hparams(source="speechbrain/tts-fastspeech2-internal-alignment-ljspeech", savedir="pretrained_models/tts-fastspeech2-internal-alignment-ljspeech")
7hifi_gan = HIFIGAN.from_hparams(source="speechbrain/tts-hifigan-ljspeech", savedir="pretrained_models/tts-hifigan-ljspeech")
8
9# Run TTS with text input
10input_text = "Welcome to speechbrain, this is a test run with fastspeech internal alignment."
11
12mel_output, durations, pitch, energy = fastspeech2.encode_text(
13 [input_text],
14 pace=1.0, # scale up/down the speed
15 pitch_rate=1.0, # scale up/down the pitch
16 energy_rate=1.0, # scale up/down the energy
17)
18
19# Running Vocoder (spectrogram-to-waveform)
20waveforms = hifi_gan.decode_batch(mel_output)
21
22# Save the waverform
23torchaudio.save('example_TTS_input_text.wav', waveforms.squeeze(1), 22050)
24
25
26# Run TTS with phoneme input
27input_phonemes = ['W', 'ER', ' ', 'DH', 'AH', ' ', 'L', 'IY', 'D', 'ER', 'Z', ' ', 'IH', 'N', ' ', 'DH', 'IH', 'S', ' ', 'L', 'AH', 'K', 'L', 'AH', 'S', ' ', 'CH', 'EY', 'N', 'JH', ';', " ", 'DH', 'OW', ' ', 'AW', 'ER', ' ', 'OW', 'N', ' ', 'B', 'AE', 'S', 'K', 'ER', 'V', 'IH', 'L', ';', " ", 'HH', 'UW', ' ', 'W', 'AA', 'Z', ' ', 'AE', 'T', ' ', 'W', 'ER', 'K', ' ', 'S', 'AH', 'M', ' ', 'Y', 'IH', 'R', 'Z', ' ', 'B', 'IH', 'F', 'AO', 'R', ' ', 'DH', 'EH', 'M', ';', " ", 'W', 'EH', 'N', 'T', ' ', 'M', 'AH', 'CH', ' ', 'AA', 'N', ' ', 'DH', 'AH', ' ', 'S', 'EY', 'M', ' ', 'L', 'AY', 'N', 'Z', ';']
28
29mel_output, durations, pitch, energy = fastspeech2.encode_phoneme(
30 [input_phonemes],
31 pace=1.0, # scale up/down the speed
32 pitch_rate=1.0, # scale up/down the pitch
33 energy_rate=1.0, # scale up/down the energy
34)
35
36# Running Vocoder (spectrogram-to-waveform)
37waveforms = hifi_gan.decode_batch(mel_output)
38
39# Save the waverform
40torchaudio.save('example_TTS_input_phoneme.wav', waveforms.squeeze(1), 22050)1from speechbrain.inference.TTS import FastSpeech2InternalAlignment
2fastspeech2 = FastSpeech2InternalAlignment.from_hparams(source="speechbrain/tts-fastspeech2-internal-alignment-ljspeech", savedir="pretrained_models/tts-fastspeech2-internal-alignment-ljspeech")
3items = [
4 "A quick brown fox jumped over the lazy dog",
5 "How much wood would a woodchuck chuck?",
6 "Never odd or even"
7]
8mel_outputs, durations, pitch, energy = fastspeech2.encode_text(
9 items,
10 pace=1.0, # scale up/down the speed
11 pitch_rate=1.0, # scale up/down the pitch
12 energy_rate=1.0, # scale up/down the energy
13)run_opts={"device":"cuda"} when calling the from_hparams method.git clone https://github.com/speechbrain/speechbrain/1cd speechbrain
2pip install -r requirements.txt
3pip install -e .1cd recipes/LJSpeech/TTS/fastspeech2/
2python train_internal_alignment.py hparams/train_internal_alignment.yaml --data_folder=/your_folder/LJSpeech-1.11@misc{speechbrain,
2 title={{SpeechBrain}: A General-Purpose Speech Toolkit},
3 author={Mirco Ravanelli and Titouan Parcollet and Peter Plantinga and Aku Rouhe and Samuele Cornell and Loren Lugosch and Cem Subakan and Nauman Dawalatabad and Abdelwahab Heba and Jianyuan Zhong and Ju-Chieh Chou and Sung-Lin Yeh and Szu-Wei Fu and Chien-Feng Liao and Elena Rastorgueva and François Grondin and William Aris and Hwidong Na and Yan Gao and Renato De Mori and Yoshua Bengio},
4 year={2021},
5 eprint={2106.04624},
6 archivePrefix={arXiv},
7 primaryClass={eess.AS},
8 note={arXiv:2106.04624}
9}