Search in sources :

Example 1 with SoeClient

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

the class EvaluationExamples method main.

public static void main(String[] args) {
    Credential cred = new Credential(SECRET_ID, SECRET_KEY);
    HttpProfile httpProfile = new HttpProfile();
    /**
     *  设置访问域名,如果需要就近部署,可以使用 soe-tencentcloudapi.com, 腾讯云将根据访问的地域解析到合适的服务器上,如果调用服务已确定地域,如华南地区
     *  可以直接使用地域域名,加快访问速度
     */
    httpProfile.setEndpoint(END_POINT);
    ClientProfile clientProfile = new ClientProfile();
    clientProfile.setHttpProfile(httpProfile);
    SoeClient client = new SoeClient(cred, REGION, clientProfile);
    EvaluationOnce(client);
    EvaluationCn(client);
    EvaluationMutipleSeq(client);
    EvaluationAsync(client);
    EvaluationTransWithInit(client);
}
Also used : Credential(com.tencentcloudapi.common.Credential) ClientProfile(com.tencentcloudapi.common.profile.ClientProfile) HttpProfile(com.tencentcloudapi.common.profile.HttpProfile) SoeClient(com.tencentcloudapi.soe.v20180724.SoeClient)

Example 2 with SoeClient

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

the class InitOralProcess 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);
        InitOralProcessRequest req = new InitOralProcessRequest();
        req.setSessionId("test_123456");
        req.setRefText("bike");
        req.setWorkMode(1);
        req.setEvalMode(0);
        req.setScoreCoeff(1.0f);
        req.setServerType(0);
        InitOralProcessResponse res = client.InitOralProcess(req);
        // 输出json格式的字符串回包
        System.out.println(InitOralProcessResponse.toJsonString(res));
        // 也可以取出单个值。
        // 你可以通过官网接口文档或跳转到response对象的定义处查看返回字段的定义
        System.out.println(res.getRequestId());
    } 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) InitOralProcessRequest(com.tencentcloudapi.soe.v20180724.models.InitOralProcessRequest) SoeClient(com.tencentcloudapi.soe.v20180724.SoeClient) InitOralProcessResponse(com.tencentcloudapi.soe.v20180724.models.InitOralProcessResponse)

Example 3 with SoeClient

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

the class KeywordEvaluate method main.

public static void main(String[] args) throws IOException {
    try {
        Credential cred = new Credential("", "");
        HttpProfile httpProfile = new HttpProfile();
        httpProfile.setEndpoint("soe.tencentcloudapi.com");
        ClientProfile clientProfile = new ClientProfile();
        clientProfile.setHttpProfile(httpProfile);
        SoeClient client = new SoeClient(cred, "", clientProfile);
        KeywordEvaluateRequest req = new KeywordEvaluateRequest();
        req.setSeqId(1);
        req.setIsEnd(1);
        req.setVoiceFileType(3);
        req.setVoiceEncodeType(1);
        req.setSessionId("test_12345_456");
        byte[] buf = Files.readAllBytes(Paths.get(AUDIO_FOR_ONCE));
        String base64Str = new sun.misc.BASE64Encoder().encode(buf);
        req.setUserVoiceData(base64Str);
        Keyword[] keywords1 = new Keyword[2];
        Keyword keyword1 = new Keyword();
        keyword1.setRefText("bike");
        keyword1.setEvalMode(0);
        keyword1.setServerType(0);
        keyword1.setScoreCoeff(1.0f);
        keyword1.setTextMode(0);
        keywords1[0] = keyword1;
        Keyword keyword2 = new Keyword();
        keyword2.setRefText("bick");
        keyword2.setEvalMode(0);
        keyword2.setServerType(0);
        keyword2.setScoreCoeff(1.0f);
        keyword2.setTextMode(0);
        keywords1[1] = keyword2;
        req.setKeywords(keywords1);
        KeywordEvaluateResponse resp = client.KeywordEvaluate(req);
        System.out.println(KeywordEvaluateResponse.toJsonString(resp));
    } catch (TencentCloudSDKException | IOException e) {
        System.out.println(e.toString());
    }
}
Also used : Credential(com.tencentcloudapi.common.Credential) TencentCloudSDKException(com.tencentcloudapi.common.exception.TencentCloudSDKException) ClientProfile(com.tencentcloudapi.common.profile.ClientProfile) Keyword(com.tencentcloudapi.soe.v20180724.models.Keyword) KeywordEvaluateRequest(com.tencentcloudapi.soe.v20180724.models.KeywordEvaluateRequest) HttpProfile(com.tencentcloudapi.common.profile.HttpProfile) SoeClient(com.tencentcloudapi.soe.v20180724.SoeClient) IOException(java.io.IOException) KeywordEvaluateResponse(com.tencentcloudapi.soe.v20180724.models.KeywordEvaluateResponse)

Example 4 with SoeClient

use of com.tencentcloudapi.soe.v20180724.SoeClient 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)

Example 5 with SoeClient

use of com.tencentcloudapi.soe.v20180724.SoeClient 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)5 ClientProfile (com.tencentcloudapi.common.profile.ClientProfile)5 HttpProfile (com.tencentcloudapi.common.profile.HttpProfile)5 SoeClient (com.tencentcloudapi.soe.v20180724.SoeClient)5 TencentCloudSDKException (com.tencentcloudapi.common.exception.TencentCloudSDKException)4 IOException (java.io.IOException)2 InitOralProcessRequest (com.tencentcloudapi.soe.v20180724.models.InitOralProcessRequest)1 InitOralProcessResponse (com.tencentcloudapi.soe.v20180724.models.InitOralProcessResponse)1 Keyword (com.tencentcloudapi.soe.v20180724.models.Keyword)1 KeywordEvaluateRequest (com.tencentcloudapi.soe.v20180724.models.KeywordEvaluateRequest)1 KeywordEvaluateResponse (com.tencentcloudapi.soe.v20180724.models.KeywordEvaluateResponse)1 TransmitOralProcessRequest (com.tencentcloudapi.soe.v20180724.models.TransmitOralProcessRequest)1 TransmitOralProcessResponse (com.tencentcloudapi.soe.v20180724.models.TransmitOralProcessResponse)1 TransmitOralProcessWithInitRequest (com.tencentcloudapi.soe.v20180724.models.TransmitOralProcessWithInitRequest)1 TransmitOralProcessWithInitResponse (com.tencentcloudapi.soe.v20180724.models.TransmitOralProcessWithInitResponse)1 BASE64Encoder (sun.misc.BASE64Encoder)1