开通语音识别服务
![](https://qcloudimg.tencent-cloud.cn/image/document/b87125608f98df93fd514abe3cb48d7f.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/b87125608f98df93fd514abe3cb48d7f.png)
服务开通成功后,您将获得各项服务对应的免费调用额度,可在 资源包管理页 查看。同时您也可以在 语音识别购买页 中购买对应语音识别服务的资源包,若免费额度以及资源包调用次数耗尽,接口计费将自动转为后付费方式按月进行结算,具体计费标准可以查看语音识别的 购买指南。
![](https://qcloudimg.tencent-cloud.cn/image/document/d25a5fc625757a19b927dcdb30f14ae9.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/d25a5fc625757a19b927dcdb30f14ae9.png)
说明
语音识别服务开通成功后,您可根据喜好选择如下两种方式来调用语音识别服务,建议选择 API 3.0 Explorer。
使用 API 3.0 Explorer 调用语音识别接口
输入参数
![](https://qcloudimg.tencent-cloud.cn/image/document/1463dc9ad90f5beb006532e8372af303.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/1463dc9ad90f5beb006532e8372af303.png)
在 API 3.0 Explorer 界面的参数说明选项卡中可以查看对应接口输入参数的具体含义。
![](https://qcloudimg.tencent-cloud.cn/image/document/f99d18800d6b070ad46df4b6114f189b.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/f99d18800d6b070ad46df4b6114f189b.png)
填写好输入参数之后,选择代码生成选项卡,可以看到自动生成的不同编程语言代码(可支持 Java、Python、Node.js、PHP、GO、.NET、C++ 语言),生成代码中的部分字段信息和填写内容是关联的,如需调整传入参数,可在左侧修改参数值后重新生成代码。
![](https://qcloudimg.tencent-cloud.cn/image/document/0076b03fbad1eeba134dc74a6fe992b2.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/0076b03fbad1eeba134dc74a6fe992b2.png)
发起请求
填写好输入参数之后,选择在线调用选项卡,单击发送请求按钮可进行真实请求,供您调试、参考。
![](https://qcloudimg.tencent-cloud.cn/image/document/9605a02f04a15c599d359771fefe2260.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/9605a02f04a15c599d359771fefe2260.png)
使用 Postman 调用语音识别接口
Postman 下载安装
1. 下载地址:Download Postman | Get Started for Free ,按照电脑类型选择安装包。
2. 下载完成后,双击打开安装包,按照提示安装,如无特殊需求选择默认即可。初次打开需要登录,若无账号,选择跳过。
接口调用
导入 Postman 配置
借助 Postman 的导入功能来初始化配置,配置链接:
https://postman-demo-1256237915.cos.ap-guangzhou.myqcloud.com/postman_collection.json
具体导入步骤如下:
![](https://qcloudimg.tencent-cloud.cn/image/document/1d24e0c7e28c781848a0519a70e0f9fe.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/1d24e0c7e28c781848a0519a70e0f9fe.png)
初始配置包含一个接口示例,其所需配置信息都已包含在内。看到如下内容表示导入成功。
![](https://qcloudimg.tencent-cloud.cn/image/document/f3f3e2f84ee6592665bd812869025305.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/f3f3e2f84ee6592665bd812869025305.png)
修改腾讯云密钥
发起请求前,需先将该请求对应 Pre-request-Script 中的密钥修改为自己的,这样脚本才能正确计算鉴权参数。
1. 登录访问管理控制台 获取密钥。![](https://qcloudimg.tencent-cloud.cn/image/document/0dbcfb545b128f7ca9c1edab6dc75bb0.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/0dbcfb545b128f7ca9c1edab6dc75bb0.png)
2. 例如我们要调用 一句话识别接口,修改其预处理脚本中的密钥。![](https://qcloudimg.tencent-cloud.cn/image/document/6455cf68872228d66d995cc8443c7e5c.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/6455cf68872228d66d995cc8443c7e5c.png)
发起请求
密钥修改完后,选择 Body 完善请求参数。单击 Send 发送请求,看到如下内容表示请求成功。
![](https://qcloudimg.tencent-cloud.cn/image/document/ae2c6c5740ea4d0da3c87af0938165b2.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/ae2c6c5740ea4d0da3c87af0938165b2.png)
如何修改请求参数和请求接口
参数介绍
![](https://qcloudimg.tencent-cloud.cn/image/document/e7aa1963b310df00dad88c2f4291b75c.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/e7aa1963b310df00dad88c2f4291b75c.png)
对应到 Postman 当中:
![](https://qcloudimg.tencent-cloud.cn/image/document/705bc2572f79771e6b8ec3f5fc60ba36.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/705bc2572f79771e6b8ec3f5fc60ba36.png)
注意:
![](https://qcloudimg.tencent-cloud.cn/image/document/ed130dfeb99aeec2830957e26e0d5052.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/ed130dfeb99aeec2830957e26e0d5052.png)
请求参数变更
如果想解析不同的录音或者设置不同的请求参数,步骤如下:
1. 查看接口入参定义,例如 一句话识别。![](https://qcloudimg.tencent-cloud.cn/image/document/a4b2bfd8060b4e06e453f24e3d8bb301.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/a4b2bfd8060b4e06e453f24e3d8bb301.png)
2. 在 Body 中变更参数,例如我们想识别的引擎模型为16k_en 英语而不是16k_zh 中文,则需传递 16k_en 参数,如一句话识别示例接口的传参。![](https://qcloudimg.tencent-cloud.cn/image/document/2b776d027685819a5334cb82e8e84931.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/2b776d027685819a5334cb82e8e84931.png)
请求接口变更
如需请求 ASR 服务的其他接口,需修改 Header 中的 X-TC-Action。
![](https://qcloudimg.tencent-cloud.cn/image/document/c1f5065f6a08ab2b2a2f6be8d278819c.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/c1f5065f6a08ab2b2a2f6be8d278819c.png)
X-TC-Action 参数对应接口文档的 Action 入参,如录音文件识别接口的 Action 为 CreateRecTask。
![](https://qcloudimg.tencent-cloud.cn/image/document/77c105b11fbac924492f8da7e31b676f.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/77c105b11fbac924492f8da7e31b676f.png)
修改 Action 之后,再按照接口文档修改请求 Body,发起请求即可。