Sound is a vibration of the air. Measure this vibration at regular intervals (sampling), write it down on a fixed set of levels (quantization), cut it into short pieces (windows), split out which pitches of vibration are mixed in (Fourier transform), and regroup them on a scale that, like the human ear, looks more finely at low sounds (mel) — and you get a matrix of numbers that a neural network can read. Every sound is synthesized directly on this page.
When a speaker cone moves back and forth, the air is squeezed and loosened again and again, and this spreads outward. How many times it vibrates per second is the pitch (frequency); how strongly it vibrates is the loudness (amplitude).
measurements ≥ 2 × highest frequencyShannon, 1949
To capture a vibration properly, you must measure at least twice during each cycle. Measuring fs times per second can capture only up to fs/2 Hz (the Nyquist limit); faster vibrations show up as a misleadingly slow vibration (aliasing) [R1]. The human ear hears up to about 20,000 Hz, so music CDs measure 44,100 times per second. The telephone only needs to carry speech, so it uses 8,000. The mel spectrogram on this page also uses 8,000 (8 kHz). That is why it cannot capture sounds above 4,000 Hz. Real recording equipment filters out sounds above the limit before sampling.
A measured value is a real number whose decimals go on forever. To store it, you must round it to the nearest of a fixed set of levels. With b bits there are 2b levels. The difference created by rounding is quantization noise.
Speech changes from moment to moment. So we cut it into 25 ms pieces, analyze each piece separately, and repeat while moving 10 ms at a time. The multiplication that gently shrinks both ends of each piece is the "window."
A plain cut makes the values drop off abruptly at both ends of the piece. The Fourier transform calculates as if the piece repeats endlessly. So the sudden jump at the cut leaks out into frequencies that were not there (leakage). The Hann window multiplies by a curve that rises smoothly from 0 to 1 and back (0.5 − 0.5·cos), bringing both ends to 0. The price is a slightly wider peak. 25 ms·10 ms are values commonly used in speech analysis, and they are changed depending on the task.
Any sound can be expressed as a sum of sine waves of different pitches. The Fourier transform takes a waveform and returns "how much of each Hz component it contains." It is like a prism splitting white light into a rainbow.
mel = 2595 · log10(1 + Hz / 700)"Do-Re-Mi-Fa" 1 s → 98 frames × 20 bins
The human ear easily tells apart a small difference between low sounds (100 Hz and 200 Hz), but has trouble with the same difference between high sounds (3,000 Hz and 3,100 Hz). The mel scale divides low frequencies finely and high frequencies coarsely. Grouping the Fourier transform result (129 bins) with 20 triangular filters on this scale and taking the log (decibels) gives the mel spectrogram. The formula above is one widely used definition. Features based on the mel scale (MFCC) performed better than other features in speech recognition and were long used as a de facto standard [R2].
A mel spectrogram is a "frequency × time" matrix of numbers. Neural networks read it in two ways. The detailed architectures were covered in earlier parts.
Both code examples use only libraries preinstalled in Colab. After "Download notebook (.ipynb)", open it in Colab with File → Upload notebook, or copy the code and paste it into a new notebook cell.
Computes sampling, quantization, windows, the Fourier transform and the mel spectrogram without libraries. The numbers on the page (aliasing 3 Hz, leakage 7.95% → 0.05%, mel bin values) come out exactly. To use your own data, change SIGNAL and FS.
Converts the same sound into a mel spectrogram with librosa, the library used in practice, and compares it with the hand-made result. To use a recording, follow the [To use your own data] line in the code (prepare your own file).
These are prompts to paste into AI assistants such as ChatGPT, Qwen, or Claude. Pressing "Copy" attaches the chosen code after the prompt. Replace the parts in 〔 〕 with your own situation.
An AI's answer is only a starting point. Always check any papers, figures, or library functions it suggests against the original sources and official documentation. If you used AI help for a competition entry or paper, disclose the fact and extent of its use according to the rules of the organizers and the journal.
This is the same dictionary as the yellow dotted underlines in the text. The same terms are used throughout the series. Click a section name to jump to where the term first appears.
Analogies are a first step to understanding, but they can also seed misunderstanding. Fruit fly and brain analogies are marked by strength. Direct evidence that they actually do the same thing · Partial only some properties are similar · None no known counterpart
| Concept | Everyday analogy | Fruit fly / brain analogy | Where the analogy breaks down |
|---|---|---|---|
| Sampling | Photographing a runner once every second | Partial A fruit fly's compound eye also follows changes in brightness only at a fixed rate | A photo captures an instant, but a sample is only a value at a fixed interval. Motion faster than the interval looks wrong (aliasing) |
| Quantization | Measuring height with a ruler marked in 1 cm | None | A ruler's marks are even, but in real audio the marks are set by the number of bits |
| Window | Blurring the edges of a photo (vignetting) | None | A window is multiplied in not to look nice, but to reduce the fake frequencies created by the cut ends |
| Fourier transform | A prism splitting light into a rainbow | Direct The human cochlea responds to different pitches at different positions, splitting sound by pitch | The cochlea splits continuously over time and responds nonlinearly to changes in loudness. The Fourier transform computes one cut piece at a time |
| Mel scale | Piano keys: the same spacing every time the pitch doubles | Partial Pitch intervals as people perceive them | There are several mel formulas, and people hear differently. The formula on this page is just one widely used version |
| Mel spectrogram | Sheet music: time (horizontal) × pitch (vertical) | None | Sheet music writes each note, but a spectrogram writes all the energy, including harmonics and noise, into each cell |
E-1 About the author · E-2 Academic references · E-3 Figure sources
All sounds were synthesized on the page (no recordings).
A guide for instructors, on-the-job (OJT) trainers, and tutors. Times are estimates; adjust them to your actual class.
| Audience | University students and practitioners who want to work with speech and sound data (call center recordings, equipment noise, voice commands) |
|---|---|
| Prerequisites | Sine curves and logarithms. If you know "a photo is a grid of numbers" from 3-3, Sections 6 and 7 are easy |
| Learning objectives | ① Explain with numbers what sampling and quantization lose ② Explain in order how sound becomes a matrix through windows, the Fourier transform and mel filters ③ Distinguish the two ways CNNs and sequence models read the mel matrix |
| Estimated time | Reading 35–45 min · animation and sound demos 20 min · Colab practice 25 min (Code 1 15 min, Code 2 10 min) |
Intro 5 min (Section 1, listening) → Section 2 aliasing 10 min → Section 3 comparing sounds by bit depth 10 min → Sections 4·5 15 min → Section 6 matrix of numbers 5 min → Check questions 5 min.
Compare Sections 2·3 with your equipment's recording specs (sampling rate, bits) 15 min → Sections 4–6 25 min → put your own recording into Code 2 30 min → discussion "Is our data CNN-type or sequence-type?" 20 min.
Beginners: Sections 1·2·5·6 only. Intermediate learners: have them compute one cell of mel_filterbank in Code 1 by hand and compare it with the filter triangle figure on the page.
| Section | Questions to pause and ask | Hands-on tips |
|---|---|---|
| 1 Vibration | "How many times faster does 440 Hz vibrate than 220 Hz? How will it sound?" | Play the two tones in turn (if there is no sound, check the device volume) |
| 2 Sampling | "Why does it look like 3 Hz when we measure 8 times per second?" | Press 50 → 12 → 8 times in that order |
| 3 Quantization | "What sounds different between a 3-bit sound and a 16-bit sound?" | Play it at 3 bits and at 16 bits |
| 4 Framing · window | "Why does a plain cut create frequencies that were not there?" | Switch between Rectangular ↔ Hann and watch the skirt of the graph below |
| 5 Fourier transform | "It is the same 'Do', so why do a piano and a violin sound different?" | Play the pure tone → instrument tone in order and compare the number of peaks |
| 6 Mel spectrogram | "How many numbers did 1 second of sound become?" | Press the Do → Fa frames and watch the brightest cell move upward |
| 7 How models read it | "Which approach suits doorbell sound classification, and which suits dictation?" | Switch between the two modes |
| Misconception | Correct explanation | Scene to show |
|---|---|---|
| Measuring more often is always better | Twice the highest frequency you want to capture is enough. More only increases storage | 12 times in Section 2 (5 Hz is captured) |
| Fewer bits make the sound quieter | It is the noise, not the volume, that grows. Each bit makes it about 6 dB cleaner | Section 3 |
| The Fourier transform analyzes the whole sound at once | It is done separately for each short piece (frame). That is why we can see changes over time | Sections 4·6 |
| A spectrogram is a picture, so it can be treated just like a photo | The horizontal (time) and vertical (frequency) axes mean different things. Shifting vertically makes it a different sound | Section 7 |
| A mel spectrogram keeps the sound as it is | It is a reduced summary that discards phase and fine frequency information (8,000 → 1,960) | Section 6 numeric summary |
8,000 ÷ 2 = 4,000 Hz (the Nyquist limit).
|5 − 8| = 3 Hz. It exceeds the limit (4 Hz), so aliasing occurs.
6.02 × (16 − 8) ≈ 48 dB. The theoretical values are 49.92 dB and 98.08 dB.
(8,000 − 200) ÷ 80 + 1 = 98 (drop the decimals, then add 1).
1,960. 8,000 ÷ 1,960 ≈ 4.1, so about one quarter.
In Code 1, change NMEL from 20 to 40 and FRAME from 200 to 400. Write three sentences on how the size and picture of the mel matrix change, connecting this to the trade-off between time resolution and frequency resolution.
Run Code 2 with a file you recorded yourself of your voice or of equipment sounds (prepare your own file; mind personal information). Record the same sound twice, compare how similar the mel matrices are using the correlation coefficient, and write what causes the differences.
| Beginners | Sections 3·4 can be skipped without breaking the flow. Be sure to do the listening in Sections 1·5 |
|---|---|
| Advanced | Have them investigate how window length, step and number of mel bins affect recognition performance. Check the papers they find in the original |
| Further learning | Sangsun Ahn, “Data Science for Business” lecture notes (data science in general) · STEP [K-Digital] AI Natural Language Processing (linked to 3-5 and 3-8) · STEP [K-Digital] Fundamentals of Fintech Data Analysis (linked to 3-6) |
| Materials for instructors | Grading criteria for the check questions and sample answers for the assignments are on the Answer key for educators page (3-4) |
You have read "3-4 Speech" to the end. Everyone in the lab will sum it up for you in a word each.