Sub topic 1
What Automatic Speech Recognition Does
Prerequisites
This chapter assumes that you know basic Python, understand common audio formats such as WAV and MP3, and have a general idea of what a neural network does. You should also know how to install a Python package with pip.
The goal of automatic speech recognition
Automatic speech recognition (ASR) is the process of converting spoken audio into written text. A recording is the input. A sequence of words is the output.
For example, an ASR system might receive a recording of someone saying:
> Please send the report before Friday.
It produces text such as:
Please send the report before Friday.
ASR is useful for subtitles, meeting notes, voice search, accessibility tools, call analysis, and searchable audio archives. The system does not receive the meaning of a sentence directly. It must infer words from sound, even when speakers pause, pronounce words differently, or speak over background noise.
The working model
A recording is stored as a waveform. A waveform is a sequence of numbers that records air-pressure changes over time. A neural ASR model does not usually process the entire raw waveform at once. It first converts the audio into a representation that exposes how sound energy changes across time and frequency.
Whisper uses a log-Mel spectrogram for this representation. A spectrogram shows which frequencies are strong at each moment. The Mel scale groups frequencies in a way that roughly follows human hearing. Taking the logarithm makes large differences in sound energy easier for the model to handle.
The model then predicts text tokens. A token is a small piece of text, such as a word, part of a word, punctuation, or a special control symbol. The model predicts one token after another while considering the audio and the tokens it has already produced.
| Stage | Input | Output |
|---|---|---|
| Audio preparation | Audio waveform | Log-Mel spectrogram |
| Audio understanding | Spectrogram | Internal representation of speech |
| Text generation | Audio representation and prior tokens | Transcription tokens |
| Text assembly | Tokens | Readable text |
Whisper's role in the pipeline
Whisper is a family of ASR models released by OpenAI. It supports transcription in many languages. It can also translate non-English speech into English, although translation and transcription are different tasks.
Internally, Whisper uses an encoder-decoder transformer. The encoder reads the spectrogram and creates a representation of the audio. The decoder generates text tokens from that representation. A transformer is a neural-network architecture that uses attention to relate different parts of its input. Attention helps the model use both nearby sounds and wider context.
Whisper was trained on a large collection of audio and text gathered from the web. Much of this data is weakly supervised, meaning that the text may be an imperfect transcript or a related caption rather than a carefully verified label. This broad training helps Whisper handle many accents, topics, recording conditions, and languages. It also creates failure cases, because the training data contains errors and uneven coverage.
What affects the result
The model must choose text that best fits the audio and its learned language patterns. Clear speech usually produces better text than distant, noisy, or overlapping speech. A strong accent is not automatically a problem, but an accent unfamiliar to the model can increase errors. Domain terms, names, and unusual abbreviations are also common error sources.
Whisper may sometimes produce plausible text when the audio contains silence or noise. This behavior is called hallucination: the model generates text that sounds reasonable but was not spoken. Treat a transcription as a prediction that may require review, especially when accuracy matters.
Exercise
Exercise
What are the two main transformations Whisper performs between an audio file and a transcription?
Show answer
It converts the audio waveform into a log-Mel spectrogram and then uses the spectrogram to generate text tokens, which are assembled into a transcription.