我正在尝试以与使用cURL命令相同的方式将音频上传到URL。 cURL看起来像这样:
curl -XPOST 'https://api.wit.ai/speech' \
-i -L \
-H "Authorization: Bearer $TOKEN" \
-H 'Accept: application/vnd.wit.20140620+json' \
-H "Content-Type: audio/wav" \
--data-binary "@sample.wav"
这是我当前使用纯文本URL的代码,它完美运行:
Dim editedText As String = TextBox1.Text.Replace(" ", "%20")
Dim myHttpWebRequest = CType(WebRequest.Create("https://api.wit.ai/message?v=20140609&q=" + editedText + "&units=metric"), HttpWebRequest)
myHttpWebRequest.Headers.Add("Authorization: Bearer <myautcodegoeshere>")
Dim myHttpWebResponse = CType(myHttpWebRequest.GetResponse(), HttpWebResponse)
Dim myWebSource As New StreamReader(myHttpWebResponse.GetResponseStream())
Dim myPageSource As String = myWebSource.ReadToEnd()
Return myPageSource
感谢您的帮助!