Welcome to the course on AI voice attendants, with emphasis on low-latency turn-taking: the systems problem of making perception, inference, and speech synthesis overlap so the agent answers quickly without sounding abrupt.
Latency is the product requirement, not a nicety. A sub-300 millisecond first-syllable budget keeps turn exchange inside the human conversational rhythm; beyond roughly half a second, users perceive hesitation, overlap rises, and task completion degrades.
We will formalize turn-taking as endpoint detection plus floor control: voice activity detection, incremental ASR confidence, prosodic cues, and barge-in handling decide when to listen, when to speak, and when to yield without collisions.
The session maps the full stack: front-end signal processing, streaming encoders and decoders, latency-aware language modeling, text-to-speech chunking, transport jitter, and the evaluation metrics that expose where milliseconds are lost.
By the end, you should be able to budget end-to-end latency, reason about accuracy-versus-delay trade-offs, and design an attendant that remains robust under noise, network variation, and real conversational interruptions.
• Latency budget: sub-300 ms first syllable across capture, ASR, LLM, TTS, network
• Turn-taking: VAD, endpointing, prosody, barge-in, duplex floor control
• Goals: streaming architecture, accuracy-latency trade-offs, evaluation under jitter and noise
Moment 02 / 11
Latency Budget Breakdown
Here is the latency budget for a voice assistant pipeline, and how sub-second end-to-end response is engineered rather than assumed.
First, speech-to-text decoding consumes roughly 100 to 200 milliseconds, where streaming acoustic encoders transcribe the audio into token sequences.
Next, large language model generation takes another 100 to 200 milliseconds, dominated by autoregressive decoding where each token requires a full forward pass through the network.
Then text-to-speech emission adds 100 to 200 milliseconds, synthesizing the response into audible waveforms, ideally with streaming output so playback begins before generation completes.
These stages sum to a total target perceived turn latency under 600 milliseconds, the threshold for a natural conversational rhythm.
This budget is not arbitrary: human turn-taking gaps in dialogue average around 200 to 500 milliseconds, so exceeding it produces perceptibly awkward pauses.
Meeting it requires optimizing every stage concurrently, through techniques like streaming inference, speculative decoding, and quantization, so the system feels instantaneous despite the heavy computation underneath.
Equations, code and original cards
Latency Budget Breakdown
End-to-end sub-second latency of voice pipelines
Speech-to-Text (STT)
Streaming Decoding Latency
100–200 ms
Large Language Model (LLM)
Autoregressive Generation Latency
100–200 ms
Text-to-Speech (TTS)
Streaming Emission Latency
100–200 ms
Total Target Perceived Turn Latency
< 600 ms
Moment 03 / 11
Mathematical Formulations: Latency Pipelines
Here we formalize the latency pipeline coupling speech recognition, the language model, and speech synthesis. The framework lets us reason about end-to-end delay rather than treating each stage as an isolated black box.
First, predictor states evolve through a linear recurrence: the next hidden state equals a state matrix times the current state plus an input matrix times the control. This tracks how partial hypotheses propagate.
Next, differentiate the latency objective with respect to the parameters and backpropagate through every stage, so gradient descent reduces delay instead of only chasing lower recognition error.
The key objective is a weighted sum: cross-entropy across time steps plus a latency penalty delta-t, with a coefficient lambda trading accuracy against time-to-first-token.
That penalty is the crucial modeling choice: it pushes the optimizer toward early confident emission rather than marginally better but slower hypotheses, which interactive systems actually need.
In summary: linear state recurrences for predictor dynamics, gradients of a latency-aware objective propagated across stages, and a loss that penalizes delay alongside error. These formulations are the basis for optimizing real-time interactive systems.
Equations, code and original cards
Mathematical Formulations: Latency Pipelines
State-Space Model of Predictor Dynamics
• Recurrence: x_{t+1} = A x_t + B u_t (linear dynamical system)
Loss L = Σ_t CE(p_t, y_t) + λ·Δ_t, balancing cross-entropy against latency
Moment 04 / 11
Turn-Taking Timeline Visualization
This timeline decomposes end-to-end latency across streaming speech recognition, language model time-to-first-token, and incremental speech synthesis, measured against the roughly 300-millisecond gap humans tolerate in conversational turn-taking.
Vary each component's duration to see how the pipeline overlaps recognition, inference, and synthesis; exceeding the budget produces perceptible dead air that breaks conversational flow.
Equations, code and original cards
Moment 05 / 11
Interruption & Barge-In Handling
We now examine interruption and barge-in handling: the control path that lets a spoken agent halt synthesis, revise state, and resume listening without perceptible seams.
Begin with voice activity detection: a streaming classifier that maps short acoustic windows to speech-versus-nonspeech posteriors, often using energy, spectral flux, or a small neural model.
The hard problem is canceling text-to-speech inside a phoneme: flush the playback buffer, abort the vocoder, and keep end-to-end latency near conversational thresholds.
Mode switching is a state-machine problem: on barge-in, close the synthesis stream, reopen the microphone path, update dialogue context, and synchronize clocks so neither dead air nor double-talk appears.
Together, detection, cancellation, and synchronization determine whether barge-in feels human: low false accepts, fast teardown, and context preserved across the turn boundary.
• Half-duplex state machine: speaker to listener without dead air
• Reopen capture, update dialogue context, synchronize clocks and state
Moment 06 / 11
Endpoint Detection Models
We now turn to endpoint detection models: the component that estimates, frame by frame, whether the user has completed a turn or merely paused.
A silence only rule is really a voice activity detector with a fixed timeout. It assumes turn final pauses are longer than turn internal pauses, but those distributions overlap under hesitation, planning, breathing, and noise.
So the failure mode is not excess silence; it is label ambiguity. The same four hundred millisecond pause can precede continuation, repair, or handoff, producing premature cutoffs or sluggish responses.
Modern endpointers therefore train a discriminative classifier, often recurrent or Transformer based, to output the posterior probability of turn completion from lexical hypotheses, acoustic energy, pitch, timing, and speaking rate.
Final intonation matters because falling contours with lengthening and reduced energy favor completion, while level or rising contours favor continuation; reported accuracy near ninety five percent is task and threshold dependent.
The principle is multimodal evidence aggregation: semantics supplies intent, prosody supplies boundary shape, and a calibrated decision rule converts their posterior into low latency, low interruption turn taking.
Equations, code and original cards
Endpoint Detection as Turn Boundary Classification
• Silence Timeout Failure Modes
• Posterior Objective & Feature Streams
• Final Intonation, Calibration, Latency
• Silence Timeout Limits
- Turn final and internal pause distributions overlap
- Noise and overlap break energy based VAD
• Discriminative Endpointer
- Posterior of completion from lexical and acoustic streams
- Features: ASR hypotheses, pitch slope, energy, rate, timing
• Prosody and Decision Rule
- Falling contour plus lengthening signals completion
- Threshold calibrated for cutoff versus latency cost
Moment 07 / 11
Advanced Techniques and Optimizations
We now isolate the optimizations that separate 2024 to 2026 systems from merely large transformers: kernel-aware attention, sparsity, quantization, and alignment objectives that trade latency against perplexity and task reward.
Efficient transformers attack the quadratic attention term and memory bandwidth: FlashAttention tiles the softmax, multi-query and grouped-query attention shrink the key-value cache, and RoPE preserves relative position under long contexts.
Scaling laws turn latency and accuracy into a budgeting problem: loss falls as a power law in parameters, data, and compute, while inference cost tracks active parameters, cache bytes, and the effective receptive field.
For voice assistants, alignment must couple semantics with prosody: preference optimization and instruction tuning shape content, while duration, pitch, and energy predictors are regularized so synthesized speech keeps meaning, cadence, and speaker identity.
The design principle is co-design: choose architecture, data mixture, precision, and alignment loss jointly, then ablate; gains that fail latency, memory, or preference budgets are not gains.
Equations, code and original cards
Advanced Techniques and Optimizations: 2024-2026
FlashAttention, MQA and GQA RoPE, MoE, INT8 and FP8
Power Laws: Parameters, Data, Compute Latency, Memory, Accuracy
Preference Optimization and Instruction Tuning Prosody: Duration, Pitch, Energy
Moment 08 / 11
Implementation Details: Code Walkthrough
Let's walk through the implementation of a streaming speech interface. We will cover three components: speech-to-text integration with voice activity detection, a learned semantic endpoint classifier, and latency-sensitive inference. Each addresses a distinct bottleneck in the real-time pipeline.
Here is the architecture at a glance: STT integration with VAD, the semantic endpoint classifier, and latency-sensitive inference. Keep this decomposition in mind, because each module trades off accuracy against latency differently, and the system only works if those tradeoffs are made deliberately.
This snippet handles STT hypotheses. Streaming recognizers emit partial transcripts that are revised as more audio arrives, so the is_final flag distinguishes committed tokens from provisional ones. Confidence scores and timing metadata let downstream logic decide whether to act on a hypothesis or wait for a more stable one.
Next, the semantic endpoint classifier. Silence-based endpointing is the naive baseline, and it fails on mid-sentence pauses and trailing hesitation. This module instead predicts utterance completeness from semantic content, which cuts both premature cutoffs and dead air at turn boundaries.
Finally, latency-sensitive inference in PyTorch. The no_grad context disables autograd graph construction, which removes bookkeeping overhead and reduces memory pressure during the forward pass. The argmax over the output logits then yields the predicted endpoint decision with minimal added cost.
Composed together, these modules balance recognition accuracy, turn-taking responsiveness, and semantic understanding. This decomposition is standard in production speech interfaces, and the same profiling-driven mindset transfers directly to any latency-critical system you build.
# Latency-Sensitive Model Inferencewith torch.no_grad(): outputs = model(inputs) predictions = torch.argmax(outputs, dim=-1)
Moment 09 / 11
Voice Persona Management
Voice persona management is the discipline of holding a text-to-speech system's prosodic and stylistic identity stable across model updates, prompts, and deployment regimes.
Persona specification is a constrained target distribution: warmth, speaking rate, formality, pitch range, and disfluency policy, encoded so decoding cannot drift outside the brand manifold.
Lock and version voice identifiers as immutable artifacts, with hashes over reference audio, conditioning embeddings, tokenizer settings, and decoding defaults, so every rollout is reproducible and auditable.
Validate each candidate checkpoint against frozen persona probes: measure speaker similarity, prosody error, mean opinion score degradation, and attribute classifiers for warmth and formality before promotion.
The payoff is a stable synthetic identity: lower regression risk, cleaner experiments, faster incident rollback, and a voice users recognize across releases.
Equations, code and original cards
Voice Persona Management
Operational controls for stable prosody, style, and identity across TTS releases
Today we survey open research problems in voice assistant design: adaptive latency control, multimodal endpointing, and full-duplex turn-taking.
Adaptive latency balancing treats delay as a controllable variable, trading time-to-first-token and speculative decoding depth against perceived responsiveness.
Multimodal endpoint detection fuses acoustic prosody with visual cues like gaze and gesture to estimate turn-completion probability, reducing both premature cutoffs and dead air.
Human-like interruption handling remains open: full-duplex models such as Moshi must learn barge-in, backchanneling, and turn-yielding from data, not hand-coded state machines.
Progress here, measured in interruption latency and turn-taking naturalness, decides whether spoken agents feel conversational or merely transactional.
Equations, code and original cards
Cutting-Edge Variations and Open Research
Open questions at the frontier of low-latency, full-duplex spoken dialogue systems.
Current Research Focus
• Adaptive latency balancing: time-to-first-token vs. speculative decoding depth
Now let's probe how deeply the material has actually taken hold. Work through each question independently before committing; these problems target the underlying mechanisms, not surface terminology.
After you submit, we'll walk through the solutions together, and I'll clarify any concept whose reasoning still feels unsettled.
Equations, code and original cards
MAKE IT YOURS
Explain the change.
References, scope & corrections
Research snapshots in the source material are not a claim of current state of the art. The reference review corrects identified errors; it is not exhaustive certification of every historical statement. Source code snippets are examples, not a tested production training system.