curl -v -X POST “https://kakaoi-newtone-openapi.kakao.com/v1/recognize” -H “Transfer-Encoding: chunked” -H “Content-Type: application/octet-stream” -H “Authorization: KakaoAK *****” --data-binary @test.wav
로는 dos 화면에서 결과가 잘 나옵니다.
그런데 java 에서 다음과 변경하여 작업 하였습니다.
StringBuilder urlBuilder = new StringBuilder(“https://kakaoi-newtone-openapi.kakao.com/v1/recognize”);
URL url = new URL(urlBuilder.toString());
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("POST");
conn.setRequestProperty("Accept", "application/json");
conn.setRequestProperty("Transfer-Encoding", "chunked");
conn.setRequestProperty("Content-Type", "application/octet-stream");
conn.setRequestProperty("Cache-Control","no-cache");
conn.setRequestProperty("Authorization", "KakaoAK ********" );
conn.setDoOutput(true);
conn.setDoInput(true);
conn.setUseCaches(false);
OutputStreamWriter writer = new OutputStreamWriter(conn.getOutputStream());
writer.write("@test.wav" );
writer.flush();
writer.close();
conn.getOutputStream().close();
다음과 같은 에러 메시지가 나옵니다. 에러가 나오는 이유가 뭘까요?
------newtoneZF27BywpgLZFcr8HContent-Type: application/json; charset=UTF-8{“type”:“errorCalled”,“value”:“Error 4 Received Nack - no result”}------newtoneZF27BywpgLZFcr8H–