Algorithm Search⌘K

Modelresearch

Neural codec language model

Also called VALL-E.

TTS as language modeling over the discrete tokens of a neural audio codec, prompted by a few seconds of a speaker to copy an unseen voice.

A neural codec language model treats text-to-speech as language modeling. A neural audio codec turns speech into a short sequence of discrete tokens and back. A transformer language model is trained to continue a sequence of such tokens, given the phonemes of the text. To speak in a new voice, the model gets a few seconds of a recording of that voice as a prompt and continues it with the new text, the way a text language model continues a prompt. VALL-E (Wang and colleagues 2023) is the first model of this kind for TTS. It uses the EnCodec codec, whose tokens come from residual vector quantization, and was trained on 60000 hours of audiobook speech. The approach copies the voice, the recording conditions and some of the emotion of the prompt, with no training on the new speaker.

The machine

Sizes: TT codec frames at 75 Hz, Q=8Q = 8 codebooks of K=1024K = 1024 entries, nn phonemes, and a transformer of 12 layers, 16 heads, width 1024 and feedforward width 4096. Shapes are for one utterance.

Codec. EnCodec maps 24 kHz audio to frames at 75 Hz, one frame per 320 samples. A convolutional encoder gives a vector ete_t for each frame. Residual vector quantization codes it with QQ codebooks B1,…,BQB_1, \ldots, B_Q:

r0=et,ct,q=argmin⁡k∥rq−1−Bq[k]∥,rq=rq−1−Bq[ct,q].r_0 = e_t, \qquad c_{t,q} = \operatorname{argmin}_{k} \| r_{q-1} - B_q[k] \|, \qquad r_q = r_{q-1} - B_q[c_{t,q}].

The decoder of the codec maps ∑qBq[ct,q]\sum_q B_q[c_{t,q}] back to audio. A clip becomes a code matrix CC of shape T×8T \times 8, with entries in {0,…,1023}\{0, \ldots, 1023\}. The first codebook carries the coarse content and the later ones the detail, because each codes what the earlier ones left.

Autoregressive model (first codebook). A decoder-only transformer with a causal mask reads the phonemes xx of the prompt and the target text, then the first-codebook tokens c~:,1\tilde c_{:,1} of the prompt, and continues with the tokens of the new speech:

p(c:,1∣x,c~:,1)=∏tp(ct,1∣c<t,1,c~:,1,x).p(c_{:,1} \mid x, \tilde c_{:,1}) = \prod_{t} p(c_{t,1} \mid c_{<t,1}, \tilde c_{:,1}, x).

An end token stops the sequence, so this model also decides the length of the speech and thus its durations.

Non-autoregressive model (codebooks 2 to 8). A second transformer, with no causal mask, predicts all frames of codebook jj at once, given the earlier codebooks of the new speech, the whole T×8T \times 8 prompt C~\tilde C and the phonemes:

p(C:,2:8∣x,C~)=∏j=28p(c:,j∣C:,<j,x,C~).p(C_{:,2:8} \mid x, \tilde C) = \prod_{j=2}^{8} p(c_{:,j} \mid C_{:,<j}, x, \tilde C).

The embeddings of the earlier codebooks are summed for each frame, and the stage jj enters through adaptive layer normalization. The full model is the product of the two parts.

Inference. The first codebook is sampled token by token from the autoregressive model; the paper uses sampling because beam search could loop forever. The other 7 codebooks are decoded greedily by the non-autoregressive model in 7 parallel passes. The codec decoder makes the waveform.

Training. The training data is LibriLight: 60000 hours of English audiobooks from about 7000 speakers, transcribed into phonemes by a speech recognizer. Each training example is a random crop of 10 to 20 seconds.

Standing assumptions. A frozen codec, a phoneme input, and a prompt from the target speaker with its phoneme transcription.

What it counts

The model defines a distribution over code matrices given the phonemes and the prompt. The waveform is a fixed function of the code matrix.

  • Bit rate. 75 frames per second times 8 codebooks times log⁡21024=10\log_2 1024 = 10 bits is 6000 bits per second. A 10 s clip is a matrix of 750×8750 \times 8 codes. Only the first codebook is generated step by step: 750 sequential steps for 10 s, against 240000 for a sample-level model such as WaveNet at the same sample rate.
  • Example of residual quantization. In two dimensions, take e=(0.9,−0.3)e = (0.9, -0.3), B1={(1,0),(0,1),(−1,0),(0,−1)}B_1 = \{(1, 0), (0, 1), (-1, 0), (0, -1)\} and B2={(0.2,0),(−0.2,0),(0,0.2),(0,−0.2)}B_2 = \{(0.2, 0), (-0.2, 0), (0, 0.2), (0, -0.2)\}. The first stage picks (1,0)(1, 0) and leaves r1=(−0.1,−0.3)r_1 = (-0.1, -0.3), with ∥r1∥2=0.10\|r_1\|^2 = 0.10. The squared distances from r1r_1 to the entries of B2B_2 are 0.180.18, 0.100.10, 0.260.26 and 0.020.02, so the second stage picks (0,−0.2)(0, -0.2) and leaves r2=(−0.1,−0.1)r_2 = (-0.1, -0.1), with ∥r2∥2=0.02\|r_2\|^2 = 0.02. The codes are (0,3)(0, 3) and the reconstruction is (1,−0.2)(1, -0.2).
  • Cost. The autoregressive pass costs, with a key-value cache, O(d2+(n+T)d)O(d^2 + (n + T) d) per layer and step over TT steps. Each non-autoregressive pass costs O((n+T)2d+(n+T)d2)O((n + T)^2 d + (n + T) d^2) per layer, and there are 7 of them.

Relation to other models

  • Causal language models for text, such as GPT, are the template. The prompt plays the role of in-context learning: the speaker is given by example, not by an embedding trained for it.
  • Tacotron, FastSpeech and VITS predict continuous features with a regression or a variational loss, mostly for speakers seen in training. The codec model predicts discrete tokens with a cross-entropy loss, so it can sample many different renderings of one text.
  • WaveNet also predicts discrete tokens with a softmax, but at the sample rate. The codec lowers the rate from 24000 to 75 steps per second.
  • SoundStream and EnCodec are the codecs: a convolutional encoder and decoder trained with reconstruction and adversarial losses, and a residual vector quantizer between them. AudioLM had earlier used SoundStream tokens for speech continuation with no text.

Known results in the model

  • Zero-shot quality on LibriSpeech (measurement). On utterances of 4 to 10 s from LibriSpeech test-clean, with a 3 s prompt from another utterance of the same speaker, VALL-E had a word error rate of 5.9% under an automatic recognizer and a speaker similarity of 0.580 from a speaker verification model, against 7.7% and 0.337 for YourTTS and 2.2% and 0.754 for the recordings.
  • Listening tests (measurement). On LibriSpeech with 40 speakers, the similarity MOS was 4.38 ± 0.10 for VALL-E, 3.45 ± 0.09 for YourTTS and 4.5 ± 0.10 for the recordings, on a 1 to 5 scale. On VCTK, where the accents differ from the training data, it was 3.81 ± 0.09 against 3.70 ± 0.09 for YourTTS and 4.29 ± 0.09 for the recordings.
  • The prompt sets the voice (measurement). Without the acoustic prompt, the speaker similarity of the autoregressive model fell from 0.585 to 0.236 at the same word error rate. In the non-autoregressive model, given the true first codebook, the word error rate was 19.6% without any prompt and 2.8% with the phoneme and acoustic prompts.
  • Robustness (observation). The paper reports that some words are unclear, skipped or repeated, and traces this to the attention alignment of the autoregressive model. This is the same kind of failure as in Tacotron, and it is not present in duration-based models.
  • Misuse (observation). A model that copies a voice from 3 seconds of audio can be used to impersonate a speaker. The paper notes this risk and suggests a detection model for synthetic speech.

References

  1. Wang et al. 2023, Section 4 (the codec tokens, the autoregressive and non-autoregressive models and the inference), Section 5 (the setup on LibriLight), Tables 2 and 3 (LibriSpeech test-clean), Tables 4 and 5 (ablations) and the limitations section
  2. Neil Zeghidour, Alejandro Luebs, Ahmed Omran, Jan Skoglund and Marco Tagliasacchi, SoundStream: An end-to-end neural audio codec, IEEE/ACM Transactions on Audio, Speech, and Language Processing 30, 495-507, 2022, the encoder, the residual vector quantizer and the decoder
  3. Défossez et al. 2023 (EnCodec), the model description, with the residual vector quantization and the bit rates

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/93QYYQ/text.yaml