JAVA使用谷歌语音识别API
我正在尝试使用谷歌语音识别API。 这是我写的代码:
http://pastebin.com/zJEhnJ74
有用。 我从服务器得到答案:
{"status":5,"id":"8803471b14a2310dfcf917754e8bd4a7-1","hypotheses":[]}
现在的问题是“状态:5”。 事实上,这里的状态代码:
status: 0 – correct , status: 4 – missing audio file, status: 5 – incorrect audio file.
我的问题是“音频文件不正确”。 我不明白它是否是.flac文件错误(你可以在这里下载我的测试.flac文件: http ://www21.zippyshare.com/v/61888405/file.html)或我如何读取文件(在一个字节数组然后将其转换为字符串)
感谢帮助! 抱歉我的英语不好
你必须使用wr.write(data);
而不是wr.writeBytes(new String(data));
谷歌回答:
{"status":0,"id":"e0f4ced346ad18bbb81756ed4d639164-1","hypotheses":[{"utterance":"hello how are you","confidence":0.94028234},{"utterance":"hello how r you"},{"utterance":"hello how are u"},{"utterance":"hello how are you in"}]}