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.
Two WebSocket client events control a Paraformer real-time speech recognition 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.
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.
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.
User guide: For model details and selection guidance, see Speech-to-text.
Event flow: For the event interaction sequence, see WebSocket API.
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.
headerobject(Required)
Properties action string(Required)Instruction type. Set to run-task.task_idstring(Required)Client-generated task ID in UUID format. Used to correlate subsequent events with this task.streamingstring(Required)Set to duplex.object(Required)
Properties task_group string(Required)Task group. Set to audio.taskstring(Required)Task type. Set to asr.functionstring(Required)Function type. Set to recognition.modelstring(Required)Model name.inputobject(Required)Set to {}.parametersobject(Required)Speech recognition parameters.
Properties format string(Required)Audio format.Valid values:
integer(Required)Sample rate, in Hz.Valid values:
string(Optional)Hotword vocabulary ID.disfluency_removal_enabledboolean(Optional)Whether to filter out filler words.Default: false.language_hintsarray[string](Optional)Language of the audio to recognize. No default value. If not set, the model detects the language automatically.Valid values:
boolean(Optional)Whether to enable semantic-based sentence segmentation.Default: false.
integer(Optional)Silence threshold for VAD-based sentence segmentation, in milliseconds. The system ends the current sentence when silence after a speech segment exceeds this threshold.Default: 1300.Valid range: [200, 6000].multi_threshold_mode_enabledboolean(Optional)Whether to enable multi-threshold mode. When enabled, this mode prevents VAD-based segmentation from producing overly long segments.Default: false.punctuation_prediction_enabledboolean(Optional)Whether to add punctuation to the recognition results.Default: true.heartbeatboolean(Optional)Whether to enable heartbeat packets.Default: false.
boolean(Optional)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.
headerobject(Required)
Properties action string(Required)Instruction type. Set to finish-task.task_idstring(Required)Client-generated task ID in UUID format. Must match the task_id used in the run-task event.streamingstring(Required)Set to duplex.object(Required)
Properties input object(Required)Set to {}. |