This topic describes the client events that the client sends to the server over WebSocket in the Fun-ASR-Realtime real-time speech recognition service, including the data structures and field definitions for run-task (start a task), and finish-task (end a task).
run-task
Starts a speech recognition task and sets parameters such as the model, audio format, and sample rate.
When to send: Send immediately after the WebSocket connection is established.
Response event: You can send audio only after the server returns the task-started event.
headerobject(Required)
Properties action string(Required)The command type. Set to run-task.task_idstring(Required)A client-generated task ID (UUID format) that links subsequent events to this task.streamingstring(Required)Set to duplex.object(Required)
Properties task_group string(Required)The task group. Set to audio.taskstring(Required)The task type. Set to asr.functionstring(Required)The function type. Set to recognition.modelstring(Required)The model name.inputobject(Required)The input object. Pass {} when no context is provided.
Properties context array(object)(Optional)The conversation context, which improves recognition accuracy for domain-specific vocabulary. For usage details, see Context enhancement.
Properties role string(Required)The message role. Valid values:
array(object)(Required)The list of message contents.
Properties type string(Required)The content type. Valid values:
string(Required)The text content. When type is input_text, enter the recognition results from previous turns of user speech or a domain-specific word list. When type is text, enter the responses from the large language model in previous turns.object(Required)The speech recognition parameters.
Properties format string(Required)The audio format.Valid values:
integer(Required)The sample rate, in Hz.Valid values: 8 kHz models support only 8000 Hz; other models support any sample rate.vocabulary_idstring(Optional)The ID of a precompiled hot word list.Generate this ID in advance by calling the create hot word list API. Pass the ID during recognition to use the hot words in the list.Suitable for scenarios where the vocabulary is known and relatively stable, and where you need to reuse the same word list across requests.For usage details, see Precompiled hotwords.language_hintsarray[string](Optional)The language of the audio to recognize. There is no default value; if not set, the model detects the language automatically.You can set 1 value. If you set more, only the first value takes effect.
Click to view the supported language codes
integer(Optional)The VAD silence threshold for segmentation, in ms. When the silence after a segment of speech exceeds this threshold, the system determines that the sentence has ended.Default value: 1300.Valid values: [200, 6000].multi_threshold_mode_enabledboolean(Optional)Whether to enable multi-threshold mode. When enabled, this prevents VAD segments from becoming too long.Default value: false.heartbeatboolean(Optional)Whether to enable heartbeat packets.Default value: false.
float(Optional)The threshold for distinguishing speech from noise, used to adjust the sensitivity of Voice Activity Detection (VAD).Valid values: [-1.0, 1.0].Value descriptions:
string(Optional)Sensitive-word filtering rules that replace specified words in recognition results with the same number of asterisks or remove them. The value is a JSON string serialized from the rule object. Up to 32 sensitive words can be configured. No filtering is applied when the parameter is omitted.
|
finish-task
Notifies the server that all audio has been sent and requests to end the task.
When to send: Send after all audio data has been sent.
Response event: The server returns the task-finished event.
headerobject(Required)
Properties action string(Required)The command type. Set to finish-task.task_idstring(Required)A client-generated task ID (UUID format) that must match the task_id in the run-task event.streamingstring(Required)Set to duplex.object(Required)
Properties input object(Required)Set to {}. |