0
我尝试录制我的声音并将其发送到Wit.ai上的/ speech方法。所以,从我的浏览器,我收集像这样的斑点,并希望执行$。阿贾克斯()请求:Wit.ai POST /发送HTTP请求
recorder && recorder.exportWAV(function (blob) {
callback(blob);
// Ajax request here !
var data = new FormData();
data.append('file', blob);
$.ajax({
url : "https://api.wit.ai/speech?v=20171010",
headers: {
'X-Requested-With': 'JSONHttpRequest',
'Content-Type': 'audio/wav',
'Authorization' : 'Bearer OHROML6TAXxxxxxxxxxxxxSRYOVFCC'
},
type: 'POST',
data: data,
contentType: false,
processData: false,
success: function(data) {
alert(data);
},
error: function(error) {
alert("not so boa!"+JSON.stringify(error));
}
});
recorder.clear();
}, (AudioFormat || "audio/wav"));
我所有的成绩都是400错误!错误的请求 !或“不匹配内容类型”。
任何帮助将不胜感激。
我尝试没有成功:
recorder && recorder.exportWAV(function (blob) {
callback(blob);
$.ajax({
type: 'POST',
headers: {
'Authorization' : 'Bearer OHROML6TAEDFxxxx5W2SRYOVFCC'
},
url: 'https://api.wit.ai/speech?v=20171010',
data: blob,
contentType: 'audio/wav', // set accordingly
processData: false,
success: function(data) {
alert(data);
},
error: function(error) {
alert("not so boa!"+JSON.stringify(error));
}
});
// Clear the Recorder to start again !
recorder.clear();
}, (AudioFormat || "audio/wav"));
我还是一样的问题:
坏请求或机智没有按“T识别样品为WAV音频
谢谢,你是对的!我编辑了我的问题。 –
@PabloDelaNoche将'recorder.clear()'移到你的'success'和'error'回调中。你确定'blob'有你期望的数据吗? –