User guide: For model introduction and selection recommendations, see Speech synthesis.
task-started
When the client sends the run-task command, the server returns a task-started event to indicate the task has started.
header.task_idstring The task ID generated by the client. header.eventstring The event type. Fixed value: task-started. payloadobject Empty object with no content. | {
"header": {
"task_id": "2bf83b9a-baeb-4fda-8d9a-xxxxxxxxxxxx",
"event": "task-started",
"attributes": {}
},
"payload": {}
}
|
result-generated
After the client sends text, the server streams result-generated events. Each event includes full timestamp data in output.sentence, with word-level and phoneme-level timestamps when the corresponding parameters are enabled.
header.task_idstring The task ID generated by the client. header.eventstring The event type. Fixed value: result-generated. payload.outputobject The output information. Properties sentence.begin_timeinteger The begin timestamp of the sentence. Unit: milliseconds. sentence.end_timeinteger The end timestamp of the sentence. Unit: milliseconds. sentence.wordsarray Word-level timestamps for each word in the sentence. Element properties of words textstring The text content of the word. begin_timeinteger The begin timestamp of the word in the audio. Unit: milliseconds. end_timeinteger The end timestamp of the word in the audio. Unit: milliseconds. phonemesarray(requires phoneme_timestamp_enabled) Phoneme-level timestamps for each phoneme in the word. Element properties of phonemes textstring The phoneme text. toneinteger The tone value. begin_timeinteger The begin timestamp of the phoneme. Unit: milliseconds. end_timeinteger The end timestamp of the phoneme. Unit: milliseconds. payload.usageobject Billing information. Properties charactersinteger The cumulative billed character count up to the current event. | {
"header": {
"task_id": "2bf83b9a-baeb-4fda-8d9a-xxxxxxxxxxxx",
"event": "result-generated",
"attributes": {}
},
"payload": {
"output": {
"sentence": {
"begin_time": 0,
"end_time": 1162,
"words": [
{
"text": "床",
"begin_time": 0,
"end_time": 263,
"phonemes": [
{
"begin_time": 0,
"end_time": 119,
"text": "ch_c",
"tone": 2
}
]
}
]
}
},
"usage": {
"characters": 6
}
}
}
|
task-finished
When the task is complete, the server returns a task-finished event. The client can then close the WebSocket connection or reuse the connection for a new task.
header.task_idstring The task ID generated by the client. header.eventstring The event type. Fixed value: task-finished. payload.usage.charactersinteger The cumulative billed character count up to the current event. | {
"header": {
"task_id": "2bf83b9a-baeb-4fda-8d9a-xxxxxxxxxxxx",
"event": "task-finished",
"attributes": {
"request_uuid": "0a9dba9e-d3a6-45a4-be6d-xxxxxxxxxxxx"
}
},
"payload": {
"usage": {
"characters": 13
}
}
}
|
task-failed
When a task fails, the server returns a task-failed event. Close the WebSocket connection and handle the error.
header.task_idstring The task ID generated by the client. header.eventstring The event type. Fixed value: task-failed. header.error_codestring The error code. header.error_messagestring The detailed error message. | {
"header": {
"task_id": "2bf83b9a-baeb-4fda-8d9a-xxxxxxxxxxxx",
"event": "task-failed",
"error_code": "InvalidParameter",
"error_message": "[tts:]Engine return error code: 418",
"attributes": {}
},
"payload": {}
}
|