The Voice Agent Stack on SIP: Bridges, Turn Detection and a Sourced Latency Budget
The Voice Agent Stack on SIP: Bridges, Turn Detection and a Sourced Latency Budget
The problem
A voice agent on the phone feels slow long before any single part of it is slow. The caller stops talking, and then a chain of small waits adds up: audio crossing the phone network, a buffer smoothing out late packets, a detector deciding the caller has really finished, speech-to-text producing a final transcript, the language model producing its first words, text-to-speech producing the first audio, and the phone network carrying that audio back.
Most published "latency" numbers cover one link in that chain, measured in one vendor's setup. If you add them up carelessly you get a figure nobody can defend. This post does two things. It lays out the parts of a SIP-connected agent and what the official docs of LiveKit, Pipecat, Asterisk and Jambonz say about each one. Then it builds a latency budget only from published numbers, labelled as an estimate, with the gaps left visibly empty.
This is part 5 of the Voice AI over SIP series. If a term is new to you, the glossary defines it in plain language and links to the part that covers it.
The layers, from carrier to model
textCaller -> PSTN -> SIP trunk -> [SBC / SIP server] -> [media bridge] -> VAD + turn detection -> STT -> LLM -> TTS <- audio back the same way <-
flowchart TD A[Caller on a phone] --> B[PSTN: the phone network] B --> C[Carrier PSTN gateway] C -->|SIP trunk: SIP + RTP| D[SBC at your network edge] D --> E[Asterisk or LiveKit SIP] E -->|RTP to audio frames| F[Media bridge] F --> G[VAD + turn detection] G --> H[STT] H --> I[LLM] I --> J[TTS] J -->|audio back the same way| F
Diagram: The path of a call: phone network, carrier gateway, SIP trunk, SBC, Asterisk or LiveKit SIP, bridge, then the agent.
1. SBC or SIP server
An SBC (session border controller) sits at the edge of your network and terminates SIP and RTP from the carrier. RFC 4961 lists SBCs among the RTP relays that need "symmetric RTP" (sending and receiving on the same port) to work across NAT. In practice this layer is a dedicated SBC, a SIP server such as Asterisk, or the SIP service built into a realtime framework. Its jobs: authenticate the trunk, pick the codec in SDP, and hand clean audio to the next layer. How SIP and SDP work is covered in part 4, how a phone call reaches an AI voice agent.
2. The media bridge
This is the piece that turns RTP packets on a phone call into audio frames your agent code can read and write. The official options differ mainly in transport and audio format.
| Bridge | Transport to your code | Audio format (from the docs) | Barge-in hook |
|---|---|---|---|
| LiveKit SIP | LiveKit's own SIP service (see the setup post) | Default SIP codecs PCMU, PCMA, G722 | Not covered on the pages fetched here |
| Asterisk ARI External Media | RTP over UDP, AudioSocket over TCP, or WebSocket | format is a required parameter | Your app decides what audio to send |
| Asterisk AudioSocket | TCP with a 3-byte header per message | 16-bit 8 kHz mono PCM from the dialplan app; protocol also defines types for 12 kHz to 192 kHz | Your app decides what audio to send |
Jambonz listen verb | WebSocket, binary frames | Linear16 PCM at 8000, 16000, 24000, 48000 or 64000 Hz | killAudio command |
| Pipecat with Twilio Media Streams | WebSocket via the Twilio serializer | 8 kHz mu-law, converted to and from PCM | Interruptions on by default |
Some details worth knowing, each from the project's own docs:
LiveKit SIP. The codec page says LiveKit ranks G722 first, then PCMU, then PCMA, and picks its highest-ranked codec present in the offer. An INVITE without SDP gets 400 Bad Request unless delayed offer has been enabled on request. The inbound trunk page warns against creating a trunk per call, because changes take a few seconds to propagate. A full setup walkthrough is in LiveKit SIP trunk voice agent setup.
Asterisk ARI External Media. The Asterisk 20 Channels REST API documents POST /channels/externalMedia, available since 16.6.0 and 17.1.0. The combination of transport and encapsulation picks the channel driver: udp plus rtp gives chan_rtp, tcp plus audiosocket gives chan_audiosocket, and websocket plus none gives chan_websocket. app and format are required; payload_type (96 to 127) applies to RTP only. The same API has GET /channels/{channelId}/rtp_statistics (since 13.27.0 and 16.4.0), which is handy for monitoring. Config and CLI details are in the Asterisk reference chart.
Asterisk AudioSocket. The protocol page defines a tiny framing: one byte of type, two bytes of big-endian length, then payload. Type 0x01 carries the call's 16-byte UUID, 0x03 a DTMF digit, 0x10 signed linear 16-bit 8 kHz mono audio, and 0x00 hangup. The dialplan application (since Asterisk 18.0.0) does not answer the call itself, so the docs say to put Answer() or Progress() before it. The documented syntax:
text; Syntax as given in the Asterisk 21 AudioSocket application docs (not run here) AudioSocket(uuid,service) ; uuid : a UUID in standard form, sent to your server as the 0x01 message ; service : host:port of your AudioSocket server ; The app does not answer the call, so run Answer() or Progress() before it
Jambonz listen. The verb streams linear16 PCM in binary WebSocket frames. The first text frame carries metadata such as callSid, sampleRate and mixType. With bidirectionalAudio enabled, your server can stream audio back, and the doc recommends 320-byte frames at 8 kHz and 640-byte frames at 16 kHz. Both work out to 20 ms of 16-bit audio (my arithmetic: 8000 x 0.020 x 2 bytes = 320). The killAudio command flushes audio that is playing or buffered, which is exactly what barge-in needs. The doc's own example:
javascript// From the jambonz listen verb docs (updated 2026-11-05) { verb: 'listen', sampleRate: 8000, bidirectionalAudio: { enabled: true, streaming: true, sampleRate: 16000 } }
Pipecat. The Twilio serializer page says Twilio Media Streams uses 8 kHz mu-law and the serializer converts to and from PCM. audio_in_sample_rate and audio_out_sample_rate default to 8000, and the older twilio_sample_rate has been deprecated since 1.16.0. DTMF arrives as InputDTMFFrame.
FreeSWITCH. I could not find an official FreeSWITCH document for an audio streaming module comparable to the ones above, so I am leaving it out of this table rather than describing a third-party module as if it were core.
3. VAD: is anyone speaking?
VAD (voice activity detection) labels each short chunk of audio as speech or not speech. Pipecat's Silero VAD docs say sample_rate must be 8000 or 16000, with 256 samples per frame at 8 kHz and 512 at 16 kHz. Defaults are confidence 0.7, start_secs 0.2, stop_secs 0.2 and min_volume 0.6. Pipecat's speech input guide says Silero processes 30+ ms chunks in under 1 ms on one CPU thread, and that local VAD is "150-200ms faster" than remote VAD services (that is, 150 to 200 ms).
stop_secs matters most for latency. It is how long the audio must stay silent before VAD reports "speech stopped". Every turn pays it.
4. Turn detection: has the caller finished?
Silence is not the same as being done. People pause mid-sentence. A turn detector looks at more context to decide whether a pause is the end of a turn.
Pipecat. The speech input guide says the default end-of-turn strategy is Smart Turn (TurnAnalyzerUserTurnStopStrategy with LocalSmartTurnAnalyzerV3). It also notes its built-in STT P99 latency figures are measured with stop_secs=0.2.
LiveKit. The turn detector docs describe two versions, v1 (served through LiveKit Inference) and v1-mini (runs locally on CPU, about 310 to 340 MB of weights). Endpointing delays default to min_delay 0.5 s and max_delay 3.0 s, and drop to 0.3 s and 2.5 s when the turn detector is enabled. If no prediction arrives within about a second, the turn is committed anyway. It supports 14 languages, including Hindi, and needs livekit-agents 1.8.12+ (Python) or @livekit/agents 1.10.0+ (Node). The docs recommend compute-optimized instances, not burstable ones.
LiveKit's blog post on Turn Detector v1.1 (20 Nov 2026) publishes vendor benchmark numbers, where "latency" means the wait after the user stops speaking, measured on its eot-bench harness. Two rows from the English results:
| Model | Wait at 10% cut-off rate, all 2,288 turns | Wait at 5% cut-off rate, all 2,288 turns |
|---|---|---|
| v1.1 | 414 ms | 810 ms |
| v1 | 632 ms | 996 ms |
| v1.1-mini | 738 ms | 1,124 ms |
| v1-mini | 922 ms | 1,352 ms |
The "cut-off rate" is how often the model wrongly decides the caller is done. Waiting longer cuts people off less. The same post gives a 13-language mean for v1.1 of 329 ms at 10% and 521 ms at 5%. These are the vendor's own benchmarks, not independent measurements.
5. Barge-in
Barge-in means the caller talks over the agent and the agent stops. Pipecat's guide says interruptions are on by default: the bot stops speaking and in-flight work is cancelled. Jambonz gives you killAudio to flush audio already queued for playback. With Asterisk External Media or AudioSocket, my reading of the docs is that the agent hears what your server sends, so stopping is your code's job. Whatever the bridge, the important part is flushing audio already buffered downstream, otherwise the caller hears the agent keep talking for a moment after it "stopped".
sequenceDiagram autonumber participant C as Caller participant B as Media bridge participant V as VAD participant A as Agent (LLM + TTS) A->>B: TTS audio frames B->>C: agent speaking C->>B: caller talks over the agent B->>V: caller audio V-->>A: speech started Note over A: cancel in-flight LLM and TTS A->>B: flush buffered audio (jambonz: killAudio) Note over B,C: Without the flush, the caller still hears the agent B-->>C: agent goes quiet
Diagram: Barge-in: the caller talks, VAD fires, the agent cancels and flushes buffered audio.
The latency budget (an estimate)
The quantity that matters to the caller is the gap between when they stop talking and when they hear the agent start. I will build it from published figures only. Where no official number was fetched for this post, the cell says so.
Animation: An estimate, not a measurement: 500 ms (Pipecat VAD) or 714 ms (LiveKit v1.1) before STT, LLM and TTS add their share.
Reference points from ITU-T G.114 (05/2003):
- For network planning, one-way delay should not exceed 400 ms.
- If mouth-to-ear delay stays below 150 ms, most applications "will experience essentially transparent interactivity".
- Appendix II says that for many intra-regional routes of 5000 km or less, VoIP users are likely to see mouth-to-ear delays under 150 ms.
- A de-jitter buffer should be planned as adding half its peak delay. G.114's example: a buffer covering 50 ms of delay variation adds 25 ms on average.
- Codec delay in IP networks with several frames per packet is at least (N + 1) x frame size + look-ahead, and at most (2N + 1) x frame size + look-ahead.
G.711 packet delay, worked from that formula (my arithmetic). G.114 Table I.3 gives G.711 0.25 ms minimum and 0.375 ms maximum with one frame per packet, which matches a 0.125 ms frame and no look-ahead in the 2 x and 3 x rule. A 20 ms packet, the RFC 3551 default, holds N = 20 / 0.125 = 160 frames. Minimum delay is 161 x 0.125 = 20.1 ms. Maximum is 321 x 0.125 = 40.1 ms.
The budget:
| Step | Figure used | Where it comes from |
|---|---|---|
| A. Caller to agent, mouth to agent's ear | up to 150 ms | G.114 Appendix II, intra-regional VoIP routes of 5000 km or less. Covers the full mouth-to-ear path, terminals included. |
| B. End-of-turn wait | 200 ms (Pipecat VAD stop_secs default) or 414 ms (LiveKit v1.1, English, 10% cut-off) | Pipecat Silero VAD docs; LiveKit blog |
| C. STT final transcript after end of turn | S, no official figure fetched | |
| D. LLM time to first token | L, no official figure fetched | |
| E. TTS time to first audio | T, no official figure fetched | |
| F. Agent to caller, mouth to ear | up to 150 ms | G.114 Appendix II, same assumption as A |
Estimate, with the math:
- With Pipecat's default VAD stop: 150 + 200 + 150 = 500 ms + S + L + T
- With LiveKit Turn Detector v1.1 at the 10% cut-off point: 150 + 414 + 150 = 714 ms + S + L + T
So before a single model has run, an estimated half a second to about three quarters of a second is already gone, assuming a well-engineered regional route. For its worst-case 27,500 km route, with 80 ms in total for the terminals and 20 ms packets, G.114 Appendix II puts the delay at just over 300 ms. Using 300 ms each way, the fixed part would be 300 + 200 + 300 = 800 ms with the Pipecat figure.
Two cautions. First, G.114 is a standard for one-way transmission delay in human conversations. It is not a target for an agent's reply time, and I am using it only for the network legs. Second, the end-of-turn figures were measured in different ways: Pipecat's 200 ms is a configured silence threshold, while LiveKit's 414 ms is a benchmark result. They are not a like-for-like comparison.
Where the fixed part can grow without you noticing
- Jitter buffers. If your bridge adds its own jitter buffer on top of the carrier's, G.114's half-peak rule applies to each one. A buffer sized for 100 ms of variation would add about 50 ms on average by that rule.
- Big audio chunks to STT. Google's STT best practices recommend 100 ms streaming frames. My reading: if you collect 100 ms before sending, the first sample in each chunk waits up to 100 ms extra. Smaller chunks reduce that wait but cost more messages.
- Packetization above 20 ms. RFC 3551 lets receivers accept up to 200 ms per packet. Using G.114's formula, every extra frame per packet adds delay. Check the
a=ptimeline in SDP. - Resampling and transcoding. Each format change in the bridge is a buffer. G.711 in, PCM 16 kHz to STT, TTS out at 24 kHz, back to G.711 is three conversions.
- Turn commit fallback. LiveKit commits the turn after about a second with no prediction. A slow or overloaded detector therefore shows up as about one-second gaps, which is why the docs warn against burstable instances.
What I would measure first
My opinion, not a measured result: I would log five timestamps per turn (VAD stop, final transcript, first LLM token, first TTS byte, first RTP packet sent back) and fill S, L and T in that table with your own numbers. The fixed network part is the one you can estimate from standards; the model part is the one you can only measure.
How this connects to the rest of the series
The SIP and codec basics are in part 4, how a phone call reaches an AI voice agent. When calls connect but audio goes one way, see SIP voice AI production reliability and one-way audio. Rejected calls are decoded in the SIP response code chart. For what each piece costs per minute, see voice AI cost per minute, India vs US.
Sources
- ITU-T G.114 (05/2003): One-way transmission time
- RFC 3551: RTP Profile for Audio and Video Conferences
- RFC 4961: Symmetric RTP and RTCP
- LiveKit: Codecs and negotiation
- LiveKit: Inbound trunk
- LiveKit: Turn detector
- LiveKit blog: Turn Detector v1.1
- Pipecat: Speech input and turn detection
- Pipecat: Silero VAD analyzer
- Pipecat: Twilio frame serializer
- Asterisk 20: Channels REST API
- Asterisk: AudioSocket channel driver and protocol
- Asterisk 21: AudioSocket dialplan application
- jambonz: listen verb
- Google Cloud Speech-to-Text: Best practices
