Realtime Voice AI Essentials
> Realtime voice AI lets a user have a natural, low-latency spoken conversation with an AI system — think voice assistants, AI phone agents, or in-car assistants. This notebook covers how these pipelines are built, the latency constraints that shape every design decision, and where they're actually used.
What is Realtime Voice AI?
Realtime voice AI is the class of systems that hold a live, spoken, back-and-forth conversation with a user — not a "record a message, get a text reply, have it read aloud" experience, but continuous audio in, continuous audio out, with the responsiveness of a phone call.
That responsiveness is the entire engineering challenge. Human conversation tolerates roughly 200–500ms of response latency before it starts feeling unnatural; a system built by chaining a batch speech-to-text step, an LLM call, and a batch text-to-speech step will typically blow past that, because each stage waits for the previous one to fully finish.
Two Architectures
1. Cascaded (pipeline) architecture Three separate models, streaming into each other:Microphone → Speech-to-Text (streaming) → LLM (streaming) → Text-to-Speech (streaming) → Speaker
Each stage starts processing before the previous stage has fully finished — the LLM can start generating a response from partial transcript, and TTS can start speaking the first sentence while the LLM is still generating the rest. This is the more common and more controllable architecture: you can swap any component, add moderation between stages, and reuse your existing text-based LLM logic.
2. Speech-to-speech (native) architecture
A single multimodal model takes audio in and produces audio out directly, without an intermediate text transcript as a hard boundary.
Microphone → Multimodal Model (audio-in, audio-out) → Speaker
This can achieve lower latency and preserve paralinguistic information (tone, emotion, pacing) that gets lost when everything is forced through a text transcript. It's less mature and harder to instrument (there's no clean text layer to log, moderate, or fine-tune against as easily).
Core Concepts
Common Use Cases
Practical Example: A Minimal Cascaded Session (Sketch)
This illustrates the shape of a cascaded pipeline session, not a production implementation:
async def handle_voice_session(audio_stream):
async for transcript_chunk in speech_to_text_stream(audio_stream):
if is_end_of_turn(transcript_chunk):
full_utterance = transcript_buffer.finalize()
async for text_chunk in llm.stream(full_utterance):
# start speaking before the LLM has finished generating
async for audio_chunk in text_to_speech_stream(text_chunk):
await send_to_speaker(audio_chunk)
elif user_started_speaking_again():
# barge-in: stop current playback immediately
await stop_playback()
transcript_buffer.reset()
Several providers (e.g. OpenAI's Realtime API, ElevenLabs Conversational AI) now expose this entire loop — VAD, streaming STT/LLM/TTS or native speech-to-speech, and interruption handling — as a single managed API, which is usually the pragmatic starting point rather than assembling the pipeline from raw components.