我尝试将Nuance Dragon API用于我的Java应用程序。
由于我对cURL
一无所知,因此我将-k , -v
和--data-binary
参数设置为URLConnection
- 对象时遇到了问题。
cURL请求:
curl "https://dictation.nuancemobility.net:443/NMDPAsrCmdServlet/dictation?appId=[INSERT YOUR APP ID]&appKey=[INSERT YOUR 128-BYTE STRING APP KEY]&id=C4461956B60B"
-H "Content-Type: audio/x-wav;codec=pcm;bit=16;rate=8000"
-H "Accept-Language: ENUS"
-H "Transfer-Encoding: chunked"
-H "Accept: application/xml"
-H "Accept-Topic: Dictation"
-k --data-binary @audio.wav -v
我目前的代码:
URLConnection connection = new URL(url).openConnection();
connection.setDoOutput(true);
connection.setRequestProperty("Accept-Charset", "ENUS");
connection.setRequestProperty("Content-Type", "audio/x-wav;codec=pcm;bit=16;rate=8000");
connection.setRequestProperty("Transfer-Encoding", "chunked");
connection.setRequestProperty("Accept", "application/xml");
connection.setRequestProperty("Accept-Topic", "Dictation");
这个问题有更简单的解决方案吗?也许是java-lib?
感谢。