Search

Search papers and lessons

SpecAugment: A Simple Data Augmentation Method for Automatic Speech Recognition

Daniel S. Park, William Chan, Yu Zhang et al. · 2019

Park and colleagues (2019) show that masking blocks of time and frequency in a speech spectrogram, plus a small warp, lets an end-to-end recognizer reach state-of-the-art word error rates without a language model.

On this page

  • Colour = topic mix
  • Discrete math
  • Calculus
  • Neural network basics
  • Linear algebra
  • Probability
  • Architectures
  • ReadReady to readNot yet

TL;DR

SpecAugment is a data augmentation method for speech recognition, published by Daniel Park, William Chan and colleagues at Google in 2019. It works on the spectrogram, the picture of sound over time and frequency that the network reads. It warps the picture slightly, blanks out random bands of frequencies, and blanks out random stretches of time. The network still has to recognize the words, so it cannot rely on any one part of the sound. With this recipe, an end-to-end recognizer beats the previous best hybrid systems on LibriSpeech and Switchboard, even without a language model.

Builds on: Data Augmentation, Listen, Attend and Spell, Attention Mechanism, Connectionist Temporal Classification (CTC) · Leads to: augmentation as a default part of training speech models; the paper's finding that augmentation changes the problem from overfitting to underfitting

Why it mattered

Before this paper, the strongest speech systems were hybrids: a neural network scored sounds, and a separate hand-built system combined those scores into words. The paper showed that a single end-to-end network, trained with SpecAugment and no language model, could beat those hybrids on two standard benchmarks. The method itself costs almost nothing. It needs no extra audio, it runs on the fly during training, and it changes only the input.

The paper also changed how people talk about augmentation in speech. Its discussion section argues that with augmentation the network under-fits its training data, which is the reverse of the usual picture. Its response to that is bigger models and longer schedules, not less training.

History

Speech systems had used augmentation before. The paper's introduction lists speed perturbation, vocal tract length normalization, added noise, simulated rooms and feature drop-outs, each for a particular setting. SpecAugment's contribution was a simple, fixed policy that works directly on the spectrogram, following the masking idea that the paper credits to the Cutout method in computer vision. The paper credits a 2016 end-to-end recognizer, Listen, Attend and Spell, as the network it trained.

The problem

Speech recognition maps a long audio signal to a short text. The network has to learn which sounds mean which words, and it has to do so from a limited amount of labeled audio. The paper's introduction says these networks "tend to overfit easily and require large amounts of training data." Hand-collected audio is expensive, so the question is how to make the same audio go further.

Image augmentation works by flipping and cropping pictures, which keeps the label. Applying those ideas to audio is less direct, because a flipped spectrogram is not a plausible sound. The paper's aim is an augmentation that acts on the spectrogram as if it were an image, while respecting the things a recognizer must be robust to: small shifts in timing, loss of part of the frequency range, and short gaps in speech.

How it works

The input is a log mel spectrogram: a grid with time along one axis and a set of frequency bands (mel channels) along the other, where each cell holds the log energy of that band at that time. The network reads this grid, and the augmentation edits it before each training step. Here is one tiny spectrogram traced through, with 10 time steps and 6 mel channels.

  1. Take a clean input. Start with the 10 by 6 grid of log energies. Its values are normalized to zero mean, so a masked cell set to 0 is the same as a cell set to the average.
  2. Warp it in time. Pick a point near the middle of the time axis and move it left or right by a random distance up to the warp parameter W. The surrounding grid stretches to follow. Check: the grid still has 10 time steps, but the content in the middle has moved a few steps.
  3. Mask a band of frequencies. Draw a width f from 0 up to the frequency parameter F, here 2. Draw a start f0 so the band fits inside the 6 channels. Suppose f = 2 and f0 = 1. Set channels 1 and 2 to zero. Check: 2 of 6 channels, or one third, are now silent.
  4. Mask a block of time. Draw a width t from 0 up to the time parameter T, capped at p times the number of time steps. Suppose t = 3 and t0 = 4. Set time steps 4, 5 and 6 to zero. Check: 3 of 10 steps are now silent.
  5. Feed the result to the network. The masked grid goes into the encoder, a stack of convolutional and recurrent layers, and the decoder emits word pieces one at a time. A new random warp and masks are drawn for the next example, so the network rarely sees the same masked grid twice.
  6. Decode and score. The decoder's output is searched with beam search (Beam Search). If a language model is added, each next word piece is also scored by that model (shallow fusion, see The math). The transcript is compared with the reference using word error rate, the share of words that were substituted, deleted or inserted.
flowchart LR
  A[Audio] --> B[Log mel spectrogram]
  B --> C[Time warp]
  C --> D[Frequency mask]
  D --> E[Time mask]
  E --> F[LAS encoder: CNN then BiLSTM]
  F --> G[Attention decoder]
  G --> H[Beam search and transcript]

The network described in the paper is Listen, Attend and Spell (Listen, Attend and Spell). It has a two-layer convolutional front end with max-pooling, an encoder of stacked bidirectional Long Short-Term Memory layers, and a two-layer recurrent decoder that uses Attention Mechanism to decide which part of the encoded audio to read. Its output units are word pieces, a vocabulary of 16,000 pieces for LibriSpeech.

0100200300400500020406080100number of time steps τlargest allowed time mask
  • LB, LD: T = 100, p = 1.0
  • SM, SS: T = 70, p = 0.2
The cap on a single time mask. For the strong policies the mask is limited to a fraction of the utterance, so long utterances are not blanked out in one block.

The math

Let the spectrogram have τ time steps and ν mel channels. The three augmentations are defined by a few parameters, listed in the paper's Table 1 as W, F, m_F, T, p and m_T.

Step 1 in symbols: time warp

Treat the spectrogram as an image, with time horizontal and frequency vertical. Pick a point along the horizontal line through the image centre, within the range (W, τ − W). Move it left or right by a distance w drawn uniformly from 0 to W. The paper fixes six anchor points on the border, the four corners and the midpoints of the two vertical edges, and moves the grid points near that anchor so the image is stretched.

Step 2 in symbols: frequency mask

Draw f ∼ Uniform(0, F) and f0 ∼ Uniform(0, ν − f). Set every cell with mel channel k in [f0, f0 + f) to zero. Setting a whole band to zero is the same as setting it to the mean, because the spectrogram is normalized first.

Step 3 in symbols: time mask

Draw t ∼ Uniform(0, min(T, p·τ)) and t0 ∼ Uniform(0, τ − t). Set every cell at time step s in [t0, t0 + t) to zero. The cap p·τ is the paper's upper bound: a time mask cannot be wider than the fraction p of the utterance.

Step 4 in symbols: shallow fusion

To add a language model, the paper picks each next token y* by scoring it with both models:

y* = argmax_y [ log P(y | x) + λ · log P_LM(y) ].

Here P(y | x) is the recognizer's probability of token y given the audio, P_LM(y) is the language model's probability, and λ weighs the two. The paper uses λ = 0.35 for LibriSpeech and a coverage penalty c = 0.05 from earlier work, and notes that for Switchboard the best λ does not transfer between networks.

Worked examples

Example
1. Tiny: a time mask by hand
  1. The spectrogram has τ = 10 time steps. The time mask parameter is T = 5 and p = 1.0.
  2. The cap is min(T, p·τ) = min(5, 10) = 5, so the mask width t is drawn from 0 to 5.
  3. Suppose t = 3. The start must satisfy 0 ≤ t0 < τ − t = 7. Suppose t0 = 4.
  4. The masked steps are [4, 7), which are steps 4, 5 and 6 counting from 0.
  5. Check: 3 steps out of 10 is 30%, and the start 4 is below 7, so the choice was valid.
  6. Interpretation: the network sees a spectrogram with a three-step silent gap in the middle and must still get the words.
Example
2. Standard: a frequency mask with the LB policy
  1. The LB policy has F = 27 and one frequency mask. Take a spectrogram with ν = 80 mel channels.
  2. Draw f = 10. This is within 0 to 27, as required.
  3. Draw f0 = 50. The rule is 0 ≤ f0 < ν − f = 70, and 50 is inside that range.
  4. The masked channels are [50, 60), which are 10 channels.
  5. Check: 10 / 80 = 0.125, so 12.5% of the frequency axis is hidden in this example.
  6. Interpretation: the network loses a band of frequencies that a speaker's voice happens to occupy, and must rely on the other bands. The paper's motivation is exactly this: robustness to partial loss of frequency information.
Example
3. Realistic: a LibriSpeech utterance with the LD policy
  1. The LD policy uses two frequency masks with F = 27, and two time masks with T = 100 and p = 1.0.
  2. Take an utterance with τ = 1000 time steps. This number is illustrative; real lengths vary.
  3. Each time mask width is capped at min(100, 1.0 · 1000) = 100. Suppose the two drawn widths are t = 60 and t = 30.
  4. The total masked time is 60 + 30 = 90 steps, which is 90 / 1000 = 9% of the utterance.
  5. Each mask is placed at a random start, so the two masks may overlap. Overlap only lowers the masked share.
  6. Interpretation: most of the utterance is still visible, so the network can recover the words from context, which is why the paper finds the augmented networks under-fit rather than fail.

Try it: policy SM uses T = 70 and p = 0.2. For an utterance with τ = 200 time steps, what is the largest time mask allowed? Answer: min(70, 0.2 · 200) = min(70, 40) = 40 steps.

Common mistakes and tradeoffs

It is tempting to think SpecAugment is just adding noise. In fact it removes information, in bands and blocks: masked cells are set to the mean, not filled with random values, and the network has to recover the words from what is left.

It is tempting to think a stronger policy is always better. In fact the paper's Table 6 shows that dropping time warping costs little (test-other goes from 10.0 to 10.1 without warp), while dropping frequency masking or time masking costs more (11.0 and 10.9). Time warping has the smallest effect in Table 6, so it is the first candidate to drop under a tight budget.

It is tempting to think augmentation alone is enough. In fact the paper finds the largest gains came from combining augmentation with bigger networks and longer schedules. The training curves show the augmented networks still under-fit, so more capacity and more steps helped.

When to use it: end-to-end recognizers trained on modest amounts of audio, where a cheap, online augmentation is wanted. When not to use it: settings where the spectrogram masks would hide the information a task needs, such as very short commands where a single masked band removes most of the signal. Alternatives include speed perturbation and added noise, which the paper lists as earlier methods, and Label Smoothing, which the paper combines with SpecAugment on Switchboard and finds additive in its table.

Results

The paper reports word error rate (WER), the share of words wrong, so lower is better. Numbers are for test sets as given in the paper.

  • LibriSpeech 960h, LAS-6-1280 (Table 3). Without a language model: LAS 4.1 on test-clean and 12.5 on test-other; LAS with SpecAugment 2.8 and 6.8. With a language model: LAS 3.2 and 9.8; with SpecAugment 2.5 and 5.8. The best prior hybrid system with a language model in the table is 2.97 and 7.50 (Yang et al., 2018); the paper's abstract cites 7.5% on test-other for the previous state-of-the-art hybrid.
  • LibriSpeech ablation grid (Table 2). LAS-4-1024 with schedule B: no augmentation gives 4.7 and 13.4 without a language model; policy LD gives 3.6 and 9.2. Schedule D with policy LD gives 3.4 and 8.3. The largest network, LAS-6-1280, with schedule D and policy LD gives 3.2 and 7.7.
  • Switchboard 300h, LAS-4-1024 (Table 4). Without a language model, on the Switchboard and CallHome subsets: no augmentation and no label smoothing gives 12.1 and 22.6; policy SM gives 9.5 and 18.8; policy SS gives 9.7 and 18.2. Adding label smoothing lowers each entry further, to 8.5 and 16.1 for SM. The paper says the two effects are additive for this corpus.
  • Switchboard 300h, LAS-6-1280 (Table 5). Without a language model: LAS 11.2 and 21.6, LAS with SpecAugment (SM) 7.2 and 14.6. With a language model: SpecAugment (SM) reaches 6.8 and 14.1, against 8.3 and 17.3 for the previous best hybrid with a language model (Zeyer et al., 2018).
  • Time warp, time mask and frequency mask ablation (Table 6, test-other and test, no LM). Full policy 10.0 and 3.7; without warp 10.1 and 3.8; without frequency masks 11.0 and 4.0; without time masks 10.9 and 4.1.

The limits are the paper's own. The experiments use a few hand-crafted policies rather than a learned search. Results are for one network family, LAS, and for two corpora in English. Label smoothing interacts with augmentation: the paper reports instability on LibriSpeech when both are on as the learning rate decays, and so it turns label smoothing off partway through that schedule.

Reading guide

The paper is compact. Read it in this order.

Check yourself

QuestionRecall: name the three augmentations in SpecAugment, and say which one changes the time axis without removing anything.Show answer

The three augmentations are time warping, frequency masking and time masking. Time warping moves a point in the spectrogram and stretches its neighbourhood, so it changes the layout of the time axis without setting any cell to zero. Frequency masking and time masking both set blocks of cells to zero.

QuestionComputation: a spectrogram has ν = 40 mel channels. A frequency mask draws f = 8 and f0 = 30. Which channels are masked, and is the draw valid?Show answer

The masked channels are [30, 38), which are channels 30 through 37. The draw is valid only if f0 < ν − f. Here ν − f = 40 − 8 = 32, and 30 < 32, so the draw is valid.

QuestionWhy: the paper argues that augmentation makes the network under-fit rather than over-fit. Why would masking the input make training harder, and why might that be good?Show answer

Masking hides parts of the input on every training step, so the network cannot memorize the exact training spectrograms. Its loss on the augmented training set stays high, which is the under-fitting the paper observes. That is useful because a network that cannot memorize the training audio has to learn patterns that generalize. The paper then makes the network larger and trains it longer, which is the usual remedy for under-fitting.

QuestionApplied: a team has 50 hours of recordings of one speaker reading one book and sees a large gap between training and test errors. They consider SpecAugment. Would you recommend it, and what would you check first?Show answer

Yes, it is a reasonable first step. The gap is the over-fitting the paper describes, and SpecAugment needs no extra audio. Before committing, check the policy parameters against utterance length, because a time mask capped by p·τ can be a large share of a short clip, and the paper's strong policies use p = 0.2. Also watch whether the recognizer still learns: if training error stays high, the policy may be too strong for 50 hours of data.

Sources

  • Park, D. S., Chan, W., Zhang, Y., Chiu, C.-C., Zoph, B., Cubuk, E. D., and Le, Q. V. (2019). SpecAugment: A Simple Data Augmentation Method for Automatic Speech Recognition. arXiv:1904.08779. https://arxiv.org/abs/1904.08779
  • Chan, W., Jaitly, N., Le, Q. V., and Vinyals, O. (2015). Listen, Attend and Spell. arXiv:1508.01211. https://arxiv.org/abs/1508.01211

Read the full paper

Daniel S. Park, William Chan, Yu Zhang et al., 2019. arXiv:1904.08779