zoukankan      html  css  js  c++  java
  • 语音转文字-腾讯云

    调用腾讯云API,进行声音到文字的转换

    # -*- encoding: utf-8 -*-
    
    # 地址链接:https://cloud.tencent.com/document/product/1093/35731
    # 调用腾讯云API的使用方法
    # 以下分别是通过语音 URL和本地语音上传请求方式的 demo,以及轮询接口查询识别结果,来帮助客户快速接入。
    
    # 通过语音 URL 方式请求
    # -*- coding: utf-8 -*-
    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
    
    # 音频 URL 方式
    try:
        # 此处<Your SecretId><Your SecretKey>需要替换成客户自己的账号信息
        cred = credential.Credential("XXX", "XXX")
        httpProfile = HttpProfile()
        httpProfile.endpoint = "asr.tencentcloudapi.com"
        clientProfile = ClientProfile()
        clientProfile.httpProfile = httpProfile
        clientProfile.signMethod = "TC3-HMAC-SHA256"
        client = asr_client.AsrClient(cred, "ap-shanghai", clientProfile)
        req = models.CreateRecTaskRequest()
        params = {"EngineModelType": "16k_0", "ChannelNum": 1, "ResTextFormat": 0, "SourceType": 0,
                  "Url": "XXX"}
        req._deserialize(params)
        resp = client.CreateRecTask(req)
        print(resp.to_json_string())
        # windows 系统使用下面一行替换上面一行
        # print(resp.to_json_string().decode('UTF-8').encode('GBK') )
    
    except TencentCloudSDKException as err:
        print(err)
    
    
  • 相关阅读:
    浏览器渲染HTML页面步骤
    JavaScript中必记英语单词及含义
    JavaScript中的线程与进程
    成绩转换 题解
    计算球的体积 题解 #define
    计算两点间的距离 题解
    ASCII码排序 题解
    python学习——协程
    python学习——进程
    python学习——锁
  • 原文地址:https://www.cnblogs.com/xuehuiping/p/15246671.html
Copyright © 2011-2022 走看看