我正在开发一个WP8应用程序,文本到语音被大量使用,在应用程序中,当您单击按钮转到新页面时,它会告诉您按下了哪个按钮,但我希望将文本发送到一旦它改变页面就停止,有一种方法可以在新页面出现时立即停止文本到语音,即使文本到语音只是它所说的一半。这是我的应用程序中的一小段代码,所以我想在进入说明页面时切断语音,任何帮助你都会非常感激。感谢
private async void SayWords(string words)
{
SpeechSynthesizer synth = new SpeechSynthesizer();
await synth.SpeakTextAsync(words);
}
private void Instructions_Click(object sender, RoutedEventArgs e)
{
checkSender(sender);
TapCount++;
if (TapCount == 2)
{
NavigationService.Navigate(new Uri("/instructions.xaml", UriKind.Relative));
}
else
{
SayWords("You have selected the Instructions");
}
}
答案 0 :(得分:0)
如果您使用标准SpeechSynthesizer
,则只需调用CancelAll
方法。
答案 1 :(得分:0)
使用CancelAll
方法。
private SpeechSynthesizer synth = new SpeechSynthesizer();
private async void Button_Click(object sender, RoutedEventArgs e)
{
await synth.SpeakTextAsync("You have an incoming notification from Big Bank.");
}
private void Button_Click_1(object sender, RoutedEventArgs e)
{
synth.CancelAll();
}