File transcription Java SDK for Qwen-Audio-3.0-ASR-Flash-Filetrans/Fun-ASR
For model details, see Audio file recognition - Fun-ASR/Paraformer.
Input format: Only publicly accessible file URLs (HTTP/HTTPS) are accepted. Local files and Base64-encoded audio are not supported.
Example:
Configure request parameters using the chained methods of
If
Field descriptions:
Supported language codes by model:
Success example
Error example
The recognition result is a JSON file.
The following parameters are worth noting:
Import
Prerequisites
For temporary access or high-risk operations, use a temporary token instead. Tokens expire after 60 seconds and reduce leakage risk.Replace the API key in your code with the token.
Model availability
| Model | Version | Unit price | Free quota (Note) |
|---|---|---|---|
| fun-asr Currently, fun-asr-2025-11-07 | Stable | $0.000035/second | 36,000 seconds (10 hours) Valid for 90 days |
| fun-asr-2025-11-07 Improved far-field VAD over fun-asr-2025-08-25 for higher accuracy | Snapshot | $0.000035/second | 36,000 seconds (10 hours) Valid for 90 days |
| fun-asr-2025-08-25 | Snapshot | $0.000035/second | 36,000 seconds (10 hours) Valid for 90 days |
| fun-asr-mtl Currently, fun-asr-mtl-2025-08-25 | Stable | $0.000035/second | 36,000 seconds (10 hours) Valid for 90 days |
| fun-asr-mtl-2025-08-25 | Snapshot | $0.000035/second | 36,000 seconds (10 hours) Valid for 90 days |
- Supported languages:
- fun-asr, fun-asr-2025-11-07, fun-asr-mtl, and fun-asr-mtl-2025-08-25: Chinese (Mandarin, Cantonese, Wu, Minnan, Hakka, Gan, Xiang, and Jin; also supports Mandarin accents from Zhongyuan, Southwest, Jilu, Jianghuai, Lanyin, Jiaoliao, Northeast, Beijing, and Hong Kong-Taiwan regions -- including Henan, Shaanxi, Hubei, Sichuan, Chongqing, Yunnan, Guizhou, Guangdong, Guangxi, Hebei, Tianjin, Shandong, Anhui, Nanjing, Jiangsu, Hangzhou, Gansu, and Ningxia), English, Japanese, Korean, Vietnamese, Indonesian, Thai, Malay, Filipino, Arabic, Bulgarian, Croatian, Czech, Danish, Dutch, Estonian, Finnish, Greek, Hindi, Hungarian, Irish, Latvian, Lithuanian, Maltese, Polish, Portuguese, Romanian, Slovak, Slovenian, and Swedish.
- fun-asr-2025-08-25: Mandarin and English.
- Supported sample rates: Any
- Supported audio formats: aac, amr, avi, flac, flv, m4a, mkv, mov, mp3, mp4, mpeg, ogg, opus, wav, webm, wma, wmv
Limitations
Input format: Only publicly accessible file URLs (HTTP/HTTPS) are accepted. Local files and Base64-encoded audio are not supported.
Example: https://your-domain.com/file.mp3
Set file URLs with the fileUrls parameter. Each request accepts up to 100 URLs.
- Audio formats:
aac,amr,avi,flac,flv,m4a,mkv,mov,mp3,mp4,mpeg,ogg,opus,wav,webm,wma,wmv
Many audio and video format variants exist. The API cannot guarantee correct recognition for all of them. Test your files to verify results.
- Audio sample rate: Any
- File size and duration: Up to 2 GB and 12 hours. If speaker diarization is enabled, keep the audio duration under 2 hours. For larger files, see preprocessing best practices.
- Batch size: Up to 100 file URLs per request.
- Supported languages: fun-asr, fun-asr-mtl, and their snapshot versions support Chinese and 29 other languages. fun-asr-2025-08-25 supports Chinese and English only. See Supported languages.
Request parameters
Configure request parameters using the chained methods of TranscriptionParam.
Click to view the example
Click to view the example
| Parameter | Type | Required | Description |
|---|---|---|---|
| model | String | Yes | The model name. Supported values include the Qwen-Audio-3.0-ASR-Flash-Filetrans and Fun-ASR model families. For details, see Supported models and regions. |
| fileUrls | List<String> | Yes | A list of URLs of the audio or video files to transcribe. HTTP and HTTPS are supported. A single request supports only one URL. For input requirements such as supported audio formats, file size limits, and duration limits, see Audio specifications. If the recording is stored in Alibaba Cloud OSS, the RESTful API supports temporary URLs prefixed with oss://, whereas the SDK does not support oss://-prefixed temporary URLs. A temporary URL is valid for 48 hours and cannot be used after it expires. Do not use it in production. The upload credential interface is rate-limited to 100 QPS and cannot be scaled up. Do not use it in production, high-concurrency, or load-testing scenarios. For production, use stable storage such as Alibaba Cloud OSS to keep files available long-term and avoid rate limiting. |
| vocabularyId | String | No | 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. |
| vocabulary | Map<String, Integer> | No | 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 configured together with precompiled hot words, only the instant hot words take effect. For usage details, see Instant hotwords. Only qwen-audio-3.0-asr-flash-filetrans supports inline hotwords. |
| channelId | List<Integer> | No | The index of the audio tracks to recognize in a multi-track audio file. The index starts at 0. For example, [0] recognizes the first track, and [0, 1] recognizes the first and second tracks at the same time. If you omit this parameter, only the first track is processed. Each specified track is billed independently. For example, requesting [0, 1] for a single file incurs two separate charges. |
| specialWordFilter | String | No | The sensitive words to process during speech recognition. You can set a different handling method for each sensitive word. For details, see Sensitive word filtering. |
| diarizationEnabled | Boolean | No | Whether to enable speaker diarization. Disabled by default. Applies only to mono audio. Multi-channel audio does not support speaker diarization. When enabled, the recognition result includes a speaker_id field that distinguishes different speakers. When speaker diarization is enabled, keep the audio duration within 2 hours. Otherwise, recognition may fail or time out. speaker_id, see Recognition result. |
| speakerCount | Integer | No | Takes effect only when speaker diarization is enabled ( diarization_enabled is set to true). |
| language_hints | String[] | No | The language codes to recognize. If you cannot determine the language in advance, leave it unset and the model detects the language automatically. For Qwen-Audio-3.0-ASR-Flash-Filetrans models, you can set up to 4 values; any values beyond the first 4 are ignored. For Fun-ASR models, you can set only 1 value; if you set multiple, only the first takes effect. See Supported languages. |
| apiKey | String | No | Your API key. If you have configured the API key as an environment variable, you do not need to set it in your code. Otherwise, you must set it in your code. |
Setting vocabulary
Set
vocabulary through the parameter method or the parameters method of the TranscriptionParam instance:- Set through parameter
- Set through parameters
Sensitive word filter details
If specialWordFilter is not set, built-in filtering applies (matches from the QwenCloud sensitive word list are replaced with *).
When set, you can use these policies:
- Replace with
*: Replaces matched words with asterisks of the same length. - Filter out: Removes matched words from the result.
filter_with_signed- Type: object (optional)
- Replaces matched words with
*of the same length. - Example: "Help me test this piece of code" -> "Help me **** this piece of code"
- Field:
word_list(string array of words to replace)
filter_with_empty- Type: object (optional)
- Removes matched words from results.
- Example: "Is the game about to start?" -> "Is the game about to?"
- Field:
word_list(string array of words to remove)
system_reserved_filter- Type: boolean (default: true)
- Enables preset sensitive word rules. When true, built-in filtering applies (QwenCloud word list matches replaced with
*).
Supported languages
Supported language codes by model:
- qwen-audio-3.0-asr-flash-filetrans, fun-asr, fun-asr-2025-11-07, fun-asr-mtl, fun-asr-mtl-2025-08-25:
- zh: Chinese
- en: English
- ja: Japanese
- ko: Korean
- vi: Vietnamese
- id: Indonesian
- th: Thai
- ms: Malay
- tl: Filipino
- ar: Arabic
- bg: Bulgarian
- hr: Croatian
- cs: Czech
- da: Danish
- nl: Dutch
- et: Estonian
- fi: Finnish
- el: Greek
- hi: Hindi
- hu: Hungarian
- ga: Irish
- lv: Latvian
- lt: Lithuanian
- mt: Maltese
- pl: Polish
- pt: Portuguese
- ro: Romanian
- sk: Slovak
- sl: Slovenian
- sv: Swedish
- fun-asr-2025-08-25:
- zh: Chinese
- en: English
Set
language_hints through the parameter method or the parameters method of the TranscriptionParam instance:- Set through parameter
- Set through parameters
Response
Task result (TranscriptionResult)
TranscriptionResult encapsulates the result of the current task.
| Method | Parameter | Return value | Description |
|---|---|---|---|
public String getRequestId() | None | requestId | Gets the requestId. |
public String getTaskId() | None | taskId | Gets the taskId. |
public TaskStatus getTaskStatus() | None | TaskStatus, the task status | Gets the task status. TaskStatus is an enum. You only need to focus on the following four states: PENDING, RUNNING, SUCCEEDED, and FAILED. When a task contains multiple subtasks, the overall task status is marked as SUCCEEDED as long as any one subtask succeeds. Use the subtask_status field to check the result of each individual subtask. |
public List<TranscriptionTaskResult> getResults() | None | Subtask result (TranscriptionTaskResult) | Gets the Subtask result (TranscriptionTaskResult). Each task recognizes one or more audio files. Different audio files are processed in separate subtasks, so each task corresponds to one or more subtasks. |
public JsonObject getOutput() | None | The task result, in JSON format | Gets the task result. The result is data in JSON format. If you want to get the task result through the getOutput interface, parse it yourself after you get the result. See JSON output examples. |
JSON output examples
Success example
code and message fields appear only when an error occurs. You can use them, together with the Error codes, to troubleshoot the problem.
Subtask result (TranscriptionTaskResult)
TranscriptionTaskResult encapsulates the result of a subtask. A subtask recognizes a single audio file.
| Method | Parameter | Return value | Description |
|---|---|---|---|
public String getFileUrl() | None | The URL of the recognized audio file | Gets the URL of the recognized audio file. |
public String getTranscriptionUrl() | None | The URL of the recognition result | Gets the URL of the recognition result. This URL is valid for 24 hours. After it expires, you can no longer query the task or download the result through the URL returned in a previous query. The recognition result is saved as a JSON file. You can download the file through the URL or read its content directly through an HTTP request. See Recognition result. |
public TaskStatus getSubTaskStatus() | None | TaskStatus, the subtask status | Gets the subtask status. TaskStatus is an enum. You only need to focus on the following four states: PENDING, RUNNING, SUCCEEDED, and FAILED. |
public String getMessage() | None | Key information generated during task execution, which may be empty | Gets the key information generated during task execution. When a task fails, check this content to analyze the cause. |
Recognition result
The recognition result is a JSON file.
Click to view the recognition result example
Click to view the recognition result example
| Parameter | Type | Description |
|---|---|---|
| audio_format | string | The audio format of the source file. |
| channels | array[integer] | The track index of the audio in the source file. For single-track audio, [0] is returned; for dual-track audio, [0, 1] is returned; and so on. |
| original_sampling_rate | integer | The sampling rate (Hz) of the audio in the source file. |
| original_duration_in_milliseconds | integer | The original audio duration (ms) in the source file. |
| channel_id | integer | The track index of the transcription result, starting from 0. |
| content_duration | integer | The duration (ms) of content in the track that is identified as speech. The speech recognition model service transcribes only the content in a track that is identified as speech, and meters and bills based on that duration. Non-speech content is not metered or billed. Typically, the speech content duration is shorter than the original audio duration. Because whether speech content exists is determined by an AI model, the result may differ slightly from the actual situation. |
| transcript | string | The paragraph-level transcription result. |
| sentences | array | The sentence-level transcription result. |
| words | array | The word-level transcription result. |
| begin_time | integer | The start timestamp (ms). |
| end_time | integer | The end timestamp (ms). |
| text | string | The transcription result. |
| speaker_id | integer | The index of the current speaker, starting from 0, used to distinguish between different speakers. This field appears in the recognition result only when speaker diarization is enabled. |
| punctuation | string | The punctuation predicted after the word, if any. |
Key interfaces
Query parameter class (TranscriptionQueryParam)
TranscriptionQueryParam is used when waiting for a task to finish (calling the wait method of Transcription) or querying the task result (calling the fetch method of Transcription).
Create a TranscriptionQueryParam instance through the static method FromTranscriptionParam.
Show example
Show example
| Interface/method | Parameters | Return value | Description |
|---|---|---|---|
public static TranscriptionQueryParam FromTranscriptionParam(TranscriptionParam param, String taskId) | param: a TranscriptionParam instance, taskId: the task ID | a TranscriptionQueryParam instance | Creates a TranscriptionQueryParam instance. |
Core class (Transcription)
Import Transcription with "import com.alibaba.dashscope.audio.asr.transcription.*;". Its key interfaces are as follows:
| Interface/method | Parameters | Return value | Description |
|---|---|---|---|
public TranscriptionResult asyncCall(TranscriptionParam param) | param: the speech recognition parameters, a TranscriptionParam instance | Task result (TranscriptionResult) | Submits a speech recognition task asynchronously. |
public TranscriptionResult wait(TranscriptionQueryParam queryParam) | queryParam: a TranscriptionQueryParam instance | Task result (TranscriptionResult) | Blocks the current thread until the asynchronous task ends (the task status is SUCCEEDED or FAILED). |
public TranscriptionResult fetch(TranscriptionQueryParam queryParam) | queryParam: a TranscriptionQueryParam instance | Task result (TranscriptionResult) | Queries the current task result asynchronously. |