试图在uwp中实现文本到语音

问题描述 投票:-1回答:1

我正试图在uwp中实现文本到语音,但它不起作用。任何帮助都将受到赞赏。 XAML

<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));
}
c# xaml uwp text-to-speech
1个回答
0
投票

我尝试了你的代码,但它对我来说正常。你确定你没有听到任何声音吗?也许这是你机器的音量?此外,请确保您的Tapped事件真正被触发。添加断点以确保它被触发。

希望能帮助到你!