output_modalities: ["text"] in your session.update. The reply then streams as response.output_text.delta, with no audio events, and you send it to the text-to-speech provider of your choice.
Full code on GitHub
A Python agent that speaks each reply through ElevenLabs as it streams, with every section of this page in code.
When to use your own text-to-speech
The server’s voice needs no wiring. Audio arrives asresponse.output_audio.delta at the pace it plays, the words arrive as response.output_audio_transcript.delta, and the server tracks playback itself, so barge-in and conversation history follow what the caller heard. Pick a voice with audio.output.voice, a Cartesia voice id. Dialog-RSN-1 can also write Cartesia’s non-speech tags, such as [laughter], and the server’s voice performs them. The response style recipes show how to ask for them.
Use your own text-to-speech when you want:
- a voice or vendor other than Cartesia,
- control over playback, such as your own buffering or audio pipeline,
- the reply as text first, so you can log it or run your own guardrails over it before a caller hears it.
Stream each delta to TTS
response.output_text.delta arrives while the model is still writing the reply. Push each delta to a streaming TTS context as it arrives, and the voice starts speaking before the reply is finished. Waiting for response.output_text.done adds the whole generation to the caller’s silence.
pseudocode
Open one TTS context per response
Open one TTS streaming context perresponse_id, and start it on response.created. A barge-in can cancel a response mid-stream, and a context per response means a canceled reply’s audio can’t leak into the next one.
When the model calls a tool that looks slow, such as an API lookup, it says a short line too, like “let me check that”. That line arrives as the response’s text and goes through the same context.
Stop speaking on barge-in
When the caller talks over a reply, Dialog-RSN-1 checks that the sound is the caller and then sendsinput_audio_buffer.speech_started. Stop the reply straight away. Stopping takes two steps:
- Cancel the TTS context for that response. Stop feeding it text so it synthesizes no more audio for that reply.
- Flush what’s already queued in the speaker. Audio synthesized before the cancellation can still be in a playback buffer, and closing the TTS context doesn’t clear it. Clear it yourself, or the caller keeps hearing the end of a reply they interrupted.
speech_started is usually the only signal you get. If the reply was still generating, response.done with status: "cancelled" follows too. Both mean the same thing, so stop only once.
With push-to-talk (turn_detection: null) nothing barges in. Send response.cancel and stop playback yourself when the caller presses the button.
Playback reports
With your own text-to-speech, only your client knows what the caller is hearing. Three client events tell the server:poly.output_audio.started, .delta and .stopped. They change two things.
- Barge-in follows your real playback. For as long as a reply is audible, Dialog-RSN-1 checks that a sound like an “mm-hm” or a cough is a real interruption before it stops the reply. Reports tell it exactly how long your reply is audible, so a backchannel late in a slow reply still gets that check.
- History keeps what the caller heard. On
stopped, the server cuts the reply in conversation history back tospoken_text, ending in a dash ifdropped_mssays it was cut off. The model’s next turn then knows exactly where the caller cut in, and doesn’t assume they heard the rest.
you send: playback reports
- Send
startedwhen the first sample of the reply plays. - Send a
deltaabout every 250 ms, withaudio_ms, the cumulative milliseconds played so far, anddelta, the text spoken since the last report. Becauseaudio_msis cumulative, a lost report leaves the count in step. - Send
stoppedwhen the reply finishes or is cut off, withaudio_ms,dropped_ms(audio synthesized but never played) andspoken_text(everything the caller heard). Always send it, even when the reply played to the end. Until it arrives, the server treats the reply as still playing. - Carry the
response_idfromresponse.createdthrough every report about that reply. A report that names a response that is no longer playing is ignored.
audio_ms. Cartesia sends word timestamps, and ElevenLabs sends character alignment when you ask for it.
Reports are optional. Without them, the server estimates playback from a typical speaking rate, and your voice’s real pace and buffering make that estimate drift. The first report you send replaces the estimate for the rest of the session, so once you start, send reports for every reply. On a session where the server speaks the reply, it tracks playback itself and ignores reports.
The API reference lists the event fields. If you evaluate your agent, send reports in your test harness exactly as your production client does.
Skip text with nothing to say
A reply can be empty, or only punctuation, once you strip tags and whitespace. Most TTS providers reject that with a 400, and if your code treats a TTS failure as fatal, that 400 ends the call. Check what’s left and skip the synthesis call when nothing is:pseudocode
Strip tags before text-to-speech
If your instructions ask for an emotion tag on each reply, strip it before the text reaches your synthesizer. Send[reassuring] Don't worry, I can get that sorted for you. straight to TTS and most providers say “reassuring” out loud before the reply.
Parse the tag where text leaves your code for TTS, and pass it as a style or voice parameter:
pseudocode
Measure time to first audio
The caller hears nothing until your speaker plays the reply’s first sample. Measure latency to that point: from the end of the caller’s turn to first audio. It includes the model, your text buffering and the round trip to your synthesizer, and the caller hears all of it as silence. Time the firstresponse.output_text.delta too. The gap between first text and first audio is your text-to-speech’s share, and if first text is fast but first audio is slow, look at your provider’s buffering and whether you open a new TTS connection for each reply. Evaluating a Dialog-RSN-1 agent defines each latency metric.
Next steps
Voice agent with Cartesia
A sample app with everything on this page: a Python server and browser page that stream each reply into Cartesia.
Response style
Instructions for spoken replies: text normalization for your voice, emotion tags and non-speech tags.
API reference
The fields of
poly.output_audio.started, .delta and .stopped.Evaluation
Time to first token, time to first audio, and how to measure the gap.

