WIT.ai HTTP tutoral has the following curl requset: $ curl -XPOST 'https://api.wit.ai/speech?v=20141022' \
-i -L \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: audio/wav" \
--data-binary "@sample.wav"
I was trying to translate it into jQuery Ajax:
function sendWav(){
var data = new FormData();
data.append('file',$('input[type=file]')[0].files[0]);
//alert(JSON.stringify(data));
$.ajax({
url: 'https://api.wit.ai/speech?v=20141022',
dataType: 'jsonp',
data: {
'access_token': 'token',
'Content-Type': 'audio/wav',data},
processData: false,
method: 'POST',
success: function(data){
alert("Success");
//alert(JSON.stringify(data));
//process the JSON data etc
},
error: function(xhr,textStatus,err) {
alert("readyState: " + xhr.readyState);
alert("responseText: "+ xhr.responseText);
alert("status: " + xhr.status);
alert("text status: " + textStatus);
alert("error: " + err);}
});
}
It gives an error: readyState: 4, status: 404. I've checked url it alive. Any help would highly appreciated!