This topic describes the parameters and interface details of the Qwen-Audio-ASR non-real-time speech recognition HTTP API.
For input requirements such as supported audio formats, file size limits, and duration limits, see Audio specifications.
In streaming mode, the client needs to handle the following:
Service endpoints
- Singapore
- China (Beijing)
POST https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generationReplace {WorkspaceId} with your actual Workspace ID.Request headers
| Parameter | Type | Required | Description |
|---|---|---|---|
Authorization | string | Yes | The authentication token, in the format Bearer <your_api_key>. Replace "<your_api_key>" with your actual API key. |
Content-Type | string | Yes | The media type of the request body. Fixed to application/json. |
X-DashScope-SSE | string | No | Controls whether to request streaming results. Set to enable to request SSE streaming. Set to disable or omit this parameter to return only the final result.Applies only to qwen-audio-3.0-asr-flash: SSE streaming is available only for audio that is at least 1 minute long. |
Request bodymodelstring(Required)The model name.inputobject(Required)The input information.
Properties messages array(object)(Required)The message list. It contains the audio to recognize and, optionally, conversation context that improves recognition accuracy.
Properties role string(Required)The message role. Valid values:
array(object)(Required)The message content list.
Properties type string(Required)The content type. Each request needs at least one message of type input_audio. Valid values:
object(Conditionally required)Required when type is input_audio.
Properties data string(Required)The audio data to recognize. For input requirements such as supported audio formats, file size limits, and duration limits, see Audio specifications. Two methods are supported:
https://example.com/audio/sample.wavExample (Base64): data:audio/wav;base64,{BASE64_ENCODED_DATA}string(Conditionally required)When type is input_text, enter the recognition results of the user's speech from previous turns or a domain-specific word list. When type is text, enter the large language model's replies from previous turns. Text length is measured in characters, where each character counts as 1. The combined length of the text fields across all messages in a single context turn cannot exceed 400 characters. Any excess is truncated from the end.object(Required)The model parameters.Text polishing is disabled by default and is not yet available for qwen-audio-3.0-asr-flash. qwen-audio-3.1-asr-flash supports native text polishing.Text polishing: While transcribing speech, the model removes meaningless filler words and stuttered repetitions, handles self-corrections, smooths out colloquial expressions, and standardizes punctuation and text formatting. The output is more concise, fluent, and readable while preserving the speaker’s final intent and key information as much as possible.
Properties speaker_diarization_enabled boolean (Optional)Applies only to qwen-audio-3.1-asr-flash.false. When set to true, the response uses speaker_id to distinguish speakers and includes output.sentences. When diarization is enabled, keep_dialect and language_hints are ignored.keep_dialect boolean (Optional)Applies only to qwen-audio-3.1-asr-flash.false. Set to false to transcribe dialect speech as standard Mandarin text, or true to preserve dialect expressions.formatstring(Required)The audio format. Set this to match your actual audio format. Supported values include wav, mp3, and opus. For details, see Audio specifications.sample_ratestring(Optional)The audio sample rate, in Hz. For example, 16000 means a 16 kHz sample rate. For details, see Audio specifications.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.vocabularyobject(Optional)Instant 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_hints array[string](Optional)The language codes to recognize. If the language is unknown in advance, omit this parameter to let the model detect it automatically. You can set up to 4 values. If you set more, only the first 4 take effect.Specifying language codes can improve recognition accuracy.
Supported language codes
qwen-audio-3.1-asr-flash also supports the following language codes:
| The following examples use the configuration for the Singapore region. Replace "{WorkspaceId}" with your actual workspace ID. The configuration differs across regions, and the API key for the Singapore region differs from the one for the Beijing region.
|
Response bodyrequest_idstringThe unique identifier of this request.outputobjectThe output result.
Properties text stringThe full recognized text accumulated so far.sentences array[object]Applies only to qwen-audio-3.1-asr-flash.sentence.sentenceobjectThe details of the current sentence.
Properties speaker_id integer | nullApplies only to qwen-audio-3.1-asr-flash.null otherwise.sentence_idintegerThe sentence number, starting from 1.sentence_endbooleanWhether this is the final result for the sentence. true indicates that recognition of the sentence is complete.begin_timeintegerThe start time of the sentence, in milliseconds.end_timeintegerThe end time of the sentence, in milliseconds. Returned only when sentence_end is true.textstringThe recognized text of the current sentence.channel_idintegerThe channel number, starting from 0.wordsarrayThe list of word-level timestamps.
Properties speaker_id integer | nullApplies only to qwen-audio-3.1-asr-flash.null otherwise.textstringThe word text.begin_timeintegerThe start time of the word, in milliseconds.end_timeintegerThe end time of the word, in milliseconds.punctuationstringThe punctuation mark after the word. An empty string when there is no punctuation.fixedbooleanWhether the word is stabilized. false indicates that the word's timestamp may be adjusted in subsequent events.objectThe usage information. Returned only when sentence_end is true.
Properties duration integerThe processed audio duration, in seconds.input_tokens integerApplies only to qwen-audio-3.1-asr-flash.integerApplies only to qwen-audio-3.1-asr-flash.integerApplies only to qwen-audio-3.1-asr-flash.input_tokens and output_tokens. |
|
SSE streaming result processing logic
In streaming mode, the client needs to handle the following:
- For each SSE event received, parse the JSON in the
datafield. - For
qwen-audio-3.0-asr-flash, useoutput.sentence.sentence_endto determine whether the current sentence has ended. When it istrue, recognition is complete, the word-level timestamps are stabilized, and the result can be used as final. When it isfalse, recognition is still in progress, and text and timestamps may be updated in subsequent events. - The
usageinformation is returned only in sentence-end events and includes the processed audio duration. Forqwen-audio-3.1-asr-flash, it also includes the input, output, and total token counts for the request. This model is billed by token usage.
qwen-audio-3.1-asr-flash without speaker diarization, a word timestamp becomes final only when output.sentence.words[i].fixed is true. Until then, timestamps may change. When speaker diarization is enabled, read the current and previous sentence results from output.sentences.