Sub topic 1
What automatic speech recognition does
Prerequisites
This chapter assumes you can write basic Python and install packages with pip. You should know that audio is stored in files such as WAV or MP3, and you should have a rough idea of what a neural network does.
Automatic speech recognition
Automatic speech recognition (ASR) turns a speech audio signal into text. A recognizer must handle accents, background noise, fast speech, and words it has not seen before. Modern ASR systems are neural networks trained on many hours of paired audio and transcripts.
Accuracy is usually reported as word error rate (WER): the number of substituted, deleted, and inserted words divided by the number of words in the reference transcript. Lower is better.
Preparing audio: 16 kHz mono and log-Mel spectrograms
Whisper expects audio resampled to 16 kHz mono. At 16,000 samples per second, the signal captures frequencies up to 8 kHz, which covers most of the information in speech.
A spectrogram is a grid of frequency energy over time. A log-Mel spectrogram warps the frequency axis to match human pitch perception and log-scales the energy values. The openai-whisper package computes this for you. The encoder receives 80 mel bins per frame for each 30-second window (large-v3 uses 128).
How Whisper works: an encoder-decoder transformer trained on weakly supervised data
Whisper is an encoder-decoder transformer. The encoder reads the log-Mel spectrogram and produces a sequence of audio representations. The decoder writes text tokens one at a time while attending to the encoder output. Special tokens tell the decoder which task to run (transcribe or translate), which language is spoken, and whether to output timestamps.
OpenAI trained Whisper on about 680,000 hours of web audio paired with transcripts. Many transcripts came from other systems and were not checked by people. This is weak supervision: the labels are plentiful but noisy. The trade-off gives broad robustness, and it also explains some failure modes covered later.
Choosing a model size: tiny to large, English-only and multilingual
Whisper comes in five sizes: tiny, base, small, medium, and large. The tiny through medium sizes also have English-only (.en) versions.
| Model | Parameters | Relative speed | Best for |
|---|---|---|---|
| tiny | 39 M | Fastest | Quick drafts, low memory |
| base | 74 M | Fast | Light workloads |
| small | 244 M | Moderate | Good English accuracy on modest hardware |
| medium | 769 M | Slow | Higher accuracy, multilingual work |
| large | 1550 M | Slowest | Highest accuracy across languages |
For English-only audio, a .en model is usually more accurate than the multilingual model of the same size. For other languages, use a multilingual model. When memory or latency is limited, step down one size and measure WER on your own audio.
Exercise
You need to transcribe English podcast episodes on a laptop with about 2 GB of free GPU memory. Which model would you choose, and why?
Show answer
small.en. It is English-only, so it is more accurate than the multilingual small model for English, and its size fits within about 2 GB. The medium and large models need more memory than the laptop has.