我想讓Google TTS語音正常工作,因爲Windows RT/Metro不包含System.Speech的定義。下面的代碼編譯沒有錯誤,但沒有任何說話。我已調試並檢查'ListBox.SelectedItem'是否包含文本,並且它確實如此。Google TTS語音問題
庫稱爲:
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
using Windows.UI.Popups;
using System.Net.Http;
這是我如何我打電話myMediaElement:
MediaElement myMediaElement = new MediaElement();
這就是我要做的:
private void RepeatWord_Click(object sender, RoutedEventArgs e)
{
string pathx = "http://translate.google.com/translate_tts?tl=en&q=" + ListBox.SelectedItem.ToString();
myMediaElement.Source = new Uri(pathx, UriKind.RelativeOrAbsolute);
myMediaElement.Play();
}
謝謝。我將它添加到用戶界面,並添加了代碼將其作爲子項添加到網格中。 'MainGrid.Children.Add(myMediaElement)',它工作。 – zzwyb89