JA EN
LearnAudio & Speech
·★ MEMBER·PAPER·13 min read

Representing Sound — Mel Spectrograms and Audio Tokens

Why speech models never eat raw waveforms, and what they eat instead: the chain from short-time Fourier transform to the mel scale to the log to discrete tokens. Covers the window-length tradeoff, why MFCCs dropped the DCT, how acoustic and semantic tokens differ, and the config mismatches that silently wreck audio in production.

ModalitytextTaskspeech

Robust Speech Recognition via Large-Scale Weak Supervision

Primary source — what this article is built on

undefined2022-12-06undefined2026-08-273y 9mo later

HuBERT: Self-Supervised Speech Representation Learning by Masked Prediction of Hidden UnitsarXiv:2106.07447Paper page·PDF
Robust Speech Recognition via Large-Scale Weak SupervisionAlec Radford, Jong Wook Kim, Tao Xu et al. · 2022-12-06 · v1arXiv:2212.04356Paper page·PDF
undefined

We study the capabilities of speech processing systems trained simply to predict large amounts of transcripts of audio on the internet. When scaled to 680,000 hours of multilingual and multitask supervision, the resulting models generalize well to standard benchmarks and are often competitive with prior fully supervised results but in a zero-shot transfer setting without the need for any fine-tuning. When compared to humans, the models approach their accuracy and robustness. We are releasing models and inference code to serve as a foundation for further work on robust speech processing.


What the microphone actually hands you

A microphone does something simple. It measures air pressure at fixed intervals and writes each measurement down as a number. At 16 kHz — the standard rate for speech — that is 16,000 numbers per second, so ten seconds of talking arrives as a strip of 160,000 numbers.

Inside that strip your voice, the noise from the next room, and the reflections off the walls are all dissolved into a single wave. Human ears pull words out of it effortlessly. Handing a machine those 160,000 numbers directly, though, is like asking someone to read a book by studying ink density values on the page. Not impossible. Just a very long way round.

So essentially every audio system converts the waveform into some other representation before the real work begins. This article walks the whole chain as one road: Fourier transform → mel scale → log → discrete tokens. You may already know one link in that chain; what changes the picture is seeing why they come in that order.

The metaphor: sheet music is a compression format

Imagine trying to preserve an orchestral performance on paper. Transcribing the actual air vibrations is hopeless. But we have sheet music, which records only when a pitch sounds, which pitch, and how loudly. It says nothing about the player's timbre, nothing about the hall's reverberation, nothing about the phase of the wave. And yet hand it to a different orchestra and the piece comes back.

A spectrogram is sheet music for machines: sound laid out as a table with pitch running up and time running across, phase thrown away exactly as a score throws it away.

A mel spectrogram is that same score with the staff lines respaced to match human hearing — fine detail down low, broad strokes up high.

And tokenization is what happens when you round each note to one of a fixed set of symbols. Handwriting becomes movable type. Once sound is a string of symbols, the enormous machinery built for language models will happily consume it.

Why not just feed the waveform?

Three reasons.

It is too long. Thirty seconds at 16 kHz is 480,000 samples. Self-attention costs grow with the square of sequence length, so nobody wants to attack that head-on.

Sounds that are identical to the ear are wildly different as numbers. Record the same vowel one millisecond later and every number changes. Shift the phase, scale the amplitude slightly — still the same sound to you, still a completely different array. A network fed raw samples has to learn all of that invariance from scratch before it learns anything about language.

The features that carry meaning are invisible in the time domain. What separates "ah" from "ee" is the position of the resonant peaks the vocal tract produces — the formants. Stare at the waveform as long as you like; the peaks are not there to see. Move to frequency and they appear as visible stripes.

Switching to a frequency representation fixes all three at once: the sequence shrinks to one frame per 10 milliseconds, dropping phase hands you the invariance for free, and formants become picture-like structure.

Mechanism 1: the short-time Fourier transform

The tool that "unmixes a combined wave into its component pitches" is the Fourier transform. (How it works, and why it can be computed so fast, is the subject of FFT from scratch.)

Apply it once to ten seconds of speech, though, and all ten seconds of frequency content collapse into a single graph. When each sound occurred is gone entirely — as if an entire score were summarized as one chord.

The fix is to chop first. Cut a window of roughly 25 milliseconds, transform only what is inside it, slide the window forward by 10 milliseconds, repeat. That is the short-time Fourier transform (STFT).

X[t,k]=n=0N1w[n]x[n+tH]ei2πkn/NX[t, k] = \sum_{n=0}^{N-1} w[n]\, x[n + tH]\, e^{-i 2\pi k n / N}
(1)

Symbol by symbol: xx is the waveform, NN the window length in samples, HH the hop size, ww the window function, tt which slice we are on, kk which frequency we are asking about. Equation (1) says only this: build a table whose entry (t,k)(t, k) is "how much of pitch kk lives inside slice tt", for every slice and every pitch.

Each XX is a complex number carrying a magnitude (how strong that component is) and an angle (its phase). Discard the angle, keep X2|X|^2, and you have a power spectrogram.

That ei2πkn/Ne^{-i 2\pi k n / N} at the end is just "a sine wave at frequency kk." Multiplying it into the signal and summing is a dot product. The more the signal points the same way as that sine wave, the larger the sum. Frequency analysis, stripped down, is taking a great many dot products at once.

FIG 1Frequency analysis is a dot product in disguise. Treat the signal as one vector and "a sine wave at some pitch" as another — the more their directions agree, the stronger that pitch is judged to be. Rotate them toward 90 degrees and watch the value sink to zero

The window length decides what you are allowed to see

The first thing you choose in an STFT is the window length, and the choice carries a tradeoff you cannot undo later.

A longer window fits more cycles of each wave, so frequency resolution improves and you can separate pitches that sit close together. The price is that everything happening inside that span gets flattened into one frame, so time resolution degrades — the sharp onset of a plosive smears out. Shorten the window and the two effects swap places.

The relationship is roughly ΔtΔfconstant\Delta t \cdot \Delta f \approx \text{constant}: improve one and the other gets worse. This is not an implementation artifact. It is a structural limit on looking at a signal through time and through frequency at the same time.

Speech settled on 25 ms windows with a 10 ms hop because that matches a useful rule of thumb: over that span, the shape of the mouth and tongue barely changes. Music analysis prefers longer windows (2048 samples is common) — you want to resolve the notes inside a chord, so you spend your budget on the frequency side.

What's behind this

§

Members-only from here

371 walkthroughs, 26 textbook chapters, 48 student units and 6 close readings — all included for $4.99/mo, with three new explainers every day. Cancel any time; access runs to the end of the period.

Already a member? Sign in to keep reading

References

  1. HuBERT: Self-Supervised Speech Representation Learning by Masked Prediction of Hidden Units. arXiv:2106.07447Paper page·PDF
  2. Alec Radford, Jong Wook Kim, Tao Xu, Greg Brockman et al.. (2022-12-06) Robust Speech Recognition via Large-Scale Weak Supervision. arXiv:2212.04356Paper page·PDF

This article is written from the source paper above. Where they differ, the original is authoritative.

Comments

Sign in to comment