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)
    def __init__(self):
        self.name = QC_NAME
        self.region = REGION
        self.logger = getLogger()
        self.logger.info("Init Qcloud SCF Client...\n")
        self.logger.info("The region is: %s\n" % self.region)
        cred = credential.Credential(QC_API_ID, QC_API_KEY)
        self.logger.info("The secert info:")
        self.logger.info("Secret Id: %s" % (QC_API_ID[0:5]+"******"))
        self.logger.info("Secret Key: %s\n" % (QC_API_KEY[0:5]+"******"))
        httpProfile = HttpProfile()
        httpProfile.reqMethod = "GET"
        httpProfile.reqTimeout = 30
        httpProfile.endpoint = QC_ENDPOINT_MODEL % self.region
        self.logger.info("The request endpoint is: %s\n" % httpProfile.endpoint)
        httpProfile.keepAlive = True

        clientProfile = ClientProfile()

        clientProfile.signMethod = "HmacSHA256"
        clientProfile.httpProfile = httpProfile

        self.client = scf_client.ScfClient(cred, 'ap-' + self.region, clientProfile)

        self.logger.info("SCF client init success!\n")

        self.logger.info("Start to get VPC info...")
        self.logger.info("VPC id is: %s"% QC_VPC)
        self.logger.info("VPC-Subnet id is: %s\n" % QC_SUBNET)
Exemplo n.º 3
0
 def SetHttpProxy(self, httpProfile: HttpProfile) -> None:
     # 如果需要指定proxy访问接口,可以按照如下方式初始化hp
     # httpProfile = HttpProfile(proxy="http://用户名:密码@代理IP:代理端口")
     # 在外网互通的网络环境下支持http协议(默认是https协议),建议使用https协议
     httpProfile.protocol = "https"
     httpProfile.keepAlive = True  # 状态保持,默认是False
     httpProfile.reqMethod = "GET"  # get请求(默认为post请求)
     httpProfile.reqTimeout = 30    # 请求超时时间,单位为秒(默认60秒)
     # 指定接入地域域名(默认就近接入)
     httpProfile.endpoint = "tmt.ap-shanghai.tencentcloudapi.com"
     return
Exemplo n.º 4
0
from tencentcloud.common.profile.client_profile import ClientProfile
from tencentcloud.common.profile.http_profile import HttpProfile

try:
    # 实例化一个认证对象,入参需要传入腾讯云账户secretId,secretKey
    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格式的字符串回包
Exemplo n.º 5
0
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.soe.v20180724 import soe_client, models
import uuid

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为最高年龄段