question

behnoush avatar image
behnoush asked

Cannot play the audio from the speechrecognizer response

Hi, I am trying to implement an android app to use AVS. I have been able to send a request and receive a speech recognizer response with Directive Object having the value of "speak". My problem is that I cannot play it on android with AudioTrack. I only hear some noise. Is there other way of playing the audio on android? here is a snippet of the code: int minSize =AudioTrack.getMinBufferSize(16000, AudioFormat.CHANNEL_OUT_MONO, AudioFormat.ENCODING_PCM_16BIT); AudioTrack mtrack = new AudioTrack(AudioManager.STREAM_MUSIC, 16000, AudioFormat.CHANNEL_OUT_MONO, AudioFormat.ENCODING_PCM_16BIT, minSize, AudioTrack.MODE_STREAM); ... ... mtrack.play(); int res = 1; while(res > 0) { temp = new byte[minSize]; ByteArrayInputStream f = response.getAudio().get(cid); res = f.read(temp, 0, temp.length); mtrack.write(temp, 0, res); mtrack.flush(); } Any help is appreciated. Thanks.
alexa voice service
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

Eric@Amazon avatar image
Eric@Amazon answered
The reply that you get back from AVS is in MP3 format, not 16kHz mono output. The Android MediaPlayer may be helpful.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.