我正在尝试整合 Bing Translate 的 Speak Method。 http://msdn.microsoft.com/en-us/library/ff512420.aspx
使用 PHP 的确切示例代码,我可以播放 wav 文件。但是,当我为我的 Sharepoint Web 部件使用 C# 示例代码时,我根本无法播放 wav 文件。
我错过了什么吗?
private void SpeakMethod(string authToken)
{
string toText = "sun";
string toLang = "en";
//string uri = "http://api.microsofttranslator.com/v2/Http.svc/Speak?text=" + toText + "&language=" + toLang +"&format=" + HttpUtility.UrlEncode("audio/wav") + "&options=MaxQuality";
string uri = "http://api.microsofttranslator.com/v2/Http.svc/Speak?text=welcome&language=en&format=" + HttpUtility.UrlEncode("audio/wav") + "&options=MaxQuality";
HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(uri);
httpWebRequest.Headers.Add("Authorization", authToken);
WebResponse response = null;
try
{
response = httpWebRequest.GetResponse();
using (Stream stream = response.GetResponseStream())
{
using (SoundPlayer player = new SoundPlayer(stream))
{
player.PlaySync();
alpha.Text = "alpha";
}
}
}
catch
{
throw;
}
finally
{
if (response != null)
{
response.Close();
response = null;
}
}
}