Tacotron 2

Tacotron 2

AdvancedSpeech Synthesis

Educational content in the form of a scientific draft that needs expert review before being adopted as an academic reference. No experimental result that was not actually run is shown here.

Definition

A sequence-to-sequence speech synthesis model that produces a mel spectrogram from text by autoregressive decoding with attention, and then converts the spectrogram to a waveform with a separate vocoder.

Mathematical Idea

The encoder is convolutional layers followed by a bidirectional LSTM. The decoder is an autoregressive LSTM that predicts one mel frame at each step, relying on the previous frame and a location-sensitive attention context. A subsequent network (Postnet) refines the spectrogram, and a stop token determines the end. The vocoder converts the spectrogram to a waveform.

How It Works

  1. Convert the text to tokens and embeddings
  2. Encoder: convolution then bidirectional LSTM
  3. Location-sensitive attention to select the text position
  4. An autoregressive LSTM decoder predicts a mel frame
  5. Postnet and stop token prediction
  6. A vocoder converts the spectrogram to a waveform

Stages Diagram

  1. Text
  2. Encoder
  3. Attention
  4. Autoregressive Decoder
  5. Postnet
  6. Vocoder

Equations

$$c_i=\sum_j\alpha_{ij}h_j,\quad \alpha_i=\mathrm{softmax}(e_i)$$

The context vector from attention; $h_j$ are the encoder outputs.

$$\mathcal{L}=\|\hat{M}-M\|_2^2+\|\hat{M}_{post}-M\|_2^2+\mathrm{BCE}(\hat{s},s)$$

The spectrogram loss before and after the Postnet, together with the stop token.

Advantages

  • Natural quality in controlled environments
  • An understandable architecture that is easy to study
  • Does not need hand-crafted linguistic features

Limitations

  • Slow autoregressive decoding
  • Attention errors: repetition, skipping, or early stopping
  • Needs a lot of data from a single speaker

Use Cases

  • Single-speaker speech synthesis
  • Style control research
  • The spectrogram stage in traditional TTS pipelines

Applied Example

If the spectrogram hop is 256 samples at 22,050 Hz, a single frame covers 256/22050 ≈ 11.6 ms.

Code Example

PythonIllustrative, not implemented in testing
import torch, torchaudio
bundle = torchaudio.pipelines.TACOTRON2_WAVERNN_CHAR_LJSPEECH   # weights are downloaded on first use
processor = bundle.get_text_processor()
tacotron2 = bundle.get_tacotron2().eval()
vocoder = bundle.get_vocoder().eval()
text = "hello world"                       # English model (LJSpeech)
with torch.inference_mode():
    tokens, lengths = processor(text)
    mel, mel_lengths, _ = tacotron2.infer(tokens, lengths)
    wav, wav_lengths = vocoder(mel, mel_lengths)
print(mel.shape, bundle.sample_rate)

References

  1. Shen et al.. Natural TTS Synthesis by Conditioning WaveNet on Mel Spectrogram Predictions. arXiv (2017). DOI
  2. van den Oord et al.. WaveNet: A Generative Model for Raw Audio. arXiv (2016). DOI
  3. Chan, Jaitly, Le, Vinyals. Listen, Attend and Spell (2015). DOI

Audio processing in the experiments takes place inside your browser. Audio, texts, and conversations are not saved on the server. Privacy Policy