Modelresearch
HiFi-GAN
Also called HiFi-GAN vocoder.
A GAN vocoder that turns mel spectrograms into waveforms with a convolutional generator, judged by multi-period and multi-scale discriminators.
HiFi-GAN is a neural vocoder: it turns a mel spectrogram into a waveform. It is the second stage of most two-stage text-to-speech systems, after an acoustic model such as Tacotron 2 or FastSpeech, and it is the decoder inside VITS. The generator is a stack of transposed convolutions that raise the frame rate to the sample rate, each followed by residual blocks with dilated convolutions. It runs on all samples in parallel, unlike WaveNet, which makes one sample at a time. The generator is trained as a generative adversarial network: two sets of discriminators judge the waveform, one by looking at samples spaced by a fixed period and one at several time scales. A mel spectrogram loss and a feature matching loss keep the output close to the target.
The machine
Sizes: mel frames with bands, hop samples at 22.05 kHz, and output samples. Shapes are written as channels by length for one utterance.
Generator . A convolution maps the input of shape to ( in the V1 setting). Then four upsampling stages run in turn. Stage is a transposed convolution with stride and kernel size that halves the channels and multiplies the length by , with and . After stage 4 the tensor has shape . A final convolution and give one channel of samples in .
Multi-receptive field fusion (MRF). After each transposed convolution, three residual blocks with kernel sizes read the same input, and their outputs are averaged. In V1 each block has three pairs of dilated convolutions with dilations , each pair with a leaky ReLU before each convolution and a residual sum. The blocks see patterns of different lengths in parallel. All convolutions of use weight normalization.
Multi-period discriminator (MPD). For each period , a sub-discriminator pads the waveform of length to a multiple of and reshapes it to a 2-D array of shape , so that column holds the samples . Convolutions with kernels of width 1 along the period axis then look at each column alone, at strides of samples. The periods are prime so that the sub-discriminators see different structure.
Multi-scale discriminator (MSD). Three sub-discriminators, taken from MelGAN, look at the raw waveform, the waveform average-pooled by 2, and the waveform average-pooled by 4, with 1-D grouped convolutions. The first uses spectral normalization and the others weight normalization.
Losses. With the least squares GAN form, for each sub-discriminator , a real waveform and its mel spectrogram :
The mel loss is , where is the log mel spectrogram. The feature matching loss is the L1 distance between the inner feature maps of each discriminator on and on , divided by their sizes. The generator minimizes
and each discriminator minimizes . Both are trained with AdamW, with , and a learning rate of that decays by a factor of 0.999 each epoch.
Standing assumptions. A fixed sample rate and a fixed mel analysis (window, hop and bands) that the vocoder and the acoustic model share. The vocoder is trained on mel spectrograms of real speech and often fine-tuned on the outputs of the acoustic model.
What it counts
The generator is a deterministic function from a mel spectrogram of shape to a waveform of samples. It has no noise input. The discriminators exist only for training.
- Lengths. Each mel frame becomes exactly samples. For example, 3 s at 22050 Hz is 66150 samples, about 258 frames at a hop of 256.
- Cost of one pass. Every layer is a convolution over the whole sequence, so the cost is linear in and all positions are computed in parallel. The arithmetic of a stage grows with its length times the square of its channel count. In the V1 setting (upsampling by 8, 8, 2 and 2, channels 256, 128, 64 and 32) that is 0.52M, 1.05M, 0.52M and 0.26M multiply-adds per layer, kernel tap and mel frame, so the second stage costs most and the last stage least.
- Size. The paper gives three settings: V1 for quality, and V2 and V3 with fewer channels or fewer blocks for speed.
- Period view. For period the reshaped array has rows. With and the waveform is padded to 66154 samples and gives 6014 rows of 11 columns.
Relation to other models
- WaveNet models each sample given the past and must run steps one after the other. HiFi-GAN makes all samples in one parallel pass.
- MelGAN (Kumar and colleagues 2019) is the direct parent: a GAN vocoder with the same kind of transposed convolution generator and the multi-scale discriminator. HiFi-GAN adds the MPD, the MRF blocks and the mel loss.
- Griffin-Lim reconstructs a phase from a magnitude spectrogram by iteration and needs no training. It was the vocoder of the first Tacotron; its output has audible artifacts that neural vocoders avoid.
- VITS uses the V1 generator as its decoder, with a latent sequence in place of the mel spectrogram, and the MPD as its discriminator.
Known results in the model
- Quality (measurement). On LJ Speech, the paper reports a mean opinion score of 4.36 ± 0.07 for V1, on a 1 to 5 scale, against 4.45 ± 0.06 for the recorded speech, 4.02 ± 0.08 for a WaveNet vocoder, 3.81 ± 0.08 for WaveGlow and 3.79 ± 0.09 for MelGAN. V2 has 4.23 ± 0.07 and V3 4.05 ± 0.08.
- Speed (measurement). On the GPU of the paper, V1 generates 167.86 times faster than real time and V3 1186.80 times. On a CPU, V1 runs at 1.43 times real time and V3 at 13.44 times. The WaveNet vocoder in the same table runs at 0.003 times real time on the GPU. V1 has 13.92 million weights, V2 0.92 million and V3 1.46 million.
- The period view matters (measurement). In the ablation with the V3 generator, the full model has a MOS of 4.10 ± 0.05. Without the MPD it falls to 2.28 ± 0.09, without the mel loss to 3.25 ± 0.05, without the MSD to 3.74 ± 0.05 and without the MRF to 3.92 ± 0.05. Periods 2, 4, 8, 16 and 32 in place of the primes give 3.90 ± 0.05.
- Unseen speakers (measurement). Trained on the VCTK corpus with nine speakers held out, V1 has a MOS of 3.77 ± 0.07 on the held-out speakers against 3.79 ± 0.07 for the recordings, with 50 utterances per speaker. So a mel spectrogram carries most of what the vocoder needs.
References
- Kong, Kim and Bae 2020, Section 2 (the generator, the multi-receptive field fusion, the multi-period and multi-scale discriminators and the losses), Table 1 (MOS, speed and size on LJ Speech), the ablation table, the unseen speaker test on VCTK, and the appendix with the V1, V2 and V3 settings
- Paul Taylor, Text-to-Speech Synthesis, Cambridge University Press, 2009, Chapter 12 (Analysis of speech signals), for the spectrogram that the vocoder inverts
Where this leads
About this page
The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H0 no proof |
|
| Lean | L0 no Lean part |
|
| Visual | V0 none |
|
| Writing | W4 complete |
|
Tag EWV61N Edit this page History Report an error Markdown