Capturing Audio Sent To Google's Speech Recognition Server
Solution 1:
I tend to say this might be a inconsistency in the behavior of the recognition service, maybe even a bug in the Android version you use. However, the documentation states, that it is not guaranteed that this method is called so it would fit into the specification. What I noticed so far is the following (on Android 2.3.4): I get the bytes while recording, but if there is for example a SocketTimeout
it tries to resend the data to the server after some time, but without calling onBufferReceived
again for the same data. The code used to test that was the same as the one you have linked in your posting.
Why do you think some chunks are missing from the audio you received in the method? If it were only a few chunks missing, it might even be the case, that the recognition worked although those chunks were missing.
Solution 2:
In modern versions onBufferReceieved does not work, you can check record/save audio from voice recognition intent instead.
Solution 3:
Best way to achieve this is round the other way. Capture your audio data using the AudioRecord
, (I'd recommend using VOICE_COMMUNICATION
rather than MIC
as an input so you get really clean audio), then pass it through to the SpeechRecognizer
. :)
Post a Comment for "Capturing Audio Sent To Google's Speech Recognition Server"