I'm trying to use the speech recognition REST API service from wit.ai
I have used Volley to send a POST request to the URL https://api.wit.ai/speech
This is what I have currently done:
void makeApiCall(){
StringRequest request = new StringRequest(Request.Method.POST, "https://api.wit.ai/speech", new Response.Listener<String>() {
@Override
public void onResponse(String response) {
Log.d("wit_response",response);
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Log.d("wit_response",error.toString());
}
}){
@Override
protected Map<String,String> getParams() throws AuthFailureError{
Map<String,String> params = new HashMap<>();
params.put("Authorization","Bearer XXXXXX"); //hidden my token
params.put("Content-Type","audio/mpeg3");
return params;
}
@Override
public byte[] getBody() throws AuthFailureError {
return sendToByte();
}
};
RequestQueue queue = Volley.newRequestQueue(getApplicationContext());
queue.add(request);
}
I am receiving an error of com.android.volley.ClientError
on the wit_response log key inside onErrorResponse()
method
I have not missed the content type and authorization header, and my sendToByte function is succesfully returning an mp3 file converted to byte array.
What is the issue?