I have a HttpURLConnection which I send audio to. I use
setRequestProperty("Content-Type", "audio/x-flac; rate=48000");
to specify the type of the audio I am sending. I am supposed to receive a string of whatever the audio file says.
It works when I get a byte array of the audio file and send that but I want to be able to send audio taken from my microphone as a byte array but I don't know how to specify that.
Or I could send a wav file but I tried it with a test file using "audio/wav" and that still doesn't work.
The error I get when it doesn't work is
java.io.IOException: Server returned HTTP response code: 500 for URL: https://www.google.com/speech-api/v1/recognize?xjerr=1&client=speech2text&lang=en-US&maxresults=10
The line it refers to is
connection.getInputStream();
Thanks.