JAVA 使用谷歌语音识别 API [英] JAVA using google speech recognition API
问题描述
我正在尝试使用谷歌语音识别 API.这是我写的代码:
I'm trying to use google speech recognition API. Here's the code i've written:
它有效.我从服务器得到答复:
It works. I get an answer from the server:
{"status":5,"id":"8803471b14a2310dfcf917754e8bd4a7-1","hypotheses":[]}
现在的问题是状态:5".事实上,这是状态代码:
Now the problem is "status:5". Infact, here's status code:
status: 0 – correct
, status: 4 – missing audio file,
status: 5 – incorrect audio file.
我的问题是音频文件不正确".我不明白是否是 .flac 文件错误(您可以在此处下载我的测试 .flac 文件:http://www21.zippyshare.com/v/61888405/file.html) 或我如何读取文件(在字节数组中,然后将其转换为字符串)
My problem is "incorrect audio file". I don't understand if it is a .flac file error (you can download my test .flac file here: http://www21.zippyshare.com/v/61888405/file.html) or how i read the file (in a byte array then convert it into string)
感谢帮助!很抱歉我的英语不好
Thanks for help! and sorry for my bad english
推荐答案
你必须使用 wr.write(data);
而不是 wr.writeBytes(new String(data));
You must use wr.write(data);
instead of 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"}]}
这篇关于JAVA 使用谷歌语音识别 API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!