跳转到主要内容
语音识别

录音文件转写

将音视频文件转为文字

千问云提供三个模型系列用于录音文件转写:Fun-ASR 支持高精度多语言转写与歌曲识别,Qwen-ASR 具备增强的语义理解能力,Qwen-Omni 支持基于提示词的上下文感知转写。
有关模型可用性、支持语言和功能对比,请参见语音识别模型

快速开始

  • Fun-ASR
  • Qwen-ASR
  • Qwen-Omni
支持的模型
  • Fun-ASR:fun-asr(稳定版,当前等同 fun-asr-2025-11-07)、fun-asr-2025-11-07(快照版)、fun-asr-2025-08-25(快照版)、fun-asr-mtl(稳定版,当前等同 fun-asr-mtl-2025-08-25)、fun-asr-mtl-2025-08-25(快照版)
  • Fun-ASR-Flash:fun-asr-flash-2026-06-15。支持同步调用(最长 5 分钟)和上下文增强
支持语言
  • fun-asr 和 fun-asr-2025-11-07:普通话、粤语、吴语、闽南语、客家话、赣语、湘语、晋语、英语、日语、韩语、越南语、泰语、印尼语、马来语、菲律宾语、印地语、阿拉伯语、法语、德语、西班牙语、葡萄牙语、俄语、意大利语、荷兰语、瑞典语、丹麦语、芬兰语、挪威语、希腊语、波兰语、捷克语、匈牙利语、罗马尼亚语、保加利亚语、克罗地亚语、斯洛伐克语。同时支持中原、西南、冀鲁、江淮、兰银、胶辽、东北、北京、港台等地区的普通话口音。
  • fun-asr-2025-08-25:普通话和英语。
  • fun-asr-mtl 和 fun-asr-mtl-2025-08-25:普通话、粤语、英语、日语、韩语、越南语、泰语、印尼语、马来语、菲律宾语、印地语、阿拉伯语、法语、德语、西班牙语、葡萄牙语、俄语、意大利语、荷兰语、瑞典语、丹麦语、芬兰语、挪威语、希腊语、波兰语、捷克语、匈牙利语、罗马尼亚语、保加利亚语、克罗地亚语和斯洛伐克语。
  • fun-asr-flash-2026-06-15:同 fun-asr-2025-11-07。
支持采样率:任意支持音频格式:aac、amr、avi、flac、flv、m4a、mkv、mov、mp3、mp4、mpeg、ogg、opus、wav、webm、wma、wmv

发起首次调用

获取 API Key将其设置为环境变量。如需使用 SDK,请先安装 SDK由于音视频文件通常较大,文件传输和语音识别可能需要较长时间。录音文件识别 API 采用异步调用方式提交任务。识别完成后,需要通过查询接口获取识别结果。

异步提交并同步等待

提交任务后阻塞等待,直到任务完成。
from http import HTTPStatus
from dashscope.audio.asr import Transcription
from urllib import request
import dashscope
import os
import json

dashscope.base_http_api_url = 'https://dashscope.aliyuncs.com/api/v1'

# 如果您没有配置环境变量,请用 API Key 替换下行代码:dashscope.api_key = "sk-xxx"
dashscope.api_key = os.getenv("DASHSCOPE_API_KEY")

task_response = Transcription.async_call(
  model='fun-asr',
  file_urls=['https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260401/bjgrbu/hello_world_female_en.wav',
      'https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260401/rlrbee/hello_world_male_en.wav'],
  language_hints=['zh', 'en']  # language_hints 为可选参数,用于指定音频的语言代码。取值范围请参见 API 参考文档。
)

transcription_response = Transcription.wait(task=task_response.output.task_id)

if transcription_response.status_code == HTTPStatus.OK:
  for transcription in transcription_response.output['results']:
    if transcription['subtask_status'] == 'SUCCEEDED':
      url = transcription['transcription_url']
      result = json.loads(request.urlopen(url).read().decode('utf8'))
      print(json.dumps(result, indent=4,
      ensure_ascii=False))
    else:
      print('转写失败!')
      print(transcription)
else:
  print('错误:', transcription_response.output.message)
第一条结果
{
  "file_url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260401/bjgrbu/hello_world_female_en.wav",
  "properties": {
    "audio_format": "pcm_s16le",
    "channels": [
      0
    ],
    "original_sampling_rate": 24000,
    "original_duration_in_milliseconds": 3280
  },
  "transcripts": [
    {
      "channel_id": 0,
      "content_duration_in_milliseconds": 3000,
      "text": "Hello world, this is Alibaba Speech Lab. ",
      "sentences": [
        {
          "begin_time": 240,
          "end_time": 3240,
          "text": "Hello world, this is Alibaba Speech Lab. ",
          "sentence_id": 1,
          "words": [
            {
              "begin_time": 240,
              "end_time": 640,
              "text": "Hello",
              "punctuation": ""
            },
            {
              "begin_time": 640,
              "end_time": 960,
              "text": " world",
              "punctuation": ","
            },
            {
              "begin_time": 1280,
              "end_time": 1480,
              "text": " this",
              "punctuation": ""
            },
            {
              "begin_time": 1480,
              "end_time": 1840,
              "text": " is",
              "punctuation": ""
            },
            {
              "begin_time": 1840,
              "end_time": 2520,
              "text": " Alibaba",
              "punctuation": ""
            },
            {
              "begin_time": 2520,
              "end_time": 2920,
              "text": " Speech",
              "punctuation": ""
            },
            {
              "begin_time": 2920,
              "end_time": 3240,
              "text": " Lab",
              "punctuation": ". "
            }
          ]
        }
      ]
    }
  ]
}
第二条结果
{
  "file_url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260401/rlrbee/hello_world_male_en.wav",
  "properties": {
    "audio_format": "pcm_s16le",
    "channels": [
      0
    ],
    "original_sampling_rate": 24000,
    "original_duration_in_milliseconds": 4000
  },
  "transcripts": [
    {
      "channel_id": 0,
      "content_duration_in_milliseconds": 3160,
      "text": "Hello world, this is Alibaba Speech Lab. ",
      "sentences": [
        {
          "begin_time": 800,
          "end_time": 3960,
          "text": "Hello world, this is Alibaba Speech Lab. ",
          "sentence_id": 1,
          "words": [
            {
              "begin_time": 800,
              "end_time": 1200,
              "text": "Hello",
              "punctuation": ""
            },
            {
              "begin_time": 1200,
              "end_time": 1640,
              "text": " world",
              "punctuation": ","
            },
            {
              "begin_time": 1880,
              "end_time": 2120,
              "text": " this",
              "punctuation": ""
            },
            {
              "begin_time": 2120,
              "end_time": 2560,
              "text": " is",
              "punctuation": ""
            },
            {
              "begin_time": 2560,
              "end_time": 3360,
              "text": " Alibaba",
              "punctuation": ""
            },
            {
              "begin_time": 3360,
              "end_time": 3720,
              "text": " Speech",
              "punctuation": ""
            },
            {
              "begin_time": 3720,
              "end_time": 3960,
              "text": " Lab",
              "punctuation": ". "
            }
          ]
        }
      ]
    }
  ]
}

异步提交并轮询查询

提交任务后通过轮询获取结果,而非阻塞等待。
from http import HTTPStatus
from dashscope.audio.asr import Transcription
import dashscope
import os
import json

dashscope.base_http_api_url = 'https://dashscope.aliyuncs.com/api/v1'

# 如果您没有配置环境变量,请用 API Key 替换下行代码:dashscope.api_key = "sk-xxx"
dashscope.api_key = os.getenv("DASHSCOPE_API_KEY")

transcribe_response = Transcription.async_call(
  model='fun-asr',
  file_urls=['https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260401/bjgrbu/hello_world_female_en.wav',
      'https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260401/rlrbee/hello_world_male_en.wav']
)

while True:
  if transcribe_response.output.task_status == 'SUCCEEDED' or transcribe_response.output.task_status == 'FAILED':
    break
  transcribe_response = Transcription.fetch(task=transcribe_response.output.task_id)

if transcribe_response.status_code == HTTPStatus.OK:
  print(json.dumps(transcribe_response.output, indent=4, ensure_ascii=False))
  print('转写完成!')

RESTful API

使用任意 HTTP 库提交任务并轮询获取结果。以下 Python 示例演示了完整流程:
import requests
import json
import os
import time

# 如果您没有配置环境变量,请用 API Key 替换下行代码:api_key = "sk-xxx"
api_key = os.getenv("DASHSCOPE_API_KEY")
file_urls = [
  "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260401/bjgrbu/hello_world_female_en.wav",
  "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260401/rlrbee/hello_world_male_en.wav",
]

region = "dashscope.aliyuncs.com"

# 提交录音文件转写任务,包含待转写的文件 URL 列表
def submit_task(apikey, file_urls) -> str:

  headers = {
    "Authorization": f"Bearer {apikey}",
    "Content-Type": "application/json",
    "X-DashScope-Async": "enable",
  }
  data = {
    "model": "fun-asr",
    "input": {"file_urls": file_urls},
    "parameters": {
      "channel_id": [0],
      # "vocabulary_id": "vocab-Xxxx", # 可选,热词 ID。
    },
  }
  # 录音文件转写服务的 URL
  service_url = (
    f"https://{region}/api/v1/services/audio/asr/transcription"
  )
  response = requests.post(
    service_url, headers=headers, data=json.dumps(data)
  )

  # 打印响应内容
  if response.status_code == 200:
    return response.json()["output"]["task_id"]
  else:
    print("任务提交失败!")
    print(response.json())
    return None


# 循环查询任务状态,直到任务完成
def wait_for_complete(task_id):
  headers = {
    "Authorization": f"Bearer {api_key}",
    "Content-Type": "application/json",
  }

  pending = True
  while pending:
    # 任务状态查询服务的 URL
    service_url = f"https://{region}/api/v1/tasks/{task_id}"
    response = requests.get(
      service_url, headers=headers
    )
    if response.status_code == 200:
      status = response.json()['output']['task_status']
      if status == 'SUCCEEDED':
        print("任务完成!")
        pending = False
        return response.json()['output']['results']
      elif status == 'RUNNING' or status == 'PENDING':
        pass
      else:
        print("任务失败!")
        pending = False
    else:
      print("查询失败!")
      pending = False
    print(response.json())
    time.sleep(0.1)


task_id = submit_task(apikey=api_key, file_urls=file_urls)
print("task_id: ", task_id)
result = wait_for_complete(task_id)
print("转写结果:", result)

同步调用(fun-asr-flash-2026-06-15)

fun-asr-flash-2026-06-15 支持对最长 5 分钟的音频文件进行同步调用,结果可以以流式或非流式方式返回。
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-flash-2026-06-15",
  "input": {
    "messages": [
      {
        "role": "user",
        "content": [
          {
            "type": "input_audio",
            "input_audio": {
              "data": "https://dashscope.oss-cn-beijing.aliyuncs.com/samples/audio/paraformer/hello_world_female2.wav"
            }
          }
        ]
      }
    ]
  },
  "parameters": {
    "format": "wav",
    "sample_rate": "16000"
  }
}'

上下文增强

适用模型:fun-asr-flash-2026-06-15 支持上下文增强。 使用场景: 适用于将 ASR 与大语言模型结合的场景。将历史对话上下文(LLM 的回复和此前的识别结果)传入 ASR 模型,可显著提升对人名、地名、产品术语等专有名词的转写准确率——比传统热词更灵活。 用法: 通过 input.messages 传入对话历史。使用 assistant 角色表示 LLM 此前的回复,使用 user 角色配合 input_text 类型表示此前的识别结果。上下文需成对出现在当前音频消息之前。 支持的文本类型包括(但不限于):
  • 各种分隔符格式的热词列表(例如:热词 1、热词 2、热词 3、热词 4)
  • 任意长度与格式的文本段落或篇章
  • 混合内容:词表与段落的任意组合
  • 无关或无意义文本(包括乱码)。模型对无关内容容忍度较高,识别质量很少因此下降。
示例: 某段音频的正确识别结果为:"投行圈内部的那些黑话,你了解哪些?首先,外资九大投行,Bulge Bracket,BB ……"
不使用上下文增强使用上下文增强
未使用上下文增强时,部分投行公司名称识别有误,例如 "Bird Rock" 正确应为 "Bulge Bracket"。

识别结果:"投行圈内部的那些黑话,你了解哪些?首先,外资九大投行,Bird Rock,BB ……"
使用上下文增强,对投行公司名称识别正确。

识别结果:"投行圈内部的那些黑话,你了解哪些?首先,外资九大投行,Bulge Bracket,BB ……"
实现上述效果,可在上下文中加入以下任一内容:
  • 词表:
    • 词表 1:
Bulge Bracket、Boutique、Middle Market、国内券商
  • 词表 2:
Bulge Bracket Boutique Middle Market 国内券商
  • 词表 3:
['Bulge Bracket', 'Boutique', 'Middle Market', '国内券商']
  • 自然语言:
投行分类大揭秘!
最近有不少澳洲的小伙伴问我,到底什么是投行?今天就来给大家科普一下,对于留学生来说,投行主要可以分为四大类:Bulge Bracket、Boutique、Middle Market 和国内券商。
Bulge Bracket 投行:这就是我们常说的九大投行,包括高盛、摩根士丹利等。这些大行在业务范围和规模上都相当庞大。
Boutique 投行:这些投行规模相对较小,但业务领域非常专注。比如 Lazard、Evercore 等,它们在特定领域有着深厚的专业知识和经验。
Middle Market 投行:这类投行主要服务于中型公司,提供并购、IPO 等业务。虽然规模不如大行,但在特定市场上有很高的影响力。
国内券商:随着中国市场的崛起,国内券商在国际市场上也扮演着越来越重要的角色。
此外,还有一些 Position 和 business 的划分,大家可以参考相关的图表。希望这些信息能帮助大家更好地了解投行,为未来的职业生涯做好准备!
  • 有干扰的自然语言:部分文本与识别内容无关,例如下面示例里的人名。
投行分类大揭秘!
最近有不少澳洲的小伙伴问我,到底什么是投行?今天就来给大家科普一下,对于留学生来说,投行主要可以分为四大类:Bulge Bracket、Boutique、Middle Market 和国内券商。
Bulge Bracket 投行:这就是我们常说的九大投行,包括高盛、摩根士丹利等。这些大行在业务范围和规模上都相当庞大。
Boutique 投行:这些投行规模相对较小,但业务领域非常专注。比如 Lazard、Evercore 等,它们在特定领域有着深厚的专业知识和经验。
Middle Market 投行:这类投行主要服务于中型公司,提供并购、IPO 等业务。虽然规模不如大行,但在特定市场上有很高的影响力。
国内券商:随着中国市场的崛起,国内券商在国际市场上也扮演着越来越重要的角色。
此外,还有一些 Position 和 business 的划分,大家可以参考相关的图表。希望这些信息能帮助大家更好地了解投行,为未来的职业生涯做好准备!
王皓轩 李梓涵 张景行 刘欣怡 陈俊杰 杨思远 赵雨桐 黄志强 周子墨 吴雅静 徐若曦 孙浩然 胡瑾瑜 朱晨曦 郭文博 何静姝 高宇航 林逸飞
郑晓燕 梁博文 罗佳琪 宋明哲 谢婉婷 唐子骞 韩梦瑶 冯毅然 曹沁雪 邓子睿 萧望舒 许嘉树
程一诺 袁芷若 彭浩宇 董思淼 范景玉 苏子衿 吕文轩 蒋诗涵 丁沐宸
魏书瑶 任天佑 姜亦辰 华清羽 沈星河 傅瑾瑜 姚星辰 钟灵毓 阎立诚 金若水 陶然亭 戚少商 薛芷兰 邹云帆 熊子昂 柏文峰 易千帆

API 参考

常见问题

  • Fun-ASR
  • Qwen-ASR
  • Qwen-Omni

如何提高识别准确率?

您应综合考虑所有相关因素并采取相应措施。主要影响因素包括:
  1. 音质:录音设备质量、采样率和环境噪声会影响音频清晰度。高质量的音频是准确识别的基础。
  2. 说话人特征:音高、语速、口音和方言的差异会增加识别难度,尤其是罕见方言或浓重口音。
  3. 语言和词汇:中英混合、专业术语或俚语会增加识别难度。您可以配置热词来优化这些场景的识别效果。
  4. 上下文理解:缺乏上下文可能导致语义歧义,特别是在需要上下文才能正确识别的场景中。
优化方法:
  1. 提升音频质量:使用高性能麦克风和支持推荐采样率的设备。减少环境噪声和回声。
  2. 适应说话人特征:对于涉及浓重口音或多方言的场景,选择支持相应方言的模型。
  3. 配置热词:为专业术语、专有名词等特定词汇设置热词。详情请参见自定义热词
  4. 保留上下文:避免将音频切分为过短的片段。