简介: DashScope灵积模型服务以模型为中心,致力于面向AI应用开发者提供品类丰富、数量众多的模型选择,并为其提供开箱即用、能力卓越、成本经济的模型服务API。DashScope灵积模型服务依托达摩院等机构的优质模型,在阿里云基础设施之上构建。灵积服务4.11号开通公测,目前提供Paraformer语音识别API能力,后续通义千问也将通过该服务对外提供API能力。本文演示如何快速通过Python SDK接入服务,助力快速Mass开发。

阿里云灵积平台官网:DashScope灵积模型服务 https://dashscope.aliyun.com/

一、开通灵积服务
控制台 地址,按照提示登录后即可正常开通。

图片.png

图片.png

二、安装SDK并调用服务
  • 2.1 安装SDK
pip install dashscope
注意:python需要3.7+
  • 2.2 Code Sample
# For prerequisites running the following sample, visit https://help.aliyun.com/document_detail/611472.html

import dashscope
from urllib import request
import json

dashscope.api_key='ReaNkZ*************F4CD99C11ED9B2EB2ED6BC5D65D'

task_response=dashscope.audio.asr.Transcription.async_call(
    model='paraformer-v1',
    file_urls=['https://*****.oss-cn-shanghai.aliyuncs.com/%E5%A5%94%E8%B7%91.mp3']
    )

transcription_response=dashscope.audio.asr.Transcription.wait(task=task_response.output.task_id)

transcription_url=transcription_response.output['results'][0]['transcription_url']
transcription_results=json.loads(request.urlopen(transcription_url).read().decode('utf8'))
print(json.dumps(transcription_results, indent=4, ensure_ascii=False))

图片.png

从测试的效果来看,模型整体的精度还是很高的,用户可以基于具体场景提供model即可。

图片.png

更多参考

安装DashScope SDK
Paraformer语音识别API详情

Logo

CSDN联合极客时间,共同打造面向开发者的精品内容学习社区,助力成长!

更多推荐