繁体   English   中英

停止文字转语音wp8

[英]Stopping Text to Speech wp8

我正在开发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");

        }

    }

如果您使用标准的SpeechSynthesizer则只需调用CancelAll方法。

使用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();
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM