def init_oral_process(SessionId,RefText,base64_data):
    # 实例化一个认证对象,入参需要传入腾讯云账户secretId,secretKey
    cred = credential.Credential("AKIDxe5GDPX6aonW1G78hyzmLglpeFagr9Vc", "A9uRkpfFZpqb6MQEm48xVaTs0ub3GDtK")

    # 实例化一个http选项,可选的,没有特殊需求可以跳过。
    httpProfile = HttpProfile()
    httpProfile.reqMethod = "POST"  # post请求(默认为post请求)
    httpProfile.reqTimeout = 30  # 请求超时时间,单位为秒(默认60秒)
    httpProfile.endpoint = "soe.tencentcloudapi.com"  # 指定接入地域域名(默认就近接入)
    httpProfile.keepAlive = True

    # 实例化一个client选项,可选的,没有特殊需求可以跳过。
    clientProfile = ClientProfile()
    clientProfile.signMethod = "TC3-HMAC-SHA256"  # 指定签名算法(默认为HmacSHA256)
    clientProfile.unsignedPayload = True
    clientProfile.httpProfile = httpProfile

    client = soe_client.SoeClient(cred, "", clientProfile)
    req = models.InitOralProcessRequest()
    req.SessionId = SessionId
    req.RefText = RefText
    req.WorkMode = 1
    req.EvalMode = 0
    req.ScoreCoeff = 1.0

    resp = client.InitOralProcess(req)

    # 输出json格式的字符串回包
    print("初始化:%s" % resp.to_json_string())
    transmit(SessionId,base64_data)
示例#2
0
def _test_describe_instances(http_method, sign_method, unsigned_payload=False):
    cred = credential.Credential(os.environ.get("TENCENTCLOUD_SECRET_ID"),
                                 os.environ.get("TENCENTCLOUD_SECRET_KEY"))

    httpProfile = HttpProfile()
    httpProfile.reqMethod = http_method

    clientProfile = ClientProfile()
    clientProfile.signMethod = sign_method
    clientProfile.unsignedPayload = unsigned_payload
    clientProfile.httpProfile = httpProfile

    client = cvm_client.CvmClient(cred, "ap-guangzhou", clientProfile)
    req = models.DescribeInstancesRequest()
    headers = {
        "X-TC-TraceId": "ffe0c072-8a5d-4e17-8887-a8a60252abca",
    }
    req.headers = headers

    fzone = models.Filter()
    fzone.Name = "zone"
    fzone.Values = ["ap-guangzhou-1", "ap-guangzhou-2"]
    fname = models.Filter()
    fname.Name = "instance-name"
    fname.Values = [u"中文", u"测试"]
    req.Filters = [fzone, fname]
    resp = client.DescribeInstances(req)
    assert resp.TotalCount >= 0
示例#3
0
def transmit_oral_process(sessionId,
                          userVoiceData):  #  语音段唯一标识,一个完整语音一个SessionId。
    try:
        # 实例化一个认证对象,入参需要传入腾讯云账户secretId,secretKey
        cred = credential.Credential(secretId, secretKey)

        # 实例化一个http选项,可选的,没有特殊需求可以跳过。
        httpProfile = HttpProfile()
        httpProfile.reqMethod = "POST"  # post请求(默认为post请求)
        httpProfile.reqTimeout = 30  # 请求超时时间,单位为秒(默认60秒)
        httpProfile.endpoint = "soe.tencentcloudapi.com"  # 指定接入地域域名(默认就近接入)

        clientProfile = ClientProfile()
        clientProfile.signMethod = "TC3-HMAC-SHA256"  # 指定签名算法(默认为HmacSHA256)
        clientProfile.unsignedPayload = True
        clientProfile.httpProfile = httpProfile

        client = soe_client.SoeClient(cred, "", clientProfile)
        req = models.TransmitOralProcessRequest()
        req.SessionId = sessionId
        req.VoiceFileType = 2  # 语音文件类型 1:raw, 2:wav, 3:mp3(三种格式目前仅支持16k采样率16bit编码单声道
        req.SeqId = 1  # 流式数据包的序号,从1开始,当IsEnd字段为1后后续序号无意义,当
        #IsLongLifeSession不为1且为非流式模式时无意义。
        req.VoiceEncodeType = 1  # 语音编码类型 1:pcm。
        req.IsEnd = 1  #  是否传输完毕标志,若为0表示未完毕,若为1则传输完毕开始评估,非流式模式下无意义

        req.UserVoiceData = userVoiceData  # 当前数据包数据, 流式模式下数据包大小可以按需设置,数据包大小必须 >= 4K,且必
        #须保证分片帧完整(16bit的数据必须保证音频长度为偶数),编码格式要求为BASE64。

        # process
        resp = client.TransmitOralProcess(req)

        # 输出json格式的字符串回包
        print("%s" % resp.to_json_string())

    except TencentCloudSDKException as err:
        print("%s" % err)
示例#4
0
def init_oral_process(text, sessionId):  #  语音段唯一标识,一个完整语音一个SessionId。
    try:
        # 实例化一个认证对象,入参需要传入腾讯云账户secretId,secretKey
        cred = credential.Credential(secretId, secretKey)

        # 实例化一个http选项,可选的,没有特殊需求可以跳过。
        httpProfile = HttpProfile()
        httpProfile.reqMethod = "POST"  # post请求(默认为post请求)
        httpProfile.reqTimeout = 30  # 请求超时时间,单位为秒(默认60秒)
        httpProfile.endpoint = "soe.tencentcloudapi.com"  # 指定接入地域域名(默认就近接入)

        # 实例化一个client选项,可选的,没有特殊需求可以跳过。
        clientProfile = ClientProfile()
        clientProfile.signMethod = "TC3-HMAC-SHA256"  # 指定签名算法(默认为HmacSHA256)
        clientProfile.unsignedPayload = True
        clientProfile.httpProfile = httpProfile

        client = soe_client.SoeClient(cred, "", clientProfile)
        req = models.InitOralProcessRequest()
        #req.SessionId = "stress_test_956938"
        req.SessionId = sessionId
        req.RefText = text  # refer 的文本
        req.WorkMode = 1  # workMode  语音输入模式,0:流式分片,1:非流式一次性评估
        req.EvalMode = 1  # EvalMode 评估模式,0:词模式,,1::句子模式,2:段落模式,3:自由说模式,当为词模式
        #评估时,能够提供每个音节的评估信息,当为句子模式时,能够提供完整度和流利度信息。
        req.ScoreCoeff = 3.5
        # ScoreCoeff 评价苛刻指数,取值为[1.0 - 4.0]范围内的浮点数,用于平滑不同年龄段的分数,1.0
        #为小年龄段,4.0为最高年龄段

        resp = client.InitOralProcess(req)

        # 输出json格式的字符串回包
        print("%s" % resp.to_json_string())

    except TencentCloudSDKException as err:
        print("%s" % err)
    cred = credential.Credential("", "")
    # cred = credential.Credential(
    #     os.environ.get("TENCENTCLOUD_SECRET_ID"),
    #     os.environ.get("TENCENTCLOUD_SECRET_KEY"))

    # 实例化一个http选项,可选的,没有特殊需求可以跳过。
    httpProfile = HttpProfile()
    httpProfile.reqMethod = "POST"  # post请求(默认为post请求)
    httpProfile.reqTimeout = 30  # 请求超时时间,单位为秒(默认60秒)
    httpProfile.endpoint = "tci.tencentcloudapi.com"  # 指定接入地域域名(默认就近接入)
    httpProfile.keepAlive = True

    # 实例化一个client选项,可选的,没有特殊需求可以跳过。
    clientProfile = ClientProfile()
    clientProfile.signMethod = "TC3-HMAC-SHA256"  # 指定签名算法(默认为HmacSHA256)
    clientProfile.unsignedPayload = True
    clientProfile.httpProfile = httpProfile

    client = tci_client.TciClient(cred, "", clientProfile)
    req = models.CreateFaceRequest()
    req.LibraryId = "tci_library_156403897035611372834"
    req.PersonId = "tci_person_1564039695429032573626"
    req.urls = ["https://img-blog.csdn.net/20161128171723259"]
    resp = client.CreateFace(req)

    # 输出json格式的字符串回包
    print("%s" % resp.to_json_string())

except TencentCloudSDKException as err:
    print("%s" % err)
示例#6
0
try:
    # 实例化一个认证对象,入参需要传入腾讯云账户secretId,secretKey
    cred = credential.Credential("secretId", "secretKey")

    # 实例化一个http选项,可选的,没有特殊需求可以跳过。
    httpProfile = HttpProfile()
    httpProfile.reqMethod = "POST"  # post请求(默认为post请求)
    httpProfile.reqTimeout = 30  # 请求超时时间,单位为秒(默认60秒)
    httpProfile.endpoint = "soe.tencentcloudapi.com"  # 指定接入地域域名(默认就近接入)
    httpProfile.keepAlive = True  # 保持活动状态

    # 实例化一个client选项,可选的,没有特殊需求可以跳过。
    clientProfile = ClientProfile()  # 客户端配置文件
    clientProfile.signMethod = "TC3-HMAC-SHA256"  # 指定签名算法(默认为HmacSHA256)
    clientProfile.unsignedPayload = True  # 未签署的有效负载
    clientProfile.httpProfile = httpProfile  # http选项
    client = soe_client.SoeClient(cred, "", clientProfile)  # 连接soe的连接

    # 请求参数赋值
    req = models.InitOralProcessRequest()  # 连接soe的评测初始化模块
    req.SessionId = str(uuid.uuid1())  # 语音段唯一标识,一段语音一个SessionId
    req.RefText = "red"  # 评测文本
    req.WorkMode = 1  # 语音输入模式,0:流式分片,1:非流式一次性评估
    req.EvalMode = 1  # 评估模式,0:词模式(中文评测模式下为文字模式),1:句子模式,2:段落模式,3:自由说模式,当为词模式评估时,能够提供每个音节的评估信息,当为句子模式时,能够提供完整度和流利度信息。4: 英文单词音素诊断评测模式,针对一个单词音素诊断评测。
    req.ScoreCoeff = 1  # 评价苛刻指数,取值为[1.0 - 4.0]范围内的浮点数,用于平滑不同年龄段的分数,1.0为小年龄段,4.0为最高年龄段
    # req.SoeAppId = "123456"  # 业务应用ID,与账号应用APPID无关,是用来方便客户管理服务的参数,新的 SoeAppId 可以在[控制台](https://console.cloud.tencent.com/soe)【应用管理】下新建。
    # req.IsLongLifeSession = 0  # 长效session标识,当该参数为1时,session的持续时间为300s,但会一定程度上影响第一个数据包的返回速度,且TransmitOralProcess必须同时为1才可生效。
    req.StorageMode = 0  # 音频存储模式,0:不存储,1:存储到公共对象存储,输出结果为该会话最后一个分片TransmitOralProcess 返回结果 AudioUrl 字段,2:永久存储音频,需要提工单申请,会产生一定存储费用,3:自定义存储,将音频存储到自定义的腾讯云[对象存储](https://cloud.tencent.com/product/cos)中,需要提工单登记存储信息。
    # req.SentenceInfoEnabled = 0  # 输出断句中间结果标识,0:不输出,1:输出,通过设置该参数,可以在评估过程中的分片传输请求中,返回已经评估断句的中间结果,中间结果可用于客户端 UI 更新,输出结果为TransmitOralProcess请求返回结果 SentenceInfoSet 字段。
    req.ServerType = 0  # 评估语言,0:英文,1:中文。
示例#7
0
try:
    # 实例化一个认证对象,入参需要传入腾讯云账户secretId,secretKey
    cred = credential.Credential("**************", "**************")

    # 实例化一个http选项,可选的,没有特殊需求可以跳过。
    httpProfile = HttpProfile()
    httpProfile.reqMethod = "POST"  # post请求(默认为post请求)
    httpProfile.reqTimeout = 30  # 请求超时时间,单位为秒(默认60秒)
    httpProfile.endpoint = "file.ess.tencent.cn"  # 指定接入地域域名(默认就近接入)
    httpProfile.keepAlive = True

    # 实例化一个client选项,可选的,没有特殊需求可以跳过。
    clientProfile = ClientProfile()
    clientProfile.signMethod = "TC3-HMAC-SHA256"  # 指定签名算法(默认为HmacSHA256)
    clientProfile.unsignedPayload = False
    clientProfile.httpProfile = httpProfile

    client = ess_client.EssClient(cred, "ap-guangzhou", clientProfile)
    req = models.UploadFilesRequest()

    caller = models.Caller()
    # Appid 电子签侧应用id,电子签提供
    caller.ApplicationId = "**************"
    # 管理员用户id或者员工用户id
    caller.OperatorId = "**************"
    req.Caller = caller

    req.BusinessType = "FLOW"

    with open("/*****/*****.pdf", "rb") as file: