The realtime WebSocket: the messages you send (text, flush, cancel), the audio and events you receive, and close codes.
Open a Stream
Open a WebSocket. SendAuthorization: Basic base64(<auth_id>:<auth_token>) on the upgrade request.
Arguments
No query parameters: one returns422 invalid_request naming it, and the socket doesn’t open. Options go in the first text message of each reply.
A plain GET on this URL, without a WebSocket upgrade, returns 426 with an Upgrade: websocket header.
Messages you send
All client messages are JSON text frames, up to 64 KiB.text
Your ID for this reply. A new ID opens a new reply (max 8 open per socket). Each ID can be used once per connection: opening a reply with an ID already used on the socket returns an
error event with invalid_request and param: context_id. Frames sent for a reply that has ended are ignored.language, output_format, pace, volume, pronunciations, lexicon_id, continuation, seed.
Options are fixed when the reply opens. Later text messages for the same context take only type, context_id, text and finish. Any other field, such as voice_id or pace, returns an error event with invalid_request and param naming the field.
flush
c1, including a sentence that hasn’t ended yet. The reply stays open for more text.
The reply to flush. A
context_id that isn’t open returns an error event with invalid_request.Your ID for this flush. When you send one, you get a
flush_done event with the same flush_id. Without it, no flush_done is sent.cancel
c1 at once. Leave out context_id to cancel every open reply. Each canceled reply ends with a done event whose reason is cancelled. A context_id that isn’t open is ignored.
Messages you receive
Audio (binary)
output_format of that context.
timestamps
Sent whentimestamps is on, once per sentence.
When each character starts, in milliseconds from the start of the reply’s audio. Times keep counting across events: the next sentence’s first character starts where this one ends.
How long each character lasts, in milliseconds. Several characters can share one start time with a duration of
0.flush_done
Sent after aflush that carried a flush_id, once the text up to that flush has been generated.
done
Sent once per reply when it ends: after its last audio frame, or when you cancel it.Billed characters: all the text the reply received, including text not spoken because of a cancel.
warning
A non-fatal problem.error
error event doesn’t close the socket. It affects only the reply named in context_id, and other replies keep playing. context_id is left out when the error isn’t about one reply, for example a frame that isn’t a JSON object or an unknown type. See Errors for codes.
Close codes
A client that stops reading for 30 s is dropped.