I am developing a WP8 application and Text to Speech is used heavily in it, In the app when you click on a button to go to a new page it tells which button you have pressed, but I want the text to speech to stop as soon as it changes page, Is there a way of stopping the text to speech as soon as a new page appears, even if the text to speech is only half way through what it has to say. here is a small piece of code from my application so I want to cut off the voice as soon as it goes to the instructions page, any help you be much appreciated. Thanks
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");
}
}
Use the CancelAll
method.
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();
}