Capturing audio sent to Google Speech Recognition Server

for speech recognition by the Google server, I use the SpeechRecognizer class in combination with the RecognitionListener, as suggested by Stephan's answer to this question . Also, I am trying to capture an audio signal recognized by the onBufferReceived () callback from RecognitionListener, for example:

byte[] sig = new byte[500000] ; int sigPos = 0 ; ... public void onBufferReceived(byte[] buffer) { System.arraycopy(buffer, 0, sig, sigPos, buffer.length) ; sigPos += buffer.length ; } ... 

This works just fine unless SpeechRecognizer is unable to connect to the Google server, when a piece of audio is not copied to the aforementioned sig array, and an HTTP connection timeout exception is thrown. SpeechRecognizer eventually connects to the Google server, and the recognition results show that the full audio signal was received; only in the sig array is some piece of audio missing.

Does anyone have a similar problem? Any hint of a solution? Thank!

+4
android speech-recognition voice-recognition
May 8 '11 at 4:44
source share
2 answers

I am inclined to say that this may be inconsistency in the behavior of the recognition service, perhaps even an error in the version of Android you are using. However, the documentation states that it is not guaranteed that this method is invoked so that it fits into the specification. What I have noticed so far is the following (on Android 2.3.4): I receive bytes during recording, but if there is, for example, SocketTimeout , it tries to resend the data to the server after a while, but without calling onBufferReceived again for the same data. The code used for verification was the same as the one you linked in your message.

Why do you think some fragments are missing from the audio you received in the method? If it were only a few pieces, it could even be that recognition worked, although these pieces were missing.

+1
May 10 '11 at 6:56 a.m.
source share

In modern versions of onBufferReceieved does not work, you can instead record / save audio from the intention of voice recognition .

+1
Feb 03 '16 at 15:26
source share



All Articles