HomeWindowsHow to Cancel the Speech Synthesis in windows phone 8?

How to Cancel the Speech Synthesis in windows phone 8?

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.

task.Cancel();

Download the code sample used in this blog post here

Leave a Reply

You May Also Like

This blog post will guide you through several effective methods to troubleshoot and resolve the issue of Microsoft Edge not...
Windows 11 offers a range of audio enhancements that can enrich your listening experience. These enhancements include features like virtual...
Windows 11 brings a fresh and visually stunning design to your desktop, and one of the standout features is the...