Qwen-ASR モデルの入出力パラメーターです。 API は OpenAI 互換または DashScope プロトコルを使用して呼び出します。
モデルの接続タイプ
モデルごとにサポートされる接続タイプは異なります。
モデル | 接続タイプ |
|---|---|
Qwen3-ASR-Flash-Filetrans | DashScope 非同期呼び出しのみをサポート |
Qwen3-ASR-Flash |
OpenAI 互換
重要米国リージョンは OpenAI 互換モードをサポートしていません。
URL
シンガポール
HTTP リクエストアドレス: POST https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1/chat/completions
SDK 呼び出しの base_url: https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1
{WorkspaceId} を実際のワークスペース ID に置き換えてください。
{WorkspaceId} を実際のワークスペース ID に置き換えてください。
米国 (バージニア)
米国のデプロイメント範囲を選択した場合、モデル推論の計算リソースは米国内に制限されます。静的データは選択したリージョンに保存されます。サポートされているリージョン:米国 (バージニア)。
HTTP リクエストアドレス: POST https://{WorkspaceId}.us-east-1.maas.aliyuncs.com/compatible-mode/v1/chat/completions
SDK 呼び出しの base_url: https://{WorkspaceId}.us-east-1.maas.aliyuncs.com/compatible-mode/v1
中国 (北京)
HTTP リクエストアドレス: POST https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1/chat/completions
SDK 呼び出しの base_url: https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1
{WorkspaceId} を実際のワークスペース ID に置き換えてください。
{WorkspaceId} を実際のワークスペース ID に置き換えてください。
重要Alibaba Cloud Model Studio は、中国 (北京) およびシンガポールリージョン向けにワークスペース固有のドメインをリリースしました。新しい専用ドメインは、推論リクエストに対して優れたパフォーマンスと高い安定性を提供します。新しいドメインへの移行を推奨します:
- 中国 (北京):
dashscope.aliyuncs.comから{WorkspaceId}.cn-beijing.maas.aliyuncs.comへ - シンガポール:
dashscope-intl.aliyuncs.comから{WorkspaceId}.ap-southeast-1.maas.aliyuncs.comへ
リクエストボディmodel モデル名。このパラメーターは Qwen3-ASR-Flash モデルにのみ適用されます。 messages メッセージのリスト。 asr_options 特定の機能を有効にするかどうかを指定します。 注記 stream ストリーミング出力を使用するかどうかを指定します。「ストリーミング出力」をご参照ください。 有効な値:
stream_options ストリーミング出力の設定項目。このパラメーターは、 | リクエスト例注記OpenAI Python SDK は 入力:音声ファイル URLPython SDKNode.js SDKcURL以下の設定はシンガポールリージョン向けです。 入力:Base64 エンコードされた音声ファイルBase64 エンコードされたデータを
|
レスポンスボディ注記Qwen3-ASR-Flash は OpenAI 互換 API 経由で呼び出した場合、タイムスタンプを返しません。タイムスタンプが必要な場合は、Qwen-Audio-ASR-Filetrans シリーズを使用してください。呼び出し方法については、HTTP APIをご参照ください。 感情ラベルは、ストリーミング出力では id この呼び出しの一意の識別子。 choices モデルからの出力情報。 プロパティ finish_reason 有効な値:
index
message モデルによって出力されたメッセージオブジェクト。 created リクエストが作成されたときの UNIX タイムスタンプ (秒単位)。 model このリクエストに使用されたモデル。 object 常に usage このリクエストのトークン消費情報。 | |
DashScope 同期
URL
シンガポール
HTTP リクエストアドレス: POST https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation
SDK 呼び出しの base_url: https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1
{WorkspaceId} を実際のワークスペース ID に置き換えてください。
{WorkspaceId} を実際のワークスペース ID に置き換えてください。
米国 (バージニア)
米国のデプロイメント範囲を選択した場合、モデル推論の計算リソースは米国内に制限されます。静的データは選択したリージョンに保存されます。サポートされているリージョン:米国 (バージニア)。
HTTP リクエストアドレス: POST https://{WorkspaceId}.us-east-1.maas.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation
SDK 呼び出しの base_url: https://{WorkspaceId}.us-east-1.maas.aliyuncs.com/api/v1
中国 (北京)
HTTP リクエストアドレス: POST https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation
SDK 呼び出しの base_url: https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1
{WorkspaceId} を実際のワークスペース ID に置き換えてください。
重要Alibaba Cloud Model Studio は、中国 (北京) およびシンガポールリージョン向けにワークスペース固有のドメインをリリースしました。新しい専用ドメインは、推論リクエストに対して優れたパフォーマンスと高い安定性を提供します。新しいドメインへの移行を推奨します:
- 中国 (北京):
dashscope.aliyuncs.comから{WorkspaceId}.cn-beijing.maas.aliyuncs.comへ - シンガポール:
dashscope-intl.aliyuncs.comから{WorkspaceId}.ap-southeast-1.maas.aliyuncs.comへ
リクエストボディmodel モデル名。このパラメーターは Qwen3-ASR-Flash モデルにのみ適用されます。 messages メッセージのリスト。 注記HTTP 呼び出しを行う場合、 asr_options 特定の機能を有効にするかどうかを指定します。 このパラメーターは Qwen3-ASR-Flash モデルでのみサポートされます。 | リクエスト例Qwen3-ASR-Flash は、最長 5 分間の録音をサポートし、入力として公開音声ファイルの URL またはローカルファイルのアップロードを受け付け、ストリーミングモードで認識結果を返すことができます。 入力:音声ファイルの URL入力:Base64 エンコードされた音声ファイルBase64 エンコードされたデータ (データ URL) を「
入力:ローカル音声ファイルの絶対パスDashScope SDK でローカル音声ファイルを処理する場合、ファイルパスを渡します。呼び出しメソッドとオペレーティングシステムに基づいてパスを構築するには、次の表をご参照ください。
重要ローカルファイルの呼び出しは 100 QPS に制限されており、スケールアップできません。そのため、本番環境、高同時実行数、またはストレステストのシナリオには適していません。より高い同時実行数が必要な場合は、ファイルを OSS にアップロードし、URL を介して呼び出してください。 ストリーミング出力モデルは中間結果を段階的に生成し、最終結果はそれらを組み立てて作成されます。非ストリーミング呼び出しは、すべての結果が生成されるのを待ってから一度に返しますが、ストリーミング呼び出しは結果が生成されるとすぐに返すため、最初のトークンまでの時間が大幅に短縮されます。呼び出しメソッドに合わせてストリーミングパラメーターを選択してください:
Python SDKJava SDKcURL以下の構成はシンガポール リージョン向けです。 |
レスポンスボディrequest_id この呼び出しの一意の識別子。 注記Java SDK によって返されるパラメーターは output 呼び出し結果情報。 usage このリクエストのトークン消費情報。 | |
DashScope 非同期呼び出し
プロセスの説明
非同期呼び出しは、長時間の音声ファイルや時間のかかるタスク向けに設計されています。リクエストのタイムアウトを防ぐために、「送信-ポーリング」の 2 段階のプロセスを使用します:
-
ステップ 1:タスクの送信
- クライアントは非同期処理リクエストを開始します。
- リクエストを検証した後、サーバーはタスクをすぐに実行しません。代わりに、タスクが正常に作成されたことを示す一意の
task_idを返します。
-
ステップ 2:結果の取得
- クライアントは
task_idを使用して結果クエリ API をポーリングします。 - タスクが完了すると、結果クエリ API は最終的な認識結果を返します。
- クライアントは
統合環境に基づいて、SDK を使用するか、RESTful API を直接呼び出すかを選択できます。
-
SDK を使用します。サンプルコードについては、「リクエスト例」をご参照ください。リクエストパラメーターについては、タスクの送信操作のリクエストボディをご参照ください。応答については、「非同期呼び出し結果の説明」をご参照ください。
SDK は、基盤となる API 呼び出しの詳細を自動的に処理します。
- タスクの送信:
async_call()(Python) またはasyncCall()(Java) メソッドを呼び出してタスクを送信します。このメソッドは、task_idを含むタスクオブジェクトを返します。 - 結果の取得:前のステップで返されたタスクオブジェクトまたは
task_idを使用して、fetch()メソッドを呼び出して結果を取得します。SDK は、タスクが完了するかタイムアウトするまで、内部のポーリングロジックを自動的に処理します。
- タスクの送信:
-
RESTful API を使用する
RESTful API を直接呼び出すことで、最大限の柔軟性が得られます。
- タスクを送信します。リクエストが成功した場合、レスポンスボディには
task_idが含まれます。 - 前のステップの
task_idを使用して、タスク実行結果を取得します。
- タスクを送信します。リクエストが成功した場合、レスポンスボディには
完全な例
HTTP
import com.google.gson.Gson;
import com.google.gson.annotations.SerializedName;
import okhttp3.*;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
public class Main {
// The following is the configuration for the Singapore region. When calling, replace "{WorkspaceId}" with your actual workspace ID. The configuration differs by region.
private static final String API_URL_SUBMIT = "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/services/audio/asr/transcription";
// The following is the configuration for the Singapore region. When calling, replace "{WorkspaceId}" with your actual workspace ID. The configuration differs by region.
private static final String API_URL_QUERY = "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/tasks/";
private static final Gson gson = new Gson();
public static void main(String[] args) {
// The API Key differs between the Singapore and Beijing regions. Get an API Key: https://www.alibabacloud.com/help/model-studio/get-api-key
// If you have not configured the environment variable, replace the following line with your Alibaba Cloud Model Studio API Key: String apiKey = "sk-xxx"
String apiKey = System.getenv("DASHSCOPE_API_KEY");
OkHttpClient client = new OkHttpClient();
// 1. Submit the task
/*String payloadJson = """
{
"model": "qwen3-asr-flash-filetrans",
"input": {
"file_url": "{YOUR_AUDIO_URL}"
},
"parameters": {
"channel_id": [0],
"enable_itn": false,
"language": "zh"
}
}
""";*/
String payloadJson = """
{
"model": "qwen3-asr-flash-filetrans",
"input": {
"file_url": "{YOUR_AUDIO_URL}"
},
"parameters": {
"channel_id": [0],
"enable_itn": false,
"enable_words": true
}
}
""";
RequestBody body = RequestBody.create(payloadJson, MediaType.get("application/json; charset=utf-8"));
Request submitRequest = new Request.Builder()
.url(API_URL_SUBMIT)
.addHeader("Authorization", "Bearer " + apiKey)
.addHeader("Content-Type", "application/json")
.addHeader("X-DashScope-Async", "enable")
.post(body)
.build();
String taskId = null;
try (Response response = client.newCall(submitRequest).execute()) {
if (response.isSuccessful() && response.body() != null) {
String respBody = response.body().string();
ApiResponse apiResp = gson.fromJson(respBody, ApiResponse.class);
if (apiResp.output != null) {
taskId = apiResp.output.taskId;
System.out.println("Task submitted, task_id: " + taskId);
} else {
System.out.println("Submission response content: " + respBody);
return;
}
} else {
System.out.println("Task submission failed! HTTP code: " + response.code());
if (response.body() != null) {
System.out.println(response.body().string());
}
return;
}
} catch (IOException e) {
e.printStackTrace();
return;
}
// 2. Poll the task status
boolean finished = false;
while (!finished) {
try {
TimeUnit.SECONDS.sleep(2); // Wait 2 seconds before querying again
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
return;
}
String queryUrl = API_URL_QUERY + taskId;
Request queryRequest = new Request.Builder()
.url(queryUrl)
.addHeader("Authorization", "Bearer " + apiKey)
.addHeader("Content-Type", "application/json")
.get()
.build();
try (Response response = client.newCall(queryRequest).execute()) {
if (response.body() != null) {
String queryResponse = response.body().string();
ApiResponse apiResp = gson.fromJson(queryResponse, ApiResponse.class);
if (apiResp.output != null && apiResp.output.taskStatus != null) {
String status = apiResp.output.taskStatus;
System.out.println("Current task status: " + status);
if ("SUCCEEDED".equalsIgnoreCase(status)
|| "FAILED".equalsIgnoreCase(status)
|| "UNKNOWN".equalsIgnoreCase(status)) {
finished = true;
System.out.println("Task completed, final result: ");
System.out.println(queryResponse);
}
} else {
System.out.println("Query response content: " + queryResponse);
}
}
} catch (IOException e) {
e.printStackTrace();
return;
}
}
}
static class ApiResponse {
@SerializedName("request_id")
String requestId;
Output output;
}
static class Output {
@SerializedName("task_id")
String taskId;
@SerializedName("task_status")
String taskStatus;
}
}
import os
import time
import requests
import json
# The following is the configuration for the Singapore region. When calling, replace "{WorkspaceId}" with your actual workspace ID. The configuration differs by region.
API_URL_SUBMIT = "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/services/audio/asr/transcription"
# The following is the configuration for the Singapore region. When calling, replace "{WorkspaceId}" with your actual workspace ID. The configuration differs by region.
API_URL_QUERY_BASE = "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/tasks/"
def main():
# The API Key differs between the Singapore and Beijing regions. Get an API Key: https://www.alibabacloud.com/help/model-studio/get-api-key
# If you have not configured the environment variable, replace the following line with your Alibaba Cloud Model Studio API Key: api_key = "sk-xxx"
api_key = os.getenv("DASHSCOPE_API_KEY")
headers = {
"Authorization": f"Bearer {api_key}",
"Content-Type": "application/json",
"X-DashScope-Async": "enable"
}
# 1. Submit the task
payload = {
"model": "qwen3-asr-flash-filetrans",
"input": {
"file_url": "{YOUR_AUDIO_URL}"
},
"parameters": {
"channel_id": [0],
# "language": "zh",
"enable_itn": False,
"enable_words": True
}
}
print("Submitting ASR transcription task...")
try:
submit_resp = requests.post(API_URL_SUBMIT, headers=headers, data=json.dumps(payload))
except requests.RequestException as e:
print(f"Failed to request task submission: {e}")
return
if submit_resp.status_code != 200:
print(f"Task submission failed! HTTP code: {submit_resp.status_code}")
print(submit_resp.text)
return
resp_data = submit_resp.json()
output = resp_data.get("output")
if not output or "task_id" not in output:
print("Abnormal submission response content:", resp_data)
return
task_id = output["task_id"]
print(f"Task submitted, task_id: {task_id}")
# 2. Poll the task status
finished = False
while not finished:
time.sleep(2) # Wait 2 seconds before querying again
query_url = API_URL_QUERY_BASE + task_id
try:
query_resp = requests.get(query_url, headers={"Authorization": f"Bearer {api_key}"})
except requests.RequestException as e:
print(f"Failed to request task query: {e}")
return
if query_resp.status_code != 200:
print(f"Task query failed! HTTP code: {query_resp.status_code}")
print(query_resp.text)
return
query_data = query_resp.json()
output = query_data.get("output")
if output and "task_status" in output:
status = output["task_status"]
print(f"Current task status: {status}")
if status.upper() in ("SUCCEEDED", "FAILED", "UNKNOWN"):
finished = True
print("Task completed. The final result is as follows:")
print(json.dumps(query_data, indent=2, ensure_ascii=False))
else:
print("Query response content:", query_data)
if __name__ == "__main__":
main()
Java SDK
import com.alibaba.dashscope.audio.qwen_asr.*;
import com.alibaba.dashscope.utils.Constants;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonObject;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
public class Main {
public static void main(String[] args) {
// The following is the configuration for the Singapore region. When calling, replace "{WorkspaceId}" with your actual workspace ID. The configuration differs by region.
Constants.baseHttpApiUrl = "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1";
QwenTranscriptionParam param =
QwenTranscriptionParam.builder()
// The API Key differs between the Singapore and Beijing regions. Get an API Key: https://www.alibabacloud.com/help/model-studio/get-api-key
// If you have not configured the environment variable, replace the following line with your Alibaba Cloud Model Studio API Key: .apiKey("sk-xxx")
.apiKey(System.getenv("DASHSCOPE_API_KEY"))
.model("qwen3-asr-flash-filetrans")
.fileUrl("{YOUR_AUDIO_URL}")
//.parameter("language", "zh")
//.parameter("channel_id", new ArrayList<String>(){{add("0");add("1");}})
.parameter("enable_itn", false)
.parameter("enable_words", true)
.build();
try {
QwenTranscription transcription = new QwenTranscription();
// Submit the task
QwenTranscriptionResult result = transcription.asyncCall(param);
System.out.println("create task result: " + result);
// Check whether the task was submitted successfully
if (result.getTaskId() == null) {
System.out.println("Error: " + result.getOutput());
return;
}
// Query the task status
result = transcription.fetch(QwenTranscriptionQueryParam.FromTranscriptionParam(param, result.getTaskId()));
System.out.println("task status: " + result);
// Wait for the task to complete
result =
transcription.wait(
QwenTranscriptionQueryParam.FromTranscriptionParam(param, result.getTaskId()));
System.out.println("task result: " + result);
// Get the speech recognition result
QwenTranscriptionTaskResult taskResult = result.getResult();
if (taskResult != null) {
// Get the URL of the recognition result
String transcriptionUrl = taskResult.getTranscriptionUrl();
// Get the result corresponding to the URL
HttpURLConnection connection =
(HttpURLConnection) new URL(transcriptionUrl).openConnection();
connection.setRequestMethod("GET");
connection.connect();
BufferedReader reader =
new BufferedReader(new InputStreamReader(connection.getInputStream()));
// Format and output the json result
Gson gson = new GsonBuilder().setPrettyPrinting().create();
System.out.println(gson.toJson(gson.fromJson(reader, JsonObject.class)));
}
} catch (Exception e) {
System.out.println("error: " + e);
}
}
}
Python SDK
import json
import os
import sys
from http import HTTPStatus
import dashscope
from dashscope.audio.qwen_asr import QwenTranscription
from dashscope.api_entities.dashscope_response import TranscriptionResponse
# run the transcription script
if __name__ == '__main__':
# The API Key differs between the Singapore and Beijing regions. Get an API Key: https://www.alibabacloud.com/help/model-studio/get-api-key
# If you have not configured the environment variable, replace the following line with your Alibaba Cloud Model Studio API Key: dashscope.api_key = "sk-xxx"
dashscope.api_key = os.getenv("DASHSCOPE_API_KEY")
# The following is the configuration for the Singapore region. When calling, replace "{WorkspaceId}" with your actual workspace ID. The configuration differs by region.
dashscope.base_http_api_url = 'https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1'
task_response = QwenTranscription.async_call(
model='qwen3-asr-flash-filetrans',
file_url='{YOUR_AUDIO_URL}',
#language="",
enable_itn=False,
enable_words=True
)
print(f'task_response: {task_response}')
print(task_response.output.task_id)
query_response = QwenTranscription.fetch(task=task_response.output.task_id)
print(f'query_response: {query_response}')
task_result = QwenTranscription.wait(task=task_response.output.task_id)
print(f'task_result: {task_result}')
認識結果のダウンロード
タスクが成功すると、クエリ API によって返される output.result.transcription_url は、完全な認識結果を含むパブリックにダウンロード可能な JSON ファイルを指します。この URL はデフォルトで 24 時間有効ですので、速やかにダウンロードして保存してください。
# Replace {transcription_url} with the transcription_url value returned by the query API
curl -sS '{transcription_url}' -o transcription.json
cat transcription.json | jq .
タスクの送信
URL
シンガポール
HTTP リクエストアドレス: POST https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/services/audio/asr/transcription
SDK 呼び出しの base_url: https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1
{WorkspaceId} を実際のワークスペース ID に置き換えてください。
{WorkspaceId} を実際のワークスペース ID に置き換えてください。
中国 (北京)
HTTP リクエストアドレス: POST https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/services/audio/asr/transcription
SDK 呼び出しの base_url: https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1
{WorkspaceId} を実際のワークスペース ID に置き換えてください。
重要Alibaba Cloud Model Studio は、中国 (北京) およびシンガポールリージョン向けにワークスペース固有のドメインをリリースしました。新しい専用ドメインは、推論リクエストに対して優れたパフォーマンスと高い安定性を提供します。新しいドメインへの移行を推奨します:
- 中国 (北京):
dashscope.aliyuncs.comから{WorkspaceId}.cn-beijing.maas.aliyuncs.comへ - シンガポール:
dashscope-intl.aliyuncs.comから{WorkspaceId}.ap-southeast-1.maas.aliyuncs.comへ
リクエストボディmodel モデル名。このパラメーターは Qwen3-ASR-Flash-Filetrans モデルにのみ適用されます。 input parameters | cURLJavaSDK の例については、「リクエスト例」をご参照ください。 PythonSDK の例については、「リクエスト例」をご参照ください。 |
レスポンスボディrequest_id この呼び出しの一意の識別子。 output 呼び出し結果情報。 | |
タスク実行結果の取得
URL
シンガポール
HTTP リクエストアドレス: GET https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/tasks/{task_id}
SDK 呼び出しの base_url: https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1
{WorkspaceId} を実際のワークスペース ID に置き換えてください。
{WorkspaceId} を実際のワークスペース ID に置き換えてください。
中国 (北京)
HTTP リクエストアドレス: GET https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/tasks/{task_id}
SDK 呼び出しの base_url: https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1
{WorkspaceId} を実際のワークスペース ID に置き換えてください。
重要Alibaba Cloud Model Studio は、中国 (北京) およびシンガポールリージョン向けにワークスペース固有のドメインをリリースしました。新しい専用ドメインは、推論リクエストに対して優れたパフォーマンスと高い安定性を提供します。新しいドメインへの移行を推奨します:
- 中国 (北京):
dashscope.aliyuncs.comから{WorkspaceId}.cn-beijing.maas.aliyuncs.comへ - シンガポール:
dashscope-intl.aliyuncs.comから{WorkspaceId}.ap-southeast-1.maas.aliyuncs.comへ
リクエストボディtask_id タスク ID。タスクの送信操作の応答から task_id を渡して、音声認識結果をクエリします。 | cURLJavaSDK の例については、「リクエスト例」をご参照ください。 PythonSDK の例については、「リクエスト例」をご参照ください。 |
レスポンスボディrequest_id この呼び出しの一意の識別子。 output 呼び出し結果情報。 | |
非同期呼び出し結果の説明file_url 認識された音声ファイルの URL。 audio_info 認識された音声ファイルに関する情報。 transcripts 完全な認識結果のリスト。各要素は、オーディオトラックの認識されたコンテンツに対応します。 | |