VOICECRAFT: Zero-Shot Speech Editing and Text-to-Speech in the Wild (2024)

Abstract: We introduce VOICECRAFT, a token infilling neural codec language model, that achieves state-of-the-art performance on both speech editing and zero-shot text-to-speech (TTS) on audiobooks, internet videos, and podcasts1. VOICECRAFT employs a Transformer decoder architecture and introduces a token rearrangement procedure that combines causal masking and delayed stacking to enable generation within an existing sequence. On speech editing tasks, VOICECRAFT produces edited speech that is nearly indistinguishable from unedited recordings in terms of naturalness, as evaluated by humans; for zero-shot TTS, our model outperforms prior SotA models including VALLE and the popular commercial model XTTS v2. Crucially, the models are evaluated on challenging and realistic datasets, that consist of diverse accents, speaking styles, recording conditions, and background noise and music, and our model performs consistently well compared to other models and real recordings. In particular, for speech editing evaluation, we introduce a high quality, challenging, and realistic dataset named REALEDIT. We encourage readers to listen to the demos at https: //jasonppy.github.io/VoiceCraft_web.

heading: 1 Introduction
text: We introduce VOICECRAFT, a Transformer-based neural codec language model (NCLM) that performs infilling generation of neural speech codec tokens autoregressively conditioned on bidirectional context. VOICECRAFT achieves state-of-the-art (SotA) performance on both speech editing (shown in Fig. 1) and zero-shot TTS. Our method is based on a two-step token rearrangement procedure that consists of a causal masking step and delayed stacking step. The causal masking technique is inspired by the success of causal masked multimodal
1Data, code, and model weights are available at https: //github.com/jasonppy/VoiceCraft.
model in joint text-image modeling (Aghajanyan et al., 2022), and our proposed technique works for speech codec sequences, which enables autoregressive generation with bidirectional context. In addition, we further integrate causal masking with delayed stacking (Kharitonov et al., 2021a; Copet et al., 2023) as our proposed token rearrangement procedure, to ensure efficient multi-codebook modeling.
To evaluate speech editing, we manually crafted a first-of-its-kind, realistic, and challenging dataset named REALEDIT. REALEDIT consists of 310 real world speech editing examples, with waveforms sourced from audiobooks (Zen et al., 2019), YouTube videos (Chen et al., 2021a), and Spotify podcasts (Clifton et al., 2020), and duration ranging from 5 seconds to 12 seconds. To create the target transcripts, the transcripts of the source speech are edited in such a way that the edited transcripts remain grammatically correct and are semantically coherent. The dataset is designed to cover a wide range of editing scenarios, including insertion, deletion, substitution, and multi-span editing, with the length of the edited text ranging from 1 word to 16 words. Compared to commonly used speech synthesis evaluation datasets that only contain audiobooks such as VCTK (Yamagishi et al., 2019), LJSpeech (Ito and Johnson, 2017), and LibriTTS (Zen et al., 2019), REALEDIT is
1 12442
more challenging in that the recordings have diverse content, accents, speaking styles, recording conditions, and background sounds. We believe that the realism and diversity of REALEDIT makes it a reliable indicator of the practicality of speech editing models in the real world.
In the subjective human listening tests, VOICECRAFT significantly outperforms prior SotA speech editing model on REALEDIT. Importantly, the edited speech produced by VOICECRAFT is nearly indistinguishable from the original unedited recording in terms of naturalness. We found that VOICECRAFT generalizes well to zero-shot TTS without any finetuning, achieving SotA performance on a dataset comprised of audiobooks and YouTube videos, outperforming strong baselines including reproduced VALL-E (Wang et al., 2023a) and the popular commercial model XTTS v2 (COQUI, 2023). In summary, our contributions are:
1. We introduce VOICECRAFT, a neural codec language model for speech editing that generates synthesized speech that is nearly indistinguishable from in-the-wild recordings according to human listeners. We also release the code and model weights for VOICECRAFT.
2. We show that VOICECRAFT generalizes well to zero-shot TTS without finetuning.
3. We release a high quality, challenging, and realistic speech editing evaluation dataset REALEDIT.

heading: 2 Related Work
text: Neural codec langauge models (NCLM) and zero-shot TTS. Tokenizing speech signals into sequences of learnable, discrete units and then training a language model on the resulting unit sequences was initially proposed in the context of textless NLP (Hsu et al., 2021; Lakhotia et al., 2021; Kharitonov et al., 2021b; Nguyen et al., 2022), where the goal is to perform NLP tasks directly on spoken utterances without the need to first transcribe the speech into text. Recently, NCLMs that operates on tokens from Residual vector quantization (RVQ)-based models (Zeghidour et al., 2021; Defossez et al., 2022) attract increased attention due to its high quality generation. For example, AudioLM (Borsos et al., 2022a) exhibits strong performance on long-term coherent speech continuation. Zero-shot TTS is a task where a model needs to synthesize speech in a target voice
which was unseen during training, given only the target transcript and a short reference recording of the target voice. Framing zero-shot TTS as transcript-conditioned speech continuation, VALLE (Wang et al., 2023a) and Spear-TTS (Kharitonov et al., 2023) are the first applications of NCLMs on this task, significantly outperforming non-NCLM approaches. Zhang et al. (2023) extends VALL-E to cross-lingual TTS. Guo et al. (2022); Yang et al. (2023); Liu et al. (2023); Ji et al. (2023); Lyth and King (2024) adapt NCLMs style-controlled speech synthesis. Song et al. (2024); Du et al. (2024b) enhance phoneme alignment in NCLMs to reduce error. Wang et al. (2023b) proposes a unified NCLM for both speech generation and recognition tasks. Borsos et al. (2023) proposes an efficient parallel decoding method. Jiang et al. (2024) proposes disentangled timbre and prosody modeling, where the latter is modeled with a NCLM. NCLMs have also been successfully applied to other audio domains. Kreuk et al. (2022) applies NCLM to sound effects generation, and Agostinelli et al. (2023); Donahue et al. (2023); Garcia et al. (2023); Copet et al. (2023) use NCLMs for music generation.
Speech editing. This task requires a model to alter words or phrases within an utterance to match a target transcript, but the regions of the original speech not targeted for editing must remain unchanged (see Fig. 1 for an example). Early methods achieve text-guided speech insertion and substitution by combining a single speaker TTS model and a voice conversion model to generate desired speech segment, which is then concatenated with unedited part (Jin et al., 2017). Since the generation is not conditioned on the unedited part of the speech, the result sounds unnatural due to prosody mismatch and boundary artifacts (Morrison et al., 2021). More recent speech editing models have attempted to condition their generation on surrounding speech context. Tan et al. (2021) uses two unidirectional LSTM models with bidirectional fusion. Wang et al. (2022); Bai et al. (2022); Borsos et al. (2022b) uses the masked reconstruction objective with Convolutional or Transformer models to further improve contextualization. FluentSpeech (Jiang et al., 2023b) is a diffusion-based speech editing model that achieves SotA performance on speech editing on LibriTTS and VCTK.
The research community starts to investigate the possibility of having a unified model for both zeroshot TTS and speech editing. Yin et al. (2022); Jiang et al. (2023a) propose modular models for
2
the two tasks, while our model is end-to-end. Concurrent work SpeechX (Wang et al., 2023c) adapt VALL-E by prompt tuning for a range of tasks including speech editing and zero-shot TTS, but no human evaluation is conducted in their paper. Concurrent work UniCATS (Du et al., 2024a) is a diffusion-based modular model for the two tasks. However their model is only evaluated on masked speech reconstruction of span length less than 2 seconds, while our model is evaluated on as much as 16 words editing. Voicebox (Le et al., 2023) is a recent flow matching based model capable of a wide range of tasks including speech editing and zeroshot TTS. However the speech editing capability is not evaluated in their paper, and only shown in their demo page. We therefore compare our model’s editing results with Voicebox’s on our demo page using on the same examples from their demo page.

heading: 3 Method
text: VOICECRAFT casts both sequence infilling (for speech editing) and continuation (for zero-shot TTS) as a simple left-to-right language modeling by rearranging neural codec’s output tokens. The rearrangement involves two steps: (1) causal masking (§3.1) to enable autoregressive continuation/infilling with bidirectional context and (2) delayed stacking (§3.2) to ensure efficient multi-codebook modeling. VOICECRAFT employs decoder-only Transformers and is trained with an autoregressive sequence prediction (§3.3). We introduce the inference setup for speech editing and zero-shot TTS in §3.4.

heading: 3.1 Rearrangement Step 1: Causal Masking
text: As shown on the left hand side of Fig. 2, given a continuous speech waveform as input, we first use Encodec (Defossez et al., 2022) to quantize it into a T by K codec matrix X , where T is the number of temporal frames, and K is the number of RVQ codebooks. X can be written as (X1, · · · , XT ), where Xt is a vector of length K representing the codes from different codebooks at time step t, and we assume that code from codebook k models the residual from codebook k − 1. During training, our goal is to randomly mask some span of tokens (Xt0 , . . . , Xt1), and then autoregressively predict these masked tokens conditioned on all of the unmasked tokens. This is a problem when t1 < T , because we cannot condition on future outputs when performing autoregressive generation. We need to
modify the masking on X so that it is causal, by moving the span to be masked to the end of the sequence, so that when infilling these tokens the model can condition on both past and future unmasked tokens (Aghajanyan et al., 2022; Donahue et al., 2020; Bavarian et al., 2022).
The procedure outlined above can be trivially extended to multiple masked spans by simply moving all masked spans to the end of the sequence. The number of spans to be masked n is sampled from Poison(λ), and then for each span, we sample a span length l ∼ Uniform(1, L). Finally, we randomly select the locations of the spans within X under the constraint that they do not overlap with each other. The selected n spans are then replaced with mask tokens 〈M1〉, · · · , 〈Mn〉. The original tokens within these masked spans are moved to the end of the sequence X , with each span preceded by its corresponding mask token.
Consider this example: let X = (X1, . . . , X6) and imagine we wish to mask a single span from X2 to X4. The original sequence X is rearranged into Y = (Y1; 〈M1〉;Y2; 〈M1〉;Y3; ), where Y1 = (X1), Y2 = (X5, X6), and Y3 = (X2, X3, X4). We call Y1 and Y2 the unmasked spans, and Y3 the masked span. An end of span or EOS token is added to the end of each masked span (in this example at the end of Y3), and an end of utterance or EOU token is added to the end of the utterance (i.e. Y2). For simplicity, we do not explicitly denote these special tokens and assume they are part of the spans.

heading: 3.2 Rearrangement Step 2: Delayed Stacking
text: After the causal masking token rearrangement, each timestep of the rearranged matrix Y is vector of K tokens. Copet et al. (2023) observed that when performing autoregressive generation over stacked RVQ tokens, it is advantageous to apply a delay pattern so that the prediction of codebook k at time t can be conditioned on the prediction of codebook k − 1 from the same timestep. We take a similar approach which we describe here. Assume a span Ys is of shape Ls × K. Applying the delay pattern rearranges it into Zs = (Zs,0, Zs,1, · · · , Zs,Ls+K−1), where Zs,t, t ∈ [Ls +K − 1] is defined as2:
Zs,t = (Ys,t,1, Ys,t+1,2, · · · , Ys,t−K+1,K) (1) where Ys,t−k+1,k denotes the token located at coordinate (t− k+1, k) in matrix Ys, i.e. the kth codebook entry at the (t− k + 1)th timestep. To make
2[N ] represents integer set {0, 1, · · · , N}
3
x1 x2 x3 x4 x5 x6 x1 x2 x3 x4 x5 x6 x1 x2 x3 x4 x5 x6 x1 x2 x3 x4 x5 x6
span2 (to be masked)
x1 x2 x3 x4x5 x6 x1 x2 x3 x4x5 x6 x1 x2 x3 x4x5 x6 x1 x2 x3 x4x5 x6 m1 m1 m1 m1 m1 m1 m1 m1 u u u u s s s s
x2 x3 x4 x2 x3 x4
x2 x3 x4 x2 x3 x4
s s
s s
Step 1: Causal Masking span1
Step 2: Delayed Stacking
x1 x1
x1 x1 m1 m1 m1 m1
x5 x6 x5 x6
x5 x6 x5 x6
u u
u u m1 m1 m1 m1
CB1
CB2
CB3
CB4 x x x x codec tokens from different codebooks
s u end-of-span
m end-of-uCerance
Nota9on:
Transformer Decoder
v ɔɪ s x4 x3 x4 x2 x3 x4
x2 x3
s s … … … … … … … …
… …autoregressive genera/on
Phonemized transcript
span3
Encodec Encoder Encodec
Decoder
❄ ❄
Rearrange
"
empty token mask token
…
Token Rearrangement Modeling
span1 span2 (to be masked) span3
X
Y
Z
Adjust for ACL
rearranged codec tokens
Figure 2: An example of the token rearrangement procedure and modeling framework. The rearrangement procedure involves two steps: (1) Causal masking, where masked spans are replaced with mask tokens and moved to the end, and (2) Delayed stacking, where tokens are shifted in the time dimension based on their codebook index.
sure that ∀t ∈ [Ls +K − 1], Zs,t contains K valid tokens, we introduce a special learnable [empty] token and define Ys,t−k+1,k ≜ [empty] ,∀t ∈ {s : s < k ∪ s − k + 1 > Ls}. Note that the mask tokens are not part of any span and are not changed during delayed stacking. We define the resulting matrix of delayed stacking Z = (Z1, 〈M1〉, Z2, 〈M1〉, · · · , 〈MS−1
2 〉, ZS) (as-
suming Y consists of S spans). See the diagram for Z in Fig. 2 for an illustration.

heading: 3.3 Modeling
text: As shown in the right hand side of Fig. 2, we use a Transformer decoder to model Z autoregressively, conditioned on transcript of the speech W . Therefore, the input to the decoder is [W ;Z], where “;” denotes concatenation. At timestep t of span s in codec matrix Z, the model predicts all K tokens of Zs,t simultaneously, by using K MLP heads to project the transformer’s final hidden state to K sets of logits, one for each of the K codebooks. Note that the prediction is conditioned on transcript W , and all tokens in Z before Zs,t, denoted as Hs,t. Mathematically, the Transformer decoder models the factorized conditional distribution of Z:
Pθ(Z|W ) = ∏
s
∏
t
Pθ(Zs,t|W,Hs,t) (2)
= ∏
s
∏
t
K∏
k=1
Pθ(Zs,t,k|W,Hs,t) (3)
Where θ represent the parameters of the model. Equation 2 is the autoregressive factorization across time, while Equation 3 is the factorization across codebooks given an independence assump-
tion - given W and Hs,t, the K RVQ codes in Zs,t are assumed to be independent of each other. We argue in appendix D that this assumption is mild.
With the token level probability formulation in Equation 3, we derive the training loss as the negative log likelihood L(θ) = − logPθ(Z|W ) = −∑Kk=1 Lk(θ). Empirically, we found that weighting the first residual codebooks more than the latter codebooks leads to better performance, and therefore our final loss is L(θ) =∑Kk=1 αkLk(θ), where (αk)Kk=1 are tunable hyperparameters. Note that we follow Aghajanyan et al. (2022) and calculate the prediction loss on all tokens (not just the tokens in the masked spans), except for mask tokens and [empty] tokens.

heading: 3.4 Inference
text: Speech Editing. The setting for speech editing is the following: we have a speech recording R and its transcript W , and we want the model to modify only the relevant spans of R so that it matches the target transcript W ′. We assume that W ′ is an edited version of W , where some words have been inserted, substituted, or deleted. This task is almost exactly the same as the training task, with two differences: 1) during training, the input transcript is simply the transcript of the original recording W , while during inference it is a modified transcript W ′ 2) during training, the spans to be masked (i.e. edited) are chosen randomly. During inference, we select them by comparing the original transcript and the target transcript to identify the words that should be masked out, and then use the word level forced alignment of the original transcript to identify the codec token spans that correspond to these
4
words to be masked. To ensure a smooth transition between the edited speech and the unedited speech, the neighboring words surrounding the span to be edited also need to be slightly modified in order to model co-articulation effects. Therefore, we specify a small margin hyperparameter ϵ, and extend the mask span length by ϵ on both the left and right sides3. During autoregressive generation, we feed the model the target transcript with all unmasked spans, with mask tokens inserted in the locations where the edits should take place. We then have the model autoregressively continue this sequence, whereby it fills in the masked spans. The generated codec tokens are then spliced back into their correct location in the utterance, and we map the complete codec token sequence back to a waveform using the Encodec decoder network.
Zero-shot TTS. As we previously noted, zeroshot TTS for our model is straightforward because it simply corresponds to performing an insertion edit at the end of the original utterance. In this case, the model is provided a voice prompt with its transcription, as well as the target transcript of the speech to be generated. The three inputs are concatenated together and fed to the model, after which it generates the codec sequence of the target transcript autoregressively.

heading: 4 REALEDIT: a realistic and challenging speech editing dataset
text: To support as realistic an evaluation as possible, we constructed a first-of-its-kind dataset of 310 manually-crafted speech editing examples. Each example consists of a tuple: (original audio, original transcript, edited transcript). The dataset contains 100 utterances from LibriTTS (dev-clean and dev-other) (Zen et al., 2019), 100 utterances from YouTube (from Gigaspeech testset) (Chen et al., 2021a) and 110 utterances from the Spotify Pod-
3for substitution and deletion, the spans that are to be masked are just those words that are different from the target plus the margin; for insertion, the spans are just left and right margin spanning from the middle of the two words where the insertion happens
cast dataset (Clifton et al., 2020). We manually checked the utterances for accuracy, then had native English speakers revise them to create edited transcripts. For each utterance, we determine the type of modification using predefined probability distributions of editing type, number of disjoint spans to be edited, and editing span length. Specifically, we study the following categories: 1) number of edited spans: 1 or 2; 2) type of edits: insertion, deletion and substitution; 3) editing span length: short (1-2 words), medium (3-6 words), long (7- 12 words). Crucially, a edited transcript must be grammatically correct and semantically coherent. Examples of the dataset are shown in table 1 and 8, and statistics are shown in table 2,

heading: 5 Experiments

heading: 5.1 Setup
text: Data. Gigaspeech training set (Chen et al., 2021a) is used as the training data, which contains 9k hours of audiobooks, podcasts, and YouTube videos at 16kHz audio sampling rate. Audio files that shorter than 2 seconds are dropped. For ablation studies, we use the masked reconstruction task, and a 1000- utterance random subset of Gigaspeech validation set as the testing utterances (detailed in §C). For speech editing evaluation, we use the proposed REALEDIT dataset. For zero-shot TTS evaluation, we constructed a 250 prompt-transcript paired dataset from LibriTTS (Zen et al., 2019) and the YouTube portion of the Gigaspeech test set, with half of the examples drawn from each dataset. The length of each voice prompt is kept as close as pos-
5
sible to 3 seconds long, with the constraint applied that we only cut the audio between complete words. The transcript is a concatenation of the transcript of the voice prompt and the target transcript. The target transcripts are chosen from different utterances spoken by the same speaker as the prompt, and range from 8 to 40 words in length. We only select utterances with a WER lower than 15% by Whisper medium.en (Radford et al., 2022).
Model. Encodec (Defossez et al., 2022) is used as the speech tokenizer, which has 4 RVQ codebooks each with vocabulary size of 2048, and a codec framerate of 50Hz on 16kHz recordings. (see §C for detailed config). To choose the number of spans to mask in training, we use a Poison(1) distribution truncated to a minimum of 1 and maximum of 3. Span lengths are sampled from Uniform(1, 600) i.e. the masked speech can be as long as 12 seconds. At each time step, the embeddings of codes from different codebooks are summed (Wang et al., 2023a), then added by sinusoidal positional encoding (Vaswani et al., 2017), before being fed to the transformer. Text transcripts are phonemized based on the IPA phoneset using the toolkit provided by Bernard and Titeux (2021). Our main VOICECRAFT model has 16 transformers layer with hidden/FFN dimensions of 2048/8192, and 12 attention heads. The output of the last layers are fed to four separate 2-layer MLP modules to get prediction logits. Our Main model has 830M parameters and codebook weight hyperparameters α is set to be (5, 1, 0.5, 0.1). Ablations on model sizes and codebook weights are shown in §5.2.
Training and inference. The training of the Encodec model largely follows the setting in Copet et al. (2023), detailed in §C. To train VOICECRAFT, we used the ScaledAdam optimizer and Eden Scheduler proposed in (Yao et al., 2024) with a base learning rate of 0.05, batch size of 400k frames (i.e. 133.2 minutes), and total training step of 50k with gradient accumulation. The training of the 830M VOICECRAFT model took about 2 weeks on 4 NVIDIA A40 GPUs. More details can be found in §C. We compare the performance of ScaledAdam and AdamW in §A.1. For inference, we use Nucleus sampling (Holtzman et al., 2020) with p = 0.8 and a temperature of 1 for all experiments. Due to the stochasticity of autoregressive generation, via manual inspection we found that while most of the time the model produces natural sounding speech, it sometimes produces excessively long silence or drags out certain sounds.
We found that happens when the codec token generation gets stuck in a repeating loop. To resolve it, we use a simple heuristic: for each input utterance we generate several different output utterances and throw away the longest outputs. Specifically for speech editing, we run inference 10 times with different margin parameters, stepping ϵ up from 0.05 to 0.14 in 0.01 increments. The 4 longest outputs are discarded, and then we randomly select one sample from the remaining 6 outputs. For zero-shot TTS, we reduce the probability of generating the same token in consecutive timesteps in proportion to how many times that token was consecutively generated in the immediately preceding timesteps. In addition, we generate 5 samples with different random seeds, and select the shortest for TTS evaluation. The sample selection process is completely automatic and unsupervised (i.e. no human intervention or ASR scoring).
Baselines. For speech editing, we compare VOICECRAFT with the diffusion-based model FluentSpeech (Jiang et al., 2023b) which is the current open-source SotA model for speech editing. Since the original FluentSpeech model is trained on LibriTTS, for a fair comparison, we took the official GitHub repo and trained the model on Gigaspeech. Please find more details in §C. For zeroshot TTS, we compare our VOICECRAFT with VALL-E (Wang et al., 2023a), XTTS v2 (COQUI, 2023), YourTTS (Casanova et al., 2021), and FluentSpeech. Since the original VALL-E is not open-sourced, we use the code from the popular open-source implementation by Li (2023), and also trained the model on Gigaspeech. XTTS v2 is a popular commercial zero-shot TTS model4 trained on a mixture of publicly available data and webcrawled data, although the exact data sources are unknown. YourTTS is trained on VCTK, LibriTTS, and also French and Portugese corpora.
Metrics. For ablation studies, since ground truth waveform is avaliable, in addition to WER (using Whisper medium.en as the ASR model), we
4The GitHub repo hosting XTTS v2 has 26k stars by Jan 2024.
6
use mel-ceptral distortion (MCD), F0 distance (F0) and energy distance (Energy). These are all objective metrics and their definitions are detailed in §C. For speech editing and zero-shot TTS evaluation, we use a combination of objective and subjective metrics. For the objective metrics, we used WER and speaker similarity (SIM) following prior works(Wang et al., 2023a; Kharitonov et al., 2023). SIM is calculated using the WavLMTDCNN (Chen et al., 2021b). WER and SIM are calculated on all 310 utterances in REALEDIT, and 250 utterances in the zero-shot TTS dataset. For our subjective evaluation, we used the Amazon Mechanical Turk platform to conduct human listening tests. For speech editing, the outputs of our model on all 310 utterances from REALEDIT are evaluated by Turkers in terms of naturalness and intelligibility, and we use a 5-point Likert scale where 1 means poor and 5 means excellent. We also performed side-by-side A/B testing of VOICECRAFT’s output against the original (non-edited) speech, as well as the edited speech produced by FluentSpeech. In both cases, Turkers were asked to determine which utterance sounds more natural. The Turkers can choose either one of the two, or indicate that they are equally natural. Each evaluation received 5 ratings from 5 different Turkers. For zero-shot TTS, we randomly sampled 80 utterances (40 from LibriTTS and 40 from YouTube) from the original evaluation set, and asked Turkers
to rate the naturalness, intelligibility, and speaker similarity of the generated speech to the reference prompt on a 5-point Likert scale. Each evaluation received 10 ratings. For all evaluations except the side-by-side comparison, Mean-Opinion-Score (MOS) with 95% confidence interval are reported. For the side-by-side comparison, we report the percentage of the time one model is preferred over the other. 64 and 59 Turkers participated in speech editing and TTS evaluation respectively. Please refer to §E for instructions and participants description.

heading: 5.2 Ablations
text: In table 3, we see that larger model sizes lead to better performance across all metrics . In addition, we see a bigger gap between the bigger models, indicating the potential of further scaling model (and possibly training data) sizes. For the impact of codebook re-weighting, and we see that weighting earlier codebook heavier leads to better performance on intelligibility related metrics WER and MCD, while worse performance on prosody related metrics F0 and Energy5. We choose weight (5, 1, 0.5, 0.1) in our final 830M model because anecdotally, we found that VOICECRAFT is stronger in prosody compared to intelligibility (similar properties about NCLMs are also found in (Jiang et al., 2023a; Song et al., 2024; Du et al., 2024b))

heading: 5.3 Speech Editing Results
text: Table 4 shows the results of speech editing evaluation in terms of WER, and human preference
5This can be regarded as a probing results that shows the properties of different codebooks in RVQ models. Since this is not the focus of our work, we do not conduct further experiment on this direction.
7
on intelligibility and naturalness. Our VOICECRAFToutperforms FluentSpeech on both intelligibility and naturalness MOS across different sources. Interestingly, FluentSpeech achieves a WER lower than the original recording (4.5 v.s. 5.4), although its intelligibility MOS (3.97) is worse than both VOICECRAFT (4.11) and original recording (4.22). This suggests that ASR model and human judgement diverge on FluentSpeech’s intelligibility. Anecdotally, we observe that FluentSpeech tends to produce dull and sometimes robotic speech 6, and we hypothesize that this type of speech tends be more easily recognized by ASR, but is less intelligible to human ears. We notice this same phenomenon in our results on zero-shot TTS.
Human listeners rate LibriTTS’s naturalness lower than YouTube and Spotify on original speech (results on TTS is consistent with this). This suggests that to better evaluate speech synthesis in general, the research community should consider evaluating on other speech domains besides audiobooks as is commonly done.
Table 5 presents side-by-side utterance naturalness comparison of VOICECRAFT vs. FluentSpeech and VOICECRAFT vs. the original, unedited speech. We observe that VOICECRAFT is preferred over FluentSpeech 56.1% of the time, with an additional 19.7% of the time the two are tied. This means that 75.9% of the time, human listeners’ think VOICECRAFT produces equal or more natural speech than FluentSpeech. Impressively, human listeners judge the edited speech produced by VOICECRAFT to be equally or more natural than the original unedited speech 56.4% of the time. Fig. 4 shows the breakdown of the side-by-side comparisons by edit type and edit span length. We see that compared to the original speech, VOICECRAFT performs consistently well across different edit types, but human listeners think its outputs are slightly less natural with longer edit span(s).
6please refer to our demo page for examples

heading: 5.4 Zero-Shot TTS Results
text: Table 6 shows both objective and subjective evaluation on zero-shot TTS. We observe that VOICECRAFT achieves the best results in both automatic speaker similarity metric SIM, and all human evaluation metrics. In particular, VOICECRAFT is only slightly worse than ground truth in terms of intelligibility MOS (4.23 v.s. 4.39), and speaker similarity MOS (4.34 v.s. 4.44). The gap on naturalness is larger between VOICECRAFT and ground truth (4.17 v.s. 4.48), especially on YouTube utterances, which highlights the challenges of zero-shot TTS on noisy, in-the-wild data. The commercial model XTTS v2 comes second in terms of intelligibility and naturalness, and second to last on speaker similarity MOS. VALL-E achieves the second best on both automatic metric SIM and subjective metric speaker similarity MOS. Similarly to the speech editing results, ground truth YouTube utterances receive higher MOS scores than ground truth LibriTTS utterances in Table 6, which again suggests that we should consider using more diverse data for future speech synthesis model evaluation. Lastly, we again observe that FluentSpeech achieves lower WER than the ground truth, but receives much lower ratings in terms of intelligibility MOS from human listeners, indicating that WER could be misleading in evaluating intelligibility of speech synthesis systems7.

heading: 6 Conclusion
text: We introduce a neural codec language model VOICECRAFT that achieves state-of-the-art performance on speech editing and zero-shot TTS on inthe-wild data. The key lies in an innovative token rearrangement procedure which enables efficient and effective autoregressive codec generation with bidirectional context. In addition, we introduce a first-of-its-kind high quality, challenging, and re-
7we also tried Whisper Large-v3, it gets WER of 4.1 for ground truth, and 2.7 for FluentSpeech.
8
alistic speech editing dataset REALEDIT, which we believe can reliably measure the practicality of speech editing models.

heading: 7 Limitations
text: Given the advancement of made by VOICECRAFT, there are still limitations. First and foremost is the long silence and scratching sound that occasionally occur during generation. Although in this work, we overcome it with sampling multiple utterances and selecting the shorter ones, more elegant and efficient methods are needed. Another important aspect is AI safety, how can we watermark and detect synthesized speech? While watermarking and deepfake detection has attracted increasing attention in the research community, and remarkable progress has been made (Zhang et al., 2020; Yamagishi et al., 2021; Chen et al., 2023; Roman et al., 2024), more advanced models such as VOICECRAFT presents new opportunities and challenges to safety research. To facilitate speech synthesis and AI safety research, we fully open source our codebase and model weights.

heading: 8 Ethical Implications
text: The speech synthesis model VOICECRAFT introduced in this work has both positive and negative implications.
On the positive side, VOICECRAFT holds the promise of significant benefits across several domains. For individuals with speech impairments or who have lost the use of their voice, VOICECRAFT could be transformative, enabling these individuals new ways to communicate with ease and clarity that were previously not possible. Content creators, whether they work in education, video production, or podcasting, could leverage VOICECRAFT to streamline their editing processes, making it easier to produce high-quality content without the need to re-record takes when they contain a small mistake. Furthermore, VOICECRAFT’s ability to handle diverse accents without compromising on quality opens up new possibilities for creating synthetic data. This could, in turn, enhance speech recognition systems, such as Voicebox (Le et al., 2023), by providing them with a richer and more varied dataset to learn from, thereby improving their accuracy and accessibility to users worldwide.
However, the potential negative impacts of VOICECRAFT cannot be overlooked. One of the primary concerns is the model’s potential to exac-
erbate existing biases, particularly those related to ethnicity. If not carefully monitored and corrected, these biases could lead to unequal performance across different groups, perpetuating and possibly even worsening existing disparities. Moreover, the ease with which voices can be cloned raises serious concerns about misuse, including impersonation and fraud. The ability to replicate someone’s voice with only a few seconds of reference audio could be exploited to commit crimes or spread misinformation, posing significant ethical and security challenges. As such, while the benefits of VOICECRAFT are clear and substantial, it is imperative to approach its deployment with caution, ensuring that measures are in place to mitigate these risks and protect against potential misuse.
Despite the concerns regarding impersonation and fraud associated with VOICECRAFT, there are compelling reasons to advocate for its release. Foremost among these is the opportunity it presents for the broader research community and technology developers to better understand and mitigate these negative impacts. By making these methods open source, we can catalyze the development of more robust countermeasures against the misuse of voice cloning technologies. This collaborative approach allows for the rapid identification of vulnerabilities and the exploration of innovative strategies to address them. Moreover, the authors of this work fully committed to advancing the field responsibly. We are actively working on pioneering deepfake detection and watermarking algorithms specifically designed for synthetic speech. By doing so, we not only acknowledge the potential risks associated with our technology but also take concrete steps to ensure its ethical use. This dual approach of open collaboration and dedicated research into safeguarding mechanisms reflects our commitment to fostering a technological ecosystem where the benefits of voice cloning can be realized while minimizing its potential for harm.

heading: 9 Acknowledgements
text: We thank Ziyue Jiang for providing guidance in running inference with and scaling up the FluentSpeech model. We thank students at SALT Lab of UT Austin for helpful discussions. This work is supported in part by the National Science Foundation under Grant No. 2238605.
9

heading: A Additional Experiments
text: A.1 Comparing ScaledAdam and AdamW
The hyperparameters settings of ScaledAdam can be found in table 9. For AdamW (Loshchilov and Hutter, 2017), we tried 3 settings:
• setting1: peak learning rate: 1e-5, batch size: 3.3 min, update steps: 500k
• setting2: peak learning rate: 1e-4, batch size: 33.3 min (same as ScaledAdam), update steps: 80k
• setting3: peak learning rate: 1e-4, batch size: 3.3 min, update steps: 500k
For all settings, we use a linear scheduler which linear ramp up the learning rate to peak in first 8% steps, and linearly decay it afterwards. We use the common default values for other hyperparameters, setting β1 = 0.9, β2 = 0.999, weight-decay = 0.01. All experiments are done on 4 A40 GPUs. Results are shown in table 7.8 We see that ScaledAdam achieves better performance in all metrics while using less compute. However we note that due to limitation in computational resources, we could not exhaust hyperparameter search for AdamW, therefore we do not over-generalize our finding here.
A.2 Breakdown of side-by-side human preference comparison.
The comparison breakdown between VOICECRAFT and FluentSpeech is shown in figure 4. We see that VOICECRAFT outperforms FluentSpeech across the board, especially for substitution edits and when the edit span length is long.
A.3 Spectrograms Comparison
Spectrogram level comparison between FluentSpeech and VOICECRAFTare shown in figure 5, 6, 7 with the edited part marked in dark green rectangle. The three examples have increasing difficulty in terms of accents and recording conditions, in particular, the examples in figure 7 appears to be in low bandwidth transmission. In all 3 examples, we see that VOICECRAFT is able to generated more detailed frequency patterns. The corresponding audio can be found in the demo page.
8We early stopped AdamW setting 2 at step 57k to save the compute, as it has already taken more time than the finished ScaledAdam job while the performance was worse.
13
14
15

heading: B Examples of the Speech Editing Dataset REALEDIT
text: Examples of REALEDIT are shown in table 8.
C Implementational Details
The Encodec model. The Encodec model we use has a stride of 320 samples, which means the codec framerate is 50Hz for recording of sample rate 16kHz. The base dimension is 64, doubling at each of the 5 convolutional layer in the encoder. Following (Copet et al., 2023), we use the opensourced audiocraft repo9 for Encodec model training. 1 second speech segments sampled from Gigaspeech over a total of 160 epochs (320k steps) with a batch size of 240. The model is trained with the Adam (Kingma and Ba, 2014) with base learning rate of 3e-4.
Eden Scheduler (Yao et al., 2024). the scheduler adjust the learning rate αt at step t using the following formula:
αt =αbase · ( t2 + α2step
α2step
)−0.25 ·
· ( e2 + α2epoch
α2epoch
)−0.25 ·
· linear(αstart, twarmup, t). Where αbase base learning rate, t is the step index, e is the epoch index, and αstep and αepoch controls the amount of data the model has seen before significantly reducing the learning rate. linear(αstart, twarmup, t) linearly increase the outcome from αstart to 1 over twarmup steps, and stays at 1. In our experiment, we set
αbase = 0.05, αstep = 3000, αepoch = 4,
αstart = 0.5, twarmup = 500
Since our dataset is quite large, we use pseudoepoch instead of the actual epoch, and 1 pseudoepoch is set to be 3000 training steps. Note that the choice of these hyperparameters are inspired by Yao et al. (2024); Li (2023), and if computation resources permitted, a grid search might find better hyperparameters settings.
Configuration in ablation studies. Configuration of different models are shown in table 9. Note that we use base learning rate 3e-2 for 430M model instead of 5e-2 because the latter gave a NaN error.
9Encodec training doc can be here
Task and Data for ablation studies. The evaluation task is masked reconstruction, where for each utterance, we randomly select a span of length 1 to 15 words to mask, and ask VOICECRAFT to reconstruct the masked speech based on the transcript and unmasked speech. We use a 1000-utterance random subset of the Gigaspeech validation set, which contains YouTube videos and podcast data. We ensure that each utterance in the subset has a WER lower than 15% when decoded by Whisper medium.en (Radford et al., 2022).
Metrics for ablation studies. Since ground truth is available for masked reconstruction evaluation, in addition to WER (measured from Whisper medium.en’s output), we also measure the melcepstral distortion (MCD) (Kubichek, 1993), F0 distance (F0), and energy distance (Energy) WER and MCD are better correlated with intelligibility of the speech, and F0 and Energy are better correlated with prosody similarity between the generated and ground truth. MCD measures the difference of Mel Frequency Cepstrum Coefficients (MFCC) between generated and ground truth, defined as
MCD = 10
ln 10 √√√√1 2 L∑
i=1
(mgi −mri )2
where L is the order of MFCC, which we set to be 13. mgi is the ith MFCC of ground truth recording and mri is the ith MFCC of the generated. We use pymcd package 10 for calculating MCD. For F0 estimation, we use the pYIN (Mauch and Dixon, 2014) algorithm implemented in librosa (McFee et al., 2015) with minimal frequency 80hz and maximal frequency 600hz. For energy calculation, we use the root mean square of magnitude of spectrogram, which is extracted using short time Fourier transform with window length of 640, hop size of 160. Note that since generated speech might have a different length compared to ground truth, dynamic time wrapping is first applied to time aligned the extracted MFCC/F0/energy before calculating their euclidean distances. For each model in the ablation study, we use 3 different random seeds and report the averaged results.
Scaling FluentSpeech. The original FluentSpeech (Jiang et al., 2023b) is trained on LibriTTS, and we made our best effort in scaling it for a fair comparison. Taking guidance from the authors of FluentSpeech. We scale the batch size
10https://github.com/chenqi008/pymcd
16
from 16 utterances to 256 utterances. Diffusion base hidden dimension from 320 to 1024, residual layers from 20 layers to 30 layers, residual channels from 256 to 512. The final model contains 330M parameters, which is roughly the same as the Voicebox model (Le et al., 2023). The model was trained on Gigaspeech training set on 1 A40 GPU for 626k steps which took 10 days. The HiFi-GAN vocoder is also retrained on Gigaspeech training set for 400k steps using hyperparameters used on Voicebox (Le et al., 2023) (they also use Hifi-GAN as vocoder to decode to 16kHz speech)
Baselines for zero-shot TTS. For zero-shot TTS, we compare our VOICECRAFT with VALLE (Wang et al., 2023a), XTTS v2 (COQUI, 2023), YourTTS (Casanova et al., 2021), and FluentSpeech. Since the original VALL-E is not open-sourced, we use the code from the popular open-source implementation by Li (2023), and also trained the model on Gigaspeech. Both the AR and NAR model are trained for 50k steps using the ScaledAdam optimizer and Eden scheduler, same as our VOICECRAFT. The commercial model XTTS v2 is composed of three modules, VQ-VAE (van den Oord et al., 2017) for speech tokenization, a GPT-2 (Radford et al., 2019) model for speech token modeling and a customized HiFiGAN (Kong et al., 2020) model for token to waveform generation. XTTS v2 is trained on a mixture of publicly available data and web-crawled data, but the exact data sources are unknown. YourTTS is a zero-shot TTS model built upon the adversarial VAE model VITS (Kim et al., 2021), with novel zero-shot multi-speaker and multilingual training. The model is trained on VCTK, LibriTTS, and also French and Portugese corpora. The FluentSpeech model we used for TTS is the same as in speech editing, as the model can be configured to do zeroshot TTS similar to Voicebox (Le et al., 2023).
Licenses of the speech corpora. Licenses: LibriTTS: CC BY 4.0; Gigaspeech: Apache-2.0; Spotify Podcast dataset: CC BY 4.0.

heading: D The Conditional Independence Assumption
text: To better explain the rational behind the conditional independent assumption in equation 3, we go back to sequence Y produced by causal masking. The assumption we are making for equation 3 to hold is equivalent to the assumption that given W and Hs,t, Ys,t,k is independent of I (1) s,t,k and I (2) s,t,k defined as
I (1) s,t,k ≜ (Ys,t+k−1,1, Ys,t+k−2,2, · · · , Ys,t+1,k−1) I (2) s,t,k ≜ (Ys,t−1,k+1, Ys,t−2,k+2, · · · , Ys,t−K+k,K)
We argue that this assumption is mild, because 1) I(1)s,t,k are tokens from timestep after t and therefore should have less impact on the distribution of Yt,k given past tokens Hs,t (Hs,t might also contain also future tokens in physical time if Zs,t is in the masked spans); 2) although I(2)s,t,k are tokens from timestep before t, they are from codebooks that are later than codebook k in the residual quantization chain, meaning that they model the residual left by codebook k (at the corresponding timesteps). Given the fact that {Ys,t−1,k, Ys,t−2,k+1, · · · , Ys,t−K+k,K−1} ⊂ Hs,t
11, meaning that the “fitted parts” are given, and therefore the “unfitted parts” (which is the residual) should have miner impact on the distribution of Ys,t,k. Empirically, MusicGen shows that a codec language model trained with the Delay Pattern enjoys the efficiency of the naive parallel pattern, while achieving similar modeling performance as completely flattened sequence.
E Instructions for human listening test
Screenshots of instructions for the human listening test we used on Amazon Mechanical Turk is shown in figure 8 (speech editing - intelligibility), figure 9(speech editing - naturalness), figure 10 (speech editing - side-by-side comparison), figure 11 (zero-shot TTS - intelligibility), figure 12
11A weaker condition holds for the first K tokens in unmasked spans (which accounts for at most 0.08s of speech for our models), but we omit the discussion here for simplicity
18
(zero-shot TTS - speaker similarity), figure 13 (zero-shot TTS - naturalness). For speech editing evaluation, 64 Turkers participated and we paid 474.3 USD in total; for zero-shot TTS evaluation, 59 Turkers participated and we paid 457.6 USD. We only allow Turkers who are resident of the U.S. to do the tasks, and the goal is to increase the probability of Turkers being native English speakers. We acknowledge that this is a perfect approach and might need to bias in judgement, but since Amazon Mechanical Turk doesn’t allow selection on native language, this is the best approach we could think of as a proxy to constraining the native language.
19
20
21

heading: Future Work
text: The assumption we are making for equation 3 to hold is equivalent to the assumption that given W and Hs,t, Ys,t,k is independent of I (1) s,t,k and I (2) s,t,k defined as
I (1) s,t,k ≜ (Ys,t+k−1,1, Ys,t+k−2,2, · · · , Ys,t+1,k−1) I (2) s,t,k ≜ (Ys,t−1,k+1, Ys,t−2,k+2, · · · , Ys,t−K+k,K)
We argue that this assumption is mild, because 1) I(1)s,t,k are tokens from timestep after t and therefore should have less impact on the distribution of Yt,k given past tokens Hs,t (Hs,t might also contain also future tokens in physical time if Zs,t is in the masked spans); 2) although I(2)s,t,k are tokens from timestep before t, they are from codebooks that are later than codebook k in the residual quantization chain, meaning that they model the residual left by codebook k (at the corresponding timesteps). Given the fact that {Ys,t−1,k, Ys,t−2,k+1, · · · , Ys,t−K+k,K−1} ⊂ Hs,t
11, meaning that the “fitted parts” are given, and therefore the “unfitted parts” (which is the residual) should have miner impact on the distribution of Ys,t,k. Empirically, MusicGen shows that a codec language model trained with the Delay Pattern enjoys the efficiency of the naive parallel pattern, while achieving similar modeling performance as completely flattened sequence. E Instructions for human listening test
Screenshots of instructions for the human listening test we used on Amazon Mechanical Turk is shown in figure 8 (speech editing - intelligibility), figure 9(speech editing - naturalness), figure 10 (speech editing - side-by-side comparison), figure 11 (zero-shot TTS - intelligibility), figure 12
11A weaker condition holds for the first K tokens in unmasked spans (which accounts for at most 0