我正在尝试使用谷歌语音识别API。这是我写的代码:
有效。我从服务器得到答案:
{"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)或我如何读取文件(在字节数组中然后将其转换为字符串)
感谢您的帮助!抱歉我的英文不好
答案 0 :(得分:6)
您必须使用wr.write(data);
代替wr.writeBytes(new String(data));
Google回答:
{"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"}]}