Skip to main content
Non-realtime

Qwen-Audio-3.0-ASR-Flash-Filetrans/Fun-ASR recording Java SDK

File transcription Java SDK for Qwen-Audio-3.0-ASR-Flash-Filetrans/Fun-ASR

For model details, see Audio file recognition - Fun-ASR/Paraformer.

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

ModelVersionUnit priceFree quota (Note)
fun-asr
Currently, fun-asr-2025-11-07
Stable$0.000035/second36,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/second36,000 seconds (10 hours)
Valid for 90 days
fun-asr-2025-08-25Snapshot$0.000035/second36,000 seconds (10 hours)
Valid for 90 days
fun-asr-mtl
Currently, fun-asr-mtl-2025-08-25
Stable$0.000035/second36,000 seconds (10 hours)
Valid for 90 days
fun-asr-mtl-2025-08-25Snapshot$0.000035/second36,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.
TranscriptionParam param = TranscriptionParam.builder()
  .model("qwen-audio-3.0-asr-flash-filetrans")
  .fileUrls(
          Arrays.asList(
                  "{YOUR_AUDIO_URL}"))
  .build();
ParameterTypeRequiredDescription
modelStringYesThe 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.
fileUrlsList<String>YesA 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.
vocabularyIdStringNoThe 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.
vocabularyMap<String, Integer>NoInstant 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.
See Setting vocabulary for code examples.
channelIdList<Integer>NoThe 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.
Default value: [0].
specialWordFilterStringNoThe sensitive words to process during speech recognition. You can set a different handling method for each sensitive word. For details, see Sensitive word filtering.
diarizationEnabledBooleanNoWhether 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.
Default value: false. For an example of speaker_id, see Recognition result.
speakerCountIntegerNo
Takes effect only when speaker diarization is enabled (diarization_enabled is set to true).
A reference value for the number of speakers. The valid range is an integer from 2 to 100 (inclusive). By default, the number of speakers is detected automatically. If you set this value, it only guides the algorithm to output the specified count when possible and does not guarantee that exact count. No default value.
language_hintsString[]NoThe 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.
apiKeyStringNoYour 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
Map<String, Integer> vocab = new HashMap<>();
vocab.put("John Smith", 5);
vocab.put("Jane Doe", 5);
TranscriptionParam param = TranscriptionParam.builder()
  .model("qwen-audio-3.0-asr-flash-filetrans")
  .parameter("vocabulary", vocab)
  .build();

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.
The value must be a JSON string:
{
  "filter_with_signed": {
    "word_list": ["test"]
  },
  "filter_with_empty": {
    "word_list": ["start", "happen"]
  },
  "system_reserved_filter": true
}
Field descriptions:
  • 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
TranscriptionParam param = TranscriptionParam.builder()
  .model("qwen-audio-3.0-asr-flash-filetrans")
  .parameter("language_hints", new String[]{"zh"})
  .build();

Response

Task result (TranscriptionResult)

TranscriptionResult encapsulates the result of the current task.
MethodParameterReturn valueDescription
public String getRequestId()NonerequestIdGets the requestId.
public String getTaskId()NonetaskIdGets the taskId.
public TaskStatus getTaskStatus()NoneTaskStatus, the task statusGets 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()NoneSubtask 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()NoneThe task result, in JSON formatGets 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
{
  "task_id":"0795ff8c-b666-4e91-bb8b-xxx",
  "task_status":"SUCCEEDED",
  "submit_time":"2025-02-13 16:12:09.109",
  "scheduled_time":"2025-02-13 16:12:09.128",
  "end_time":"2025-02-13 16:12:10.189",
  "results":[
    {
      "file_url":"{YOUR_AUDIO_URL}",
      "transcription_url":"https://dashscope-result-bj.oss-cn-beijing.aliyuncs.com/prod/paraformer-v2/20250213/16%3A12/34604a7b-579a-4223-8797-5116a49b07ec-1.json?Expires=1739520730&OSSAccessKeyId=yourOSSAccessKeyId&Signature=tMqyH56oB5rDW9%2FFqD8Yo%2F3WaPk%3D",
      "subtask_status":"SUCCEEDED"
    },
    {
      "file_url":"{YOUR_AUDIO_URL}",
      "transcription_url":"https://dashscope-result-bj.oss-cn-beijing.aliyuncs.com/prod/paraformer-v2/20250213/16%3A12/3baafe5f-d09d-46c6-8b01-724927670edb-1.json?Expires=1739520730&OSSAccessKeyId=yourOSSAccessKeyId&Signature=BF7vPxlsJN9hkJlY%2BLReezxOwK8%3D",
      "subtask_status":"SUCCEEDED"
    }
  ],
  "task_metrics":{
    "TOTAL":2,
    "SUCCEEDED":2,
    "FAILED":0
  }
}
Error example code and message fields appear only when an error occurs. You can use them, together with the Error codes, to troubleshoot the problem.
{
  "task_id": "7bac899c-06ec-4a79-8875-xxxxxxxxxxxx",
  "task_status": "SUCCEEDED",
  "submit_time": "2024-12-16 16:30:59.170",
  "scheduled_time": "2024-12-16 16:30:59.204",
  "end_time": "2024-12-16 16:31:02.375",
  "results": [
    {
      "file_url": "https://dashscope.oss-cn-beijing.aliyuncs.com/samples/audio/sensevoice/long_audio_demo_cn.mp3",
      "transcription_url": "https://dashscope-result-bj.oss-cn-beijing.aliyuncs.com/prod/paraformer-v2/20241216/xxxx",
      "subtask_status": "SUCCEEDED"
    },
    {
      "file_url": "{YOUR_AUDIO_URL}",
      "code": "InvalidFile.DownloadFailed",
      "message": "The audio file cannot be downloaded.",
      "subtask_status": "FAILED"
    }
  ],
  "task_metrics": {
    "TOTAL": 2,
    "SUCCEEDED": 1,
    "FAILED": 1
  }
}

Subtask result (TranscriptionTaskResult)

TranscriptionTaskResult encapsulates the result of a subtask. A subtask recognizes a single audio file.
MethodParameterReturn valueDescription
public String getFileUrl()NoneThe URL of the recognized audio fileGets the URL of the recognized audio file.
public String getTranscriptionUrl()NoneThe URL of the recognition resultGets 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()NoneTaskStatus, the subtask statusGets 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()NoneKey information generated during task execution, which may be emptyGets 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.
{
  "file_url":"{YOUR_AUDIO_URL}",
  "properties":{
    "audio_format":"pcm_s16le",
    "channels":[
      0
    ],
    "original_sampling_rate":16000,
    "original_duration_in_milliseconds":3834
  },
  "transcripts":[
    {
      "channel_id":0,
      "content_duration_in_milliseconds":3720,
      "text":"Hello world, this is Alibaba Speech Lab.",
      "sentences":[
        {
          "begin_time":100,
          "end_time":3820,
          "text":"Hello world, this is Alibaba Speech Lab.",
          "sentence_id":1,
          "speaker_id":0,
          "words":[
            {
              "begin_time":100,
              "end_time":596,
              "text":"Hello ",
              "punctuation":""
            },
            {
              "begin_time":596,
              "end_time":844,
              "text":"world",
              "punctuation":", "
            }
          ]
        }
      ]
    }
  ]
}
The following parameters are worth noting:
ParameterTypeDescription
audio_formatstringThe audio format of the source file.
channelsarray[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_rateintegerThe sampling rate (Hz) of the audio in the source file.
original_duration_in_millisecondsintegerThe original audio duration (ms) in the source file.
channel_idintegerThe track index of the transcription result, starting from 0.
content_durationintegerThe 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.
transcriptstringThe paragraph-level transcription result.
sentencesarrayThe sentence-level transcription result.
wordsarrayThe word-level transcription result.
begin_timeintegerThe start timestamp (ms).
end_timeintegerThe end timestamp (ms).
textstringThe transcription result.
speaker_idintegerThe 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.
punctuationstringThe 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.
// Build the transcription request parameters
TranscriptionParam param =
    TranscriptionParam.builder()
        // If you have not set the API key as an environment variable, replace apiKey with your own API key
        //.apiKey("apikey")
        .model("qwen-audio-3.0-asr-flash-filetrans")
        .fileUrls(
            Arrays.asList(
                "{YOUR_AUDIO_URL}"))
        .build();
try {
  Transcription transcription = new Transcription();
  // Submit the transcription request
  TranscriptionResult result = transcription.asyncCall(param);
  System.out.println("RequestId: " + result.getRequestId());
  TranscriptionQueryParam queryParam = TranscriptionQueryParam.FromTranscriptionParam(param, result.getTaskId());

} catch (Exception e) {
  System.out.println("error: " + e);
}
Interface/methodParametersReturn valueDescription
public static TranscriptionQueryParam FromTranscriptionParam(TranscriptionParam param, String taskId)param: a TranscriptionParam instance, taskId: the task IDa TranscriptionQueryParam instanceCreates a TranscriptionQueryParam instance.

Core class (Transcription)

Import Transcription with "import com.alibaba.dashscope.audio.asr.transcription.*;". Its key interfaces are as follows:
Interface/methodParametersReturn valueDescription
public TranscriptionResult asyncCall(TranscriptionParam param)param: the speech recognition parameters, a TranscriptionParam instanceTask result (TranscriptionResult)Submits a speech recognition task asynchronously.
public TranscriptionResult wait(TranscriptionQueryParam queryParam)queryParam: a TranscriptionQueryParam instanceTask 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 instanceTask result (TranscriptionResult)Queries the current task result asynchronously.