Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JAVA using google speech recognition API

Tags:

java

api

speech

I'm trying to use google speech recognition API. Here's the code i've written:

http://pastebin.com/zJEhnJ74

It works. I get an answer from the server:

{"status":5,"id":"8803471b14a2310dfcf917754e8bd4a7-1","hypotheses":[]}

Now the problem is "status:5". Infact, here's status code:

status: 0 – correct
, status: 4 – missing audio file, 
status: 5 – incorrect audio file.

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

like image 331
seicaratteri Avatar asked May 24 '13 20:05

seicaratteri


People also ask

How do I use Google Text-to-Speech API in Java?

Set Up an Eclipse IDE-Based Development Environment Select or create a Google Cloud project. Enable billing for the project. Enable Google Cloud's Text-to-Speech Service; follow this page, Cloud Text-to-Speech API to enable the service. Do not forget to select the project you created in the above steps.

How do I get voice recognition in Java?

Java Speech API: The Java Speech API allows Java applications to incorporate speech technology into their user interfaces. It defines a cross-platform API to support command and control recognizers, dictation systems and speech synthesizers.

Is Google speech API free?

The Google Speech-To-Text API isn't free, however. It is free for speech recognition for audio less than 60 minutes. For audio transcriptions longer than that, it costs $0.006 per 15 seconds. For video transcriptions, it costs $0.006 per 15 seconds for videos up to 60 minutes in length.


1 Answers

You must use wr.write(data); instead of wr.writeBytes(new String(data));

Google answer:

{"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"}]}
like image 115
Jarandinor Avatar answered Nov 03 '22 00:11

Jarandinor