SpeakAsync Method

SpeechSynthesizer.SpeakAsync Method

Generates speech output asynchronously from a string, a Prompt object, or a PromptBuilder object.

  NameDescription
Public method SpeakAsync(String) Asynchronously speaks the contents of a string.
Public method SpeakAsync(Prompt) Asynchronously speaks the contents of a Prompt object.
Public method SpeakAsync(PromptBuilder) Asynchronously speaks the contents of a PromptBuilder object.
Top

The SpeakAsync() methods generate speech asynchronously. The methods return immediately without waiting for the content of the SpeakAsync() object to finish speaking. Use SpeakAsync() if your application needs to perform tasks while speaking, for example highlight text, paint animation, monitor controls, or other tasks. Because the SpeakAsync() calls are asynchronous, you will typically play the output in a handler for the SpeakCompleted event. See the examples in this section.

During a call to a SpeakAsync() method, the SpeechSynthesizer can raise the following events:

  • StateChanged. Raised when the speaking state of the synthesizer changes.

  • SpeakStarted. Raised when the synthesizer begins generating speech.

  • SpeakProgress. Raised each time the synthesizer completes speaking a word.

  • BookmarkReached. Raised when the synthesizer encounters a bookmark in a prompt.

  • VoiceChange. Raised when the speaking voice for the synthesizer changes.

  • SpeakCompleted. Raised when the synthesizer finishes a SpeakAsync() operation.

If your application does not need to perform tasks while speaking, you can use the Speak() methods or the SpeakSsml(String) method to generate speech synchronously.

Show:
© 2016 Microsoft