Search in sources :

Example 1 with KeywordEvaluateRequest

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

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