Server event reference for Qwen-Audio-ASR-Message: task startup, recognition results, completion, failure, and corresponding requests.
Event flow
- Send run-task. Wait for task-started before sending audio.
- Continue sending audio while receiving result-generated events.
- During the task, use continue-task to update the conversation context. Continue sending audio through the audio channel.
- After sending all audio, send finish-task and receive results until task-finished arrives. A failed task returns task-failed.
run-task: WebSocket uses binary frames, and AOQ uses an Audio Track. For connection setup, authentication, and audio transport, see WebSocket API or AOQ access.
task-started
Indicates that the task has started successfully and the client can begin sending audio.
headerobjecttask_idstringThe task ID generated by the client (in UUID format).
eventstringThe event type. This value is always
task-started.attributesobjectAdditional attributes. This value is usually empty.
payloadobjectThis value is always
{}.Request:
Response:
result-generated
Returns recognition results, including sentence starts, intermediate results, final sentence results, and heartbeats. Intermediate results are disabled by default; set intermediate_result_enabled=true to enable them.
headerobjecttask_idstringThe task ID generated by the client (in UUID format).
eventstringThe event type. This value is always
result-generated.payloadobjectoutputobjectsentenceobjectsentence_idintegerThe sequence identifier of the sentence. In normal recognition results,
sentence_id increments from 1. When heartbeat is true (that is, a heartbeat packet), sentence_id is always 0.begin_timeintegerThe start time of the sentence, in milliseconds.
end_timeintegerThe end time of the sentence, in milliseconds.May be
null in intermediate results or heartbeats.textstringThe recognized text.
Intermediate text can change as recognition progresses. Update the displayed text for the same
sentence_id instead of concatenating intermediate text.sentence_beginbooleanA value of
true indicates the start of a sentence. The text field may be empty at this point.sentence_endbooleanWhether the sentence has ended (
true = final result, false = intermediate result).heartbeatbooleanIf this value is
true, the result is a heartbeat packet and can be ignored.wordsarray[object]Word-level timestamp information.
begin_timeintegerThe start time of the word, in milliseconds.
end_timeintegerThe end time of the word, in milliseconds.
textstringThe recognized text.
punctuationstringThe punctuation mark.
usageobjectCumulative usage for the current task as of this event.
usage contains cumulative usage for the current task. Do not add usage values across events. After the task completes, use the final cumulative usage in task-finished.durationintegerCumulative audio duration in seconds, retained for compatibility.
input_tokensintegerCumulative number of input tokens.
output_tokensintegerCumulative number of output tokens.
total_tokensintegerCumulative total number of tokens: the sum of
input_tokens and output_tokens.- Sentence start
- Intermediate result
- Final sentence result
Request:
Response:
task-finished
Task processing is complete and all recognition results have been returned. The client can close the connection or reuse it to start a new task.
headerobjecttask_idstringThe task ID generated by the client (in UUID format).
eventstringThe event type. This value is always
task-finished.attributesobjectAdditional attributes. This value is usually empty.
payloadobjectContains
output (an empty object) and usage (the final cumulative usage for this task). The usage fields have the same definitions as in result-generated.Request:
Response:
task-failed
Indicates that the task failed. Check error_code and error_message for the cause. After a task fails, the WebSocket connection is closed and cannot be reused.
headerobjecttask_idstringThe task ID generated by the client (in UUID format).
eventstringThe event type. This value is always
task-failed.error_codestringA description of the error type.
error_messagestringThe specific cause of the error.
attributesobjectAdditional attributes. This value is usually empty.
payloadobjectThis value is always
{}.This request uses an unsupported audio format to demonstrate
task-failed. The error code and message depend on the cause of failure.Request:
Response: