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,
workspaceId: process.env.DASHSCOPE_WORKSPACE_ID,
baseUrl: 'dashscope.aliyuncs.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:
Parameter | Type | Required | Description |
|---|---|---|---|
|
| No | API key. Defaults to |
|
| No | Workspace ID. Defaults to |
|
| No | Service hostname. Default: |
|
| No | Model ID. Default: |
|
| No | Polling interval. Default: |
|
| No | Polling timeout in ms. Default: |
|
| No | HTTP request timeout in ms. Default: |
Transcription parameters
The second argument of transcribe() and submitTask() is parameters; the third accepts context. See the HTTP API for full model parameter details.
Parameter | Type | Required | Description |
|---|---|---|---|
|
| Yes | Publicly accessible audio URL; one file per task. |
|
| No | Preserve dialect expressions. Default: |
|
| No | Precompiled vocabulary ID. |
|
| No | Instant vocabulary: words as keys and weights in |
|
| No | Audio channel indices. Default: |
|
| No | Sensitive-word filtering configuration as a JSON string or object. |
|
| No | Speaker diarization for mono audio. Default: |
|
| No | Expected speaker count: |
|
| No | Recognition language hints. Up to the first 4 values take effect. Language is detected automatically if omitted. |
|
| No | Recognition context. Message format: |
|
| No | Polling progress callback with |
Main methods
Method | Return value | Description |
|---|---|---|
|
| Submit audio, poll, and download results. |
|
| Submit a task and return its ID and initial status. Set context with |
|
| Query a task once for its status and result URLs. |
Return values
Field | Type | Description |
|---|---|---|
|
| Task ID. |
|
| Task status. |
|
| Per-file results with |
|
| Usage returned by the service. |
|
| Raw task query response. |