FastSpeech is built from a feed-forward structure called the Feed-Forward Transformer (FFT). The left side of the figure at the top of the article shows the overall flow, and the right side shows the inside of the length regulator.
From phonemes to mel-spectrogram, processing goes in the following order.
- Phoneme embedding: Phonemes (51 types including punctuation) are turned into 384-dimensional vectors, and positional encodings are added.
- Phoneme-side FFT blocks Γ N: Produce a hidden state for each phoneme, Hphoβ=[h1β,h2β,β¦,hnβ].
- Length regulator: Stretches the hidden states according to the phoneme durations D=[d1β,β¦,dnβ] into a sequence Hmelβ of the same length as the mel-spectrogram, m=βiβdiβ.
- Mel-side FFT blocks Γ N: Add positional encodings to the stretched sequence and process it.
- Linear layer: Converts the 384-dimensional hidden states into an 80-dimensional mel-spectrogram, outputting all frames at once.
- WaveGlow: A pre-trained vocoder turns the mel-spectrogram into a waveform.
An FFT block is a Transformer block whose feed-forward network (two fully connected layers) is replaced with two 1D convolutional layers (with ReLU). After multi-head attention and after the convolutions, residual connections, layer normalization, and dropout are added as in the Transformer. The idea is that in both phoneme sequences and mel-spectrogram sequences, adjacent hidden states are closely related, so convolutions fit better.
The length regulator is expressed as follows, where Ξ± sets the speaking rate.
Hmelβ=LR(Hphoβ,D,Ξ±)
For example, with Hphoβ=[h1β,h2β,h3β,h4β] and D=[2,2,3,1], normal speed (Ξ±=1) gives [h1β,h1β,h2β,h2β,h3β,h3β,h3β,h4β]. At Ξ±=1.3 (slow) the durations become [2.6,2.6,3.9,1.3]β[3,3,4,1], and at Ξ±=0.5 (fast) they become [1,1,1.5,0.5]β[1,1,2,1], changing the sequence length. Changing the duration of spaces in the sentence (word boundaries) also adjusts the pauses between words.
The duration predictor is a small network placed on top of the phoneme-side FFT blocks. It consists of two 1D convolutional layers (ReLU, each followed by layer normalization and dropout) and a linear layer that outputs a scalar. Durations are predicted in the logarithmic domain, which brings them closer to a Gaussian distribution and makes them easier to learn.
The settings in the paper are as follows.
| Component | Setting |
|---|
| FFT blocks | 6 on the phoneme side, 6 on the mel-spectrogram side |
| Hidden size | 384 (embedding, attention, convolution) |
| Attention heads | 2 |
| FFT block convolutions | Kernel width 3, 384 β 1,536 β 384 |
| Duration predictor convolutions | Kernel width 3, two layers of 384 β 384 |
| Output | 80-dimensional mel-spectrogram |
Autoregressive models use attention to decide "which phoneme is being read now" automatically at every step, so when the alignment drifts, words get skipped or repeated. FastSpeech decides in advance how many frames each phoneme lasts (a hard alignment), so every phoneme is read exactly once, in order.