現在unityから音声ファイル(.wav)をMicrosoftAzureのBingSpeechAPIに送信しようとしています。
しかし,csharpで音声ファイルを送信している例はあるのですがunityから音声ファイルを送信している例が見つからず困っています。
トークンの取得まではできており,あとは音声ファイルを送信するだけの状態です。
下記のプログラムで音声ファイルをAzureに送信しているのですが,Hederが間違っているなどのエラーが出現します。
public IEnumerator PostSpeech() { string filePath = savedPath; var url = @"https://stream.watsonplatform.net/speech-to-text/api/v1/recognize?continuous=true"; var postData = File.ReadAllBytes (filePath); var headers = new Dictionary<string,string> (); byte[] textBytes = System.Text.Encoding.UTF8.GetBytes ("your_username:your_password"); string base64String = System.Convert.ToBase64String (textBytes); string basicAuth = string.Format ("Basic {0}", base64String); headers.Add ("Content-Type", "audio/wav"); headers.Add ("Content-Length", postData.Length.ToString ()); headers.Add ("Transfer-Encoding", "chunked"); headers.Add ("Authorization", basicAuth); var www = new WWW (url, postData, headers); yield return www; Debug.Log (www.text); // You might parse the value of the www.text which is JSON and get the response parameters; ex. confidence or transcript. }
このような場合はどうすれば良いのでしょうか?
解決策や参考URLなどを教えていただきたいです。
よろしくお願いします。
開発環境
unity 2017.2.0.3f
MicrosoftAzure
Hololens
回答2件
あなたの回答
tips
プレビュー