Tacotron2 is an encoder-attention-decoder. The encoder is made of three parts in sequence: 1) a word embedding, 2) a convolutional network, and 3) a bi-directional LSTM. The encoded represented is connected to the decoder via a Location Sensitive Attention module. The decoder is comprised of a 2 layer LSTM network, a convolutional postnet, and a fully connected prenet.
During training, the ground frame is fed through the prenet and passed as input to the decoder LSTM layers. During inference, the model's predictions at the previous time step is used. In addition, an attention context is computed by the attention layer at each step and concatenated with the prenet output. The output of the LSTM network concatenated with the attention is sent through two projection layers. The first projects the information to a spectrogram while the other projects it to a stop token. The spectrogram is then sent through the convolutional postnet to compute a residual to add to the generated spectrogram.
This model is trained on LJSpeech sampled at 22050Hz, and has been tested on generating female English voices with an American accent.
No performance information available at this time.
This model can be automatically loaded from NGC.
NOTE: In order to generate audio, you also need a 22050Hz vocoder from NeMo. This example uses the HiFi-GAN model.
# Load Tacotron2 from nemo.collections.tts.models import Tacotron2Model spec_generator = Tacotron2Model.from_pretrained("tts_en_tacotron2") # Load vocoder from nemo.collections.tts.models import Vocoder model = Vocoder.from_pretrained(model_name="tts_hifigan") # Generate audio import soundfile as sf parsed = spec_generator.parse("You can type your sentence here to get nemo to produce speech.") spectrogram = spec_generator.generate_spectrogram(tokens=parsed) audio = model.convert_spectrogram_to_audio(spec=spectrogram) # Save the audio to disk in a file called speech.wav sf.write("speech.wav", audio.to('cpu').numpy(), 22050)
This model accepts batches of text.
This model generates mel spectrograms.
This checkpoint only works well with vocoders that were trained on 22050Hz data. Otherwise, the generated audio may be scratchy or choppy-sounding.
1.0.0 (current): An updated version of tacotron2 that standardizes mel spectrogram generation across NeMo models.
1.0.0rc1: The original version that was released with NeMo 1.0.0.rc1