Two WebSocket client events control a Paraformer real-time speech recognition task: run-task starts the task with the model and audio settings, and finish-task ends the task after the audio stream completes. This page describes the message structure and field semantics of both events.
Paraformer models are available only in the China North 2 (Beijing) region. Use an API key created in that region. See Regions and endpoints.
run-task
Description: Starts a speech recognition task and configures parameters such as the model, audio format, and sample rate.
When to send: Immediately after the WebSocket connection is established.
Response event: The server must return the task-started event before audio data can be sent.
| Parameter | Type | Description |
|---|---|---|
| header | object | (Required) |
| header.action | string | (Required) Instruction type. Set to run-task. |
| header.task_id | string | (Required) Client-generated task ID in UUID format. Used to correlate subsequent events with this task. |
| header.streaming | string | (Required) Set to duplex. |
| payload | object | (Required) |
| payload.task_group | string | (Required) Task group. Set to audio. |
| payload.task | string | (Required) Task type. Set to asr. |
| payload.function | string | (Required) Function type. Set to recognition. |
| payload.model | string | (Required) Model name. |
| payload.input | object | (Required) Set to {}. |
| payload.parameters | object | (Required) Speech recognition parameters. |
| payload.parameters.format | string | (Required) Audio format. Valid values:
|
| payload.parameters.sample_rate | integer | (Required) Sample rate, in Hz. Valid values:
|
| payload.parameters.vocabulary_id | string | (Optional) Hotword vocabulary ID. |
| payload.parameters.disfluency_removal_enabled | boolean | (Optional) Tip: Only Paraformer supports this parameter. Whether to filter out filler words. Default: false. |
| payload.parameters.language_hints | array[string] | (Optional) Language of the audio to recognize. No default value. If not set, the model detects the language automatically. Valid values:
|
| payload.parameters.semantic_punctuation_enabled | boolean | (Optional) Tip: Only Paraformer v2 supports this parameter. Whether to enable semantic-based sentence segmentation. Default: false.
|
| payload.parameters.max_sentence_silence | integer | (Optional) Tip: - Only Paraformer v2 supports this parameter.
|
| payload.parameters.multi_threshold_mode_enabled | boolean | (Optional) Tip: - Only Paraformer v2 supports this parameter.
|
| payload.parameters.punctuation_prediction_enabled | boolean | (Optional) Tip: Only Paraformer v2 supports this parameter. Whether to add punctuation to the recognition results. Default: true. |
| payload.parameters.heartbeat | boolean | (Optional) Tip: Only Paraformer v2 supports this parameter. Whether to enable heartbeat packets. Default: false.
|
| payload.parameters.inverse_text_normalization_enabled | boolean | (Optional) Tip: Only Paraformer v2 supports this parameter. Whether to enable Inverse Text Normalization (ITN). When enabled, Chinese numerals are converted to Arabic numerals. Default: true. |
finish-task
Description: Notifies the server that all audio data has been sent and requests that the task be ended.
When to send: After all audio data has been sent.
Response event: The server returns the task-finished event.
| Parameter | Type | Description |
|---|---|---|
| header | object | (Required) |
| header.action | string | (Required) Instruction type. Set to finish-task. |
| header.task_id | string | (Required) Client-generated task ID in UUID format. Must match the task_id used in the run-task event. |
| header.streaming | string | (Required) Set to duplex. |
| payload | object | (Required) |
| payload.input | object | (Required) Set to {}. |