如何将以下cURL
转换为ajax
REST呼叫?
curl -u "{username}":"{password}" \
-H "content-type: audio/wav" \
--data-binary @"/path/to/file.wav" \
"https://stream.watsonplatform.net/speech-to-text/api/v1/recognize"
我在ajax调用下添加了一些,我不知道如何添加其余部分,特别是-H
和--data-binary @
function restCall()
{
$.ajax
({
type: "GET",
url: "https://stream.watsonplatform.net/speech-to-text/api/v1/recognize",
dataType: 'json',
username: "xxxx",
password: "xxxx",
success: function (data){
alert(JSON.stringify(data));
}
});
}