Day 131 · Ears and a voice

Multimodal II — Audio & Voice

You will be able to
  • Explain how Whisper-class STT works (audio → mel spectrogram → encoder-decoder transformer)
  • Transcribe real audio locally and compute word error rate against a reference by hand
  • Break a voice interaction into its latency budget (STT + LLM + TTS) and find the bottleneck
  • Explain endpointing and barge-in and why they make or break voice UX
  • Build a transcribe-and-summarize pipeline with speaker-aware structured output
Today's ~120 minutes
Spaced-rep warm-up: due cards (vision, quantization)10 min
ELI5 + tech read; sketch the voice loop with budgets20 min
Guided: local transcription + WER, latency budget lab40 min
Practice: structured meeting minutes20 min
Project: blueprint + transcribe CLI20 min
Quiz + flashcards10 min

Builds on: Day 95The Transformer (encoder-decoder) · Day 107Streaming & latency UX · Day 110Structured outputs

The analogy

Your polymath just got ears and a voice — and suddenly the rules of conversation apply. When you talk with a person, the rhythm is unforgiving: a reply that takes three seconds feels broken, because humans answer each other in well under one. So a voice assistant is a relay race run against a stopwatch: ears transcribe your words, the brain composes an answer, the mouth speaks it — and the whole relay must finish in about the time it takes you to say "um."

Two small skills separate a natural conversation from a walkie-talkie. Knowing when you have STOPPED talking (endpointing): pause too eagerly and it interrupts your mid-sentence breath; wait too long and every exchange gains an awkward second. And being interruptible (barge-in): when you start talking over its answer, a polite assistant shuts up immediately, exactly like a person would. Neither skill is about intelligence — both are about timing. That is the theme of today: voice is 20% transcription quality and 80% latency engineering.

Why this matters on the job

Voice is where AI meets the phone call — support lines, drive-through ordering, field-worker hands-free tools, accessibility interfaces — and it is a growing slice of FDE work because the engineering is unforgiving in ways text never is. A chatbot that takes 4 seconds is fine; a voice agent that takes 4 seconds is unusable, and the customer can hear exactly how bad it is in the first ten seconds of a demo. Knowing the latency anatomy — and that streaming everything (STT, LLM, TTS) is the only way to hit budget — is the difference between a wow demo and a dead one. Transcribe-and-summarize alone (meetings, calls, voicemails) is one of the most-requested enterprise features in existence.

Guided practice

guided 1

Transcribe locally and score WER by hand

25 min
  1. Install: pip install openai-whisper (pulls PyTorch; also needs ffmpeg) — or faster-whisper if you prefer. Model base is enough.
  2. Record ~30 seconds of yourself reading a paragraph you have as text (your phone's voice memo, exported as .m4a/.wav). That text is your reference.
  3. Run the starter: it transcribes the audio, then computes WER against your reference with a from-scratch edit-distance implementation — no library, so you see that WER is Day 34's DP on words.
  4. Read the alignment output: which words were substituted/dropped? Names and numbers fail first — note it.
  5. Stress test: re-record the same paragraph with background noise (music, street) and with fast mumbling. Record all three WERs. Then transcribe 10 seconds of pure silence and observe what Whisper does with it.
🐍 python — editable, runs in your browser
Ctrl/⌘+Enter runs · Tab indents · numpy/pandas/sklearn auto-load on import (torch and network calls need a local run)
guided 2

Latency budget: the voice-turn spreadsheet in code

15 min
  1. Create voice_budget.py with the starter. It models a voice turn as stages with realistic latencies and compares three architectures: fully sequential, streamed STT, and fully streamed (overlapped LLM + sentence-streaming TTS).
  2. Run it and read the "time to first audio" for each. Only the fully streamed design gets under 1 second.
  3. Change one assumption at a time: a 1,500 ms LLM TTFT (big model), a 100 ms hosted STT, an on-device TTS at 80 ms. Which single change moves time-to-first-audio most? That is your bottleneck — write it in a comment.
  4. Add a fourth architecture in code: cascade routing (Day 129) where a small fast model answers simple turns. Estimate its blended time-to-first-audio.
🐍 python — editable, runs in your browser
Ctrl/⌘+Enter runs · Tab indents · numpy/pandas/sklearn auto-load on import (torch and network calls need a local run)

On your own

Meeting minutes, structured

20 min

Build minutes.py: feed the transcript from guided exercise 1 (or any longer recording — a podcast clip you have rights to works) through an LLM with a Day 110 structured-output contract: {summary, decisions: [], action_items: [{owner, task, due}], open_questions: []} with nulls allowed for unknown owners/dates.

Constraints: the prompt must instruct the model to only include items actually said (no invented owners), timestamps from Whisper segments must be preserved on decisions, and the output must validate against a pydantic schema with one repair round.

Test with a trap: your recording should contain one vague statement ("someone should probably look at the logs") — does the model invent an owner? Write two sentences on the result.

Hints: hallucinated attribution is THE failure mode of meeting summarizers; the null-allowed schema plus explicit "use null if unstated" instruction is the countermeasure.

Ship before you stop

Voice-tutor architecture blueprint (paper) + transcribe-summarize CLI (code)

Two deliverables. (1) voice_notes.md: the architecture for a voice tutor (the far-future ambition of this program's platform) — a labeled pipeline diagram in text (capture → endpointing → streaming STT → LLM with conversation state → streaming TTS → playback with barge-in), the latency budget per stage with your numbers from guided 2, the two hardest engineering problems (you should now know they are endpointing and overlap orchestration, not "the AI"), and where a WER regression would visibly hurt. (2) transcribe.py: a CLI — python transcribe.py audio.m4a — emitting minutes.json per your practice schema plus a WER self-check mode when a reference file is supplied. Commit both.

Rubric — check what you completed (0/6)

Common mistakes & misconceptions

  • Treating voice as "chatbot + microphone". The hard parts are timing: endpointing, streaming overlap, barge-in. A perfect answer at 3 seconds loses to a good answer at 800 ms.
  • Sequential pipeline architecture. STT-then-LLM-then-TTS in series cannot hit human latency; every stage must stream and overlap.
  • Trusting Whisper on silence and noise. It hallucinates fluent text from nothing — check no_speech_prob and trim silence before transcribing.
  • Quoting WER without conditions. WER on clean read speech says nothing about accented, noisy, jargon-heavy calls — report WER per condition, like any eval slice (Day 80).
  • Letting the summarizer invent owners and dates for action items. Null-allowed schema + "only if stated" instruction + a trap test case.
  • Ignoring privacy: audio is often the most sensitive data a customer has. Local STT (Whisper on-prem) is frequently a requirement, not an optimization.
Knowledge check

Q1. A reference has 20 words; the transcript has 2 substitutions, 1 deletion, 1 insertion. WER?

Q2. Your voice agent feels laggy despite a fast LLM. Measurements: endpointing 300ms, STT 400ms after speech ends, LLM TTFT 500ms, TTS 300ms — sequential. Highest-leverage fix?

Q3. Whisper outputs a fluent sentence for a segment that was actually silence. What is this, and what flags it?

Go deeper — curated resources

repoopenai/whisper — repo, model card & usage20 minpaperWhisper paper — Robust Speech Recognition via Large-Scale Weak Supervision30 minrepoOpenAI Cookbook — audio examples15 min
If you have a third hour
  • Speech-to-speech modelsNative audio-in/audio-out models collapse the STT→LLM→TTS relay into one model, cutting latency and preserving tone/emotion — at the cost of the modular observability you get from a pipeline. The trade-off to watch.
Done means
  • Local transcription runs; WER computed with your own DP code across 3 conditions
  • Silence hallucination observed and its detection flag identified
  • Latency lab run; bottleneck stage named for your assumptions
  • Blueprint + CLI committed; minutes.json validates
  • Quiz ≥ 2/3
How this connects

← Back: Whisper is Day 95's encoder-decoder transformer with spectrograms for input; WER is Day 34's edit distance; the streaming-overlap obsession is Day 107's TTFT thinking, three stages deep.

Forward →: Tomorrow (Day 132) you learn why a voice channel is also an attack surface — spoken injection is still injection. Latency budgets return as p50/p95 engineering on Day 155, and the voice-tutor blueprint is a genuine future-product sketch.