The Windows Phone 8 SDK provides the Speech Synthesis (Text to Speech) feature which lets the developers to provide the text input and lets the windows phone speak the text for you.
Sometimes when the Speech Synthesizer speaks the given text to the user, the user may want to cancel the speech synthesis.
How to Cancel the Speech Synthesis in windows phone 8 App?
In order to cancel the speech synthesis in Windows Phone 8 App when the phone is speaking out the text, you can use the assign the return value of the SpeakTextAsync method of the SpeechSynthesizer object to the IAsyncAction and then call the Cancel method of the IAsyncAction to cancel the speech synthesis.
For example, assume that the Speech Synthesizer and the IAsyncAction is declared in the page as shown below.
private SpeechSynthesizer synth = new SpeechSynthesizer(); private IAsyncAction task;
When the SpeakTextAsync is called, assign the result to the IAsyncAction.
task = synth.SpeakTextAsync("Welcome to developerpublish.com - All about Mobile development");
When you want to cancel the speech synthesis, call the Cancel method of the task.
Download the code sample used in this blog post here