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
The task has started successfully. The client can begin sending audio data.
| Parameter | Type | Description |
|---|---|---|
| header | object | |
| header.task_id | string | The task ID generated by the client (in UUID format). |
| header.event | string | The event type. This value is always task-started. |
| header.attributes | object | Additional attributes. This value is usually empty. |
| payload | object | This value is always {}. |
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.
Sentence-start result:
| Parameter | Type | Description |
|---|---|---|
| header.event | string | The event type. This value is always result-generated. |
| payload | object | |
| payload.output | object | |
| payload.output.sentence | object | |
| payload.output.sentence.begin_time | integer | The start time of the sentence, in milliseconds. |
| payload.output.sentence.end_time | integer | The end time of the sentence, in milliseconds. |
| payload.output.sentence.text | string | The recognized text. |
| payload.output.sentence.heartbeat | boolean | If this value is true, the result is a heartbeat packet and can be ignored. |
| payload.output.sentence.sentence_begin | boolean | Indicates the start of a sentence. |
| payload.output.sentence.sentence_end | boolean | Whether the sentence has ended (true = final result, false = intermediate result). |
| payload.output.sentence.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. |
| payload.output.sentence.words | array[object] | Word-level timestamp information. |
| payload.output.sentence.words.begin_time | integer | The start time of the word, in milliseconds. |
| payload.output.sentence.words.end_time | integer | The end time of the word, in milliseconds. |
| payload.output.sentence.words.text | string | The recognized text. |
| payload.output.sentence.words.punctuation | string | The punctuation mark. |
| payload.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. |
| payload.usage.duration | integer | The billed task duration, in seconds. |
task-finished
The task has ended normally. You can close the connection or reuse it.
| Parameter | Type | Description |
|---|---|---|
| header.event | string | The event type. This value is always task-finished. |
| payload | object | You can ignore this field. This value is usually {}. |
task-failed
The task has failed. The connection is closed and cannot be reused.
| Parameter | Type | Description |
|---|---|---|
| header.event | string | The event type. This value is always task-failed. |
| header.error_code | string | A description of the error type. |
| header.error_message | string | The specific cause of the error. |