使用HttpWebRequest将音频上传到URL(VB.NET)

时间:2014-07-18 19:45:23

标签: vb.net http curl

我正在尝试以与使用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

感谢您的帮助!

0 个答案:

没有答案