i searched for a long time on the web and didn't found anything helpful.
I record a 5s audiofile and upload it to Google Speech API. I get an empty response from Google, although in the same respond it says status=ok and give me the HTTP Responsecode 200. On the documentation it says that it was successful if it responses code 200 Here's my code for building the request
String audio = Base64.encodeBase64URLSafeString((WavFile.toString().getBytes()));
JSONObject request_cfg = new JSONObject()
.put("audio", new JSONObject()
.put("content", audio))
.put("config", new JSONObject()
.put("encoding", "LINEAR16")
.put("sampleRate", 16000)
.put("languageCode", "de-DE"));
String url = "https://speech.googleapis.com/v1beta1/speech:syncrecognize?key=" + ___YOUR_API_KEY___;
System.out.println(request_cfg);
HttpResponse<JsonNode> request = Unirest.post(url)
.body(request_cfg)
.asJson();
JSONObject response = new JSONObject(request);
System.out.println(response);
with that code the request body looks like this:
{"audio":"content":"QzpcVXNlcnNcQmVubmlcd29ya3NwYWNlXFBlcnNvbmFsX0FpX2RpZV96d2VpdGVccmVzXHJlY29yZGluZy53YXY"},"config":{"encoding":"LINEAR16","languageCode":"de-DE","sampleRate":16000}}
and the full response looks like this:
{"headers":{"X-Frame-Options":{"empty":false},"Transfer-Encoding":{"empty":false},"Server":{"empty":false},"Cache-Control":"empty":false},"Alt-Svc":{"empty":false},"X-Content-Type-Options":{"empty":false},"Vary":"empty":false},"X-XSS-Protection":"empty":false},"Date":{"empty":false},"Content-Type":"empty":false}},"rawBody":"java.io.ByteArrayInputStream@79ca92b9","statusText":"OK","body":{"array":{},"object":{}},"status":200}
So I get the statusText=ok and an HTTP 200 Response, which according to the Google Docs means it was succsessful.
I recorded in Java. Here are the Parameters:
- sample rate is 16000, I tried 41000 but that didn't work eigher
- Bit/s 16
- Channels 1
- signed integer
- little endian
I don't know what I have to do to get an answer from Google
thanks in regard