Skip to main content

Qwen-Audio-ASR-Streaming real-time speech recognition server-side events

The Qwen-Audio-ASR-Streaming 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.

task-started

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

Properties

task_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 {}.
{
    "header": {
        "task_id": "2bf83b9a-baeb-4fda-8d9a-xxxxxxxxxxxx",
        "event": "task-started",
        "attributes": {}
    },
    "payload": {}
}

result-generated

The recognition result. It includes intermediate results (sentence_end=false) and final results (sentence_end=true). The first intermediate result for a new sentence includes sentence_begin=true.
headerobject

Properties

task_idstringThe task ID generated by the client (in UUID format).eventstringThe event type. This value is always result-generated.
payloadobject

Properties

outputobject

Properties

sentenceobject

Properties

begin_timeintegerThe start time of the sentence, in milliseconds.end_timeintegerThe end time of the sentence, in milliseconds.textstringThe recognized text.heartbeatbooleanIf this value is true, the result is a heartbeat packet and can be ignored.sentence_beginbooleanIndicates the start of a sentence.sentence_endbooleanWhether the sentence has ended (true = final result, false = intermediate result).sentence_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.wordsarray[object]Word-level timestamp information.

Properties

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.

Properties

input_tokensintegerCumulative input tokens.
Applies to qwen-audio-3.1-asr-flash-streaming.
output_tokensintegerCumulative output tokens.
Applies to qwen-audio-3.1-asr-flash-streaming.
total_tokensintegerTotal cumulative tokens, equal to the sum of input and output tokens.
Applies to qwen-audio-3.1-asr-flash-streaming.
durationintegerCumulative audio duration, in seconds.
Used for billing for qwen-audio-3.0-asr-flash-streaming.
Sentence-start result:
{
  "header": {
    "task_id": "2bf83b9a-baeb-4fda-8d9a-xxxxxxxxxxxx",
    "event": "result-generated",
    "attributes": {}
  },
  "payload": {
    "output": {
      "sentence": {
        "begin_time": 0,
        "end_time": null,
        "text": "",
        "sentence_begin": true,
        "sentence_end": false,
        "sentence_id": 1,
        "words": []
      }
    }
  }
}
Final result:
{
  "header": {
    "task_id": "2bf83b9a-baeb-4fda-8d9a-xxxxxxxxxxxx",
    "event": "result-generated",
    "attributes": {}
  },
  "payload": {
    "output": {
      "sentence": {
        "sentence_id": 1,
        "begin_time": 160,
        "end_time": 1640,
        "text": "欢迎使用阿里云。",
        "channel_id": 0,
        "speaker_id": null,
        "sentence_end": true,
        "words": [
          {
            "begin_time": 160,
            "end_time": 520,
            "text": "欢迎",
            "punctuation": "",
            "fixed": true,
            "speaker_id": null
          },
          {
            "begin_time": 520,
            "end_time": 880,
            "text": "使用",
            "punctuation": "",
            "fixed": true,
            "speaker_id": null
          },
          {
            "begin_time": 880,
            "end_time": 1640,
            "text": "阿里云",
            "punctuation": "。",
            "fixed": true,
            "speaker_id": null
          }
        ],
        "stash": {
          "sentence_id": 2,
          "text": "",
          "begin_time": 1640,
          "current_time": 1640,
          "words": []
        }
      },
      "text": "欢迎使用阿里云。",
      "request_id": "95372ce8e6704bcc8747da94789c15ca",
      "output": {
        "sentence": {
          "sentence_id": 1,
          "begin_time": 160,
          "end_time": 1640,
          "text": "欢迎使用阿里云。",
          "channel_id": 0,
          "speaker_id": null,
          "sentence_end": true,
          "words": [
            {
              "begin_time": 160,
              "end_time": 520,
              "text": "欢迎",
              "punctuation": "",
              "fixed": true,
              "speaker_id": null
            },
            {
              "begin_time": 520,
              "end_time": 880,
              "text": "使用",
              "punctuation": "",
              "fixed": true,
              "speaker_id": null
            },
            {
              "begin_time": 880,
              "end_time": 1640,
              "text": "阿里云",
              "punctuation": "。",
              "fixed": true,
              "speaker_id": null
            }
          ],
          "stash": {
            "sentence_id": 2,
            "text": "",
            "begin_time": 1640,
            "current_time": 1640,
            "words": []
          }
        },
        "text": "欢迎使用阿里云。",
        "request_id": "95372ce8e6704bcc8747da94789c15ca"
      },
      "usage": {
        "duration": 2,
        "input_tokens": 85,
        "output_tokens": 4,
        "total_tokens": 89
      }
    },
    "usage": {
      "duration": 2,
      "input_tokens": 85,
      "output_tokens": 4,
      "total_tokens": 89
    }
  }
}

task-finished

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

Properties

task_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.
payload.usageobjectCumulative usage at the end of the task. The fields have the same meanings as in result-generated.usage.
{
  "header": {
    "task_id": "2bf83b9a-baeb-4fda-8d9a-xxxxxxxxxxxx",
    "event": "task-finished",
    "attributes": {}
  },
  "payload": {
    "output": {},
    "usage": {
      "duration": 9,
      "input_tokens": 365,
      "output_tokens": 12,
      "total_tokens": 377
    }
  }
}

task-failed

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

Properties

task_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 {}.
{
    "header": {
        "task_id": "2bf83b9a-baeb-4fda-8d9a-xxxxxxxxxxxx",
        "event": "task-failed",
        "error_code": "CLIENT_ERROR",
        "error_message": "request timeout after 23 seconds.",
        "attributes": {}
    },
    "payload": {}
}
Text Generation
Image Generation
Video Generation
World models
Audio
Realtime API
Text Embedding
Decision Model
TokenPlan
Model Production