すべてのプロダクト
Search
ドキュメントセンター

Alibaba Cloud Model Studio:非リアルタイム音声認識 (Qwen-ASR) API リファレンス

最終更新日:Oct 30, 2026

Qwen-ASR モデルの入出力パラメーターです。 API は OpenAI 互換または DashScope プロトコルを使用して呼び出します。

モデルの接続タイプ

モデルごとにサポートされる接続タイプは異なります。

モデル

接続タイプ

Qwen3-ASR-Flash-Filetrans

DashScope 非同期呼び出しのみをサポート

Qwen3-ASR-Flash

OpenAI 互換および DashScope 同期

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 へ

リクエストボディ

modelstring(必須)

モデル名。このパラメーターは Qwen3-ASR-Flash モデルにのみ適用されます。

messagesarray(必須)

メッセージのリスト。

メッセージタイプ

システムメッセージobject (任意)

背景テキストやエンティティ用語集など、音声認識のコンテキストを提供するために使用されます。モデルのロール設定やその他の従来のシステムプロンプトの設定はサポートしていません。システムメッセージを使用する場合、messages リストの最初のメッセージである必要があります。

プロパティ

rolestring(必須)

system に設定します。

ユーザーメッセージobject(必須)

ユーザーがモデルに送信したメッセージ。

プロパティ

contentarray(必須)

ユーザーメッセージのコンテンツ。配列には 1 つのメッセージのみが許可されます。

プロパティ

typestring(必須)

入力が音声であることを示す input_audio に設定します。

input_audioobject(必須)

認識対象の音声。このパラメーターの使用方法の詳細については、「リクエスト例」をご参照ください。

input_audio.data は、パブリックにアクセス可能な音声ファイル URL または Base64 Data URI を受け付けます。ローカルファイルの絶対パスは直接指定できません。ローカル音声ファイルは、読み込んで Data URI にエンコードしてから送信してください。

SDK を使用する場合、音声ファイルが OSS に保存されている場合、oss:// で始まる一時 URL はサポートされません。

RESTful API を使用する場合、音声ファイルが OSS に保存されている場合、oss:// で始まる一時 URL はサポートされます。注意:

重要

  • 一時 URL は 48 時間有効です。有効期限が切れると使用できなくなります。本番環境では使用しないでください。
  • ファイルアップロード認証情報 API は 100 QPS にレート制限されており、スケールアップできません。本番環境、高同時実行、またはストレステストシナリオでは使用しないでください。
  • 本番環境では、長期的なファイルの可用性を確保し、レート制限の問題を回避するために、Alibaba Cloud OSS などの安定したストレージサービスを使用することを推奨します。

rolestring(必須)

ユーザーメッセージのロール。user に設定します。

asr_optionsobject(任意)

特定の機能を有効にするかどうかを指定します。

注記asr_options は標準の OpenAI パラメーターではありません。OpenAI Python SDK では extra_body を介して渡してください。Node.js SDK では、asr_options をリクエストボディのトップレベルのパラメーターとして渡してください。

プロパティ

language string (任意) デフォルト値なし

音声の言語がわかっている場合は、このパラメーターを使用して指定することで、認識精度を向上させることができます。

指定できる言語は 1 つだけです。

音声の言語が不明な場合や、複数の言語 (中国語、英語、日本語、韓国語の混合など) が含まれる場合は、このパラメーターを指定しないでください。

有効な値

  • zh:中国語 (標準語、四川語、閩南語、呉語)
  • yue:広東語
  • en:英語
  • ja:日本語
  • de:ドイツ語
  • ko:韓国語
  • ru:ロシア語
  • fr:フランス語
  • pt:ポルトガル語
  • ar:アラビア語
  • it:イタリア語
  • es:スペイン語
  • hi:ヒンディー語
  • id:インドネシア語
  • th:タイ語
  • tr:トルコ語
  • uk:ウクライナ語
  • vi:ベトナム語
  • cs:チェコ語
  • da:デンマーク語
  • fil:フィリピン語
  • fi:フィンランド語
  • is:アイスランド語
  • ms:マレー語
  • no:ノルウェー語
  • pl:ポーランド語
  • sv:スウェーデン語

enable_itnboolean (任意) デフォルト: false

逆テキスト正規化 (ITN) を有効にするかどうかを指定します。この機能は、中国語と英語の音声にのみ適用されます。

  • true
  • false (デフォルト)

streamboolean(任意) デフォルト: false

ストリーミング出力を使用するかどうかを指定します。「ストリーミング出力」をご参照ください。

有効な値:

  • false:モデルは生成後に完全なコンテンツを返します。
  • true:モデルはコンテンツを生成しながら同時に出力します。コンテンツの一部が生成されるたびにデータブロック (チャンク) が返されます。完全な応答を組み立てるには、これらのブロックをリアルタイムで読み取る必要があります。

true に設定すると、リクエストタイムアウトのリスクが軽減されます。

stream_optionsobject(任意)

ストリーミング出力の設定項目。このパラメーターは、stream が true に設定されている場合にのみ有効です。

プロパティ

include_usageboolean(任意) デフォルト: false

応答の最後のデータブロックにトークン消費情報を含めるかどうかを指定します。

有効な値:

  • true
  • false (デフォルト)

注記ストリーミング出力中、トークン消費情報は応答の最後のデータブロックにのみ表示されます。

リクエスト例

注記OpenAI Python SDK は 1.52.0 以降、Node.js SDK は 4.68.0 以降を使用してください。

入力:音声ファイル URL

Python SDK

from openai import OpenAI
import os

try:
    client = OpenAI(
        # The API Key differs between the Singapore/US regions and the Beijing region. 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"),
        # The following is the configuration for the Singapore region. When calling, replace "{WorkspaceId}" with your actual workspace ID. The configuration differs by region.
        base_url="https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1",
    )

    stream_enabled = False  # Whether to enable streaming output
    completion = client.chat.completions.create(
        model="qwen3-asr-flash",
        messages=[
            {
                "content": [
                    {
                        "type": "input_audio",
                        "input_audio": {
                            "data": "{YOUR_AUDIO_URL}"
                        }
                    }
                ],
                "role": "user"
            }
        ],
        stream=stream_enabled,
        # When stream is set to False, the stream_options parameter cannot be set
        # stream_options={"include_usage": True},
        extra_body={
            "asr_options": {
                # "language": "zh",
                "enable_itn": False
            }
        }
    )
    if stream_enabled:
        full_content = ""
        print("The streaming output is:")
        for chunk in completion:
            # If stream_options.include_usage is True, the choices field of the last chunk is an empty list and needs to be skipped (you can get the Token usage via chunk.usage)
            print(chunk)
            if chunk.choices and chunk.choices[0].delta.content:
                full_content += chunk.choices[0].delta.content
        print(f"The complete content is: {full_content}")
    else:
        print(f"The non-streaming output is: {completion.choices[0].message.content}")
except Exception as e:
    print(f"Error message: {e}")

Node.js SDK

// Preparations before running:
// Common to Windows/Mac/Linux:
// 1. Make sure Node.js is installed (version >= 14 recommended)
// 2. Run the following command to install the required dependencies: npm install openai

import OpenAI from "openai";

const client = new OpenAI({
  // The API Key differs between the Singapore/US regions and the Beijing region. 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: process.env.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.
  baseURL: "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1",
});

async function main() {
  try {
    const streamEnabled = false; // Whether to enable streaming output
    const completion = await client.chat.completions.create({
      model: "qwen3-asr-flash",
      messages: [
        {
          role: "user",
          content: [
            {
              type: "input_audio",
              input_audio: {
                data: "{YOUR_AUDIO_URL}"
              }
            }
          ]
        }
      ],
      stream: streamEnabled,
      // When stream is set to False, the stream_options parameter cannot be set
      // stream_options: {
      //   "include_usage": true
      // },
      asr_options: {
        // language: "zh",
        enable_itn: false
      }
    });

    if (streamEnabled) {
      let fullContent = "";
      console.log("The streaming output is:");
      for await (const chunk of completion) {
        console.log(JSON.stringify(chunk));
        if (chunk.choices && chunk.choices.length > 0) {
          const delta = chunk.choices[0].delta;
          if (delta && delta.content) {
            fullContent += delta.content;
          }
        }
      }
      console.log(`The complete content is: ${fullContent}`);
    } else {
      console.log(`The non-streaming output is: ${completion.choices[0].message.content}`);
    }
  } catch (err) {
    console.error(`Error message: ${err}`);
  }
}

main();

cURL

以下の設定はシンガポールリージョン向けです。{WorkspaceId} を実際のワークスペース ID に置き換えてください。設定はリージョンによって異なります。

curl -X POST 'https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1/chat/completions' \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
    "model": "qwen3-asr-flash",
    "messages": [
        {
            "content": [
                {
                    "type": "input_audio",
                    "input_audio": {
                        "data": "{YOUR_AUDIO_URL}"
                    }
                }
            ],
            "role": "user"
        }
    ],
    "stream":false,
    "asr_options": {
        "enable_itn": false
    }
}'

入力:Base64 エンコードされた音声ファイル

Base64 エンコードされたデータを data:<mediatype>;base64,<data> の形式で Data URL として渡します。

  • <mediatype>:MIME タイプ。

    MIME タイプは音声フォーマットによって異なります。例:

    • WAV: audio/wav
    • MP3: audio/mpeg
  • <data>:音声の Base64 エンコード文字列。

    Base64 エンコーディングはデータサイズを増加させます。エンコード後の結果が入力音声サイズ制限 (10 MB) を満たすように、ソースファイルを十分に小さくしてください。

  • 例: data:audio/wav;base64,SUQzBAAAAAAAI1RTU0UAAAAPAAADTGF2ZjU4LjI5LjEwMAAAAAAAAAAAAAAA//PAxABQ/BXRbMPe4IQAhl9

    サンプルコードを表示するにはクリック

    import base64, pathlib
    
    # Replace the file path with the local audio file to recognize, and make sure it meets the audio requirements.
    file_path = pathlib.Path("{YOUR_AUDIO_FILE}")
    base64_str = base64.b64encode(file_path.read_bytes()).decode()
    data_uri = f"data:audio/mpeg;base64,{base64_str}"
    
    import java.nio.file.*;
    import java.util.Base64;
    
    public class Main {
        /**
         * Replace the file path with the local audio file to recognize, and make sure it meets the audio requirements.
         */
        public static String toDataUrl(String filePath) throws Exception {
            byte[] bytes = Files.readAllBytes(Paths.get(filePath));
            String encoded = Base64.getEncoder().encodeToString(bytes);
            return "data:audio/mpeg;base64," + encoded;
        }
    
        // Example
        public static void main(String[] args) throws Exception {
            System.out.println(toDataUrl("{YOUR_AUDIO_FILE}"));
        }
    }
    
import base64
from openai import OpenAI
import os
import pathlib

try:
    # Replace with the actual audio file path
    file_path = "{YOUR_AUDIO_FILE}"
    # Replace with the actual MIME type of the audio file
    audio_mime_type = "audio/mpeg"

    file_path_obj = pathlib.Path(file_path)
    if not file_path_obj.exists():
        raise FileNotFoundError(f"Audio file does not exist: {file_path}")

    base64_str = base64.b64encode(file_path_obj.read_bytes()).decode()
    data_uri = f"data:{audio_mime_type};base64,{base64_str}"

    client = OpenAI(
        # The API Key differs between the Singapore/US regions and the Beijing region. 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"),
        # The following is the configuration for the Singapore region. When calling, replace "{WorkspaceId}" with your actual workspace ID. The configuration differs by region.
        base_url="https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1",
    )

    stream_enabled = False  # Whether to enable streaming output
    completion = client.chat.completions.create(
        model="qwen3-asr-flash",
        messages=[
            {
                "content": [
                    {
                        "type": "input_audio",
                        "input_audio": {
                            "data": data_uri
                        }
                    }
                ],
                "role": "user"
            }
        ],
        stream=stream_enabled,
        # When stream is set to False, the stream_options parameter cannot be set
        # stream_options={"include_usage": True},
        extra_body={
            "asr_options": {
                # "language": "zh",
                "enable_itn": False
            }
        }
    )
    if stream_enabled:
        full_content = ""
        print("The streaming output is:")
        for chunk in completion:
            # If stream_options.include_usage is True, the choices field of the last chunk is an empty list and needs to be skipped (you can get the Token usage via chunk.usage)
            print(chunk)
            if chunk.choices and chunk.choices[0].delta.content:
                full_content += chunk.choices[0].delta.content
        print(f"The complete content is: {full_content}")
    else:
        print(f"The non-streaming output is: {completion.choices[0].message.content}")
except Exception as e:
    print(f"Error message: {e}")
// Preparations before running:
// Common to Windows/Mac/Linux:
// 1. Make sure Node.js is installed (version >= 14 recommended)
// 2. Run the following command to install the required dependencies: npm install openai

import OpenAI from "openai";
import { readFileSync } from 'fs';

const client = new OpenAI({
  // The API Key differs between the Singapore/US regions and the Beijing region. 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: process.env.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.
  baseURL: "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1",
});

const encodeAudioFile = (audioFilePath) => {
    const audioFile = readFileSync(audioFilePath);
    return audioFile.toString('base64');
};

// Replace with the actual audio file path
const dataUri = `data:audio/mpeg;base64,${encodeAudioFile("{YOUR_AUDIO_FILE}")}`;

async function main() {
  try {
    const streamEnabled = false; // Whether to enable streaming output
    const completion = await client.chat.completions.create({
      model: "qwen3-asr-flash",
      messages: [
        {
          role: "user",
          content: [
            {
              type: "input_audio",
              input_audio: {
                data: dataUri
              }
            }
          ]
        }
      ],
      stream: streamEnabled,
      // When stream is set to False, the stream_options parameter cannot be set
      // stream_options: {
      //   "include_usage": true
      // },
      asr_options: {
        // language: "zh",
        enable_itn: false
      }
    });

    if (streamEnabled) {
      let fullContent = "";
      console.log("The streaming output is:");
      for await (const chunk of completion) {
        console.log(JSON.stringify(chunk));
        if (chunk.choices && chunk.choices.length > 0) {
          const delta = chunk.choices[0].delta;
          if (delta && delta.content) {
            fullContent += delta.content;
          }
        }
      }
      console.log(`The complete content is: ${fullContent}`);
    } else {
      console.log(`The non-streaming output is: ${completion.choices[0].message.content}`);
    }
  } catch (err) {
    console.error(`Error message: ${err}`);
  }
}

main();

レスポンスボディ

注記Qwen3-ASR-Flash は OpenAI 互換 API 経由で呼び出した場合、タイムスタンプを返しません。タイムスタンプが必要な場合は、Qwen-Audio-ASR-Filetrans シリーズを使用してください。呼び出し方法については、HTTP APIをご参照ください。

感情ラベルは、ストリーミング出力では choices[].delta.annotations[].emotion、非ストリーミング出力では choices[].message.annotations[].emotion に含まれます。

idstring

この呼び出しの一意の識別子。

choicesarray

モデルからの出力情報。

プロパティ

finish_reasonstring

有効な値:

  • null:出力はまだ生成中です。
  • stop:出力は自然に終了したか、停止条件によって終了しました。
  • length:出力が最大長制限を超えました。

indexinteger

choices 配列内の現在のオブジェクトのインデックス。

messageobject

モデルによって出力されたメッセージオブジェクト。

プロパティ

rolestring

出力メッセージのロール。assistant に設定されます。

contentstring

音声認識結果。

annotationsarray

言語などの出力アノテーション情報。

プロパティ

languagestring

認識された音声の言語。language リクエストパラメーターが指定されている場合、この値は指定されたパラメーターと同じです。

有効な値

  • zh:中国語 (標準語、四川語、閩南語、呉語)
  • yue:広東語
  • en:英語
  • ja:日本語
  • de:ドイツ語
  • ko:韓国語
  • ru:ロシア語
  • fr:フランス語
  • pt:ポルトガル語
  • ar:アラビア語
  • it:イタリア語
  • es:スペイン語
  • hi:ヒンディー語
  • id:インドネシア語
  • th:タイ語
  • tr:トルコ語
  • uk:ウクライナ語
  • vi:ベトナム語
  • cs:チェコ語
  • da:デンマーク語
  • fil:フィリピン語
  • fi:フィンランド語
  • is:アイスランド語
  • ms:マレー語
  • no:ノルウェー語
  • pl:ポーランド語
  • sv:スウェーデン語

typestring

音声情報を示す audio_info に設定します。

emotionstring

感情認識は常に有効で、追加設定は不要です。 認識された音声の感情。以下の感情がサポートされています:

  • surprised:驚き
  • neutral:中立
  • happy:喜び
  • sad: 悲しい
  • disgusted:嫌悪
  • angry:怒り
  • fearful: 恐ろしい

createdinteger

リクエストが作成されたときの UNIX タイムスタンプ (秒単位)。

modelstring

このリクエストに使用されたモデル。

objectstring

常に chat.completion です。

usageobject

このリクエストのトークン消費情報。

プロパティ

completion_tokens integer

モデル出力のトークン数。

completion_tokens_details object

モデル出力のトークンの詳細な情報。

プロパティ

text_tokens integer

モデル出力テキストのトークン数。

prompt_tokens object

入力のトークン数。

prompt_tokens_details object

入力のトークンの詳細な情報。

プロパティ

audio_tokens integer

入力音声の長さをトークンで表したもの。音声からトークンへの変換ルール:音声 1 秒ごとに 25 トークンに変換されます。1 秒未満の持続時間は 1 秒としてカウントされます。

text_tokens integer

このパラメーターは無視できます。

seconds integer

音声の持続時間 (秒)。

total_tokens integer

入出力トークンの合計数 (total_tokens = completion_tokens + prompt_tokens)。

{
    "choices": [
        {
            "finish_reason": "stop",
            "index": 0,
            "message": {
                "annotations": [
                    {
                        "emotion": "neutral",
                        "language": "zh",
                        "type": "audio_info"
                    }
                ],
                "content": "Welcome to Alibaba Cloud.",
                "role": "assistant"
            }
        }
    ],
    "created": 1767683986,
    "id": "chatcmpl-487abe5f-d4f2-9363-a877-xxxxxxx",
    "model": "qwen3-asr-flash",
    "object": "chat.completion",
    "usage": {
        "completion_tokens": 12,
        "completion_tokens_details": {
            "text_tokens": 12
        },
        "prompt_tokens": 42,
        "prompt_tokens_details": {
            "audio_tokens": 42,
            "text_tokens": 0
        },
        "seconds": 1,
        "total_tokens": 54
    }
}
data: {"model":"qwen3-asr-flash","id":"chatcmpl-3fb97803-d27f-9289-8889-xxxxx","created":1767685989,"object":"chat.completion.chunk","usage":null,"choices":[{"logprobs":null,"index":0,"delta":{"content":"","role":"assistant"}}]}

data: {"model":"qwen3-asr-flash","id":"chatcmpl-3fb97803-d27f-9289-8889-xxxxx","choices":[{"delta":{"annotations":[{"type":"audio_info","language":"zh","emotion":"neutral"}],"content":"Welcome","role":null},"index":0}],"created":1767685989,"object":"chat.completion.chunk","usage":null}

data: {"model":"qwen3-asr-flash","id":"chatcmpl-3fb97803-d27f-9289-8889-xxxxx","choices":[{"delta":{"annotations":[{"type":"audio_info","language":"zh","emotion":"neutral"}],"content":" to","role":null},"index":0}],"created":1767685989,"object":"chat.completion.chunk","usage":null}

data: {"model":"qwen3-asr-flash","id":"chatcmpl-3fb97803-d27f-9289-8889-xxxxx","choices":[{"delta":{"annotations":[{"type":"audio_info","language":"zh","emotion":"neutral"}],"content":" Alibaba","role":null},"index":0}],"created":1767685989,"object":"chat.completion.chunk","usage":null}

data: {"model":"qwen3-asr-flash","id":"chatcmpl-3fb97803-d27f-9289-8889-xxxxx","choices":[{"delta":{"annotations":[{"type":"audio_info","language":"zh","emotion":"neutral"}],"content":" Cloud","role":null},"index":0}],"created":1767685989,"object":"chat.completion.chunk","usage":null}

data: {"model":"qwen3-asr-flash","id":"chatcmpl-3fb97803-d27f-9289-8889-xxxxx","choices":[{"delta":{"annotations":[{"type":"audio_info","language":"zh","emotion":"neutral"}],"content":".","role":null},"index":0}],"created":1767685989,"object":"chat.completion.chunk","usage":null}

data: {"model":"qwen3-asr-flash","id":"chatcmpl-3fb97803-d27f-9289-8889-xxxxx","choices":[{"delta":{"role":null},"index":0,"finish_reason":"stop"}],"created":1767685989,"object":"chat.completion.chunk","usage":null}

data: [DONE]

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 へ

リクエストボディ

modelstring(必須)

モデル名。このパラメーターは Qwen3-ASR-Flash モデルにのみ適用されます。

messagesarray(必須)

メッセージのリスト。

注記HTTP 呼び出しを行う場合、messages を input オブジェクトに配置します。

メッセージタイプ

システムメッセージobject (任意)

背景テキストやエンティティ用語集など、音声認識のコンテキストを提供するために使用されます。モデルのロール設定やその他の従来のシステムプロンプトの設定はサポートしていません。システムメッセージを設定する場合、メッセージリストの先頭に配置してください。

Qwen3-ASR-Flash のみがこのパラメーターをサポートします。

プロパティ

rolestring(必須)

system に設定します。

ユーザーメッセージobject(必須)

ユーザーがモデルに送信したメッセージ。

プロパティ

contentarray(必須)

ユーザーメッセージのコンテンツ。配列には 1 つのメッセージのみが許可されます。

プロパティ

audiostring(必須)

認識対象の音声。このパラメーターの使用方法の詳細については、「リクエスト例」をご参照ください。

DashScope を使用する場合、Qwen3-ASR-Flash モデルは、Base64 エンコードされたファイル、ローカルファイルの絶対パス、およびパブリックネットワーク経由でアクセス可能な音声ファイルの URL の 3 つの入力形式をサポートします。

SDK を使用する場合、音声ファイルが OSS に保存されている場合、oss:// で始まる一時 URL はサポートされません。

RESTful API を使用する場合、音声ファイルが OSS に保存されている場合、oss:// で始まる一時 URL はサポートされます。注意:

重要

  • 一時 URL は 48 時間有効です。有効期限が切れると使用できなくなります。本番環境では使用しないでください。
  • ファイルアップロード認証情報 API は 100 QPS にレート制限されており、スケールアップできません。本番環境、高同時実行、またはストレステストシナリオでは使用しないでください。
  • 本番環境では、長期的なファイルの可用性を確保し、レート制限の問題を回避するために、Alibaba Cloud OSS などの安定したストレージサービスを使用することを推奨します。

rolestring(必須)

ユーザーメッセージのロール。user に設定します。

asr_optionsobject(任意)

特定の機能を有効にするかどうかを指定します。

このパラメーターは Qwen3-ASR-Flash モデルでのみサポートされます。

プロパティ

language string (任意) デフォルト値なし

音声の言語がわかっている場合は、このパラメーターを使用して指定することで、認識精度を向上させることができます。

指定できる言語は 1 つだけです。

音声の言語が不明な場合や、複数の言語 (中国語、英語、日本語、韓国語の混合など) が含まれる場合は、このパラメーターを指定しないでください。

有効な値

  • zh:中国語 (標準語、四川語、閩南語、呉語)
  • yue:広東語
  • en:英語
  • ja:日本語
  • de:ドイツ語
  • ko:韓国語
  • ru:ロシア語
  • fr:フランス語
  • pt:ポルトガル語
  • ar:アラビア語
  • it:イタリア語
  • es:スペイン語
  • hi:ヒンディー語
  • id:インドネシア語
  • th:タイ語
  • tr:トルコ語
  • uk:ウクライナ語
  • vi:ベトナム語
  • cs:チェコ語
  • da:デンマーク語
  • fil:フィリピン語
  • fi:フィンランド語
  • is:アイスランド語
  • ms:マレー語
  • no:ノルウェー語
  • pl:ポーランド語
  • sv:スウェーデン語

enable_itnboolean (任意) デフォルト: false

逆テキスト正規化 (ITN) を有効にするかどうかを指定します。この機能は、中国語と英語の音声にのみ適用されます。

  • true
  • false (デフォルト)

リクエスト例

Qwen3-ASR-Flash は、最長 5 分間の録音をサポートし、入力として公開音声ファイルの URL またはローカルファイルのアップロードを受け付け、ストリーミングモードで認識結果を返すことができます。

入力:音声ファイルの URL

curl -X POST "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation" \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
    "model": "qwen3-asr-flash",
    "input": {
        "messages": [
            {
                "content": [
                    {
                        "audio": "{YOUR_AUDIO_URL}"
                    }
                ],
                "role": "user"
            }
        ]
    },
    "parameters": {
        "asr_options": {
            "enable_itn": false
        }
    }
}'
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

import com.alibaba.dashscope.aigc.multimodalconversation.MultiModalConversation;
import com.alibaba.dashscope.aigc.multimodalconversation.MultiModalConversationParam;
import com.alibaba.dashscope.aigc.multimodalconversation.MultiModalConversationResult;
import com.alibaba.dashscope.common.MultiModalMessage;
import com.alibaba.dashscope.common.Role;
import com.alibaba.dashscope.exception.ApiException;
import com.alibaba.dashscope.exception.NoApiKeyException;
import com.alibaba.dashscope.exception.UploadFileException;
import com.alibaba.dashscope.utils.Constants;
import com.alibaba.dashscope.utils.JsonUtils;

public class Main {
    public static void simpleMultiModalConversationCall()
            throws ApiException, NoApiKeyException, UploadFileException {
        MultiModalConversation conv = new MultiModalConversation();
        MultiModalMessage userMessage = MultiModalMessage.builder()
                .role(Role.USER.getValue())
                .content(Arrays.asList(
                        Collections.singletonMap("audio", "{YOUR_AUDIO_URL}")))
                .build();

        Map<String, Object> asrOptions = new HashMap<>();
        asrOptions.put("enable_itn", false);
        // asrOptions.put("language", "zh"); // Optional. If you know the language of the audio, you can use this parameter to specify the language to recognize, to improve recognition accuracy
        MultiModalConversationParam param = MultiModalConversationParam.builder()
                // The API Key differs between the Singapore/US regions and the Beijing region. 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")
                .message(userMessage)
                .parameter("asr_options", asrOptions)
                .build();
        MultiModalConversationResult result = conv.call(param);
        System.out.println(JsonUtils.toJson(result));
    }
    public static void main(String[] args) {
        try {
            // 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";
            simpleMultiModalConversationCall();
        } catch (ApiException | NoApiKeyException | UploadFileException e) {
            System.out.println(e.getMessage());
        }
        System.exit(0);
    }
}
import os
import dashscope

# 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'

messages = [
    {"role": "user", "content": [{"audio": "{YOUR_AUDIO_URL}"}]}
]

response = dashscope.MultiModalConversation.call(
    # The API Key differs between the Singapore/US regions and the Beijing region. 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"),
    model="qwen3-asr-flash",
    messages=messages,
    result_format="message",
    asr_options={
        #"language": "zh", # Optional. If you know the language of the audio, you can use this parameter to specify the language to recognize, to improve recognition accuracy
        "enable_itn":False
    }
)
print(response)

入力:Base64 エンコードされた音声ファイル

Base64 エンコードされたデータ (データ URL) を「data:<mediatype>;base64,<data>」のフォーマットで渡すことができます。

  • <mediatype>:MIME タイプ。

    これは音声フォーマットによって異なり、例えば次のようになります:

    • WAV: audio/wav
    • MP3: audio/mpeg
  • <data>:オーディオの Base64 エンコードされた文字列。

    Base64 エンコーディングはファイルサイズを増加させるため、エンコード後の結果が入力音声サイズの制限 (10 MB) を満たすように、元のファイルを十分に小さくしてください。

  • 例: data:audio/wav;base64,SUQzBAAAAAAAI1RTU0UAAAAPAAADTGF2ZjU4LjI5LjEwMAAAAAAAAAAAAAAA//PAxABQ/BXRbMPe4IQAhl9

    クリックしてサンプルコードを表示

    import base64, pathlib
    
    # input.mp3 is the local audio file used for voice cloning. Replace it with the path to your own audio file and make sure it meets the audio requirements.
    file_path = pathlib.Path("{YOUR_AUDIO_FILE}")
    base64_str = base64.b64encode(file_path.read_bytes()).decode()
    data_uri = f"data:audio/mpeg;base64,{base64_str}"
    
    import java.nio.file.*;
    import java.util.Base64;
    
    public class Main {
        /**
         * filePath is the local audio file used for voice cloning. Replace it with the path to your own audio file and make sure it meets the audio requirements.
         */
        public static String toDataUrl(String filePath) throws Exception {
            byte[] bytes = Files.readAllBytes(Paths.get(filePath));
            String encoded = Base64.getEncoder().encodeToString(bytes);
            return "data:audio/mpeg;base64," + encoded;
        }
    
        // Usage example
        public static void main(String[] args) throws Exception {
            System.out.println(toDataUrl("{YOUR_AUDIO_FILE}"));
        }
    }
    
import base64
import dashscope
import os
import pathlib

# 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'

# Replace with the actual audio file path
file_path = "{YOUR_AUDIO_FILE}"
# Replace with the actual MIME type of the audio file
audio_mime_type = "audio/mpeg"

file_path_obj = pathlib.Path(file_path)
if not file_path_obj.exists():
    raise FileNotFoundError(f"Audio file does not exist: {file_path}")

base64_str = base64.b64encode(file_path_obj.read_bytes()).decode()
data_uri = f"data:{audio_mime_type};base64,{base64_str}"

messages = [
    {"role": "user", "content": [{"audio": data_uri}]}
]
response = dashscope.MultiModalConversation.call(
    # The API Key differs between the Singapore/US regions and the Beijing region. 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"),
    model="qwen3-asr-flash",
    messages=messages,
    result_format="message",
    asr_options={
        # "language": "zh", # Optional. If you know the language of the audio, you can use this parameter to specify the language to recognize, to improve recognition accuracy
        "enable_itn":False
    }
)
print(response)
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.*;

import com.alibaba.dashscope.aigc.multimodalconversation.MultiModalConversation;
import com.alibaba.dashscope.aigc.multimodalconversation.MultiModalConversationParam;
import com.alibaba.dashscope.aigc.multimodalconversation.MultiModalConversationResult;
import com.alibaba.dashscope.common.MultiModalMessage;
import com.alibaba.dashscope.common.Role;
import com.alibaba.dashscope.exception.ApiException;
import com.alibaba.dashscope.exception.NoApiKeyException;
import com.alibaba.dashscope.exception.UploadFileException;
import com.alibaba.dashscope.utils.Constants;
import com.alibaba.dashscope.utils.JsonUtils;

public class Main {
    // Replace with the actual audio file path
    private static final String AUDIO_FILE = "{YOUR_AUDIO_FILE}";
    // Replace with the actual MIME type of the audio file
    private static final String AUDIO_MIME_TYPE = "audio/mpeg";

    public static void simpleMultiModalConversationCall()
            throws ApiException, NoApiKeyException, UploadFileException, IOException {
        MultiModalConversation conv = new MultiModalConversation();
        MultiModalMessage userMessage = MultiModalMessage.builder()
                .role(Role.USER.getValue())
                .content(Arrays.asList(
                        Collections.singletonMap("audio", toDataUrl())))
                .build();

        Map<String, Object> asrOptions = new HashMap<>();
        asrOptions.put("enable_itn", false);
        // asrOptions.put("language", "zh"); // Optional. If you know the language of the audio, you can use this parameter to specify the language to recognize, to improve recognition accuracy
        MultiModalConversationParam param = MultiModalConversationParam.builder()
                // The API Key differs between the Singapore/US regions and the Beijing region. 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")
                .message(userMessage)
                .parameter("asr_options", asrOptions)
                .build();
        MultiModalConversationResult result = conv.call(param);
        System.out.println(JsonUtils.toJson(result));
    }

    public static void main(String[] args) {
        try {
            // 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";
            simpleMultiModalConversationCall();
        } catch (ApiException | NoApiKeyException | UploadFileException | IOException e) {
            System.out.println(e.getMessage());
        }
        System.exit(0);
    }

    // Generate the data URI
    public static String toDataUrl() throws IOException {
        byte[] bytes = Files.readAllBytes(Paths.get(AUDIO_FILE));
        String encoded = Base64.getEncoder().encodeToString(bytes);
        return "data:" + AUDIO_MIME_TYPE + ";base64," + encoded;
    }
}

入力:ローカル音声ファイルの絶対パス

DashScope SDK でローカル音声ファイルを処理する場合、ファイルパスを渡します。呼び出しメソッドとオペレーティングシステムに基づいてパスを構築するには、次の表をご参照ください。

システム

SDK

渡すファイルパス

例

Linux または macOS

Python SDK

file://{ファイルの絶対パス}

file:///home/images/test.png

Java SDK

Windows

Python SDK

file://{ファイルの絶対パス}

file://D:/images/test.png

Java SDK

file:///{ファイルの絶対パス}

file:///D:/images/test.png

重要ローカルファイルの呼び出しは 100 QPS に制限されており、スケールアップできません。そのため、本番環境、高同時実行数、またはストレステストのシナリオには適していません。より高い同時実行数が必要な場合は、ファイルを OSS にアップロードし、URL を介して呼び出してください。

import os
import dashscope

# 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'

# Replace ABSOLUTE_PATH/{YOUR_AUDIO_FILE} with the absolute path of your local audio file
audio_file_path = "file://ABSOLUTE_PATH/{YOUR_AUDIO_FILE}"

messages = [
    {"role": "user", "content": [{"audio": audio_file_path}]}
]
response = dashscope.MultiModalConversation.call(
    # The API Key differs between the Singapore/US regions and the Beijing region. 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"),
    model="qwen3-asr-flash",
    messages=messages,
    result_format="message",
    asr_options={
        # "language": "zh", # Optional. If you know the language of the audio, you can use this parameter to specify the language to recognize, to improve recognition accuracy
        "enable_itn":False
    }
)
print(response)
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

import com.alibaba.dashscope.aigc.multimodalconversation.MultiModalConversation;
import com.alibaba.dashscope.aigc.multimodalconversation.MultiModalConversationParam;
import com.alibaba.dashscope.aigc.multimodalconversation.MultiModalConversationResult;
import com.alibaba.dashscope.common.MultiModalMessage;
import com.alibaba.dashscope.common.Role;
import com.alibaba.dashscope.exception.ApiException;
import com.alibaba.dashscope.exception.NoApiKeyException;
import com.alibaba.dashscope.exception.UploadFileException;
import com.alibaba.dashscope.utils.Constants;
import com.alibaba.dashscope.utils.JsonUtils;

public class Main {
    public static void simpleMultiModalConversationCall()
            throws ApiException, NoApiKeyException, UploadFileException {
        // Replace ABSOLUTE_PATH/{YOUR_AUDIO_FILE} with the absolute path of your local file
        String localFilePath = "file://ABSOLUTE_PATH/{YOUR_AUDIO_FILE}";
        MultiModalConversation conv = new MultiModalConversation();
        MultiModalMessage userMessage = MultiModalMessage.builder()
                .role(Role.USER.getValue())
                .content(Arrays.asList(
                        Collections.singletonMap("audio", localFilePath)))
                .build();

        Map<String, Object> asrOptions = new HashMap<>();
        asrOptions.put("enable_itn", false);
        // asrOptions.put("language", "zh"); // Optional. If you know the language of the audio, you can use this parameter to specify the language to recognize, to improve recognition accuracy
        MultiModalConversationParam param = MultiModalConversationParam.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")
                .message(userMessage)
                .parameter("asr_options", asrOptions)
                .build();
        MultiModalConversationResult result = conv.call(param);
        System.out.println(JsonUtils.toJson(result));
    }
    public static void main(String[] args) {
        try {
            // 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";
            simpleMultiModalConversationCall();
        } catch (ApiException | NoApiKeyException | UploadFileException e) {
            System.out.println(e.getMessage());
        }
        System.exit(0);
    }
}

ストリーミング出力

モデルは中間結果を段階的に生成し、最終結果はそれらを組み立てて作成されます。非ストリーミング呼び出しは、すべての結果が生成されるのを待ってから一度に返しますが、ストリーミング呼び出しは結果が生成されるとすぐに返すため、最初のトークンまでの時間が大幅に短縮されます。呼び出しメソッドに合わせてストリーミングパラメーターを選択してください:

  • DashScope Python SDK: stream パラメーターを true に設定します。
  • DashScope Java SDK:streamCall API を呼び出します。
  • DashScope HTTP:X-DashScope-SSE ヘッダーを enable に設定します。

Python SDK

import os
import dashscope

# 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'

messages = [
    {"role": "user", "content": [{"audio": "{YOUR_AUDIO_URL}"}]}
]
response = dashscope.MultiModalConversation.call(
    # The API Key differs between the Singapore/US regions and the Beijing region. 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"),
    model="qwen3-asr-flash",
    messages=messages,
    result_format="message",
    asr_options={
        # "language": "zh", # Optional. If you know the language of the audio, you can use this parameter to specify the language to recognize, to improve recognition accuracy
        "enable_itn":False
    },
    stream=True
)

for response in response:
    try:
        print(response["output"]["choices"][0]["message"].content[0]["text"])
    except:
        pass

Java SDK

import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

import com.alibaba.dashscope.aigc.multimodalconversation.MultiModalConversation;
import com.alibaba.dashscope.aigc.multimodalconversation.MultiModalConversationParam;
import com.alibaba.dashscope.aigc.multimodalconversation.MultiModalConversationResult;
import com.alibaba.dashscope.common.MultiModalMessage;
import com.alibaba.dashscope.common.Role;
import com.alibaba.dashscope.exception.ApiException;
import com.alibaba.dashscope.exception.NoApiKeyException;
import com.alibaba.dashscope.exception.UploadFileException;
import com.alibaba.dashscope.utils.Constants;
import io.reactivex.Flowable;

public class Main {
    public static void simpleMultiModalConversationCall()
            throws ApiException, NoApiKeyException, UploadFileException {
        MultiModalConversation conv = new MultiModalConversation();
        MultiModalMessage userMessage = MultiModalMessage.builder()
                .role(Role.USER.getValue())
                .content(Arrays.asList(
                        Collections.singletonMap("audio", "{YOUR_AUDIO_URL}")))
                .build();

        Map<String, Object> asrOptions = new HashMap<>();
        asrOptions.put("enable_itn", false);
        // asrOptions.put("language", "zh"); // Optional. If you know the language of the audio, you can use this parameter to specify the language to recognize, to improve recognition accuracy
        MultiModalConversationParam param = MultiModalConversationParam.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")
                .message(userMessage)
                .parameter("asr_options", asrOptions)
                .build();
        Flowable<MultiModalConversationResult> resultFlowable = conv.streamCall(param);
        resultFlowable.blockingForEach(item -> {
            try {
                System.out.println(item.getOutput().getChoices().get(0).getMessage().getContent().get(0).get("text"));
            } catch (Exception e){
                System.exit(0);
            }
        });
    }

    public static void main(String[] args) {
        try {
            // 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";
            simpleMultiModalConversationCall();
        } catch (ApiException | NoApiKeyException | UploadFileException e) {
            System.out.println(e.getMessage());
        }
        System.exit(0);
    }
}

cURL

以下の構成はシンガポール リージョン向けです。{WorkspaceId} を実際の ワークスペース ID に置き換えてください。構成はリージョンによって異なります。

curl -X POST "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation" \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H "Content-Type: application/json" \
-H "X-DashScope-SSE: enable" \
-d '{
    "model": "qwen3-asr-flash",
    "input": {
        "messages": [
            {
                "content": [
                    {
                        "audio": "{YOUR_AUDIO_URL}"
                    }
                ],
                "role": "user"
            }
        ]
    },
    "parameters": {
        "incremental_output": true,
        "asr_options": {
            "enable_itn": false
        }
    }
}'

レスポンスボディ

request_idstring

この呼び出しの一意の識別子。

注記Java SDK によって返されるパラメーターは requestId.

outputobject

呼び出し結果情報。

プロパティ

choicesarray

モデル出力。result_format が message の場合に返されます。

プロパティ

finish_reasonstring

有効な値:

  • null:出力はまだ生成中です。
  • stop:出力は自然に終了したか、停止条件によって終了しました。
  • length:出力が最大長制限を超えました。

messageobject

モデルによって出力されたメッセージオブジェクト。

プロパティ

rolestring

出力メッセージのロール。assistant に設定されます。

contentarray

出力メッセージのコンテンツ。

プロパティ

textstring

音声認識結果。

annotationsarray

言語などの出力アノテーション情報。

プロパティ

languagestring

認識された音声の言語。language リクエストパラメーターが指定されている場合、この値は指定されたパラメーターと同じです。

有効な値

  • zh:中国語 (標準語、四川語、閩南語、呉語)
  • yue:広東語
  • en:英語
  • ja:日本語
  • de:ドイツ語
  • ko:韓国語
  • ru:ロシア語
  • fr:フランス語
  • pt:ポルトガル語
  • ar:アラビア語
  • it:イタリア語
  • es:スペイン語
  • hi:ヒンディー語
  • id:インドネシア語
  • th:タイ語
  • tr:トルコ語
  • uk:ウクライナ語
  • vi:ベトナム語
  • cs:チェコ語
  • da:デンマーク語
  • fil:フィリピン語
  • fi:フィンランド語
  • is:アイスランド語
  • ms:マレー語
  • no:ノルウェー語
  • pl:ポーランド語
  • sv:スウェーデン語

typestring

音声情報を示す audio_info に設定します。

emotionstring

感情認識は常に有効で、追加設定は不要です。 認識された音声の感情。以下の感情がサポートされています:

  • surprised:驚き
  • neutral:中立
  • happy:喜び
  • sad:悲しみ
  • disgusted:嫌悪
  • angry:怒り
  • fearful:恐怖

usageobject

このリクエストのトークン消費情報。

プロパティ

input_tokens_details object

Qwen3-ASR-Flash の入力コンテンツの長さをトークンで表したもの。

プロパティ

text_tokens integer

このパラメーターは無視できます。

output_tokens_details object

Qwen3-ASR-Flash からの出力コンテンツの長さをトークンで表したもの。

プロパティ

text_tokens integer

Qwen3-ASR-Flash によって出力された認識テキストの長さをトークンで表したもの。

seconds integer

Qwen3-ASR-Flash の音声持続時間 (秒)。

{
    "output": {
        "choices": [
            {
                "finish_reason": "stop",
                "message": {
                    "annotations": [
                        {
                            "language": "zh",
                            "type": "audio_info",
                            "emotion": "neutral"
                        }
                    ],
                    "content": [
                        {
                            "text": "Welcome to Alibaba Cloud."
                        }
                    ],
                    "role": "assistant"
                }
            }
        ]
    },
    "usage": {
        "input_tokens_details": {
            "text_tokens": 0
        },
        "output_tokens_details": {
            "text_tokens": 6
        },
        "seconds": 1
    },
    "request_id": "568e2bf0-d6f2-97f8-9f15-a57b11dc6977"
}

DashScope 非同期呼び出し

プロセスの説明

非同期呼び出しは、長時間の音声ファイルや時間のかかるタスク向けに設計されています。リクエストのタイムアウトを防ぐために、「送信-ポーリング」の 2 段階のプロセスを使用します:

  1. ステップ 1:タスクの送信

    • クライアントは非同期処理リクエストを開始します。
    • リクエストを検証した後、サーバーはタスクをすぐに実行しません。代わりに、タスクが正常に作成されたことを示す一意の task_id を返します。
  2. ステップ 2:結果の取得

    • クライアントは task_id を使用して結果クエリ API をポーリングします。
    • タスクが完了すると、結果クエリ API は最終的な認識結果を返します。

統合環境に基づいて、SDK を使用するか、RESTful API を直接呼び出すかを選択できます。

  • SDK を使用します。サンプルコードについては、「リクエスト例」をご参照ください。リクエストパラメーターについては、タスクの送信操作のリクエストボディをご参照ください。応答については、「非同期呼び出し結果の説明」をご参照ください。

    SDK は、基盤となる API 呼び出しの詳細を自動的に処理します。

    1. タスクの送信:async_call() (Python) または asyncCall() (Java) メソッドを呼び出してタスクを送信します。このメソッドは、task_id を含むタスクオブジェクトを返します。
    2. 結果の取得:前のステップで返されたタスクオブジェクトまたは task_id を使用して、fetch() メソッドを呼び出して結果を取得します。SDK は、タスクが完了するかタイムアウトするまで、内部のポーリングロジックを自動的に処理します。
  • RESTful API を使用する

    RESTful API を直接呼び出すことで、最大限の柔軟性が得られます。

    1. タスクを送信します。リクエストが成功した場合、レスポンスボディには task_id が含まれます。
    2. 前のステップの 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 へ

リクエストボディ

modelstring(必須)

モデル名。このパラメーターは Qwen3-ASR-Flash-Filetrans モデルにのみ適用されます。

inputobject(必須)

プロパティ

file_url string(必須)

認識対象の音声ファイルの URL。URL はパブリックネットワーク経由でアクセス可能である必要があります。

SDK を使用する場合、音声ファイルが OSS に保存されている場合、oss:// で始まる一時 URL はサポートされません。

RESTful API を使用する場合、音声ファイルが OSS に保存されている場合、oss:// で始まる一時 URL はサポートされます。注意:

重要

  • 一時 URL は 48 時間有効です。有効期限が切れると使用できなくなります。本番環境では使用しないでください。
  • ファイルアップロード認証情報 API は 100 QPS にレート制限されており、スケールアップできません。本番環境、高同時実行、またはストレステストシナリオでは使用しないでください。
  • 本番環境では、長期的なファイルの可用性を確保し、レート制限の問題を回避するために、Alibaba Cloud OSS などの安定したストレージサービスを使用することを推奨します。

parametersobject(任意)

プロパティ

language string (任意) デフォルト値なし

音声の言語がわかっている場合は、このパラメーターを使用して指定することで、認識精度を向上させることができます。

指定できる言語は 1 つだけです。

音声の言語が不明な場合や、複数の言語 (中国語、英語、日本語、韓国語の混合など) が含まれる場合は、このパラメーターを指定しないでください。

有効な値

  • zh:中国語 (標準語、四川語、閩南語、呉語)
  • yue:広東語
  • en:英語
  • ja:日本語
  • de:ドイツ語
  • ko:韓国語
  • ru:ロシア語
  • fr:フランス語
  • pt:ポルトガル語
  • ar:アラビア語
  • it:イタリア語
  • es:スペイン語
  • hi:ヒンディー語
  • id:インドネシア語
  • th:タイ語
  • tr:トルコ語
  • uk:ウクライナ語
  • vi:ベトナム語
  • cs:チェコ語
  • da:デンマーク語
  • fil:フィリピン語
  • fi:フィンランド語
  • is:アイスランド語
  • ms:マレー語
  • no:ノルウェー語
  • pl:ポーランド語
  • sv:スウェーデン語

enable_itnboolean (任意) デフォルト: false

逆テキスト正規化 (ITN) を有効にするかどうかを指定します。この機能は、中国語と英語の音声にのみ適用されます。

  • true
  • false (デフォルト)

enable_wordsboolean(任意) デフォルト: false

単語レベルのタイムスタンプを返すかどうかを指定します:

  • false:文レベルのタイムスタンプを返します。

  • true:単語レベルのタイムスタンプを返します。

    単語レベルのタイムスタンプは、中国語、英語、日本語、韓国語、ドイツ語、フランス語、スペイン語、イタリア語、ポルトガル語、ロシア語のみでサポートされています。他の言語の精度は保証できません。

このパラメーターは、文のセグメンテーションルールにも影響します:

  • false:文のセグメンテーションは音声アクティビティ検出 (VAD) に基づいています。
  • true:文のセグメンテーションは VAD と句読点に基づいています。

channel_idarray(任意) デフォルト: [0]

マルチトラック音声ファイルで認識するオーディオトラックのインデックスを指定します。インデックスは 0 から始まります。たとえば、[0] は最初のオーディオトラックが認識されることを示し、[0, 1] は最初と 2 番目のオーディオトラックが同時に認識されることを示します。このパラメーターを省略した場合、デフォルトで最初のオーディオトラックが処理されます。

重要指定された各オーディオトラックは個別に課金されます。たとえば、1 つのファイルに対して [0, 1] をリクエストすると、2 回の個別の料金が発生します。

cURL

# ======= Important =======
# The following configuration is for the Singapore region. Replace "{WorkspaceId}" with your actual workspace ID. The configuration varies by region.
# The API keys for the Singapore and Beijing regions are different. For more information about how to obtain an API key, see https://www.alibabacloud.com/help/model-studio/get-api-key
# === Delete this comment before running the command. ===

curl --location --request POST 'https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/services/audio/asr/transcription' \
--header "Authorization: Bearer $DASHSCOPE_API_KEY" \
--header "Content-Type: application/json" \
--header "X-DashScope-Async: enable" \
--data '{
    "model": "qwen3-asr-flash-filetrans",
    "input": {
        "file_url": "{YOUR_AUDIO_URL}"
    },
    "parameters": {
        "channel_id":[
            0
        ],
        "enable_itn": false
    }
}'

Java

SDK の例については、「リクエスト例」をご参照ください。

import com.google.gson.Gson;
import com.google.gson.annotations.SerializedName;
import okhttp3.*;

import java.io.IOException;

public class Main {
    // The following configuration is for the Singapore region. Replace "{WorkspaceId}" with your actual workspace ID. The configuration varies by region.
    private static final String API_URL = "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/services/audio/asr/transcription";

    public static void main(String[] args) {
        // The API keys for the Singapore and Beijing regions are different. For more information about how to obtain an API key, see https://www.alibabacloud.com/help/model-studio/get-api-key
        // If the environment variable is not configured, replace the following line with your Model Studio API key: String apiKey = "sk-xxx"
        String apiKey = System.getenv("DASHSCOPE_API_KEY");

        OkHttpClient client = new OkHttpClient();
        Gson gson = new Gson();

        /*String payloadJson = """
                {
                    "model": "qwen3-asr-flash-filetrans",
                    "input": {
                        "file_url": "{YOUR_AUDIO_URL}"
                    },
                    "parameters": {
                        "channel_id": [0],
                        "enable_itn": false,
                        "language": "zh",
                        "corpus": {
                            "text": ""
                        }
                    }
                }
                """;*/
        String payloadJson = """
                {
                    "model": "qwen3-asr-flash-filetrans",
                    "input": {
                        "file_url": "{YOUR_AUDIO_URL}"
                    },
                    "parameters": {
                        "channel_id": [0],
                        "enable_itn": false
                    }
                }
                """;

        RequestBody body = RequestBody.create(payloadJson, MediaType.get("application/json; charset=utf-8"));
        Request request = new Request.Builder()
                .url(API_URL)
                .addHeader("Authorization", "Bearer " + apiKey)
                .addHeader("Content-Type", "application/json")
                .addHeader("X-DashScope-Async", "enable")
                .post(body)
                .build();

        try (Response response = client.newCall(request).execute()) {
            if (response.isSuccessful() && response.body() != null) {
                String respBody = response.body().string();
                // Parse JSON using Gson
                ApiResponse apiResp = gson.fromJson(respBody, ApiResponse.class);
                if (apiResp.output != null) {
                    System.out.println("task_id: " + apiResp.output.taskId);
                } else {
                    System.out.println(respBody);
                }
            } else {
                System.out.println("task failed! HTTP code: " + response.code());
                if (response.body() != null) {
                    System.out.println(response.body().string());
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    static class ApiResponse {
        @SerializedName("request_id")
        String requestId;

        Output output;
    }

    static class Output {
        @SerializedName("task_id")
        String taskId;

        @SerializedName("task_status")
        String taskStatus;
    }
}

Python

SDK の例については、「リクエスト例」をご参照ください。

import requests
import json
import os

# The following configuration is for the Singapore region. Replace "{WorkspaceId}" with your actual workspace ID. The configuration varies by region.
url = "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/services/audio/asr/transcription"

# The API keys for the Singapore and Beijing regions are different. For more information about how to obtain an API key, see https://www.alibabacloud.com/help/model-studio/get-api-key
# If the environment variable is not configured, replace the following line with your Model Studio API key: DASHSCOPE_API_KEY = "sk-xxx"
DASHSCOPE_API_KEY = os.getenv("DASHSCOPE_API_KEY")

headers = {
    "Authorization": f"Bearer {DASHSCOPE_API_KEY}",
    "Content-Type": "application/json",
    "X-DashScope-Async": "enable"
}

payload = {
    "model": "qwen3-asr-flash-filetrans",
    "input": {
        "file_url": "{YOUR_AUDIO_URL}"
    },
    "parameters": {
        "channel_id": [0],
        # "language": "zh",
        "enable_itn": False
        # "corpus": {
        #     "text": ""
        # }
    }
}

response = requests.post(url, headers=headers, data=json.dumps(payload))
if response.status_code == 200:
    print(f"task_id: {response.json()["output"]["task_id"]}")
else:
    print("task failed!")
    print(response.json())

レスポンスボディ

request_idstring

この呼び出しの一意の識別子。

outputobject

呼び出し結果情報。

プロパティ

task_idstring

タスク ID。この ID は、音声認識タスクをクエリするための API のリクエストパラメーターとして渡されます。

task_statusstring

タスクのステータス:

  • PENDING
  • RUNNING
  • SUCCEEDED
  • FAILED
  • UNKNOWN:タスクが存在しないか、ステータスが不明です。
{
    "request_id": "92e3decd-0c69-47a8-************",
    "output": {
        "task_id": "8fab76d0-0eed-4d20-************",
        "task_status": "PENDING"
    }
}

タスク実行結果の取得

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_idstring(必須)

タスク ID。タスクの送信操作の応答から task_id を渡して、音声認識結果をクエリします。

cURL

# ======= Important =======
# The following configuration is for the Singapore region. Replace "{WorkspaceId}" with your actual workspace ID. The configuration varies by region.
# The API keys for the Singapore and Beijing regions are different. For more information about how to obtain an API key, see https://www.alibabacloud.com/help/model-studio/get-api-key
# === Delete this comment before running the command. ===

curl --location --request GET 'https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/tasks/{task_id}' \
--header "Authorization: Bearer $DASHSCOPE_API_KEY" \
--header "Content-Type: application/json"

Java

SDK の例については、「リクエスト例」をご参照ください。

import okhttp3.*;

import java.io.IOException;

public class Main {
    public static void main(String[] args) {
        // Replace with the actual task_id.
        String taskId = "xxx";
        // The API keys for the Singapore and Beijing regions are different. For more information about how to obtain an API key, see https://www.alibabacloud.com/help/model-studio/get-api-key
        // If the environment variable is not configured, replace the following line with your Model Studio API key: String apiKey = "sk-xxx"
        String apiKey = System.getenv("DASHSCOPE_API_KEY");

        // The following configuration is for the Singapore region. Replace "{WorkspaceId}" with your actual workspace ID. The configuration varies by region.
        String apiUrl = "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/tasks/" + taskId;

        OkHttpClient client = new OkHttpClient();

        Request request = new Request.Builder()
                .url(apiUrl)
                .addHeader("Authorization", "Bearer " + apiKey)
                .addHeader("Content-Type", "application/json")
                .get()
                .build();

        try (Response response = client.newCall(request).execute()) {
            if (response.body() != null) {
                System.out.println(response.body().string());
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

Python

SDK の例については、「リクエスト例」をご参照ください。

import os
import requests

# The API keys for the Singapore and Beijing regions are different. For more information about how to obtain an API key, see https://www.alibabacloud.com/help/model-studio/get-api-key
# If the environment variable is not configured, replace the following line with your Model Studio API key: DASHSCOPE_API_KEY = "sk-xxx"
DASHSCOPE_API_KEY = os.getenv("DASHSCOPE_API_KEY")

# Replace with the actual task_id.
task_id = "xxx"
# The following configuration is for the Singapore region. Replace "{WorkspaceId}" with your actual workspace ID. The configuration varies by region.
url = f"https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/tasks/{task_id}"

headers = {
    "Authorization": f"Bearer {DASHSCOPE_API_KEY}",
    "Content-Type": "application/json"
}

response = requests.get(url, headers=headers)
print(response.json())

レスポンスボディ

request_idstring

この呼び出しの一意の識別子。

outputobject

呼び出し結果情報。

プロパティ

task_idstring

タスク ID。この ID は、音声認識タスクをクエリするための API のリクエストパラメーターとして渡されます。

task_statusstring

タスクのステータス:

  • PENDING
  • RUNNING
  • SUCCEEDED
  • FAILED
  • UNKNOWN:タスクが存在しないか、ステータスが不明です。

resultobject

音声認識結果。

プロパティ

transcription_urlstring

認識結果ファイルのダウンロード URL。リンクは 24 時間有効です。リンクの有効期限が切れると、以前の URL を使用してタスクをクエリしたり、結果をダウンロードしたりすることはできません。
認識結果は JSON ファイルとして保存されます。このリンクからファイルをダウンロードするか、HTTP リクエストを使用してファイルの内容を直接読み取ることができます。

詳細については、「非同期呼び出し結果の説明」をご参照ください。

submit_timestring

タスクが送信された時刻。

schedule_timestring

タスクがスケジュールされた時刻、つまり実行の開始時刻。

end_timestring

タスクが終了した時刻。

task_metricsobject

タスクメトリック。サブタスクのステータスに関する統計情報が含まれます。

プロパティ

TOTALinteger

サブタスクの総数。

SUCCEEDEDinteger

成功したサブタスクの数。

FAILEDinteger

失敗したサブタスクの数。

codestring

エラーコード。これはタスクが失敗した場合にのみ返されます。

messagestring

エラーメッセージ。これはタスクが失敗した場合にのみ返されます。

usageobject

このリクエストのトークン消費情報。

プロパティ

seconds integer

Qwen3-ASR-Flash の音声持続時間 (秒)。

{
    "request_id": "6769df07-2768-4fb0-ad59-************",
    "output": {
        "task_id": "9be1700a-0f8e-4778-be74-************",
        "task_status": "RUNNING",
        "submit_time": "2025-10-27 14:19:31.150",
        "scheduled_time": "2025-10-27 14:19:31.233",
        "task_metrics": {
            "TOTAL": 1,
            "SUCCEEDED": 0,
            "FAILED": 0
        }
    }
}
{
    "request_id": "1dca6c0a-0ed1-4662-aa39-************",
    "output": {
        "task_id": "8fab76d0-0eed-4d20-929f-************",
        "task_status": "SUCCEEDED",
        "submit_time": "2025-10-27 13:57:45.948",
        "scheduled_time": "2025-10-27 13:57:46.018",
        "end_time": "2025-10-27 13:57:47.079",
        "result": {
            "transcription_url": "http://dashscope-result-bj.oss-cn-beijing.aliyuncs.com/pre/pre-funasr-mlt-v1/20251027/13%3A57/7a3a8236-ffd1-4099-a280-0299686ac7da.json?Expires=1761631066&OSSAccessKeyId=YOUR_ACCESS_KEY_ID&Signature=YOUR_SIGNATURE&response-content-disposition=attachment%3Bfilename%3D7a3a8236-ffd1-4099-a280-0299686ac7da.json"
        }
    },
    "usage": {
        "seconds": 3
    }
}
{
    "request_id": "3d141841-858a-466a-9ff9-************",
    "output": {
        "task_id": "c58c7951-7789-4557-9ea3-************",
        "task_status": "FAILED",
        "submit_time": "2025-10-27 15:06:06.915",
        "scheduled_time": "2025-10-27 15:06:06.967",
        "end_time": "2025-10-27 15:06:07.584",
        "code": "FILE_403_FORBIDDEN",
        "message": "FILE_403_FORBIDDEN"
    }
}

非同期呼び出し結果の説明

file_url string

認識された音声ファイルの URL。

audio_infoobject

認識された音声ファイルに関する情報。

プロパティ

format string

音声フォーマット。

sample_rate integer

音声サンプリングレート。

transcriptsarray

完全な認識結果のリスト。各要素は、オーディオトラックの認識されたコンテンツに対応します。

プロパティ

channel_idinteger

オーディオトラックのインデックス。0 から始まります。

textstring

認識されたテキスト。

sentencesobject

文レベルの認識結果のリスト。

プロパティ

begin_time integer

文の開始タイムスタンプ (ミリ秒)。

end_time integer

文の終了タイムスタンプ (ミリ秒)。

textstring

認識されたテキスト。

sentence_idinteger

文のインデックス。0 から始まります。

languagestring

認識された音声の言語。language リクエストパラメーターが指定されている場合、この値は指定されたパラメーターと同じです。

有効な値

  • zh:中国語 (標準語、四川語、閩南語、呉語)
  • yue:広東語
  • en:英語
  • ja:日本語
  • de:ドイツ語
  • ko:韓国語
  • ru:ロシア語
  • fr:フランス語
  • pt:ポルトガル語
  • ar:アラビア語
  • it:イタリア語
  • es:スペイン語
  • hi:ヒンディー語
  • id:インドネシア語
  • th:タイ語
  • tr:トルコ語
  • uk:ウクライナ語
  • vi:ベトナム語
  • cs:チェコ語
  • da:デンマーク語
  • fil:フィリピン語
  • fi:フィンランド語
  • is:アイスランド語
  • ms:マレー語
  • no:ノルウェー語
  • pl:ポーランド語
  • sv:スウェーデン語

emotionstring

感情認識は常に有効で、追加設定は不要です。 認識された音声の感情。以下の感情がサポートされています:

  • surprised
  • neutral
  • happy
  • sad
  • disgusted
  • angry
  • fearful

wordsobject

単語レベルの認識結果のリスト。この結果は、enable_words リクエストパラメーターが true に設定されている場合に表示されます。

プロパティ

begin_time integer

開始タイムスタンプ (ミリ秒)。

end_time integer

終了タイムスタンプ (ミリ秒)。

textstring

認識されたテキスト。

punctuationstring

句読点。

{
    "file_url": "https://***.wav",
    "audio_info": {
        "format": "wav",
        "sample_rate": 16000
    },
    "transcripts": [
        {
            "channel_id": 0,
            "text": "Senior staff, Principal Doris Jackson, Wakefield faculty, and of course my fellow classmates.I am honored to have been chosen to speak before my classmates along with the students across America today.",
            "sentences": [
                {
                    "sentence_id": 0,
                    "begin_time": 240,
                    "end_time": 6720,
                    "language": "en",
                    "emotion": "happy",
                    "text": "Senior staff, Principal Doris Jackson, Wakefield faculty, and of course my fellow classmates.",
                    "words": [
                        {
                            "begin_time": 240,
                            "end_time": 1120,
                            "text": "Senior ",
                            "punctuation": ""
                        },
                        {
                            "begin_time": 1120,
                            "end_time": 1200,
                            "text": "staff",
                            "punctuation": ","
                        },
                        {
                            "begin_time": 1680,
                            "end_time": 1920,
                            "text": " Principal ",
                            "punctuation": ""
                        },
                        {
                            "begin_time": 2000,
                            "end_time": 2320,
                            "text": "Doris ",
                            "punctuation": ""
                        },
                        {
                            "begin_time": 2320,
                            "end_time": 2960,
                            "text": "Jackson",
                            "punctuation": ","
                        },
                        {
                            "begin_time": 3360,
                            "end_time": 3840,
                            "text": " Wakefield ",
                            "punctuation": ""
                        },
                        {
                            "begin_time": 3840,
                            "end_time": 4480,
                            "text": "faculty",
                            "punctuation": ","
                        },
                        {
                            "begin_time": 4800,
                            "end_time": 4960,
                            "text": " and ",
                            "punctuation": ""
                        },
                        {
                            "begin_time": 4960,
                            "end_time": 5040,
                            "text": "of ",
                            "punctuation": ""
                        },
                        {
                            "begin_time": 5040,
                            "end_time": 5520,
                            "text": "course ",
                            "punctuation": ""
                        },
                        {
                            "begin_time": 5520,
                            "end_time": 5680,
                            "text": "my ",
                            "punctuation": ""
                        },
                        {
                            "begin_time": 5760,
                            "end_time": 6000,
                            "text": "fellow ",
                            "punctuation": ""
                        },
                        {
                            "begin_time": 6000,
                            "end_time": 6720,
                            "text": "classmates",
                            "punctuation": "."
                        }
                    ]
                },
                {
                    "sentence_id": 1,
                    "begin_time": 12268,
                    "end_time": 17388,
                    "language": "en",
                    "emotion": "neutral",
                    "text": "I am honored to have been chosen to speak before my classmates along with the students across America today.",
                    "words": [
                        {
                            "begin_time": 12268,
                            "end_time": 12428,
                            "text": "I ",
                            "punctuation": ""
                        },
                        {
                            "begin_time": 12428,
                            "end_time": 12508,
                            "text": "am ",
                            "punctuation": ""
                        },
                        {
                            "begin_time": 12588,
                            "end_time": 12828,
                            "text": "honored ",
                            "punctuation": ""
                        },
                        {
                            "begin_time": 12908,
                            "end_time": 12908,
                            "text": "to ",
                            "punctuation": ""
                        },
                        {
                            "begin_time": 12908,
                            "end_time": 13068,
                            "text": "have ",
                            "punctuation": ""
                        },
                        {
                            "begin_time": 13068,
                            "end_time": 13228,
                            "text": "been ",
                            "punctuation": ""
                        },
                        {
                            "begin_time": 13228,
                            "end_time": 13628,
                            "text": "chosen ",
                            "punctuation": ""
                        },
                        {
                            "begin_time": 13628,
                            "end_time": 13708,
                            "text": "to ",
                            "punctuation": ""
                        },
                        {
                            "begin_time": 13708,
                            "end_time": 14028,
                            "text": "speak ",
                            "punctuation": ""
                        },
                        {
                            "begin_time": 14028,
                            "end_time": 14268,
                            "text": "before ",
                            "punctuation": ""
                        },
                        {
                            "begin_time": 14268,
                            "end_time": 14428,
                            "text": "my ",
                            "punctuation": ""
                        },
                        {
                            "begin_time": 14428,
                            "end_time": 15148,
                            "text": "classmates ",
                            "punctuation": ""
                        },
                        {
                            "begin_time": 15308,
                            "end_time": 15468,
                            "text": "as ",
                            "punctuation": ""
                        },
                        {
                            "begin_time": 15468,
                            "end_time": 15628,
                            "text": "well ",
                            "punctuation": ""
                        },
                        {
                            "begin_time": 15628,
                            "end_time": 15788,
                            "text": "as ",
                            "punctuation": ""
                        },
                        {
                            "begin_time": 15788,
                            "end_time": 15788,
                            "text": "the ",
                            "punctuation": ""
                        },
                        {
                            "begin_time": 15788,
                            "end_time": 16188,
                            "text": "students ",
                            "punctuation": ""
                        },
                        {
                            "begin_time": 16188,
                            "end_time": 16588,
                            "text": "across ",
                            "punctuation": ""
                        },
                        {
                            "begin_time": 16588,
                            "end_time": 16988,
                            "text": "America ",
                            "punctuation": ""
                        },
                        {
                            "begin_time": 16988,
                            "end_time": 17388,
                            "text": "today",
                            "punctuation": "."
                        }
                    ]
                }
            ]
        }
    ]
}