Part 10 · Blueprint 66
Real-Time Voice & Multimodal AI Streaming
14 min reading · Sources · Editorial review pending
Canceling generation does not remove already buffered audio or repair conversation history.
Page details
Published date · Last edited:
Draft edition. Editorial review and supplementary reading recommendations are still being completed.
Format: Architecture walkthrough. Prerequisites: the beginner bootcamp. Chapter prerequisites: Latency Numbers & Networking Foundations, Timeouts, Circuit Breakers & Backpressure, High-Throughput LLM Inference Serving.
Sixty-second mental model
Problem: Canceling generation does not remove already buffered audio or repair conversation history.
Use: Track transport, model and playback state separately during interruption.
Design boundary: Coordinate real-time media input, model generation and client playback. Interruption must cancel or fence obsolete generation and queued audio, not just stop displaying text.
Layer 1 · Intuition
Hypothetical scenario: Northwind is designing voice ai streaming. Maya represents product requirements, Dev implementation and Priya reliability. The team must agree what one audio frame means and which component owns the conversation and playback position.
Think of a conversation where listening and speaking can interrupt each other. Separate the requester from conversation and playback position, then identify the retained evidence needed after failure.
- Authority
- The entitled state owner.
- Invariant
- A rule preserved across concurrency and failures.
Architecture and worked reasoning
Design boundary: Coordinate real-time media input, model generation and client playback. Interruption must cancel or fence obsolete generation and queued audio, not just stop displaying text.
Responsibilities on the request path
Workload and limiting resource
Hypothetical path budgets are 40 ms capture, 60 ms network, 150 ms processing and 50 ms playback buffer: total 300 ms before queueing. Adding a 500 ms batching wait breaks that 300 ms target even if model execution stays unchanged.
Keep the units attached to each intermediate result. The assumptions above describe a hypothetical exercise, not observed vendor capacity. A real capacity decision also needs a measured service curve, skew, recovery traffic and an explicit admission policy for overload.
Mutation or publication path
- Assign a turn/generation identity.
- Stream bounded media and model output under latency budgets.
- Fence superseded generations when the user interrupts.
Observation and recovery path
- Render only the active generation.
- Measure capture-to-playback latency by stage.
- Discard old buffered output and expose incomplete turns honestly.
Failure that changes the decision
Hypothetical scenario: Old audio already queued at the client plays after a new turn began. Carry generation identity into the playback buffer and define its flush behavior.
Attempt this decision before reading the explanation
Does cancelling the server request automatically retract bytes already queued for playback?
No. Client buffering is a separate state machine and needs explicit interruption/version handling.
Supporting mechanism analysis
Hypothetical scenario: Northwind. Maya represents product, Dev implementation and Priya reliability. The following workflow develops the underlying mechanism.
Hypothetical scenario. Northwind has chosen a text-generation interface, but its policy evidence is not all text. Maya brings a scanned eligibility table and a spoken clarification. Dev can extract readable text from both; Priya asks what would let a reviewer check the interpretation against the source.
Maya: “The extracted amounts look right, but which column did this amount belong to?”
Priya: “Keep the page and region with the interpretation. A readable result still needs an evidence trail.”
You will trace image and speech evidence through derived representations, then distinguish that perception task from diffusion-based image generation. The question is how to preserve meaning and inspect uncertainty when an input changes form.
Before you continue: The scan’s extracted text contains the correct amounts but loses the column headings. Is it ready to become authoritative policy evidence?
Correct individual values do not preserve their relationships. Without the headings, the assistant can attach a value to the wrong condition. Inspect the table and retain source-version and region references before accepting the transformation.
This tests the meaning needed for the answer. Preserve the original evidence and the transformation identity, and represent unresolved uncertainty rather than silently treating extraction as validation.
Ho, Jain and Abbeel's diffusion-model paper describes image generation through a learned denoising process. A text-conditioned diffusion system uses the text as conditioning while iteratively refining a noisy image representation. That is different from extracting evidence from a supplied scan. The noise schedule, denoising steps and conditioning interface belong in its generation contract; a document-perception pipeline needs provenance and evidence checks instead.
Radford and colleagues' speech-recognition study provides a concrete audio-to-transcript example. A transcript is a derived representation, not the original sound. Speaker attribution, uncertain words and time alignment can matter to a later decision. Preserve the permitted audio reference rather than pretending that readable text establishes what was said.
Hypothetical scenario. Suppose Northwind divides 60 seconds of audio into six nonoverlapping ten-second segments. Six × 10 = 60 seconds are covered. Adding two seconds of left overlap to each segment after the first adds 5 × 2 = 10 seconds of repeated processing, producing 70 segment-seconds. This is an input-accounting example, not a speech-model benchmark. Reconcile overlap and deduplicate time-aligned evidence before counting assertions as independent observations.
Hypothetical scenario. A policy PDF contains a table whose footnote limits eligibility for one product. Text extraction captures the amounts but loses the column headings and footnote association. The assistant later cites the correct page while interpreting the wrong row. Retrieval succeeded at finding a page, but the evidence representation failed.
This application ingests mixed text and visually structured documents into a versioned evidence collection. It supports searchable text, page images and source references where appropriate. Scope includes parsing, table and image interpretation, review, indexing and deletion. It excludes an automatic guarantee that every scanned page can be understood.
The central requirement is traceability: a derived passage or visual representation should identify the source version and page or region it describes. Without that link, an apparently well-supported answer can be impossible to inspect.
Hypothetical scenario. A scanned policy table becomes an image crop, OCR text and a summary. An audio policy briefing becomes time-bounded transcript segments. Each representation needs its source revision and location, not just a derived filename.
An OCR error can reverse a qualification while still producing fluent text. A generated image or reconstructed audio is a model output, not an independent observation of the original event. Treat transforms as versioned, fallible steps and retain enough source evidence for review. Publication accepts a specific compatible set of derived artifacts; an older transform finishing late cannot overwrite the current source revision. Deletion and permission changes apply to crops, transcripts and summaries as well as the original file.
Reading order, layout, headers, figures and footnotes can carry meaning that a text stream does not preserve. OCR can also confuse identifiers or numbers. A clean-looking extraction is not proof that the transformation retained the relevant relationship.
A vision-language model offers another interpretation path, not an infallible replacement. It can misread small text, overlook a legend or infer an unsupported relationship. The system should preserve the original evidence and identify uncertain transformations rather than silently declaring every extraction correct.
ColPali studies retrieval using visual page representations and late interaction. It supplies a concrete alternative to purely text-derived retrieval. Its reported results do not prove that a particular organization's tables, permissions or downstream answers are handled correctly.
Record the original object's identity, version, content integrity and access scope. Parsing produces a versioned text and layout representation. OCR or visual interpretation records which page or region it used and which transform produced the result. Index construction references those artifacts rather than replacing their identity.
Choose representation per task. Exact identifiers may need reliable text fields; a chart question may need image evidence and its legend. A mixed collection requires an explicit ranking and evidence-expansion policy. Similarity scores from unrelated representations are not automatically interchangeable.
Publish a collection version only when its required source and transform coverage is ready. Keep a manifest of failed or excluded pages. A successful batch job should not hide individual documents that never became usable evidence.
A document pipeline changes representations several times: original file, extracted text or image regions, chunks, retrieval candidates and answer context. Each transformation can lose relationships. A table heading separated from its rows can turn an exception into an apparently unconditional rule. An OCR result that looks fluent is therefore an intermediate artifact to evaluate, not an authoritative replacement for its source.
Suppose a hypothetical batch contains two hundred pages, with three relevant regions per page under the chosen annotation rule. The reference set has 200 × 3 = 600 regions. If extraction preserves five hundred and forty of them in usable form, region coverage is 540 / 600 = 0.90 = 90%. That calculation says nothing yet about whether retrieval finds the right preserved region or whether generation uses it correctly.
Now suppose retrieval receives one hundred reference questions and finds adequate current evidence for eighty. Its evidence-coverage fraction is 80 / 100 = 80% for that set. It would be wrong to multiply the region percentage by this question percentage and label the product an observed answer-success rate: the denominators describe different units and the stages need not fail independently. Evaluate accepted answers on the actual question set as a separate outcome.
Layer 3 · Internals
A real-time voice service has media transport state, model generation state and client playback state. WebRTC handles media transport and connectivity mechanisms, but an application still decides turn boundaries, buffering and what interruption means. A cascaded speech-recognition, language-model and synthesis path has different observability points from a native speech-to-speech model; neither removes network and playback delay.
For a hypothetical latency budget of 300 milliseconds, allocating 60 to capture/transport, 40 to turn handling, 120 to first generated audio and 80 to delivery/playback sums to 60 + 40 + 120 + 80 = 300. These are proposed allocations, not a measured product capability. Barge-in must stop future generation, clear or truncate buffered audio and align conversation history with what was actually played. A model may have generated words the user never heard. Keep media timestamps and a played-until acknowledgment so the next turn does not assume an interrupted instruction was fully delivered.
Trade-offs and limits
| Approach | Provides | Requires |
|---|---|---|
| Cascaded speech pipeline | Exposes separate recognition, reasoning and synthesis stages. | Stage boundaries and buffering add latency and interruption state. |
| Native speech-to-speech | Can integrate conversational audio generation. | Playback alignment, observability and turn semantics still need explicit handling. |
Recovery decision
Hypothetical scenario: Old audio already queued at the client plays after a new turn began. Carry generation identity into the playback buffer and define its flush behavior.
No. Client buffering is a separate state machine and needs explicit interruption/version handling.
Write your design before revealing the review
Does cancelling the server request automatically retract bytes already queued for playback?
Drafts and self-review are stored only in this browser. They are separate from reading completion.
Compare your decision
No. Client buffering is a separate state machine and needs explicit interruption/version handling.
Old audio already queued at the client plays after a new turn began. Carry generation identity into the playback buffer and define its flush behavior.
Check your understanding
Does cancelling the server request automatically retract bytes already queued for playback?
No. Client buffering is a separate state machine and needs explicit interruption/version handling.
How would you recover from this failure: Old audio already queued at the client plays after a new turn began. Carry generation identity into the playback buffer and define its flush behavior.
Start with the exact boundary that failed. Assign a turn/generation identity. Stream bounded media and model output under latency budgets. Fence superseded generations when the user interrupts. Then recover evidence through the observation path: Render only the active generation. Measure capture-to-playback latency by stage. Discard old buffered output and expose incomplete turns honestly. Preserve the distinction between a confirmed state change and an unavailable response.
Which assumption in the worked calculation would a burst or concentrated tenant invalidate first?
Hypothetical path budgets are 40 ms capture, 60 ms network, 150 ms processing and 50 ms playback buffer: total 300 ms before queueing. Adding a 500 ms batching wait breaks that 300 ms target even if model execution stays unchanged. Recompute the affected resource rather than multiplying unrelated storage and network budgets by the same factor. Coordinate real-time media input, model generation and client playback. Interruption must cancel or fence obsolete generation and queued audio, not just stop displaying text.
Which component in this topology could be removed from a smaller first deployment?
Media ingress, Turn controller, Model stream, Playback buffer name responsibilities, not a requirement for separate processes. Co-locate responsibilities when their transaction, trust and capacity boundaries permit it. Assign a turn/generation identity.
What evidence must a caller have before relying on the observation path?
Render only the active generation. Measure capture-to-playback latency by stage. Discard old buffered output and expose incomplete turns honestly. No. Client buffering is a separate state machine and needs explicit interruption/version handling.
45-minute interview rubric
- 00–05: scope audio frame and conversation and playback position.
- 05–12: identify the limiting resource and derive the domain workload above, retaining units and assumptions.
- 12–28: draw conversation and playback position, numbered writes and reads.
- 28–40: challenge recovery: Track transport, model and playback state separately during interruption.
- 40–45: defend session_id placement, observations and remaining assumptions.
Go deeper
- Camera & microphone | LiveKit Documentation · Primary document · docs.livekit.io. Track transport, model and playback state separately during interruption. Verified 2026-10-26.
Decision log
Track transport, model and playback state separately during interruption.
Preserve audio frame identity and conversation and playback position ownership.
Revisit changed workload, observations or recovery objectives.