Algorithm Search⌘K

Modelresearch

WaveNet

Also called dilated causal convolution vocoder.

An autoregressive model of raw audio that predicts each mu-law quantized sample from the past with stacks of dilated causal convolutions.

WaveNet is a probability model of raw audio. It treats a waveform as a sequence of samples and predicts each sample from all the samples before it, like a causal language model over a vocabulary of 256 amplitude levels. The network is a deep stack of causal convolutions, which see only the past, with dilations that double from layer to layer, so the receptive field grows exponentially with depth at a linear cost. To make speech from text, the model is conditioned on features from a text-to-speech front end. In the original paper these were linguistic features and a pitch contour; in Tacotron 2 they are mel spectrogram frames, and WaveNet is used as a vocoder. Its listening scores were well above those of the parametric and concatenative systems of its time. Its weak point is speed, because generation makes one sample at a time.

The machine

Sizes: NN samples at 16 kHz, LL layers, CC residual channels, kernel size k=2k = 2, and Q=256Q = 256 output levels. Shapes are channels by time for one utterance.

Factorization. For a waveform x=(x1,…,xN)x = (x_1, \ldots, x_N) and a conditioning input hh,

p(x∣h)=∏t=1Np(xt∣x1,…,xt−1,h).p(x \mid h) = \prod_{t=1}^{N} p(x_t \mid x_1, \ldots, x_{t-1}, h).

Mu-law quantization. Each sample xt∈(−1,1)x_t \in (-1, 1) is compressed and then quantized to 256 levels:

F(x)=sign⁡(x) ln⁡(1+μ∣x∣)ln⁡(1+μ),μ=255.F(x) = \operatorname{sign}(x)\, \frac{\ln(1 + \mu |x|)}{\ln(1 + \mu)}, \qquad \mu = 255.

This gives fine steps near 0, where most speech samples lie, and coarse steps for loud samples. The output for each tt is a softmax over the 256 levels, trained with the cross-entropy loss.

Dilated causal convolution. A causal convolution with kernel size kk and dilation rr computes

yt=∑m=0k−1Wm xt−mr,y_t = \sum_{m=0}^{k-1} W_m\, x_{t - m r},

so output tt depends only on inputs at or before tt. The dilations double, 1,2,4,…,5121, 2, 4, \ldots, 512, and this block of 10 layers is repeated. A stack of layers with dilations r1,…,rLr_1, \ldots, r_L has the receptive field

R=1+(k−1)∑l=1Lrl.R = 1 + (k - 1) \sum_{l=1}^{L} r_l.

Gated residual layer. Layer ll maps its input uu of shape C×NC \times N to

z=tanh⁡(Wf∗u)⊙σ(Wg∗u),z = \tanh(W_{f} * u) \odot \sigma(W_{g} * u),

where ∗* is the dilated causal convolution and σ\sigma the logistic function. A 1×11 \times 1 convolution of zz is added to uu to give the input of the next layer (the residual path), and another 1×11 \times 1 convolution of zz goes to the skip path. The sum of all skip outputs goes through ReLU, 1×11 \times 1 convolutions and the softmax, giving shape 256×N256 \times N.

Conditioning. A global input hh, such as a speaker embedding, enters every layer as z=tanh⁡(Wf∗u+Vf⊤h)⊙σ(Wg∗u+Vg⊤h)z = \tanh(W_f * u + V_f^\top h) \odot \sigma(W_g * u + V_g^\top h). A local input, such as linguistic features or mel frames at a lower rate, is first upsampled to the sample rate by transposed convolutions, y=f(h)y = f(h), and enters as Vf∗yV_f * y and Vg∗yV_g * y with 1×11 \times 1 convolutions.

Standing assumptions. A fixed sample rate, a fixed quantization, and a fixed receptive field: the model sees no sample older than R−1R - 1 steps, except through the conditioning input.

What it counts

The model gives the probability of a whole waveform as the product of the softmax outputs. In training all NN outputs come from one parallel pass over the true waveform. In generation, each sample is drawn from the softmax and fed back as input.

  • Receptive field. One block with dilations 1,…,5121, \ldots, 512 and k=2k = 2 has R=1+1023=1024R = 1 + 1023 = 1024 samples, 64 ms at 16 kHz. Three blocks give 1+3⋅1023=30701 + 3 \cdot 1023 = 3070 samples. A plain causal stack of the same depth would see only L+1L + 1 samples. The text-to-speech models of the paper had a receptive field of 240 ms.
  • Mu-law check values. F(0.5)=ln⁡128.5/ln⁡256≈0.8757F(0.5) = \ln 128.5 / \ln 256 \approx 0.8757, F(0.01)≈0.2285F(0.01) \approx 0.2285 and F(−0.25)≈−0.7521F(-0.25) \approx -0.7521. With the level round⁡((F+1)/2⋅255)\operatorname{round}((F + 1) / 2 \cdot 255), these fall in levels 239, 157 and 32 of 0 to 255. Since 1+255⋅15/255=16=2561 + 255 \cdot 15 / 255 = 16 = \sqrt{256}, F(15/255)=0.5F(15 / 255) = 0.5 exactly, so half of the levels cover ∣x∣<15/255≈0.0588|x| < 15 / 255 \approx 0.0588.
  • Cost of generation. Each sample needs one pass through all LL layers, and the passes are sequential: 16000 passes per second of audio at 16 kHz. With caching of the past activations of each layer, a pass costs O(LC2)O(L C^2), so one second costs O(16000 LC2)O(16000\, L C^2) and no step can start before the one before it ends.
  • Cost of training. All outputs of a training clip are computed in one pass in O(NLC2)O(N L C^2), in parallel over time, because the true past samples are known.

Relation to other models

  • Causal language models have the same factorization over tokens. WaveNet uses convolutions in place of attention or recurrence, and its tokens are amplitude levels.
  • PixelCNN (van den Oord and colleagues 2016) is the image model that WaveNet adapts: masked convolutions and the same gated unit.
  • Tacotron 2 uses a WaveNet as its vocoder, conditioned on mel frames, with a mixture of 10 logistic distributions in place of the 256-way softmax, for 16-bit samples at 24 kHz.
  • HiFi-GAN and other GAN vocoders make all samples in one parallel pass. In the HiFi-GAN paper, a WaveNet vocoder runs at 0.003 times real time on a GPU, against more than 100 times for HiFi-GAN V1.
  • Unit selection and HMM-based synthesis were the baselines it replaced. The parametric baseline used a vocoder based on the source-filter model; WaveNet learns the waveform with no such model.

Known results in the model

  • Naturalness (measurement). In blind tests with 100 held-out sentences, each rated by 8 crowd-sourced subjects on a 1 to 5 scale, WaveNet conditioned on linguistic features and log F0 had a mean opinion score of 4.21 ± 0.081 in North American English, against 3.67 ± 0.098 for an LSTM parametric system, 3.86 ± 0.137 for an HMM-driven concatenative system and 4.55 ± 0.075 for 16-bit natural speech. In Mandarin Chinese the scores were 4.08 ± 0.085 for WaveNet, 3.79 ± 0.084 for the parametric system and 3.47 ± 0.108 for the concatenative one. The training data was 24.6 hours of English and 34.8 hours of Mandarin, each from one professional female speaker.
  • Exponential receptive field (theorem). With doubling dilations, the receptive field of LL layers of kernel size 2 is 2L2^L samples within one block, by the formula for RR above, while the number of weights grows linearly in LL.
  • Sequential sampling (theorem). Exact sampling from the factorization needs sample t−1t - 1 before the distribution of sample tt is known, so it takes NN dependent steps whatever the hardware. Parallel vocoders avoid this by changing the model, not the sampling.
  • Conditioning matters (measurement). Without text conditioning, WaveNet trained on many speakers produced speech-like babble with no words but with a consistent voice for each speaker identity.

References

  1. van den Oord et al. 2016, Section 2 (dilated causal convolutions, the softmax over mu-law values, the gated activation, residual and skip connections, and conditioning), Section 3.2 (the text-to-speech experiments) and Table 1 (MOS)
  2. Jonathan Shen, Ruoming Pang, Ron J. Weiss and colleagues, Natural TTS synthesis by conditioning WaveNet on mel spectrogram predictions, ICASSP 2018, Section 2.3 (WaveNet as a vocoder on mel spectrograms, with a mixture of logistics output)

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.

LadderLevelWhat the next level needs
Human proofH0 no proof
  • add a proof in proofs/ (06.5)
LeanL0 no Lean part
  • name a Lean module in the lean field (07)
VisualV0 none
  • add viz/scene.ts or a figure (10)
WritingW4 complete
  • a review of the text: no review record reviews/0NFQNJ/text.yaml