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());
}
}
Aggregations