TL;DR
The mel scale is a way of measuring pitch in which equal steps sound equally far apart to a listener. It stretches the low end of the frequency axis and squeezes the high end, the way human hearing does: a 100 Hz step from 200 Hz to 300 Hz is a far bigger change to the ear than the same 100 Hz step from 7000 Hz to 7100 Hz. Speech and audio systems use it to decide how to group frequencies before they learn from the sound.
Builds on: Logarithm, Time-Frequency Representation · Leads to: Mel Spectrogram, Automatic Speech Recognition
Where it's used
- Speech recognition. For decades, speech recognizers turned each short slice of audio into a few dozen numbers called mel-frequency cepstral coefficients, computed from energies in mel-spaced bands. The bands are the mel scale's job: they put most of the detail where the ear is sharpest.
- Neural speech models. Modern systems often skip the cepstrum and feed a log-mel spectrogram directly to the network. Whisper, OpenAI's speech recognizer, takes a log-mel spectrogram as its input, so the mel scale sets what the network can see.
- Sound classification. Tools that sort recordings by type, such as birdsong, music genre or a cough versus a siren, often work on mel-spaced energies, because the grouping keeps the features compact (a few dozen numbers per slice) and still close to what a listener hears.
How it works
Take a single pure tone and trace where the mel scale puts it, then see what it does to a set of filters. Each step uses round numbers and one idea.
- Start with a frequency in hertz. A tone at 1000 Hz is one cycle per millisecond. A spectrogram lists energy at many frequencies in hertz, which is the layout we want to change.
- Convert hertz to mel. The conversion is . Check: Hz gives mel. By convention the scale is anchored there.
- Compare steps in hertz and in mel. Going from 500 Hz to 1000 Hz covers 500 Hz, which is about 392 mel. Going from 1000 Hz to 2000 Hz covers 1000 Hz, which is only about 522 mel. Doubling the frequency does not double the mel value, so the high octaves are squeezed. Check: 500 Hz is 607.5 mel and 2000 Hz is 1522 mel, so the two spans are 392.5 and 522.
- Place filters evenly in mel. Pick three filter centers at 0, 1000 and 2000 mel. Convert them back to hertz with the inverse conversion, : they sit at 0 Hz, 1000 Hz and about 3429 Hz. Check: 2000 mel gives about 3429 Hz, and going forward again gives 2000 mel. In hertz, the centers are 1000 Hz apart at the bottom and about 2429 Hz apart at the top.
- Share each tone among the filters. Each filter is a triangle on the mel axis, with weight 1 at its center and falling to 0 one thousand mel away. A 2000 Hz tone is at 1522 mel, so the middle filter gives it weight and the top filter gives it weight . Check: the weights add to 1, so no energy is lost or double-counted.
- Repeat for every slice of audio. Stacking the filter energies over time gives a mel spectrogram. Taking the logarithm of each energy, as many systems do, is the subject of the mel spectrogram lesson.
- mel scale
- linear (mel = Hz)
The math
The mel scale maps a frequency in hertz to a pitch in mel by . Its inverse maps mel back to hertz: . The constants are chosen so that .
Step 2 in symbols: the conversion
For a tone at frequency , the logarithm is base 10, so is the power to which 10 must be raised to give . The argument is always at least 1, so is never negative and is zero at .
Check at 1000 Hz: , , and .
Step 3 in symbols: how fast the scale stretches
The slope of the scale is its derivative:
At the slope is about mel per hertz. At Hz it is about , and at Hz it is about . So each hertz at the top of the band spans about one-twelfth as many mel as each hertz at the bottom. That falling slope is the squeeze in step 3 of the walkthrough.
Steps 4 and 5 in symbols: the filter weights
Filter has its center at mel value , and the filters are spaced mel apart. Its triangular weight for a tone at mel value is
With centers , , and , a tone at receives from the filter at 1000 and from the filter at 2000. Neighboring triangles overlap so that their weights always add to 1 between two centers. The energy in band is the sum of times the energy of each tone.
Where a frequency falls between two bins of a discrete spectrum, the weight is computed by linear interpolation between the bins.
Worked examples
- Write the formula: .
- Put in : .
- Take the base-10 logarithm: .
- Multiply: .
Interpretation: 1000 Hz is 1000 mel. This is the reference point, and any other frequency is judged against it.
Filters are centered at 0, 1000 and 2000 mel, with . Take two tones.
- A 250 Hz tone: mel.
- Weight from the filter at 0 mel: .
- Weight from the filter at 1000 mel: .
- Check: .
- A 3000 Hz tone: mel.
- Weight from the filter at 1000 mel: .
- Weight from the filter at 2000 mel: .
- Check: .
Interpretation: the low tone falls mostly in the lowest band and the high tone mostly in the top band, and the bands never lose any of the tone's energy.
A speech system covers 0 to 8000 Hz with 40 filters spaced evenly in mel.
- The top of the band is mel.
- Forty evenly spaced filters give a spacing of mel.
- The first filter's edge is at Hz, so the lowest band spans about 46 Hz.
- Near the top, the band edges sit at Hz and Hz.
- Try it: how many hertz wide is the top band, from 7469 Hz to 8000 Hz?
Answer: about 530 Hz. The bottom band is about 46 Hz wide and the top band about 530 Hz wide, roughly eleven times wider. The filters follow the ear, not a uniform grid.
Common mistakes and tradeoffs
It is tempting to think the mel scale measures loudness. In fact it measures pitch, the perceived height of a tone. Loudness is a separate perception, tied to sound level, which is usually reported in decibels.
It is tempting to think that a pitch of 2000 mel is twice as high as 1000 mel. The scale was built from listening tests, where listeners judged when intervals sounded equal. It is a convenient fit to those tests, not a ratio scale, and other fits exist, such as the Bark and ERB scales.
It is tempting to think that the mel scale is always the right choice. It is a good choice for speech and general sound classification, where detail at high frequencies matters less than the overall shape. It is a poor choice for tasks that need precise high-frequency detail, such as tracking a harmonic at 6 kHz in music, because its top bands are wide. In those cases a linear frequency axis, as in a plain Fourier transform spectrum, is better. Some modern systems learn their filters from data instead of fixing them to the mel scale, at the cost of needing more training data.
| Frequency axis | Strength | Weakness |
|---|---|---|
| Linear (hertz) | Full detail at every frequency | Wastes detail at high frequencies that the ear cannot separate |
| Mel | Compact, matches hearing for speech | Coarse at high frequencies; fixed in advance |
| Learned filters | Adapts to the task | Needs more data and training |
History
In the 1930s, researchers were trying to measure how the ear maps frequency to pitch. In 1937, Stevens, Volkmann and Newman asked listeners to judge when one tone sounded half as high as another, and fitted a scale to the results, with 1000 mel defined as 1000 Hz. The name comes from "melody". The scale stayed a laboratory curiosity until engineers needed a compact description of speech.
In 1980, Davis and Mermelstein introduced mel-frequency cepstral coefficients for recognizing spoken words. Their features used mel-spaced filters and became the standard front end for speech recognition for decades. When neural networks replaced hand-built pipelines, the mel-spaced energies stayed in use as the network's input, which is why the mel spectrogram remains a common first step.
Recap
- Frequency in hertz is not how the ear hears pitch: the ear is sharper at low frequencies and coarser at high ones.
- The mel formula converts hertz to mel, with 1000 Hz mapped to 1000 mel.
- Filters spaced evenly in mel are narrow in hertz at the bottom and wide at the top.
- A tone between two filter centers splits its energy between them with triangular weights that sum to 1.
- Read next: Mel Spectrogram for the time-frequency picture built from these bands, and Automatic Speech Recognition for the main system that uses them.
Check yourself
QuestionWhat is the pitch in mel of a tone at 1000 Hz?Show answer
1000 mel. The scale is defined so that 1000 Hz maps to 1000 mel: .
QuestionCompute the pitch in mel of a 4000 Hz tone.Show answer
About 2146 mel. Compute , then , then . Note that 4000 Hz is four times 1000 Hz but only about twice 1000 mel.
QuestionWhy do speech systems not use filters spaced evenly in hertz?Show answer
Evenly spaced hertz filters would give the same width everywhere, which is too coarse at low frequencies, where the ear is sharp, and too fine at high frequencies, where the ear cannot separate nearby tones. Spacing the filters evenly in mel puts more of them where hearing resolves detail and fewer where it does not, and it keeps the number of features small.
QuestionA music tool must find the exact frequency of a harmonic near 6 kHz. Should it use mel-spaced bands?Show answer
No. The top mel bands are hundreds of hertz wide, about 530 Hz near 8 kHz, so a harmonic near 6 kHz would fall into a band too wide to pin its exact frequency. A linear frequency axis gives the uniform resolution this task needs.
Sources
- Mel scale, Wikipedia: https://en.wikipedia.org/wiki/Mel_scale
- Mel-frequency cepstrum, Wikipedia: https://en.wikipedia.org/wiki/Mel-frequency_cepstrum