Search in sources :

Example 1 with TransmitOralProcessWithInitResponse

use of com.tencentcloudapi.soe.v20180724.models.TransmitOralProcessWithInitResponse in project tencentcloud-sdk-java by TencentCloud.

the class TransmitOralProcessWithInit method main.

public static void main(String[] args) throws Exception {
    try {
        // 实例化一个认证对象,入参需要传入腾讯云账户secretId,secretKey
        Credential cred = new Credential("", "");
        // 实例化一个http选项,可选的,没有特殊需求可以跳过
        HttpProfile httpProfile = new HttpProfile();
        // post请求(默认为post请求)
        httpProfile.setReqMethod("POST");
        // 请求连接超时时间,单位为秒(默认60秒)
        httpProfile.setConnTimeout(60);
        // 指定接入地域域名(默认就近接入)
        httpProfile.setEndpoint("soe.ap-beijing.tencentcloudapi.com");
        ClientProfile clientProfile = new ClientProfile();
        clientProfile.setUnsignedPayload(true);
        clientProfile.setHttpProfile(httpProfile);
        // 实例化要请求产品的client对象,clientProfile是可选的
        SoeClient client = new SoeClient(cred, "", clientProfile);
        TransmitOralProcessWithInitRequest req = new TransmitOralProcessWithInitRequest();
        // 分片起始
        req.setIsEnd(1);
        // 分片结束
        req.setSeqId(1);
        // 语音数据类型1:pcm
        req.setVoiceEncodeType(1);
        // 语音文件类型
        req.setVoiceFileType(3);
        // 唯一标识
        req.setSessionId("test_12345678901234567");
        // 将文件装换成base64
        byte[] buf = Files.readAllBytes(Paths.get(AUDIO_FOR_ONCE));
        String base64Str = new sun.misc.BASE64Encoder().encode(buf);
        req.setUserVoiceData(base64Str);
        // 文本
        req.setRefText("bike");
        // 0,流式分片,1一次性评测
        req.setWorkMode(1);
        // 评估模式,0,单词.1,句子,2,段落,3自由说,4单词纠错
        req.setEvalMode(3);
        // 评估难度
        req.setScoreCoeff(1.0f);
        // 服务类型.0英文,1中文
        req.setServerType(0);
        // 异步
        req.setIsAsync(0);
        // 轮询
        req.setIsQuery(0);
        // 文本格式.0普通文本 1,音素结构
        req.setTextMode(0);
        TransmitOralProcessWithInitResponse resp = client.TransmitOralProcessWithInit(req);
        // 输出json格式的字符串回包
        System.out.println(TransmitOralProcessWithInitResponse.toJsonString(resp));
        // 也可以取出单个值。
        // 你可以通过官网接口文档或跳转到response对象的定义处查看返回字段的定义
        System.out.println(resp.getPronAccuracy());
    } catch (TencentCloudSDKException e) {
        e.printStackTrace();
    }
}
Also used : Credential(com.tencentcloudapi.common.Credential) TencentCloudSDKException(com.tencentcloudapi.common.exception.TencentCloudSDKException) ClientProfile(com.tencentcloudapi.common.profile.ClientProfile) HttpProfile(com.tencentcloudapi.common.profile.HttpProfile) TransmitOralProcessWithInitResponse(com.tencentcloudapi.soe.v20180724.models.TransmitOralProcessWithInitResponse) SoeClient(com.tencentcloudapi.soe.v20180724.SoeClient) TransmitOralProcessWithInitRequest(com.tencentcloudapi.soe.v20180724.models.TransmitOralProcessWithInitRequest) BASE64Encoder(sun.misc.BASE64Encoder)

Aggregations

Credential (com.tencentcloudapi.common.Credential)1 TencentCloudSDKException (com.tencentcloudapi.common.exception.TencentCloudSDKException)1 ClientProfile (com.tencentcloudapi.common.profile.ClientProfile)1 HttpProfile (com.tencentcloudapi.common.profile.HttpProfile)1 SoeClient (com.tencentcloudapi.soe.v20180724.SoeClient)1 TransmitOralProcessWithInitRequest (com.tencentcloudapi.soe.v20180724.models.TransmitOralProcessWithInitRequest)1 TransmitOralProcessWithInitResponse (com.tencentcloudapi.soe.v20180724.models.TransmitOralProcessWithInitResponse)1 BASE64Encoder (sun.misc.BASE64Encoder)1