Messages
{
"model_id": "sonic-latest",
"transcript": "Hello, world! I'm generating audio on Cartesia!",
"voice": {
"mode": "id",
"id": "a0e99841-438c-4a64-b679-ae501e7d6091"
},
"language": "en",
"context_id": "ab977222-f9e0-4563-a1c0-5a934ae8fdd6",
"output_format": {
"container": "raw",
"encoding": "pcm_s16le",
"sample_rate": 8000
},
"add_timestamps": true,
"continue": false
}{
"context_id": "50dc3b5e-5841-4aa1-9f94-60cfb9aead79",
"cancel": true
}{
"type": "chunk",
"data": "aSDinaTvuI8gbWludGxpZnk=",
"done": false,
"status_code": 206,
"step_time": 123,
"context_id": "50dc3b5e-5841-4aa1-9f94-60cfb9aead79"
}{
"type": "flush_done",
"done": false,
"flush_done": true,
"flush_id": 1,
"status_code": 206,
"context_id": "50dc3b5e-5841-4aa1-9f94-60cfb9aead79"
}{
"type": "done",
"done": true,
"status_code": 206,
"context_id": "50dc3b5e-5841-4aa1-9f94-60cfb9aead79"
}{
"type": "timestamps",
"done": false,
"status_code": 206,
"context_id": "872ec12d-bc63-4e1e-a241-4f58c879d105",
"word_timestamps": {
"words": [
"Hello",
"world"
],
"start": [
0,
0.5
],
"end": [
0.4,
0.9
]
}
}{
"type": "phoneme_timestamps",
"done": false,
"status_code": 206,
"context_id": "872ec12d-bc63-4e1e-a241-4f58c879d105",
"phoneme_timestamps": {
"phonemes": [
"h",
"ə",
"l",
"oʊ"
],
"start": [
0.093,
0.174,
0.255,
0.337
],
"end": [
0.174,
0.255,
0.337,
0.418
]
}
}{
"type": "error",
"done": true,
"error": "Invalid model: The model is not valid, make sure it is a valid model ID.",
"status_code": 400,
"context_id": "50dc3b5e-5841-4aa1-9f94-60cfb9aead79"
}TTS
Text-to-Speech (WebSocket)
Generate audio in realtime with contexts
WSS
/
tts
/
websocket
Messages
{
"model_id": "sonic-latest",
"transcript": "Hello, world! I'm generating audio on Cartesia!",
"voice": {
"mode": "id",
"id": "a0e99841-438c-4a64-b679-ae501e7d6091"
},
"language": "en",
"context_id": "ab977222-f9e0-4563-a1c0-5a934ae8fdd6",
"output_format": {
"container": "raw",
"encoding": "pcm_s16le",
"sample_rate": 8000
},
"add_timestamps": true,
"continue": false
}{
"context_id": "50dc3b5e-5841-4aa1-9f94-60cfb9aead79",
"cancel": true
}{
"type": "chunk",
"data": "aSDinaTvuI8gbWludGxpZnk=",
"done": false,
"status_code": 206,
"step_time": 123,
"context_id": "50dc3b5e-5841-4aa1-9f94-60cfb9aead79"
}{
"type": "flush_done",
"done": false,
"flush_done": true,
"flush_id": 1,
"status_code": 206,
"context_id": "50dc3b5e-5841-4aa1-9f94-60cfb9aead79"
}{
"type": "done",
"done": true,
"status_code": 206,
"context_id": "50dc3b5e-5841-4aa1-9f94-60cfb9aead79"
}{
"type": "timestamps",
"done": false,
"status_code": 206,
"context_id": "872ec12d-bc63-4e1e-a241-4f58c879d105",
"word_timestamps": {
"words": [
"Hello",
"world"
],
"start": [
0,
0.5
],
"end": [
0.4,
0.9
]
}
}{
"type": "phoneme_timestamps",
"done": false,
"status_code": 206,
"context_id": "872ec12d-bc63-4e1e-a241-4f58c879d105",
"phoneme_timestamps": {
"phonemes": [
"h",
"ə",
"l",
"oʊ"
],
"start": [
0.093,
0.174,
0.255,
0.337
],
"end": [
0.174,
0.255,
0.337,
0.418
]
}
}{
"type": "error",
"done": true,
"error": "Invalid model: The model is not valid, make sure it is a valid model ID.",
"status_code": 400,
"context_id": "50dc3b5e-5841-4aa1-9f94-60cfb9aead79"
}cartesia_version
type:string
required
API version, e.g. 2024-11-13
X-API-Key
type:httpApiKey
API key passed in a header.
access_token
type:httpApiKey
A short-lived access token passed in a query param to make API requests from a client. This is particularly useful in the browser, where WebSockets do not support headers. See Authenticate client apps to generate an access token.
Generation Request
type:object
Use this to generate speech for a transcript.
Cancel Context Request
type:object
Use this to cancel a context, so that no more messages are generated for that context.
Audio Chunk Response
type:object
Audio data chunk
Flush Done Response
type:object
Acknowledgment that flush command was received. See Context Flushing for details.
Done Response
type:object
Generation completion signal
Word Timestamps Response
type:object
Word-level timing information
Phoneme Timestamps Response
type:object
Phoneme-level timing information
Error Response
type:object
Error information for TTS WebSocket connections.
Was this page helpful?
⌘I