Multimodal II — Audio & Voice
- 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
| Spaced-rep warm-up: due cards (vision, quantization) | 10 min |
| ELI5 + tech read; sketch the voice loop with budgets | 20 min |
| Guided: local transcription + WER, latency budget lab | 40 min |
| Practice: structured meeting minutes | 20 min |
| Project: blueprint + transcribe CLI | 20 min |
| Quiz + flashcards | 10 min |
Builds on: Day 95 — The Transformer (encoder-decoder) · Day 107 — Streaming & latency UX · Day 110 — Structured outputs
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.
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
Transcribe locally and score WER by hand
25 min- Install:
pip install openai-whisper(pulls PyTorch; also needs ffmpeg) — orfaster-whisperif you prefer. Modelbaseis enough. - 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.
- 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.
- Read the alignment output: which words were substituted/dropped? Names and numbers fail first — note it.
- 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.
Latency budget: the voice-turn spreadsheet in code
15 min- Create
voice_budget.pywith 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). - Run it and read the "time to first audio" for each. Only the fully streamed design gets under 1 second.
- 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.
- 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.
On your own
Meeting minutes, structured
20 minBuild 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.
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.
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.
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
- Speech-to-speech models — Native 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.
- 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
← 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.