> ## Documentation Index
> Fetch the complete documentation index at: https://docs.modelstudio.console.alibabacloud.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Fun-ASR-Realtime real-time speech recognition server-side events

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

## task-started <span id="eac316aeacafj" /> <span id="f4dda31ab9d0q" />

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

<table bordertype="no-border" style={{ display: "table", tableLayout: "fixed", width: "100%", overflowWrap: "anywhere" }}>
  <colgroup>
    <col style={{ width: "50%" }} />

    <col style={{ width: "50%" }} />
  </colgroup>

  <tbody>
    <tr>
      <td style={{ verticalAlign: "top" }}>
        <strong>header</strong>`object`

        <Accordion title="Properties" defaultOpen>
          <strong>task\_id</strong>`string`

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

          <strong>event</strong>`string`

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

          <strong>attributes</strong>`object`

          Additional attributes. This value is usually empty.
        </Accordion>

        <strong>payload</strong>`object`

        This value is always `{}`.
      </td>

      <td style={{ verticalAlign: "top" }}>
        ```json
        {
            "header": {
                "task_id": "2bf83b9a-baeb-4fda-8d9a-xxxxxxxxxxxx",
                "event": "task-started",
                "attributes": {}
            },
            "payload": {}
        }
        ```
      </td>
    </tr>
  </tbody>
</table>

## result-generated <span id="9cb9c5831c7cs" /> <span id="18904c22aa3an" />

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.

<table bordertype="no-border" style={{ display: "table", tableLayout: "fixed", width: "100%", overflowWrap: "anywhere" }}>
  <colgroup>
    <col style={{ width: "50%" }} />

    <col style={{ width: "50%" }} />
  </colgroup>

  <tbody>
    <tr>
      <td style={{ verticalAlign: "top" }}>
        <strong>header</strong>`object`

        <Accordion title="Properties" defaultOpen>
          <strong>task\_id</strong>`string`

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

          <strong>event</strong>`string`

          The event type. This value is always `result-generated`.
        </Accordion>

        <strong>payload</strong>`object`

        <Accordion title="Properties" defaultOpen>
          <strong>output</strong>`object`

          <Accordion title="Properties" defaultOpen>
            <strong>sentence</strong>`object`

            <Accordion title="Properties" defaultOpen>
              <strong>begin\_time</strong>`integer`

              The start time of the sentence, in milliseconds.

              <strong>end\_time</strong>`integer`

              The end time of the sentence, in milliseconds.

              <strong>text</strong>`string`

              The recognized text.

              <strong>heartbeat</strong>`boolean`

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

              <strong>sentence\_begin</strong>`boolean`

              Indicates the start of a sentence.

              <strong>sentence\_end</strong>`boolean`

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

              <strong>sentence\_id</strong>`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.

              <strong>words</strong>`array[object]`

              Word-level timestamp information.

              <Accordion title="Properties" defaultOpen>
                <strong>begin\_time</strong>`integer`

                The start time of the word, in milliseconds.

                <strong>end\_time</strong>`integer`

                The end time of the word, in milliseconds.

                <strong>text</strong>`string`

                The recognized text.

                <strong>punctuation</strong>`string`

                The punctuation mark.
              </Accordion>
            </Accordion>
          </Accordion>

          <strong>usage</strong>`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.

          <Accordion title="Properties" defaultOpen>
            <strong>duration</strong>`integer`

            The billed task duration, in seconds.
          </Accordion>
        </Accordion>
      </td>

      <td style={{ verticalAlign: "top" }}>
        <strong>Sentence-start result:</strong>

        ```json expandable
        {
          "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": []
              }
            },
            "usage": null
          }
        }
        ```

        <strong>Final result:</strong>

        ```json expandable
        {
          "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
            }
          }
        }
        ```
      </td>
    </tr>
  </tbody>
</table>

## task-finished <span id="b8aefe8e0c5fr" /> <span id="dd87ec8b02c6i" />

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

<table bordertype="no-border" style={{ display: "table", tableLayout: "fixed", width: "100%", overflowWrap: "anywhere" }}>
  <colgroup>
    <col style={{ width: "50%" }} />

    <col style={{ width: "50%" }} />
  </colgroup>

  <tbody>
    <tr>
      <td style={{ verticalAlign: "top" }}>
        <strong>header</strong>`object`

        <Accordion title="Properties" defaultOpen>
          <strong>task\_id</strong>`string`

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

          <strong>event</strong>`string`

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

          <strong>attributes</strong>`object`

          Additional attributes. This value is usually empty.
        </Accordion>

        <strong>payload</strong>`object`

        You can ignore this field. This value is usually `{}`.
      </td>

      <td style={{ verticalAlign: "top" }}>
        ```json expandable
        {
            "header": {
                "task_id": "2bf83b9a-baeb-4fda-8d9a-xxxxxxxxxxxx",
                "event": "task-finished",
                "attributes": {}
            },
            "payload": {
                "output": {},
                "usage": null
            }
        }
        ```
      </td>
    </tr>
  </tbody>
</table>

## task-failed <span id="3fb17b3b199fy" /> <span id="2168ca99e126a" />

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

<table bordertype="no-border" style={{ display: "table", tableLayout: "fixed", width: "100%", overflowWrap: "anywhere" }}>
  <colgroup>
    <col style={{ width: "50%" }} />

    <col style={{ width: "50%" }} />
  </colgroup>

  <tbody>
    <tr>
      <td style={{ verticalAlign: "top" }}>
        <strong>header</strong>`object`

        <Accordion title="Properties" defaultOpen>
          <strong>task\_id</strong>`string`

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

          <strong>event</strong>`string`

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

          <strong>error\_code</strong>`string`

          A description of the error type.

          <strong>error\_message</strong>`string`

          The specific cause of the error.

          <strong>attributes</strong>`object`

          Additional attributes. This value is usually empty.
        </Accordion>

        <strong>payload</strong>`object`

        This value is always `{}`.
      </td>

      <td style={{ verticalAlign: "top" }}>
        ```json expandable
        {
            "header": {
                "task_id": "2bf83b9a-baeb-4fda-8d9a-xxxxxxxxxxxx",
                "event": "task-failed",
                "error_code": "CLIENT_ERROR",
                "error_message": "request timeout after 23 seconds.",
                "attributes": {}
            },
            "payload": {}
        }
        ```
      </td>
    </tr>
  </tbody>
</table>
