WSS wss://api.async.ai/text_to_speech/websocket/ws
| Name | Type | Required | Description |
|---|---|---|---|
api_key | string | Yes | Your Async API key. |
version | string | Yes | API version (e.g., v1). |
initializeConnection (required)| Property | Type | Required | Description |
|---|---|---|---|
model_id | string | Yes | Model ID (e.g. "asyncflow_multilingual_v1.0.0"). |
voice | object | Yes | Dictionary with keys mode and id.Example: { "mode": "id", "id": "e0f39dc4-f691-4e78-bba5-5c636692cc04" } |
output_format | object | No | Audio output settings (default): { "container": "raw", "encoding": "pcm_s16le", "sample_rate": 44100 }. |
π‘ See Text-to-Speech (Stream) for detailed parameter descriptions.
initializeContext (optional, for Multi-Context mode)context_id is not provided, the default context is used.| Property | Type | Required | Description |
|---|---|---|---|
context_id | string | No | Unique uuid identifier for the context. If omitted, default context is used. |
transcript | string | Yes | The initial text input for this context. Always ends with a single space. |
sendText (required)| Property | Type | Required | Description |
|---|---|---|---|
context_id | string | No | Target context for this text chunk. If omitted, default context is used. |
transcript | string | Yes | The new text chunk β always ends with a single space. |
force | boolean | No | Force immediate synthesis even if the buffer is small (default: false). |
closeContext (optional)| Property | Type | Required | Description |
|---|---|---|---|
context_id | string | Yes | Context to close. |
close_context | boolean | Yes | Always true. |
transcript | string | Yes | Must be an empty string (""). |
closeConnection (optional)| Property | Type | Required | Description |
|---|---|---|---|
text | string | Yes | Empty string to close connection. |
| Property | Type | Required | Description |
|---|---|---|---|
terminate | boolean | Yes | Always true |
audioOutput (streamed)| Field | Type | Required | Description |
|---|---|---|---|
context_id | string | Yes | ID of the context this audio chunk belongs to. |
audio | string | Yes | Base-64 encoded audio data. |
final | boolean | Yes | true if this is the final chunk for this context; otherwise false. |
finalOutput| Field | Type | Required | Description |
|---|---|---|---|
context_id | string | Yes | ID of the completed context. |
audio | string | Yes | Always an empty string "". |
final | boolean | Yes | Always true. Marks completion of synthesis for this context. |
error (optional)| Field | Type | Required | Description |
|---|---|---|---|
error_code | string | Yes | Error type identifier. |
message | string | Yes | Human-readable explanation. |
extra | object | No | Additional error details. |
/text_to_speech/websocket/ws{"model_id": "asyncflow_multilingual_v1.0",...{
"model_id": "asyncflow_multilingual_v1.0",
"voice": {
"mode": "id",
"id": "e0f39dc4-f691-4e78-bba5-5c636692cc04"
},
"output_format": {
"container": "raw",
"encoding": "pcm_f32le",
"sample_rate": 44100
}
}{"context_id": "e1bb2844-fed4-418b-832c-8126db5a21e9",...{
"context_id": "e1bb2844-fed4-418b-832c-8126db5a21e9",
"transcript": "Welcome to Async. "
}{
"context_id": "9f6bb19c-4616-4fbc-9d0f-f14a460eac01",
"transcript": "This is a parallel narration. "
}{"context_id":"e1bb2844-fed4-418b-832c-8126db5a21e9",...}{ "context_id": "e1bb2844-fed4-418b-832c-8126db5a21e9", "transcript": "Let's continue with our main topic. " }{"context_id":"e1bb2844-fed4-418b-832c-8126db5a21e9",...}{
"context_id": "e1bb2844-fed4-418b-832c-8126db5a21e9",
"audio": "Y3VyaW91cyBtaW5kcyB0aGluayBhbGlrZSA6KQ==",
"final": false
}{"context_id":"e1bb2844-fed4-418b-832c-8126db5a21e9",...}{
"context_id": "e1bb2844-fed4-418b-832c-8126db5a21e9",
"audio": "",
"final": true
}{"context_id":"9f6bb19c-4616-4fbc-9d0f-f14a460eac01",...}{
"context_id": "9f6bb19c-4616-4fbc-9d0f-f14a460eac01",
"close_context": true,
"transcript": ""
}{ "terminate": true }{ "terminate": true }context_id β maintains an independent state.terminate message can be used to gracefully close the entire WebSocket connection.