Qwen非实时语音识别(同步接口)
更新时间 2026-09-06 17:30:46
最近更新时间: 2026-09-06 17:30:46
本文介绍阿里Qwen非实时语音识别(同步)调用API。
支持的模型
Qwen‑Audio‑3.0‑ASR‑Flash 是通义音频系列非实时语音识别模型,面向短录音文件做语音转文字,支持30 余种语种识别,支持中文多方言口音识别,内置标点预测、文本归一化;支持即时热词、预编译热词、对话上下文增强,可提升专有名词、行业词汇识别准确率;支持 SSE 流式输出中间识别结果,也支持一次性返回完整识别文本,同时输出句子、词级时间戳信息
接口详情
http调用
请求方式:POST
请求路径:https://ai.ctaigw.cn/v1/services/aigc/multimodal-generation/generation
请求头
| 参数 | 必填 | 说明 |
|---|---|---|
| Content‑Type | 是 | 固定application/json |
| Authorization | 是 | Bearer ${YOUR_APP_KEY} |
| X‑DashScope‑SSE | 是 | enable开启 SSE 流式;disable关闭流式,仅返回最终结果。音频≥1 分钟才会产生流式分片结果 |
在流式模式下,客户端需关注以下处理要点:
每收到一个SSE事件,解析data字段中的JSON。
通过output.sentence.sentence_end判断当前句子是否结束:当该值为true时,该句识别完成,词级时间戳已稳定,可作为最终结果使用;当该值为false时,识别仍在进行中,文本和时间戳可能在后续事件中更新。
usage信息仅在句子结束事件中返回,可用于计量音频处理时长。
请求参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| model | string | 是 | 模型名 |
| input | object | 是 | 输入对象,包含消息数组 |
| messages | array(object) | 是 | 消息列表。包含当前待识别的音频,以及可选的对话上下文(用于提升识别效果)。 |
| messages.role | string | 是 | user 用户消息; assistant 上下文历史回复 |
| messages.content | array[object] | 是 | 内容数组,每一项为一种内容类型 |
| messages.content[].type | string | 是 | 内容类型。每个请求至少需要一条input_audio类型的消息。取值范围: - input_audio(必选):当前待识别的音频输入(role为user),需同时传入input_audio对象。 - input_text(可选,上下文):前几轮用户语音的识别结果或领域相关的词表(role为user),需同时传入text字段。 - text(可选,上下文):前几轮大语言模型的回复内容(role为assistant),需同时传入text字段。 |
| messages.content[].input_audio | string | 必选(至少一条) | 待识别音频;input_audio.data支持公网 URL / Base64 Data‑URI |
| messages.content[].input_text | string | 可选 | 上下文用户文本 / 领域词表,配合text字段 |
| messages.content[].text | string | 可选 | assistant 角色历史回复文本 |
| parameters | object | 必选 | 模型参数 |
| parameters.format | string | 是 | 音频格式:wav/mp3/opus等 |
| parameters.sample_rate | string | 可选 | 采样率,例16000 |
| parameters.vocabulary_id | string | 可选 | 预编译热词列表 ID,复用词表 |
| parameters.vocabulary | object | 可选 | 即时热词(仅 qwen‑audio‑3.0‑asr‑flash 支持),key 热词,value 权重 1‑5 或 50;50 为超级热词,最多 50 个超级热词 |
| parameters.language_hints | array[string] | 可选 | 语种提示码;qwen‑audio‑3.0‑asr‑flash 最多 4 个;fun‑asr‑flash 仅取第一个;如["zh","en"] |
响应参数
| 返回字段 | 类型 | 说明 |
|---|---|---|
| request_id | string | 请求唯一 ID,用于排错 |
| output.text | string | 累积完整识别文本 |
| output.sentence.sentence_id | int | 句子序号,从 1 开始 |
| output.sentence.sentence_end | bool | 是否句子结束;true 代表句子结果稳定 |
| output.sentence.begin_time | int | 句子起止时间,单位 ms,end_time 仅 sentence_end=true 返回 |
| output.sentence.end_time | ||
| output.sentence.channel_id | int | 声道编号,从 0 开始 |
| output.sentence.words | array | 词级时间戳;fixed是否稳定;punctuation后置标点 |
| usage.duration | int | 已处理音频时长,单位秒,仅句子结束返回 |
请求/响应示例
请求示例
curl --location --request POST 'https://ai.ctaigw.cn/v1/services/aigc/multimodal-generation/generation' \
--header "Authorization: Bearer ${YOUR_APP_KEY}" \
--header "Content-Type: application/json" \
--header "X-DashScope-SSE: disable" \
--data '{
"model": "qwen-audio-3.0-asr-flash",
"input": {
"messages": [
{
"role": "user",
"content": [
{
"type": "input_audio",
"input_audio": {
"data": "{YOUR_AUDIO_URL}"
}
}
]
}
]
},
"parameters": {
"format": "wav",
"sample_rate": "16000"
}
}'非流式响应示例
{
"output": {
"sentence": {
"begin_time": 760,
"channel_id": 0,
"end_time": 3800,
"sentence_end": true,
"sentence_id": 1,
"text": "Hello World",
"words": [
{"begin_time": 760, "end_time": 1040, "fixed": true, "punctuation": "", "text": "Hello"},
{"begin_time": 1040, "end_time": 1240, "fixed": true, "punctuation": ",", "text": " World"}
]
},
"text": "Hello World"
},
"usage": {
"duration": 4
},
"request_id": "00d06a841873c0a83bfaf1fae0184625"
}流式响应示例
id: 1
event:result
:HTTP_STATUS/200
data: {
"output": {
"sentence": {
"sentence_id": 1,
"sentence_end": true,
"end_time": 3800,
"words": [
{
"end_time": 1040,
"punctuation": "",
"begin_time": 760,
"fixed": true,
"text": "Hello"
},
{
"end_time": 1240,
"punctuation": ",",
"begin_time": 1040,
"fixed": true,
"text": " World"
}
],
"begin_time": 760,
"text": "Hello World",
"channel_id": 0
},
"text": "Hello World"
},
"usage": {
"duration": 4
},
"request_id": "00d06a841873c0a83bfaf1fae0184625"
}异常响应
{
"error": {
"type:": "Invalid_request",
"code": "missing_parameter",
"message": "Missing required parameters"
}
}