Foundations to Frontier
Tests
F. NLP and Large Language Models › F13 Multimodal Models

Speech: Whisper-style recognition and text-to-speech

Speech models turn audio into text (automatic speech recognition, ASR) and text into audio (text-to-speech, TTS). Whisper converts 30-second windows of audio into log-mel spectrograms, encodes them with a transformer and decodes text token by token; it was trained on 680000 hours of weakly labelled web audio. Modern TTS predicts discrete audio-codec tokens or spectrograms and turns them into waveforms with a vocoder. This page covers spectrograms, CTC and encoder-decoder recognition, word error rate, language-model fusion and context biasing, streaming, and TTS pipelines. In the exercises you compute frames, the mel scale, CTC collapsing and word error rate. You then decode noisy simulated speech with and without a language model. At 40% phone noise, the language model cut word error from 0.37 to 0.12. It also wiped out jargon it had never seen: errors on domain words went from 0.29 to 0.41, and to 1.0 with a heavy weight. Biasing towards a list of the domain words brought their error down to 0.17.

Level 0: Foundation

★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.

Turning sound into words and back

A microphone records air pressure thousands of times a second. Speech models first turn that into a picture of which pitches are loud at each moment, a spectrogram. A recogniser reads the picture and writes the words; a speech synthesiser does the reverse. Like people, recognisers use context to guess unclear words, which helps with everyday speech but can turn rare technical terms into common words. The demo shows how many frames and tokens a clip produces.

Multimodal lab
30 s of audio at a 10 ms hop: 3000 spectrogram frames, 1500 encoder tokens after 2× downsampling.
Why engineers care

Pilots, air traffic controllers and robot operators speak commands with rare call signs and jargon, so speech systems must be adapted to their vocabulary.

📝 Quick check (Level 0)
0/3 answered
  1. 1. A spectrogram shows…
  2. 2. ASR converts…
  3. 3. Using context to guess words can hurt with…

Level 1: Beginner

★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.

By hand

  • Front end: 16 kHz audio → 25 ms windows every 10 ms → 80 or 128 log-mel bands (100 frames per second).
  • CTC models (wav2vec 2.0, Conformer-CTC): one label or blank per frame; merge repeats, drop blanks; fast and streaming-friendly.
  • Encoder-decoder (Whisper): 30 s windows, 2× downsampling to 1500 encoder tokens, autoregressive text decoder with task tokens (language, transcribe or translate, timestamps).
  • Transducers (RNN-T): streaming with an internal label predictor; used on phones.
  • Word error rate: (substitutions + deletions + insertions) / reference words; normalise casing and punctuation first.
  • Language models and biasing: shallow fusion adds λ·log P_LM; context biasing (Whisper’s initial prompt, keyword boosting) raises the scores of expected words.
  • TTS: text → phonemes or tokens → acoustic model (spectrogram or codec tokens; Tacotron, FastSpeech, VALL-E, VITS) → vocoder (HiFi-GAN) → waveform. Neural codecs (EnCodec, SoundStream) make audio tokens for language-model-style generation.
  • Failure modes: hallucinated text in silence or music, accents and noise, jargon and names, voice cloning misuse.
📝 Quick check (Level 1)
0/3 answered
  1. 1. Frames per second at a 10 ms hop:
  2. 2. CTC output is cleaned by…
  3. 3. Whisper's initial prompt can be used for…

Level 2: Intermediate

★★★☆☆ Intermediate⏱ 25 minUndergraduate students and practising engineers.

Using speech models

Exercise 1.

  • Frame counts and the mel scale.
  • CTC collapsing.
  • Word error rate by edit distance.

Practice.

  • Recognition: Whisper (openai-whisper, faster-whisper, whisper.cpp), NVIDIA NeMo Parakeet and Canary, wav2vec 2.0 in transformers; cloud speech APIs.
  • Long audio: voice-activity detection to skip silence, overlapping windows, timestamp alignment (WhisperX).
  • Domain vocabulary: put names and jargon in the initial prompt or a keyword-boost list; fine-tune on in-domain audio when error stays high.
  • Evaluate with WER on normalised text (the jiwer library), per domain and per speaker group.
  • TTS: Piper, Coqui XTTS, Parler-TTS, Kokoro, cloud voices; check licensing and consent for voice cloning.
from faster_whisper import WhisperModel
model = WhisperModel("large-v3", compute_type="int8")
segments, info = model.transcribe("atc.wav", vad_filter=True,
    initial_prompt="Runway 27L, ILS approach, squawk 7000, Speedbird, QNH")
text = " ".join(s.text for s in segments)
🐍 Exercise 1: frames, CTC and WER
Count frames, convert to mel, collapse a CTC path and compute word error rate.
📝 Quick check (Level 2)
0/3 answered
  1. 1. Skip silence in long audio with…
  2. 2. Domain names and jargon go into…
  3. 3. A library for WER:

Level 3: Advanced

★★★★☆ Advanced⏱ 25 minGraduate level, with full derivations and proofs.

Theory

Noisy channel. Recognition picks the word sequence W maximising P(audio | W) · P(W). The acoustic model supplies the first factor, a language model (explicit or the decoder’s own) the second. Shallow fusion raises the language model to a power λ.

Why LMs help and hurt. Many words sound alike; the language model breaks ties using context, so word error falls sharply in noise. But the prior penalises words it rarely saw; when the audio is ambiguous, the prior wins and rare words are replaced by common ones. A larger λ makes this worse.

Biasing. Adding a bonus b to the log-score of expected words is equivalent to raising their prior by a factor of e^b. It helps when the list is accurate and costs a little on speech that does not contain those words.

CTC. The CTC loss sums the probabilities of all frame paths that collapse to the target, computed with dynamic programming; it assumes outputs are conditionally independent given the audio, which is why external language models help CTC systems more.

📝 Quick check (Level 3)
0/3 answered
  1. 1. Recognition maximises…
  2. 2. A larger LM weight…
  3. 3. A bias bonus b multiplies the prior by…

Level 4: Expert

★★★★★ Expert⏱ 30 minResearchers: original papers and open problems.

How much does a language model help speech recognition in noise, and what does it do to domain jargon it has never seen?

History.

  • A. Graves et al., “Connectionist temporal classification” (2006).
  • A. Baevski et al., “wav2vec 2.0” (2020).
  • A. Radford et al., “Robust speech recognition via large-scale weak supervision” (Whisper, 2022).

Exercise 2. A simulated recogniser at the word level.

  • Lexicon: 240 five-phone words in groups of 4 that differ in one phone, plus 20 jargon words.
  • Language: sentences of 10 words from a bigram model with 30 likely followers per word; the bigram language model is trained on 3000 sentences that never contain jargon. In the jargon test set, 15% of words are jargon.
  • Acoustics: each phone is misheard with probability ε; the exact acoustic likelihood of every word is computed.
  • Decoders: audio only; Viterbi with the language model (λ = 1); with a +3 bias on the 20 jargon words (like a prompt listing them); with a heavy language model (λ = 3). 150 test sentences per setting.
word error, seed 0 audio only LM LM + biasing heavy LM
ε 0.2, general 0.125 0.017 0.017 0.037
ε 0.4, general 0.366 0.123 0.132 0.184
ε 0.4, jargon set, all words 0.339 0.199 0.173 0.361
ε 0.2, jargon words only 0.06 0.06 0.033 0.819
ε 0.4, jargon words only 0.286 0.411 0.174 1.0
  • The language model cut general word error by two thirds or more.
  • Jargon: at ε 0.4 the language model made jargon words worse than audio alone (0.41 vs 0.29); the heavy one erased them all.
  • Biasing recovered jargon (0.17) at a small cost on general speech (0.132 vs 0.123).
  • Seeds 1 and 2, jargon words at ε 0.4: audio 0.261 and 0.272, LM 0.351 and 0.435, biased 0.156 and 0.199, heavy 1.0 both.
  • Caveat: word-level simulation with substitutions only and a known lexicon; real systems also make insertion and deletion errors and use subword vocabularies.
🐍 Exercise 2 (research): how much does a language model help speech recognition in noise, and what does it do to domain jargon it has never seen?
Decode simulated noisy speech with and without a language model and with context biasing; measure word error on general speech and on jargon.

Speech models in AI, robotics and aerospace

  • Air traffic control: ASR assistants for controllers (projects such as HAAWAII) need call signs and phraseology biasing; errors are safety relevant.
  • Cockpits and robots: voice commands for hands-busy operation, with confirmation of safety-critical commands.
  • Speech output: synthetic voices for alerts and assistants; clarity under noise matters more than naturalness.

References

  1. A. Graves, S. Fernández, F. Gomez and J. Schmidhuber (2006). “Connectionist temporal classification.” ICML.
  2. A. Baevski, H. Zhou, A. Mohamed and M. Auli (2020). “wav2vec 2.0.” NeurIPS.
  3. A. Radford et al. (2023). “Robust speech recognition via large-scale weak supervision.” ICML.
  4. C. Wang et al. (2023). “Neural codec language models are zero-shot text to speech synthesizers.” arXiv (VALL-E).