안녕하세요
카카오 음성 api 를 사용하는 도중 응답은 정상적으로 왔으나 인코딩 문제가 발생하여 문의드립니다…
private String doPOST(File file) {
RestTemplate restTemplate = new RestTemplate();
//add file
LinkedMultiValueMap<String, Object> params = new LinkedMultiValueMap<String, Object>();
params.add("file", new FileSystemResource(file));
//add array
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl("https://kakaoi-newtone-openapi.kakao.com/v1/recognize");
//another staff
String result = "";
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.MULTIPART_FORM_DATA);
headers.set("Transfer-Encoding", "chunked");
headers.set("X-DSS-Service", "DICTATION");
headers.set("Authorization", "KakaoAK da62bcaec5f2e24e8fd11fcbc4e50e33");
HttpEntity<LinkedMultiValueMap<String, Object>> requestEntity =
new HttpEntity<LinkedMultiValueMap<String, Object>>(params, headers);
ResponseEntity<String> responseEntity = restTemplate.exchange(
builder.build().encode().toUri(),
HttpMethod.POST,
requestEntity,
String.class);
HttpStatus statusCode = responseEntity.getStatusCode();
result = responseEntity.getBody();
return result;
}
다음과같이 호출하여 응답시 다음과 같이 응답데이터 value 값의 한글이 전부 인코딩이 깨저서 들어옵니다…
가이드 부탁드립니다 .
------newtonekckNpNZVXWeg58V3
Content-Type: application/json; charset=UTF-8
{“type”:“beginPointDetection”,“value”:“BPD”}
------newtonekckNpNZVXWeg58V3
Content-Type: application/json; charset=UTF-8
{“type”:“partialResult”,“value”:"??¤??´"}
------newtonekckNpNZVXWeg58V3
Content-Type: application/json; charset=UTF-8
{“type”:“partialResult”,“value”:"??¤??´ ?¹´?¹´??¤"}
------newtonekckNpNZVXWeg58V3
Content-Type: application/json; charset=UTF-8
{“type”:“endPointDetection”,“value”:“EPD”}
------newtonekckNpNZVXWeg58V3
Content-Type: application/json; charset=UTF-8
Speech-Length: 2
{“type”:“finalResult”,“value”:"??¤??´ ?¹´?¹´??¤",“nBest”:[{“value”:"??¤??´ ?¹´?¹´??¤",“score”:82},{“value”:"??¤??´ ?¹´?¹´??¤??¼",“score”:0}]}
------newtonekckNpNZVXWeg58V3–