Skip to main content
Qwen-Audio-ASR-Filetrans

Qwen-Audio-ASR-Filetrans Node.js SDK

Use the speech Node.js SDK to submit audio URLs to Qwen-Audio-ASR-Filetrans, query asynchronous tasks, and download transcripts.

Install the SDK

Requires Node.js 18 or later. Download the SDK 0.1.0 package, then run this command in your project:
npm install ./dashscope-sdk-nodejs-0.1.0.tgz

Quick start

Obtain an API key in the console and set it as the DASHSCOPE_API_KEY environment variable. Save the following example as example.mjs and run node example.mjs.
import { TranscriptionClient } from 'dashscope-sdk-nodejs/asr'

const client = new TranscriptionClient({
  apiKey: process.env.DASHSCOPE_API_KEY,
  // Singapore (ap-southeast-1). For another region, replace ap-southeast-1 in the URL.
  // API keys are region-specific. See https://docs.qwencloud.com/developer-guides/getting-started/regions
  baseUrl: 'ap-southeast-1.maas.qwencloudapi.com',
  model: 'qwen-audio-3.1-asr-flash-filetrans',
})
const job = await client.transcribe(
  'https://dashscope.oss-cn-beijing.aliyuncs.com/audios/welcome.mp3',
)
for (const result of job.results) {
  if (result.subtaskStatus === 'SUCCEEDED') {
    console.log('Transcript:', result.text)
  } else {
    console.error(result.code, result.message)
    process.exitCode = 1
  }
}

API reference

Constructor options

Constructor options for TranscriptionClient:
ParameterTypeRequiredDescription
apiKeystringNoAPI key. Defaults to DASHSCOPE_API_KEY.
baseUrlstringNoSet the service hostname to ap-southeast-1.maas.qwencloudapi.com (Singapore).
modelstringNoModel ID. Default: qwen-audio-3.1-asr-flash-filetrans.
pollIntervalMsnumberNoPolling interval. Default: 3000 ms.
pollTimeoutMsnumberNoPolling timeout in ms. Default: 600000.
requestTimeoutMsnumberNoHTTP request timeout in ms. Default: 30000; 0 disables the per-request timeout.

Transcription parameters

The second argument of transcribe() and submitTask() is parameters; the third accepts context. See the HTTP API for full model parameter details.
ParameterTypeRequiredDescription
fileUrlsstring | string[]YesPublicly accessible audio URL; one file per task.
parameters.keep_dialectbooleanNoPreserve dialect expressions. Default: false.
parameters.vocabulary_idstringNoPrecompiled vocabulary ID.
parameters.vocabularyRecord<string, number>NoInstant vocabulary: words as keys and weights in [1,5] or 50 as values.
parameters.channel_idnumber[]NoAudio channel indices. Default: [0].
parameters.special_word_filterstring | Record<string, unknown>NoSensitive-word filtering configuration as a JSON string or object.
parameters.diarization_enabledbooleanNoSpeaker diarization for mono audio. Default: false.
parameters.speaker_countnumberNoExpected speaker count: [2,100]. Requires speaker diarization.
parameters.language_hintsstring[]NoRecognition language hints. Up to the first 4 values take effect. Language is detected automatically if omitted.
callOpts.context / submitOpts.contextAsrContextMessage[]NoRecognition context. Message format: { role, content: [{ type: "input_text", text }] }, with role set to user or assistant. Up to 5 messages per role and fewer than 400 characters in total, ordered by conversation turn.
callOpts.onProgress(status: string, response: QueryTaskResponse) => voidNoPolling progress callback with status and raw response.

Main methods

MethodReturn valueDescription
transcribe(fileUrls: string | string[], parameters?: TranscriptionParameters, callOpts?: TranscribeCallOptions)Promise<TranscriptionJobResult>Submit audio, poll, and download results. callOpts accepts context and a progress callback.
submitTask(fileUrls: string | string[], parameters?: TranscriptionParameters, submitOpts?: TranscriptionSubmitOptions)Promise<{ taskId: string; taskStatus: string }>Submit a task and return its ID and initial status. Set context with submitOpts.context.
fetchTask(taskId: string, requestTimeoutMs?: number)Promise<QueryTaskResponse>Query a task once for its status and result URLs.

Return values

FieldTypeDescription
taskIdstringTask ID.
taskStatusstringTask status.
resultsFileTranscriptionResult[]Per-file results with subtaskStatus, text, and transcription; failed items include code and message.
usageRecognitionUsage | undefinedUsage returned by the service.
rawQueryTaskResponseRaw task query response.