TL;DR
Automatic speech recognition (ASR) is the task of turning a recording of someone talking into written text. The system cuts the audio into short time slices, turns each slice into numbers, and predicts the letters or words that were said. Modern systems are neural networks trained on many hours of recordings that come with their transcripts.
Builds on: Time-Frequency Representation, Recurrent Neural Network, Connectionist Temporal Classification (CTC), Edit Distance · Leads to: speech assistants, captioning and dictation tools, and the speech front ends of multimodal language models
Where it's used
Phone dictation and voice assistants. When you dictate a message, the phone converts the audio to text on the device or in a data centre, then the text is handled like any typed input. The system has to work with many accents, background noise and fast speech, all within a fraction of a second of delay.
Automatic captions. Video platforms generate captions for uploaded videos with ASR. The captions are imperfect, so the system also has to decide where sentences end and how to write names; models that predict likely word sequences help with this, see Language Model. Captioning is a good test of accuracy, because readers notice every wrong word.
Call centres and meeting notes. Companies transcribe calls to search them, count topics and check compliance. Here the recordings are noisy and two people often talk at once, so the error rate on real calls is usually higher than on clean studio speech. Teams that compare ASR systems report word error rate on their own call recordings, not on benchmark sets.
How it works
Take a tiny clip and follow it through the system. The example uses round numbers; a real system uses the same steps with more and larger numbers.
- Record the sound as numbers. A microphone turns air pressure into a waveform: a list of samples, one per tick of the clock. At 16,000 samples per second, a one-second clip is a list of 16,000 numbers. Check: a 2-second clip has 32,000 samples.
- Cut the waveform into short overlapping frames. Take a window of 25 milliseconds and slide it forward by 10 milliseconds each time. Each window becomes one frame. Check: a 1-second clip gives about 100 frames, one every 10 milliseconds.
- Turn each frame into a spectrum. A short-time Fourier transform measures how strong each frequency is inside the window. Stacking the frames side by side gives a Time-Frequency Representation, a picture called a spectrogram with time across and frequency up. Vowels show as bands of energy at particular frequencies, and that is what lets the network hear them.
- Read the frames in order. A network reads the spectrogram one frame at a time, keeping a memory of what came before. A Recurrent Neural Network does this directly. Modern systems use a Transformer that looks at all frames at once. Either way, the output for each frame depends on the frames around it, so a short sound can be read in context.
- Output one symbol per frame. For each frame, the network produces a score for every symbol in its alphabet. The alphabet is 26 letters, a space and a special blank symbol. A Softmax turns any list of scores into positive numbers that add to one, so each frame ends up with a probability for each symbol. The blank means "nothing new in this frame".
- Collapse the frames into text. The network produces one symbol per frame, so a word stretched over 30 frames gives 30 symbols. Connectionist Temporal Classification (CTC) (CTC) removes the repeats and then removes the blanks. Two letters that really are doubled must be split by a blank, which is why "hello" needs a blank between the two l's.
- Score the transcript against the truth. Compare the output with a reference transcript using Edit Distance: count the insertions, deletions and substitutions needed to turn one into the other, then divide by the number of words in the reference. This is the word error rate, the usual score for ASR.
flowchart LR A[waveform samples] --> B[frames every 10 ms] B --> C[spectrogram] C --> D[network reads frames] D --> E[one symbol per frame, with blanks] E --> F[CTC collapse to text]
The network is trained by gradient descent on pairs of audio and transcript. The loss compares the probabilities the network gives to the correct transcript, summed over every way the frames could line up with its letters. This is what CTC makes possible without someone marking the letter boundaries by hand.
The math
Let the waveform be and the spectrogram frames , where is the number of frames. Let the network output, for each frame and each symbol in the alphabet (which includes the blank), a probability . The probabilities for one frame sum to one.
Step 5 in symbols: the frame probabilities
The network gives a distribution over the alphabet for each frame. Writing for its raw scores, the Softmax is
Each lies between 0 and 1, and the probabilities over add to 1.
Step 6 in symbols: alignments and collapse
An alignment is a choice of one symbol per frame, so a path . Its probability, if the frames are treated as independent given the input, is . The collapse map removes repeated symbols and then blanks. For example , where is the blank. The probability of a transcript is the sum over every path that collapses to it:
CTC computes this sum with dynamic programming, so it does not list every path.
Step 7 in symbols: word error rate
If the reference has words and the best alignment of hypothesis to reference needs substitutions, deletions and insertions, the word error rate is
A WER of 0.1 means about one word in ten is wrong. It can exceed 1 when the output has many insertions.
Worked examples
Reference: "the cat sat". Hypothesis: "the cat sat down".
- The reference has words.
- The hypothesis adds one word, "down", at the end. That is one insertion, so , with and .
- The word error rate is , about 0.33.
Interpretation: one extra word in a three-word reference gives a WER of one third. Short references make WER jumpy, so a score on a few words says little.
The network outputs one symbol per frame. Here are 9 frames, with the blank written as -:
- Merge runs of the same symbol: . The two 's became one, and the two 's became one.
- Remove the blanks: .
- Read the result as text: "hello".
Interpretation: the blank between the two 's is what keeps them as a double letter. Without it, step 1 would merge them into a single , and the output would read "helo".
A video call produces a 10-second clip at 16,000 samples per second. The system uses a 10-millisecond hop and a 28-symbol output alphabet: 26 letters, a space and a blank.
- The clip has samples.
- One frame every 10 milliseconds gives frames.
- Each frame gets 28 probabilities, so the network produces numbers for the clip.
- Each frame's 28 probabilities add to 1, so the network makes 1000 separate choices. CTC then collapses them into text. A spoken word that lasts 0.3 seconds covers 30 frames.
Try it: how many frames does a 4-second clip at a 10-millisecond hop produce? Answer: frames.
Common mistakes and tradeoffs
It is tempting to think that ASR is "matching the sound of each word in a dictionary". In fact modern systems never see a dictionary of words; they output letters, one symbol per frame, and CTC or a decoder such as Beam Search assembles the text. This is why a system can spell a name it has never seen as a whole word.
It is tempting to think that a low word error rate on a benchmark means a low rate on your audio. In fact error rates rise with noise, accents, overlapping speakers and domain words such as drug names. Measure on recordings like the ones you will use.
It is tempting to think that the blank is an error token. In fact the blank is what lets the network say nothing for a frame, and it is the only way to write a double letter. Without it, CTC cannot represent "hello".
Tradeoffs. CTC is simple and fast, and it does not need a separate alignment step, but each frame is labeled on its own, so the output has no built-in way to model whole-sentence structure. Encoder-decoder models with Attention Mechanism read the whole input and write text autoregressively, which handles context well at a higher cost in time. Many systems add a Language Model to pick between candidate transcripts, because a word that sounds right may not fit the sentence. Use CTC when latency and simplicity matter; use an encoder-decoder with a strong language prior when accuracy on long, varied speech matters more.
History
Early machines recognised spoken digits. In the early 1950s, Bell Labs built a system that recognised a single speaker saying the digits, and IBM's early-1960s "Shoebox" recognised 16 spoken words. These systems matched sound patterns to stored templates, and they worked only for one speaker.
From the 1970s to the 2000s the standard approach was the Hidden Markov Model. It modelled speech as a hidden chain of sound states, with separate parts for sounds, pronunciations and language. It worked, but each part was built and tuned by hand.
Around 2009 to 2012, neural networks replaced the sound models in these systems and cut error rates sharply, which drew wide attention. Connectionist temporal classification in 2006 had already offered a way to train a network on unaligned audio and text, and later work on large recurrent and transformer networks made it the basis of end-to-end systems. Systems such as Whisper, released in 2022, train one network on large collections of audio with transcripts. Whisper's training data covers hundreds of thousands of hours of audio.
Recap
- Speech is a waveform, cut into 10-millisecond frames and turned into a Time-Frequency Representation.
- A network reads the frames in order, using a Recurrent Neural Network or a Transformer, and outputs a Softmax over letters and a blank for each frame.
- Connectionist Temporal Classification (CTC) sums over all alignments and collapses repeats and blanks to get the text.
- The score is the word error rate, computed with Edit Distance.
Read next: Connectionist Temporal Classification (CTC) for the training objective, then Attention Mechanism for the encoder-decoder alternative. Robust Speech Recognition via Large-Scale Weak Supervision applies these ideas at very large scale.
Check yourself
QuestionWhat does the blank symbol do in a CTC output?Show answer
QuestionA reference has 8 words. A hypothesis has 1 substitution, 1 deletion and 2 insertions compared with it. What is the word error rate?Show answer
QuestionA system collapses the frame sequence with as the blank. What text does it produce?Show answer
QuestionWhy does a clip at 16,000 samples per second with a 10-millisecond hop produce 100 frames per second, not 16,000?Show answer
QuestionA company's call-centre transcripts have a much higher error rate than the vendor's benchmark. Give two reasons why this is expected, and one thing it suggests about how to evaluate.Show answer
Sources
- Wikipedia, "Speech recognition": https://en.wikipedia.org/wiki/Speech_recognition
- Wikipedia, "Connectionist temporal classification": https://en.wikipedia.org/wiki/Connectionist_temporal_classification
- Radford et al., Robust Speech Recognition via Large-Scale Weak Supervision, arXiv:2212.04356: https://arxiv.org/abs/2212.04356