Spectrogram
A picture of sound: time runs left to right, pitch runs bottom to top, and brightness shows how loud each frequency is at each moment.
Also Mel spectrogram · log-Mel · STFT · short-time Fourier transform · frequency
Like sheet music drawn by the sound itself. Low notes appear near the bottom, high notes near the top, and loud notes glow brightly.
Where it fits
+All relationships as a list
Try it
How it works
Any sound can be described as a mix of pure tones (sine waves) at different frequencies. The Fourier transform finds that mix. But speech and music change constantly, so we compute it on short slices instead:
- Cut the waveform into short, overlapping windows (often about 25 milliseconds).
- Compute the frequency content of each window.
- Stack the results side by side.
The result is a grid: time across, frequency up, and loudness as color. A whistle is a thin line, a chord is several parallel lines, a drum hit is a vertical smear, and noise is a gray fog.
Two tweaks make spectrograms match human hearing. The Mel scale spaces frequencies the way we perceive pitch (we hear the difference between 100 and 200 Hz far more clearly than between 10,000 and 10,100 Hz), and taking the log of the power matches how we perceive loudness. That “log-Mel spectrogram” is what Whisper and most speech recognition models read.
There is a built-in trade-off: longer windows separate frequencies better but blur when things happen; shorter windows do the opposite.
The math
For a signal and window of length , frame with hop :
The spectrogram is , usually shown on a log (decibel) scale.
Everyday use cases
- Case 01
Speech recognition input
Whisper and most speech models read log-Mel spectrograms, not raw audio.
- Case 02
Song identification
Music recognition apps match distinctive peaks in a recording's spectrogram.
- Case 03
Bird and whale research
Biologists spot and classify calls by their shapes in spectrograms.
Strengths, weaknesses and when to use it
Strengths
- Turns sound into an image-like grid that CNNs and Transformers handle well.
- Makes pitch, rhythm and timbre visible.
Weaknesses
- Trade-off between time and frequency detail (window size).
- Discards phase, so turning a spectrogram back into audio needs extra work.
When to use itAs the default first step for almost any audio model.
Check yourself
- Q01
In a spectrogram, what does the vertical axis show?
Show answer
B: Frequency (pitch)
- Q02
What happens if you use a longer analysis window?
Show answer
A: Sharper frequency detail but blurrier timing