Qwen-Audio-3.0-ASR-Flash-Streaming/Fun-ASR-Realtime real-time speech recognition server-side events

更新时间:
复制 MD 格式

The Qwen-Audio-3.0-ASR-Flash-Streaming/Fun-ASR-Realtime real-time speech recognition service pushes server-side events to the client over WebSocket. This topic describes the data structures and field descriptions of the four event types: task-started, result-generated, task-finished, and task-failed.

User guide: For model descriptions and selection guidance, see Speech-to-text.

Event interaction flow: To understand the event interaction sequence, see WebSocket API.

task-started

Description: The task has started successfully. The client can begin sending audio data.

header object

Properties

task_id string

The task ID generated by the client (in UUID format).

event string

The event type. This value is always task-started.

attributes object

Additional attributes. This value is usually empty.

{
    "header": {
        "task_id": "2bf83b9a-baeb-4fda-8d9a-xxxxxxxxxxxx",
        "event": "task-started",
        "attributes": {}
    },
    "payload": {}
}

payload object

This value is always {}.

result-generated

Description: The recognition result. It includes intermediate results (sentence_end=false) and final results (sentence_end=true).

header object

Properties

task_id string

The task ID generated by the client (in UUID format).

event string

The event type. This value is always result-generated.

{
  "header": {
    "task_id": "2bf83b9a-baeb-4fda-8d9a-xxxxxxxxxxxx",
    "event": "result-generated",
    "attributes": {}
  },
  "payload": {
    "output": {
      "sentence": {
        "begin_time": 170,
        "end_time": 920,
        "text": "OK, got it.",
        "heartbeat": false,
        "sentence_end": true,
        "sentence_id": 1,
        "words": [
          {
            "begin_time": 170,
            "end_time": 295,
            "text": "OK",
            "punctuation": ","
          },
          {
            "begin_time": 295,
            "end_time": 503,
            "text": "got",
            "punctuation": ""
          },
          {
            "begin_time": 503,
            "end_time": 711,
            "text": "it",
            "punctuation": ""
          },
          {
            "begin_time": 711,
            "end_time": 920,
            "text": "",
            "punctuation": "."
          }
        ]
      }
    },
    "usage": {
      "duration": 3
    }
  }
}

payload object

Properties

output object

Properties

usage object

When payload.output.sentence.sentence_end is false (the current sentence has not ended), usage is null.

When payload.output.sentence.sentence_end is true (the current sentence has ended), usage.duration is the billed duration of the current task.

Properties

duration integer

The billed task duration, in seconds.

Properties

sentence object

Properties

begin_time integer

The start time of the sentence, in milliseconds.

end_time integer

The end time of the sentence, in milliseconds.

text string

The recognized text.

heartbeat boolean

If this value is true, the result is a heartbeat packet and can be ignored.

sentence_end boolean

Whether the sentence has ended (true = final result, false = intermediate result).

sentence_id integer

The 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.

words array[object]

Word-level timestamp information.

Properties

begin_time integer

The start time of the word, in milliseconds.

end_time integer

The end time of the word, in milliseconds.

text string

The recognized text.

punctuation string

The punctuation mark.

task-finished

Description: The task has ended normally. You can close the connection or reuse it.

header object

Properties

task_id string

The task ID generated by the client (in UUID format).

event string

The event type. This value is always task-finished.

attributes object

Additional attributes. This value is usually empty.

{
    "header": {
        "task_id": "2bf83b9a-baeb-4fda-8d9a-xxxxxxxxxxxx",
        "event": "task-finished",
        "attributes": {}
    },
    "payload": {
        "output": {},
        "usage": null
    }
}

payload object

You can ignore this field. This value is usually {}.

task-failed

Description: The task has failed. The connection is closed and cannot be reused.

header object

Properties

task_id string

The task ID generated by the client (in UUID format).

event string

The event type. This value is always task-failed.

error_code string

A description of the error type.

error_message string

The specific cause of the error.

attributes object

Additional attributes. This value is usually empty.

{
    "header": {
        "task_id": "2bf83b9a-baeb-4fda-8d9a-xxxxxxxxxxxx",
        "event": "task-failed",
        "error_code": "CLIENT_ERROR",
        "error_message": "request timeout after 23 seconds.",
        "attributes": {}
    },
    "payload": {}
}

payload object

This value is always {}.