What Is a Mel Spectrogram?

Flat illustration of a mel spectrogram concept: a grid of time-frequency tiles on deep navy with an amber energy streak flowing left to right and a stack of triangle filter shapes along the left edge

A mel spectrogram is an ordinary spectrogram (the picture our free Spectrogram tool draws) with its frequency axis warped onto the mel scale, a perceptual pitch scale, so it spends more of its rows on the low and middle frequencies where hearing is precise and squeezes the highs into a few broad bands. Time still runs left to right and brightness still means energy. Only the vertical axis changes.

If the underlying picture is new to you, start with what a spectrogram is. This post answers the narrower question: what is a mel spectrogram, how is one made, and why do so many speech and music AI models take one as input?

The mel scale: pitch as you hear it

The mel scale comes from a 1937 study by Stanley Smith Stevens, John Volkmann and Edwin Newman, who asked listeners to judge when one tone sounded half or twice as high as another. The name comes from melody. As an anchor, they defined a 1,000 Hz tone, played 40 dB above the listener's threshold of hearing, as 1,000 mels.

Below roughly 1 kHz the scale is close to linear, so each extra 100 Hz adds about the same number of mels. Above that it bends toward logarithmic, so you need ever larger jumps in hertz for the same perceived step. Going from 100 Hz to 200 Hz is an obvious move; going from 10,000 Hz to 10,100 Hz is barely noticeable. Audio frequencies explains the hertz side of this.

There's no single official formula. The most widely quoted, popularised by Douglas O'Shaughnessy in 1987, is:

m = 2595 · log10(1 + f / 700)

where f is frequency in hertz and m is mels. Other variants exist, including Malcolm Slaney's (linear below 1 kHz, logarithmic above), which is the default in the librosa Python library. They don't agree on exact values, so two tools can produce slightly different mel spectrograms of the same clip. Donald Greenwood, a student of Stevens who worked on mel-scale experiments in the 1950s, later argued the scale was skewed by experimental bias, so treat the mel scale as a useful engineering convention rather than a precise law of hearing.

How a mel spectrogram is made

  1. Short-time Fourier transform (STFT). The audio is chopped into short, overlapping windows, and an FFT measures how much of each frequency every window contains. This is the plain spectrogram, with evenly spaced bins in hertz.
  2. Power spectrum. Each bin's magnitude is squared to give energy. Phase, the timing information of each frequency, is dropped here.
  3. Mel filter bank. A set of overlapping triangular filters is spaced evenly in mels across the frequency axis: narrow triangles at the bottom covering a few bins each, wide triangles at the top that may cover dozens. Each filter sums the energy under it into one number.
  4. Fewer, perceptual bands. Instead of hundreds or thousands of linear bins, you end up with somewhere around 80 to 128 mel bands per time step.

Those triangles are why a mel spectrogram keeps detail in the bass and mids, where one bin can matter, and averages the highs, where small differences in hertz barely register.

What makes it a log-mel spectrogram

One more step is almost always added: taking the logarithm of each band's energy, usually in decibels. Raw energy spans an enormous range, and the log compresses it so quiet and loud details both show up, much like the dynamic range setting in a spectrogram viewer. The result is a log-mel spectrogram, and when papers and model cards say "mel spectrogram" this is usually what they mean.

Mel spectrogram vs spectrogram (linear and log)

The mel spectrogram vs spectrogram question comes down to how each one divides the frequency axis.

View How frequency is spaced What it looks like Best for
Linear spectrogram Equal steps in hertz Highs dominate; bass squeezed into a strip at the bottom Codec cutoffs, high-frequency detail, harmonic spacing
Log spectrogram Equal height per octave Bass and mids get room, like a piano keyboard Reading music and voices by eye
Mel spectrogram Equal steps in mels (roughly linear low, log high) A fixed number of bands; fine detail averaged away Input features for machine learning

Linear and log are the same full-resolution data drawn on different axes. A mel spectrogram goes further and discards information by merging bins into bands, so it's smaller and blurrier on purpose.

For reading music or diagnosing a recording yourself, the logarithmic view in our Spectrogram tool is the closest musical cousin, and how to read a spectrogram shows what to look for. The mel spectrogram is mainly a format for machines.

Why speech and music AI models use it

It's compact. Fewer numbers per frame means smaller models and faster training. The Tacotron 2 text-to-speech paper tested this: conditioning its WaveNet vocoder on 80-dimensional mel spectrograms performed about as well as conditioning it on 1,025-dimensional linear spectrograms.

It matches what matters to hearing. More resolution goes to the frequencies listeners are most sensitive to.

It smooths fine detail. Wide high bands blur tiny variations, which suits tasks like speech recognition that care more about what is said than about exact frequencies.

Some well-known mel-spectrogram users:

  • OpenAI's Whisper resamples audio to 16 kHz and computes an 80-channel log-mel spectrogram with 25 ms windows and a 10 ms stride. The large-v3 model moved to 128 mel bins.
  • Tacotron 2 predicts 80-channel mel spectrograms from text, and a WaveNet vocoder turns them into audio.
  • HiFi-GAN is a vocoder that does that last step, generating a waveform from a mel spectrogram.

MFCCs (mel-frequency cepstral coefficients), a classic feature in older speech systems, go one step further: apply a discrete cosine transform (DCT) to each frame of the log-mel spectrogram and keep a few coefficients that summarise its spectral shape.

Why vocal removers don't use one

A mel spectrogram is a one-way trip. Merging bins discards frequency detail, and the power step discards phase. There's no exact way back to audio; you need a trained vocoder like HiFi-GAN, or an approximation such as the Griffin-Lim algorithm, to estimate what was lost.

That's fine for speech recognition, where the output is text. Source separation has to output audio that sounds like the original vocal or drum part. So HTDemucs, the model behind our Vocal Remover and Stem Splitter, skips mel features. One branch works on the raw waveform; the other works on a full-resolution, linear-frequency STFT spectrogram. Models in the Hybrid Demucs family work on the complex STFT, which keeps phase instead of throwing it away. That branch is converted back to audio with the inverse STFT, with none of the guesswork a mel spectrogram would need, and the two branches are summed. How AI vocal removal works explains the masking idea behind it. Both tools run the model in your browser, so your audio never leaves your device; the model file downloads to you on first use.

Our Noise Reducer's Voice mode is a related case. It uses GTCRN, a small speech enhancement model that does group frequencies into perceptual bands, but with ERB bands (equivalent rectangular bandwidth, based on the ear's auditory filters) rather than mel. How AI noise reduction works covers it.

Seeing it for yourself

Our tool doesn't draw mel spectrograms, but it shows the plain spectrogram one is built from. Load a song or voice memo into the Spectrogram and flip the frequency scale between Logarithmic and Linear. On Linear, bass and voice fundamentals crowd into a thin strip at the bottom; on Logarithmic they spread out and the top compresses. A mel spectrogram squeezes the top further still, then merges everything into a fixed set of bands. For more audio explainers, browse the explainers hub.

Frequently asked questions

What is the difference between a spectrogram and a mel spectrogram? A regular spectrogram shows frequency in evenly spaced hertz bins, often hundreds or thousands per time step. A mel spectrogram groups that data into a smaller number of bands spaced along the mel scale, a perceptual pitch scale. That gives more resolution to low and middle frequencies, where hearing is precise, and less to the highs. It's more compact but loses detail, which is why it's mostly used as input for AI models.

What is a log-mel spectrogram? A log-mel spectrogram is a mel spectrogram whose band energies have been converted to a logarithmic scale, usually decibels. Raw energy values cover a huge range, so taking the log compresses them and lets quiet and loud details both register. This is the version most speech and music AI models actually use, including OpenAI's Whisper, so in a machine learning context mel spectrogram usually means the log-mel form.

How many mel bands should I use? There's no fixed rule, but two numbers come up most. Speech models often use 80 mel bands, including Tacotron 2 and the original Whisper models. 128 is another common choice: it's the default in the librosa audio library and the setting used by Whisper large-v3. More bands keep more frequency detail at the cost of larger inputs, so the right number depends on the task and the model.

Can you turn a mel spectrogram back into audio? Not exactly. Building a mel spectrogram throws away phase information and merges many frequency bins into a few bands, so the original waveform can't be perfectly recovered. To get audio back, systems use a vocoder, a neural network such as HiFi-GAN trained to generate a waveform from a mel spectrogram, or an approximation like the Griffin-Lim algorithm, which estimates the missing phase.