我正在尝试在uwp中实现文本到语音,但它不起作用。任何帮助将不胜感激。哈姆勒
<MediaElement x:Name="textToSpeech" Volume="0.9" />
C# 代码
private async void N123tap(object sender, TappedRoutedEventArgs e)
{
string speechText = "LearnCounting";
// var speechText = "LearnCounting";
var synth = new SpeechSynthesizer();
var speechStream = await synth.SynthesizeTextToStreamAsync(speechText);
this.textToSpeech.AutoPlay = true;
this.textToSpeech.SetSource(speechStream, speechStream.ContentType);
this.textToSpeech.Play();
this.Frame.Navigate(typeof(N123P));
}
我尝试了您的代码,但它对我来说工作正常。你确定你什么都没听到吗?也许这是您机器的体积?此外,请确保您的点击事件确实被触发。添加断点以确保触发断点。
希望对您有所帮助!