Skip to main content
專項模型

音頻理解(Qwen3-Omni-Captioner)

Qwen3-Omni-Captioner是以千問3-Omni為基座的開源模型,無需任何提示,自動為複雜語音、環境聲、音樂、影視聲效等產生精準、全面的描述,能識別說話人的情緒、音樂元素(如風格、樂器)、敏感資訊等,適用於音頻內容分析、安全性稽核、意圖識別、音頻剪輯等多個領域。當前模型不支援音色、音調、語氣語調等細粒度聲學特徵分析。

支援的模型

  • 新加坡
  • 華北2(北京)

模型名稱

上下文長度

最大輸入

最大輸出

輸入成本

輸出成本

免費額度

(注)

(Token數)

(每百萬Token)

qwen3-omni-30b-a3b-captioner

65,536

32,768

32,768

$3.81

$3.06

100萬Token

有效期間:阿里雲百鍊開通後90天內

音頻轉換為Token的規則:總 Tokens 數 = 音頻時間長度(單位:秒)* 12.5,若音頻時間長度不足1秒,則按 1 秒計算。

快速開始

前提條件 Qwen3-Omni-Captioner模型僅支援通過API調用,暫不支援在阿里雲百鍊的控制台線上體驗。 以下是理解線上音頻(通過URL指定,非本地音頻)的範例程式碼。瞭解如何傳入本地檔案音頻檔案的限制
  • OpenAI相容
  • DashScope
  • Python
  • Node.js
  • curl
import os
from openai import OpenAI

client = OpenAI(
    # 新加坡和北京地區的API Key不同。擷取API Key:https://www.alibabacloud.com/help/zh/model-studio/get-api-key
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    # 以下為新加坡地區URL,調用時請將WorkspaceId替換為真實的業務空間ID,各地區的URL不同。
    base_url="https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1",
)

completion = client.chat.completions.create(
    model="qwen3-omni-30b-a3b-captioner",
    messages=[
        {
            "role": "user",
            "content": [
                {
                    "type": "input_audio",
                    "input_audio": {
                        "data": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20240916/xvappi/%E8%A3%85%E4%BF%AE%E5%99%AA%E9%9F%B3.wav"
                    }
                }
            ]
        }
    ]
)
print(completion.choices[0].message.content)
The audio clip begins with a sudden, loud, metallic clanking that dominates the soundstage, immediately indicating an industrial or workshop environment. The clanking is rhythmic, consistent, and has a sharp, resonant quality, suggestive of metal tools striking metal surfaces—likely a hammer, wrench, or similar instrument being used on a hard metal object. The sound is harsh and slightly distorted, with audible clipping on each impact, likely due to the microphone’s proximity and the high volume of the sound.
As the initial clanking fades, a male voice enters, speaking in Mandarin Chinese with a tone of exasperation and complaint. His voice is clear, close-mic’d, and free from distortion. He says: “哎呀,這樣我還怎麼安靜工作啊?” (“Oh my, how can I possibly work quietly like this?”). His intonation is conversational, informal, and marked by a rising, questioning inflection, typical of everyday speech rather than performance or formal address. The accent is standard Putonghua, with no strong regional markers, suggesting he is a native Mandarin speaker from the northern or central regions of China.
During the speaker’s utterance, the metallic clanking resumes, overlapping with his voice. The timing and nature of these sounds indicate the speaker is directly reacting to the ongoing noise—likely caused by another person in the same space. The environment is acoustically “dry” with minimal echo, implying a small or medium-sized room with sound-absorbing materials, further supporting the workshop or industrial setting. There are no other background noises, music, or ambient sounds, and no evidence of a public or commercial space.
The recording quality is moderate: the microphone captures both the low-end thuds and the sharp metallic transients, but the loud clanking causes digital clipping, resulting in a harsh, “crunchy” distortion during the impacts. The speaker’s voice, however, remains clear and intelligible. The overall impression is of a candid, real-world interaction—possibly a worker or office employee complaining about an interruption in a noisy environment.
In summary, the audio depicts a Mandarin-speaking man in a workshop or industrial setting, reacting with frustration to ongoing metallic clanking that disrupts his work. The recording is informal, clear, and grounded in a context of manual labor or technical work, with no evidence of scripted performance, music, or extraneous activity.

工作方式

  • 單輪互動:模型不支援多輪對話。每次請求都是一次獨立的分析任務。
  • 固定任務:模型的核心任務是產生音頻描述(僅為英文描述),無法通過指令(如 System Message)改變其行為,例如控制輸出格式或內容重點。
  • 僅支援音頻輸入:模型僅接收音頻作為輸入,無需傳入文本提示,message參數格式固定。
    messages=[
            {
                "role": "user",
                "content": [
                    {
                        "type": "input_audio",
                        "input_audio": {
                            "data": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20240916/xvappi/%E8%A3%85%E4%BF%AE%E5%99%AA%E9%9F%B3.wav"
                        }
                    }
                ]
            }
        ]
    

流式輸出

大模型接收到輸入後,會逐步產生中間結果,最終結果由這些中間結果拼接而成。這種一邊產生一邊輸出中間結果的方式稱為流式輸出。採用流式輸出時,您可以在模型進行輸出的同時閱讀,減少等待模型回複的時間。
  • OpenAI相容
  • DashScope
通過 OpenAI 相容方式開啟流式輸出十分方便,只需在請求參數中設定stream參數為true即可。
Python
import os
from openai import OpenAI

client = OpenAI(
    # 新加坡和北京地區的API Key不同。擷取API Key:https://www.alibabacloud.com/help/zh/model-studio/get-api-key
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    # 以下為新加坡地區URL,調用時請將WorkspaceId替換為真實的業務空間ID,各地區的URL不同。
    base_url="https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1",
)

completion = client.chat.completions.create(
    model="qwen3-omni-30b-a3b-captioner",
    messages=[
        {
            "role": "user",
            "content": [
                {
                    "type": "input_audio",
                    "input_audio": {
                        "data": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20240916/xvappi/%E8%A3%85%E4%BF%AE%E5%99%AA%E9%9F%B3.wav"
                    }
                }
            ]
        }
    ],
    stream=True,
    stream_options={"include_usage": True},

)
for chunk in completion:
    # 如果stream_options.include_usage為True,則最後一個chunk的choices欄位為空白列表,需要跳過(可以通過chunk.usage擷取 Token 使用量)
    if chunk.choices and chunk.choices[0].delta.content != "":
        print(chunk.choices[0].delta.content,end="")

傳入本地檔案(Base 64 編碼或檔案路徑)

模型提供兩種本地檔案上傳方式:
  • Base 64 編碼上傳
  • 檔案路徑直接上傳(傳輸更穩定,推薦方式
上傳方式:
  • 檔案路徑傳入
  • Base 64 編碼傳入
直接向模型傳入檔案路徑。僅 DashScope Python 和 Java SDK 支援,不支援 HTTP 方式。請您參考下表,結合您的程式設計語言與作業系統指定檔案的路徑。

指定檔案的路徑

系統

SDK

傳入的檔案路徑

樣本

Linux或macOS系統

Python SDK

file://{檔案的絕對路徑}

file:///home/images/test.mp3

Java SDK

Windows系統

Python SDK

file://{檔案的絕對路徑}

file://D:/images/test.mp3

Java SDK

file:///{檔案的絕對路徑}

file:///D:/images/test.mp3

使用限制:
  • 建議優先選擇檔案路徑上傳(傳輸更穩定),1MB以下的檔案也可使用 Base 64 編碼;
  • 直接傳入檔案路徑時,音頻本身需小於 10MB;
  • Base64編碼方式傳入時,由於 Base 64 編碼會增加資料體積,需保證編碼後的 Base64 字串需小於 10MB。
  • 檔案路徑傳入
  • Base 64 編碼傳入
傳入檔案路徑僅支援 DashScope Python 和 Java SDK方式調用,不支援 HTTP 方式。
Python
import dashscope
import os

# 以下為新加坡地區URL,調用時請將WorkspaceId替換為真實的業務空間ID,各地區的URL不同。
dashscope.base_http_api_url = 'https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1'

# 將 ABSOLUTE_PATH/welcome.mp3 替換為本地音訊絕對路徑,
# 本地檔案的完整路徑必須以 file:// 為首碼,以保證路徑的合法性,例如:file:///home/images/test.mp3
audio_file_path = "file://ABSOLUTE_PATH/welcome.mp3"
messages = [
    {
        "role": "user",
        # 在 audio 參數中傳入以 file:// 為首碼的檔案路徑
        "content": [{"audio": audio_file_path}],
    }
]

response = dashscope.MultiModalConversation.call(
    # 新加坡和北京地區的API Key不同。擷取API Key:https://www.alibabacloud.com/help/zh/model-studio/get-api-key
    # 若沒有配置環境變數,請用百鍊API Key將下行替換為:api_key="sk-xxx"
    api_key=os.getenv('DASHSCOPE_API_KEY'),
    model="qwen3-omni-30b-a3b-captioner",
    messages=messages)

print("輸出結果為:")
print(response["output"]["choices"][0]["message"].content[0]["text"])

API參考

關於千問3-Omni-Captioner的輸入輸出參數,請參見文本產生

錯誤碼

如果模型調用失敗並返回報錯資訊,請參見錯誤碼進行解決。

常見問題

如何壓縮音頻檔案到滿足要求的大小?

  • 線上工具:使用 Compresss 等線上工具壓縮音頻檔案。
  • 代碼實現:使用FFmpeg工具,更多用法請參見FFmpeg官網
# 基礎轉換命令(萬能模板)
# -i,作用:輸入檔案路徑,常用值樣本:input.mp3

# -b:a,作用: 設定音頻位元速率 ,
  # 一般取值有64kbps(低品質,適合語音、低頻寬流媒體)、128k(中等品質,適合日常音頻、播客)、192kbps(高品質,適合音樂、廣播)
  # 位元速率越高,音質越好,檔案體積越大

# -ar,作用:設定音頻採樣率,表示每秒採樣的次數,
 # 一般取值為8000Hz、22050Hz、44100 Hz(標準採樣率)
 # 採樣率越高,檔案體積越大

# -ac,作用:設定音頻通道數。一般取值有 1(單聲道),2(立體聲),單聲道檔案體積更小

# -y,作用:覆蓋已存在檔案(無需值)# output.mp3,作用:輸出檔案路徑

ffmpeg -i input.mp3 -b:a 128k -ar 44100 -ac 1 output.mp3 -y

限制

模型對音頻檔案的限制如下:
  • 時間長度限制:時間長度需小於或等於 40 分鐘
  • 檔案數量:每次請求僅支援1個音頻檔案
  • 檔案格式:支援AMR、 WAV(CodecID: GSM_MS)、 WAV(PCM)、 3GP、 3GPP、 AAC、 MP3等主流格式
  • 檔案輸入方式:公網可訪問的音頻URL、 Base 64 編碼、本地檔案路徑
  • 檔案大小:
    • 公網URL傳入:不超過 1GB
    • 傳入檔案路徑:音頻本身需小於 10MB
    • Base64編碼傳入:需確保編碼後 Base64 字串小於 10MB,詳情請參見如何傳入本地檔案
    如需壓縮檔請參見如何壓縮音頻檔案到滿足要求的大小?
Token Plan
用量統計與效能監控
資產中心
服務支援