0 break-words sidebar-title">对话模型
图像生成 API
视频生成 API
3D 生成 API
专项模型 API
跳转到主要内容
非实时

Fun-ASR 录音文件识别 HTTP API

录音文件转写 REST API

使用指南: 教程、代码示例和模型详情请参见录音文件转写 该服务包含两个 API:任务提交任务查询。先提交任务,再轮询查询 API 获取结果。

限制条件

该服务不支持上传本地文件或 Base64 编码的音频。您必须提供通过 HTTP 或 HTTPS 协议公开访问的文件 URL,例如 https://your-domain.com/file.mp3 通过 file_urls 参数指定 URL,单次请求最多支持 100 个 URL。
  • 音频格式aacamraviflacflvm4amkvmovmp3mp4mpegoggopuswavwebmwmawmv
音频格式存在众多变体,API 无法保证所有格式都能正确处理。请先测试您的文件以验证结果。
  • 音频采样率: 不限
  • 文件大小和时长:最大 2 GB,最长 12 小时。超出限制的文件需先预处理,参见使用 FFmpeg 预处理音频文件
  • 批量大小:单次请求最多 100 个文件 URL。
  • 支持语言:fun-asr 系列支持 30 种语言,详见支持的语言
  • 前端调用:不支持从前端直接调用该 API,请使用后端代理。

任务提交 API

基本信息

项目说明
描述提交语音识别任务。
URLhttps://dashscope.aliyuncs.com/api/v1/services/audio/asr/transcription
请求方式POST
请求头见下文
请求体见下文
请求头
Authorization: Bearer $DASHSCOPE_API_KEY
Content-Type: application/json
X-DashScope-Async: enable
必须包含 X-DashScope-Async: enable 请求头。
请求体(包含所有请求参数,可选字段可省略):
{
  "model": "fun-asr",
  "input": {
    "file_urls": [
      "https://dashscope.oss-cn-beijing.aliyuncs.com/samples/audio/paraformer/hello_world_female2.wav",
      "https://dashscope.oss-cn-beijing.aliyuncs.com/samples/audio/paraformer/hello_world_male2.wav"
    ]
  },
  "parameters": {
    "vocabulary_id": "vocab-Xxxx",
    "channel_id": [0],
    "diarization_enabled": false,
    "speaker_count": 2
  }
}

请求参数

curl --location 'https://dashscope.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":"fun-asr","input":{"file_urls":["https://dashscope.oss-cn-beijing.aliyuncs.com/samples/audio/paraformer/hello_world_female2.wav",
              "https://dashscope.oss-cn-beijing.aliyuncs.com/samples/audio/paraformer/hello_world_male2.wav"]},"parameters":{"channel_id":[0]}}'
参数类型默认值是否必填说明
modelstring-模型名称。参见语音识别模型
file_urlsarray[string]-音频或视频文件 URL 列表(HTTP/HTTPS),单次请求最多 100 个 URL。
vocabulary_idstring-热词 ID,将热词应用于当前任务,默认禁用。参见自定义热词
channel_idarray[integer][0]多音轨文件中要识别的音轨索引,从 0 开始。例如 [0] 识别第一音轨,[0, 1] 识别前两个音轨。默认识别第一音轨。
special_word_filterstring-配置敏感词处理方式。参见敏感词过滤详情
diarization_enabledbooleanfalse启用说话人分离。仅支持单声道音频。启用后,结果中包含 speaker_id 字段以区分不同说话人。参见识别结果说明
speaker_countinteger-说话人数量参考值(2 到 100)。仅在 diarization_enabledtrue 时生效。算法会尽量输出指定数量的说话人,但不保证准确。默认自动检测。
language_hintsarray[string]["zh", "en"]识别语言代码。未设置时模型自动检测语言。参见支持的语言
channel_id 中的每个音轨单独计费。例如:对一个文件使用 [0, 1] 会产生两次计费。

运行与扩展
集成
模型生产
敏感词过滤详情

未设置 special_word_filter 时,内置过滤器将匹配的词替换为等长的星号(*)。 设置后,可使用以下策略:
  • 替换为 *:将匹配的词替换为等长的星号。
  • 过滤删除:从结果中移除匹配的词。
值必须为 JSON 字符串:
{
  "filter_with_signed": {
    "word_list": ["test"]
  },
  "filter_with_empty": {
    "word_list": ["start", "happen"]
  },
  "system_reserved_filter": true
}
字段说明
  • filter_with_signed
    • 类型:object。是否必填:否。
    • 将匹配的词替换为等长的星号。
    • 示例:"Help me test this piece of code" 变为 "Help me **** this piece of code"。
    • 内部字段:word_list -- 要替换的词的字符串数组。
  • filter_with_empty
    • 类型:object。是否必填:否。
    • 从结果中移除匹配的词。
    • 示例:"Is the game about to start?" 变为 "Is the game about to ?"。
    • 内部字段:word_list -- 要移除的词的字符串数组。
  • system_reserved_filter
    • 类型:Boolean。是否必填:否。默认值:true
    • 启用系统预设的敏感词规则。设为 true 时,匹配 千问云敏感词列表的词会被替换为等长的星号。

支持的语言

各模型支持的语言代码:
  • fun-asr, fun-asr-2025-11-07, fun-asr-mtl, fun-asr-mtl-2025-08-25
    • zh:中文、en:英文、ja:日语、ko:韩语、vi:越南语、th:泰语、id:印尼语、ms:马来语、tl:菲律宾语、hi:印地语、ar:阿拉伯语、fr:法语、de:德语、es:西班牙语、pt:葡萄牙语、ru:俄语、it:意大利语、nl:荷兰语、sv:瑞典语、da:丹麦语、fi:芬兰语、no:挪威语、el:希腊语、pl:波兰语、cs:捷克语、hu:匈牙利语、ro:罗马尼亚语、bg:保加利亚语、hr:克罗地亚语、sk:斯洛伐克语
  • fun-asr-2025-08-25
    • zh:中文、en:英文

响应参数

{
  "output": {
    "task_status": "PENDING",
    "task_id": "c2e5d63b-96e1-4607-bb91-************"
  },
  "request_id": "77ae55ae-be17-97b8-9942-************"
}
参数类型说明
task_statusstring任务状态:PENDINGRUNNINGSUCCEEDEDFAILED
task_idstring任务 ID,用于任务查询 API 获取结果。
request_idstring请求 ID。

任务查询 API

基本信息

项目说明
描述查询语音识别任务的状态和结果。
URLhttps://dashscope.aliyuncs.com/api/v1/tasks/\{task_id\}
请求方式GET
请求头见下文
请求体
请求头
Authorization: Bearer $DASHSCOPE_API_KEY

请求参数

curl --location 'https://dashscope.aliyuncs.com/api/v1/tasks/{task_id}' \
     --header "Authorization: Bearer $DASHSCOPE_API_KEY"
参数类型默认值是否必填说明
task_idstring-任务提交 API 返回的任务 ID。

响应参数

多子任务场景:只要有任何一个子任务成功,整体状态即为 SUCCEEDED。请检查 subtask_status 了解各子任务的实际结果。
{
  "request_id": "f9e1afad-94d3-997e-a83b-************",
  "output": {
    "task_id": "f86ec806-4d73-485f-a24f-************",
    "task_status": "SUCCEEDED",
    "submit_time": "2024-09-12 15:11:40.041",
    "scheduled_time": "2024-09-12 15:11:40.071",
    "end_time": "2024-09-12 15:11:40.903",
    "results": [
      {
        "file_url": "https://dashscope.oss-cn-beijing.aliyuncs.com/samples/audio/paraformer/hello_world_male2.wav",
        "transcription_url": "https://dashscope-result-bj.oss-cn-beijing.aliyuncs.com/pre/filetrans-16k/20240912/15%3A11/3bdf7689-b598-409d-806a-121cff5e4a31-1.json?Expires=1726211500&OSSAccessKeyId=yourOSSAccessKeyId&Signature=Fj%2BaF%2FH0Kayj3w3My2ECBeP****%3D",
        "subtask_status": "SUCCEEDED"
      },
      {
        "file_url": "https://dashscope.oss-cn-beijing.aliyuncs.com/samples/audio/paraformer/hello_world_female2.wav",
        "transcription_url": "https://dashscope-result-bj.oss-cn-beijing.aliyuncs.com/pre/filetrans-16k/20240912/15%3A11/409a4b92-445b-4dd8-8c1d-f110954d82d8-1.json?Expires=1726211500&OSSAccessKeyId=yourOSSAccessKeyId&Signature=v5Owy5qoAfT7mzGmQgH0g8C****%3D",
        "subtask_status": "SUCCEEDED"
      }
    ],
    "task_metrics": {
      "TOTAL": 2,
      "SUCCEEDED": 2,
      "FAILED": 0
    }
  },
  "usage": {
    "duration": 9
  }
}
code 字段包含错误码,message 字段包含错误信息。这些字段仅在出错时出现。
{
  "request_id": "a1b2c3d4-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
  "output": {
    "task_id": "7bac899c-06ec-4a79-8875-xxxxxxxxxxxx",
    "task_status": "SUCCEEDED",
    "submit_time": "2024-12-16 16:30:59.170",
    "scheduled_time": "2024-12-16 16:30:59.204",
    "end_time": "2024-12-16 16:31:02.375",
    "results": [
      {
        "file_url": "https://dashscope.oss-cn-beijing.aliyuncs.com/samples/audio/sensevoice/long_audio_demo_cn.mp3",
        "transcription_url": "https://dashscope-result-bj.oss-cn-beijing.aliyuncs.com/prod/paraformer-v2/20241216/xxxx",
        "subtask_status": "SUCCEEDED"
      },
      {
        "file_url": "https://dashscope.oss-cn-beijing.aliyuncs.com/samples/audio/sensevoice/rich_text_example_1.wav",
        "code": "InvalidFile.DownloadFailed",
        "message": "The audio file cannot be downloaded.",
        "subtask_status": "FAILED"
      }
    ],
    "task_metrics": {
      "TOTAL": 2,
      "SUCCEEDED": 1,
      "FAILED": 1
    }
  }
}
{
  "request_id": "b3c4d5e6-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
  "output": {
    "task_id": "9d1f2a3b-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
    "task_status": "RUNNING",
    "submit_time": "2024-09-12 15:11:40.041",
    "scheduled_time": "2024-09-12 15:11:40.071",
    "task_metrics": {
      "TOTAL": 2,
      "SUCCEEDED": 0,
      "FAILED": 0
    }
  }
}
参数类型说明
task_idstring任务 ID。
task_statusstring任务状态。
subtask_statusstring子任务状态。
file_urlstring已处理文件的 URL。
transcription_urlstring识别结果链接,有效期 24 小时。过期后无法查询任务或下载结果。结果为 JSON 文件,可通过 HTTP 下载或读取。参见识别结果说明
submit_timestring任务提交时间。
scheduled_timestring任务调度时间。
end_timestring任务结束时间。
task_metricsobject任务指标:包含 TOTAL(总数)、SUCCEEDED(成功数)和 FAILED(失败数)。
usageobject用量信息。duration 为总时长,单位为秒。

识别结果说明

识别结果为 JSON 文件。
以下为启用说话人分离(diarization_enabled=true)时的识别结果示例:
{
  "file_url": "https://dashscope.oss-cn-beijing.aliyuncs.com/samples/audio/paraformer/hello_world_female2.wav",
  "properties": {
    "audio_format": "pcm_s16le",
    "channels": [0],
    "original_sampling_rate": 16000,
    "original_duration_in_milliseconds": 3834
  },
  "transcripts": [
    {
      "channel_id": 0,
      "content_duration_in_milliseconds": 3720,
      "text": "Hello world, this is Alibaba Speech Lab.",
      "sentences": [
        {
          "begin_time": 100,
          "end_time": 3820,
          "text": "Hello world, this is Alibaba Speech Lab.",
          "sentence_id": 1,
          "speaker_id": 0,
          "words": [
            {
              "begin_time": 100,
              "end_time": 596,
              "text": "Hello ",
              "punctuation": ""
            },
            {
              "begin_time": 596,
              "end_time": 844,
              "text": "world",
              "punctuation": ", "
            }
          ]
        }
      ]
    }
  ]
}
speaker_id 字段仅在启用说话人分离时出现。为简洁起见,其他词条目已省略。
主要参数:
参数类型说明
audio_formatstring源文件的音频格式。
channelsarray[integer]音轨索引。单音轨返回 [0],双音轨返回 [0, 1],以此类推。
original_sampling_rateinteger采样率(Hz)。
original_duration_in_millisecondsinteger原始音频时长(毫秒)。
channel_idinteger转写的音轨索引,从 0 开始。
content_duration_in_millisecondsinteger音轨中语音内容的时长(毫秒)。
textstring转写文本(段落级或词级,取决于上下文)。
sentencesarray句级转写结果。
sentence_idinteger句子序号,从 1 开始。
wordsarray词级转写结果。
begin_timeinteger起始时间戳(毫秒)。
end_timeinteger结束时间戳(毫秒)。
speaker_idinteger说话人索引,从 0 开始。仅在启用说话人分离时出现。
punctuationstring词后的预测标点符号(如有)。
计费仅基于语音片段,而非文件总时长。非语音片段不计费。由于语音检测使用 AI 模型,计费时长可能与预期内容时长略有差异。

DashScope 同步调用

与上述异步调用(提交-轮询)不同,同步调用适用于短音频场景,一次请求立即返回识别结果。

服务端点

POST https://dashscope.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation

请求头

参数类型是否必选说明
Authorizationstring鉴权令牌,格式为 Bearer $DASHSCOPE_API_KEY
Content-Typestring固定为 application/json
X-DashScope-SSEstring设为 enable 时以 SSE 流式方式返回中间和最终结果;设为 disable 或不传则仅返回最终结果。

请求参数

参数类型是否必选说明
modelstring模型名称。取值:fun-asr-realtime(稳定版)、fun-asr-realtime-2026-02-28
input.messagesarray[object]条件必选消息列表,使用 Base64 方式上传音频时填写。与 parameters.audio_address 二选一。
input.messages[].content[].audiostring待识别音频,Data URI 格式:data:audio/wav;base64,{BASE64_ENCODED_DATA}。支持的 MIME 类型:audio/wavaudio/mp3 等。
input.messages[].rolestring固定为 user
parameters.audio_addressstring条件必选音频文件 URL(HTTP/HTTPS)。与 input.messages 二选一。
parameters.formatstring音频格式,如 mp3wav
parameters.vad_enabledboolean是否启用 VAD。默认值:false。启用后对音频做端点检测再识别。

示例

  • 非流式
  • 流式(SSE)
curl --location --request POST 'https://dashscope.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation' \
  --header "Authorization: Bearer $DASHSCOPE_API_KEY" \
  --header "Content-Type: application/json" \
  --header "X-DashScope-SSE: disable" \
  --data '{
  "model": "fun-asr-realtime",
  "input": {
    "messages": []
  },
  "parameters": {
    "audio_address": "https://example.com/audio/sample.mp3",
    "format": "mp3"
  },
  "resources": []
}'

响应字段

流式(SSE)模式下,每个事件的 output.sentence 包含以下字段:
参数类型说明
textstring识别文本。
sentence_idinteger句子序号,从 1 开始递增。
sentence_endboolean是否句子结束(true=最终结果,false=中间结果)。
sentence_beginboolean是否为语句起始帧。
begin_timeinteger语句开始时间(ms)。
end_timeinteger语句结束时间(ms)。
channel_idinteger音频通道编号。
wordsarray词级时间戳。每个词包含 begin_timeend_timetextpunctuationfixed(是否已确认)。
视频生成与编辑

通用视频编辑

重绘、延展与编辑

快捷链接:API 参考:wan2.7wan2.1

可用模型

支持的模型
模型功能输入模态输出视频规格
wan2.7-videoedit 推荐音频(自动/保留原声)、风格迁移、物体替换、参考图编辑文本、图片、视频分辨率:720P、1080P。时长:最长 10 秒。30 fps,MP4(H.264)
wan2.1-vace-plus视频无音频。多图参考、视频重绘、局部编辑、视频延展、画面扩展文本、图片、视频分辨率:720P。时长:最长 5 秒。30 fps,MP4(H.264 编码)

Wan 2.7 视频编辑

通过文本提示词和可选的参考图,以最高 1080P 分辨率编辑视频——支持风格转换、物体替换,以及将参考图中的内容迁移到源视频中。使用统一模型,无需设置 function 参数。

参数说明(wan2.7)

参数类型必选说明
modelstring"wan2.7-videoedit"
input.promptstring最多 5,000 字符。描述期望的编辑效果。
input.negative_promptstring最多 500 字符。需要排除的内容。
input.mediaarray必须包含一个 video 项。可选包含最多 4 个 reference_image 项。
parameters.resolutionstring"720P""1080P"(默认)。
parameters.ratiostring"16:9""9:16""1:1""4:3""3:4"。默认与输入视频比例一致。
parameters.durationinteger0 = 保持输入视频完整时长(默认)。2-10 = 截取输入视频指定时长。
parameters.audio_settingstring"auto"(默认,模型自动决定)或 "origin"(保留原声)。
parameters.prompt_extendboolean默认值:true
parameters.watermarkboolean默认值:false

示例:更改视频风格

  • curl
  • Python
第 1 步:创建任务
curl --location 'https://dashscope.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis' \
--header 'X-DashScope-Async: enable' \
--header "Authorization: Bearer $DASHSCOPE_API_KEY" \
--header 'Content-Type: application/json' \
--data '{
  "model": "wan2.7-videoedit",
  "input": {
    "prompt": "Convert the entire scene to a claymation style",
    "media": [
      {
        "type": "video",
        "url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260402/ldnfdf/wan2.7-videoedit-style-change.mp4"
      }
    ]
  },
  "parameters": {
    "resolution": "720P",
    "prompt_extend": true,
    "watermark": true
  }
}'
第 2 步:通过任务 ID 获取结果{task_id} 替换为上一步 API 返回的 task_id 值。
curl -X GET https://dashscope.aliyuncs.com/api/v1/tasks/{task_id} \
--header "Authorization: Bearer $DASHSCOPE_API_KEY"

示例:使用参考图编辑

通过参考图替换视频中的物体:
curl --location 'https://dashscope.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis' \
--header 'X-DashScope-Async: enable' \
--header "Authorization: Bearer $DASHSCOPE_API_KEY" \
--header 'Content-Type: application/json' \
--data '{
  "model": "wan2.7-videoedit",
  "input": {
    "prompt": "Replace the girl'\''s clothes in the video with the clothes from the image",
    "media": [
      {
        "type": "video",
        "url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260403/nlspwm/T2VA_22.mp4"
      },
      {
        "type": "reference_image",
        "url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260402/fwjpqf/wan2.7-videoedit-change-clothes.png"
      }
    ]
  },
  "parameters": {
    "resolution": "720P",
    "prompt_extend": true,
    "watermark": true
  }
}'

Wan 2.1 视频编辑(VACE)

wan2.1-vace-plus 模型支持 5 种专业编辑功能,通过 function 参数选择。

核心功能

多图参考

功能说明:支持最多 3 张参考图,涵盖主体和背景(人物、动物、服装、场景等)。模型将多张图片融合生成连贯的视频内容。 参数设置
  • function:必须设为 image_reference
  • ref_images_url:URL 数组,支持 1 到 3 张参考图。
  • obj_or_bg:标识每张图是主体(obj)还是背景(bg)。该数组长度必须与 ref_images_url 数组长度一致。
输入提示词输入参考图 1(主体参考)输入参考图 2(背景参考)输出视频
视频中,一位少女从古老而雾气弥漫的森林深处走出。她步伐轻盈,镜头捕捉着她每一个优雅的瞬间。当她停下脚步环顾四周郁郁葱葱的树木时,脸上绽放出惊喜与喜悦的微笑。这个光影交错的画面,记录了她与自然的美妙邂逅。
image
image
输出视频
调用 API 前,请先获取 API Key,然后将 API Key 设置为环境变量
  • curl
  • Python
  • Java
第 1 步:创建任务获取任务 ID
curl --location 'https://dashscope.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis' \
--header 'X-DashScope-Async: enable' \
--header "Authorization: Bearer $DASHSCOPE_API_KEY" \
--header 'Content-Type: application/json' \
--data '{
  "model": "wan2.1-vace-plus",
  "input": {
    "function": "image_reference",
    "prompt": "In the video, a girl gracefully walks out from a misty, ancient forest. Her steps are light, and the camera captures her every nimble moment. When she stops and looks around at the lush woods, a smile of surprise and joy blossoms on her face. This scene, frozen in a moment of interplay between light and shadow, records her wonderful encounter with nature.",
    "ref_images_url": [
      "http://wanx.alicdn.com/material/20250318/image_reference_2_5_16.png",
      "http://wanx.alicdn.com/material/20250318/image_reference_1_5_16.png"
    ]
  },
  "parameters": {
    "prompt_extend": true,
    "obj_or_bg": ["obj","bg"],
    "size": "1280*720"
  }
}'
第 2 步:通过任务 ID 获取结果{task_id} 替换为上一步 API 返回的 task_id 值。
curl -X GET https://dashscope.aliyuncs.com/api/v1/tasks/{task_id} \
--header "Authorization: Bearer $DASHSCOPE_API_KEY"