腾讯的sdk文档是真的坑,官方给的例子都能跑不动的。安卓语音识别的sdk居然不给源码,反编译了改了参数才生效。
下面是python的语音识别例子,在官方基础上修复了一下,需要安装官方sdk
# -*- coding:utf-8 -*-
import json
from urllib import request
from tencentcloud.common import credential
from tencentcloud.common.profile.client_profile import ClientProfile
from tencentcloud.common.profile.http_profile import HttpProfile
from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException
from tencentcloud.asr.v20190614 import asr_client, models
import base64
#通过本地语音上传方式调用
try:
#重要:<Your SecretId>、<Your SecretKey>需要替换成用户自己的账号信息
#请参考接口说明中的使用步骤1进行获取。
secret_key = ''
secretid = ''
appid = 'yourappid'
cred = credential.Credential("yourSecretId", "yourSecretkey")
httpProfile = HttpProfile()
httpProfile.endpoint = "asr.tencentcloudapi.com"
clientProfile = ClientProfile()