Client event reference for Qwen-Audio-ASR-Streaming: run-task and finish-task fields, event order, and corresponding server events.
Event flow
- Send run-task. Wait for task-started before sending audio.
- Continue sending audio while receiving result-generated events.
- After sending all audio, send finish-task and receive results until task-finished arrives. A failed task returns task-failed.
run-task: WebSocket uses binary frames, and AOQ uses an Audio Track. For connection setup, authentication, and audio transport, see WebSocket API or AOQ access.
run-task
After establishing the connection, the client sends a run-task event to start a recognition task and configure the model, audio format, sample rate, and other parameters.
headerobjectRequiredactionstringRequiredThe command type. Set to
run-task.task_idstringRequiredA client-generated task ID (UUID format) that links subsequent events to this task.
streamingstringRequiredSet to
duplex.payloadobjectRequiredtask_groupstringRequiredThe task group. Set to
audio.taskstringRequiredThe task type. Set to
asr.functionstringRequiredThe function type. Set to
recognition.modelstringRequiredThe model name.
parametersobjectRequiredThe speech recognition parameters.
formatstringRequiredThe audio format.Valid values:
pcmwavmp3opusspeexaacamr
opus/speex: Must use Ogg encapsulation.wav: Must use PCM encoding.amr: Only the AMR-NB type is supported.
sample_rateintegerRequiredThe sample rate in Hz. Any sample rate is supported.
keep_dialectbooleanOptionalApplies only to qwen-audio-3.1-asr-flash-streaming.
false. Set to false to transcribe dialect speech as standard Mandarin text, or true to preserve dialect expressions.vad_modelstringOptionalApplies only to qwen-audio-3.1-asr-flash-streaming.
far_field_meeting_16k.near_meeting_16k: For audio captured close to the speaker, such as customer service calls using a headset or voice input in an app on a handheld phone.far_field_meeting_16k: For audio captured at a distance from the speaker, such as smart speaker interactions, shared microphones in meeting rooms, and in-vehicle hands-free voice interactions.
max_sentence_silenceintegerOptionalThe 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: 800.Valid values: [200, 6000].
multi_threshold_mode_enabledbooleanOptionalWhether to enable multi-threshold mode. When enabled, this prevents VAD segments from becoming too long.Default value:
false.speech_noise_thresholdfloatOptionalThe threshold for distinguishing speech from noise, used to adjust the sensitivity of Voice Activity Detection (VAD).Valid values: [-1.0, 1.0].Value descriptions:
- The closer the value is to -1: The noise threshold decreases, so noise is more likely to be recognized as speech, which may cause more noise to be transcribed.
- The closer the value is to +1: The noise threshold increases, so speech is more likely to be misjudged as noise, which may cause some speech to be filtered out.
- Thoroughly test and verify the results before adjusting.
- Adjust in small increments based on the actual audio environment (a step of 0.1 is recommended).
vocabulary_idstringOptionalThe 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.
vocabularyobjectOptionalInstant hot words.Passed as key-value pairs, where the key is the hot word text (
string) and the value is the hot word weight (integer). No hot word list needs to be created in advance. The weight ranges from [1, 5] or is set to 50: a value in [1, 5] makes the model more likely to output the word as the value increases; a value of 50 designates a super hot word, which greatly improves recall, but the number of super hot words cannot exceed 50.Suitable for temporary, session-level hot word optimization.When instant and precompiled hotwords are configured together, the system merges both sets. If the merged set contains more than 2000 hotwords, the system randomly selects 2000 to use. For usage details, see Instant hotwords.
language_hintsarray[string]OptionalThe language of the audio to recognize. There is no default value; if not set, the model detects the language automatically.You can set up to 4 values. If you set more, only the first 4 take effect.
Click to view the supported language codes
Click to view the supported language codes
zh: Chineseen: Englishja: Japaneseko: Koreanvi: Vietnameseth: Thaiid: Indonesianms: Malaytl: Filipinohi: Hindiar: Arabicfr: Frenchde: Germanes: Spanishpt: Portugueseru: Russianit: Italiannl: Dutchsv: Swedishda: Danishfi: Finnishno: Norwegianel: Greekpl: Polishcs: Czechhu: Hungarianro: Romanianbg: Bulgarianhr: Croatiansk: Slovak
heartbeatbooleanOptionalWhether to enable heartbeat packets.Default value:
false.true: Keeps the connection to the server alive even when silent audio is sent continuously.false(default): Even when silent audio is continuously sent, the connection times out and closes after a period of time.
special_word_filterstringOptionalSensitive-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.
filter_with_signed.word_list: String array. Matched words are replaced with the same number of asterisks.filter_with_empty.word_list: String array. Matched words are removed from the result.system_reserved_filter: Boolean, defaults tofalse. Controls use of the built-in word list. The two lists above configure custom replacement and removal rules.
inputobjectRequiredThe input object. Pass
{} when no context is provided.contextarray(object)OptionalThe conversation context, which improves recognition accuracy for domain-specific vocabulary. For usage details, see Context enhancement.
- Message count: Provide at most 5 context messages of each type (
input_textandtext). If this limit is exceeded, only the 5 most recent messages are kept. - Text length: The combined length of the
userandassistanttextfields in each turn must not exceed 400 characters. Each character counts as 1. Excess text is truncated from the end. - Message order: Arrange messages by conversation turn. Within each turn, the
usermessage (input_text) must precede its correspondingassistantmessage (text).
rolestringRequiredThe message role. Valid values:
user: The recognition results from previous turns of user speech, or a domain-specific word list.assistant: The responses from the large language model in previous turns.
contentarray(object)RequiredThe list of message contents.
typestringRequiredThe content type. Valid values:
input_text: The recognition results from previous turns of user speech, or a domain-specific word list (used whenroleisuser). You must also provide thetextfield.text: The responses from the large language model in previous turns (used whenroleisassistant). You must also provide thetextfield.
textstringRequiredThe 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.- Basic request
- With context
- Instant hotwords
Request:
Response:
finish-task
After sending all audio data, the client sends a finish-task event to notify the server that audio input is complete and request task completion.
headerobjectRequiredactionstringRequiredThe command type. Set to
finish-task.task_idstringRequiredA client-generated task ID (UUID format) that must match the
task_id in the run-task event.streamingstringRequiredSet to
duplex.payloadobjectRequiredinputobjectRequiredSet to
{}.Request:
Response: