audio_format is omitted, the
server streams raw pcm int16 little-endian @ 24 khz mono as binary frames,
then a terminal {"type":"done"} json text frame.
1
mint a session
POST /v1/tts/ws-connect returns { ws_url, token }.2
connect and send
connect to
ws_url?token=<token> and send one json synthesis frame.3
collect pcm
read binary pcm chunks until the
done (or error) control frame.choose an audio format
addaudio_format to the post /v1/tts/ws-connect body to stream opus, pcm,
mulaw, alaw, or mp3. the format is fixed for that one-shot session, so do
not repeat it in the synthesis frame. always connect to the returned ws_url.
curl
interruption (barge-in)
for a live “call with ai”, keep the websocket open for the whole call and send a new{"text": "..."} frame for each thing the agent says. if the caller talks over
the agent, just send the next utterance: a new text frame while one is still
generating interrupts the current one and starts the new one. this is
“latest-wins”, there is no special barge-in frame.
frames
once connected, the session is a two-way stream of json text frames and binary audio. client → server
server → client
on a barge-in you receive
{"type": "cancelled", "reason": "interrupt"} for the old
request, then the audio chunks and done for the new one. the old audio stops
almost immediately.
behavior
- latest-wins: only the newest utterance is held. a burst of requests during one generation never queues a backlog of now-stale audio, only the latest runs next.
- immediate stop: on interrupt or cancel the old audio stops streaming right away, so the caller stops hearing it within a couple hundred milliseconds (mostly network round-trip).
example
python
silk mulberry 1.6
mulberry-1.6 streams exactly like mulberry: mint the session with
"model": "mulberry-1.6", then send the same frames. barge-in, cancel and
close work the same way.
speakerisira,aisha,siyaorzoya, and defaults toira.descriptionis optional:style, accent, pace. see the prompting guide.- send one complete sentence or utterance per
textframe, as soon as it’s ready. <laugh>,<chuckle>and<sigh>intextare performed; any other<tag>marker is removed before synthesis.- a line too long to finish ends with an
errorframe, codeGENERATION_TOO_LONG, instead of cut-off audio, and isn’t charged. any other failure isGENERATION_ERROR.
python
done frame carries type, finished, ttft_ms, ttfa_ms,
total_tokens, frames, chunks, gen_time_ms, duration_s,
audio_duration_ms, request_id and credits_used.