Search in sources :

Example 1 with TransmitOralProcessResponse

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

the class TransmitOralProcess method main.

public static void main(String[] args) {
    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);
        TransmitOralProcessRequest req = new TransmitOralProcessRequest();
        req.setIsEnd(1);
        req.setSeqId(1);
        req.setSessionId("test_123456");
        // base64编码数据
        byte[] buf = Files.readAllBytes(Paths.get(AUDIO_FOR_ONCE));
        String base64Str = new sun.misc.BASE64Encoder().encode(buf);
        req.setUserVoiceData(base64Str);
        req.setVoiceEncodeType(1);
        req.setVoiceFileType(3);
        TransmitOralProcessResponse res = client.TransmitOralProcess(req);
        // 输出json格式的字符串回包
        System.out.println(TransmitOralProcessResponse.toJsonString(res));
        // 也可以取出单个值。
        // 你可以通过官网接口文档或跳转到response对象的定义处查看返回字段的定义
        System.out.println(res.getPronAccuracy());
    } catch (TencentCloudSDKException | IOException e) {
        e.printStackTrace();
    }
}
Also used : Credential(com.tencentcloudapi.common.Credential) TencentCloudSDKException(com.tencentcloudapi.common.exception.TencentCloudSDKException) ClientProfile(com.tencentcloudapi.common.profile.ClientProfile) TransmitOralProcessResponse(com.tencentcloudapi.soe.v20180724.models.TransmitOralProcessResponse) HttpProfile(com.tencentcloudapi.common.profile.HttpProfile) SoeClient(com.tencentcloudapi.soe.v20180724.SoeClient) IOException(java.io.IOException) TransmitOralProcessRequest(com.tencentcloudapi.soe.v20180724.models.TransmitOralProcessRequest)

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 TransmitOralProcessRequest (com.tencentcloudapi.soe.v20180724.models.TransmitOralProcessRequest)1 TransmitOralProcessResponse (com.tencentcloudapi.soe.v20180724.models.TransmitOralProcessResponse)1 IOException (java.io.IOException)1