SpeechSynthesizer.SpeakAsync Method (Prompt)


Asynchronously speaks the contents of a Prompt object.

Namespace:   System.Speech.Synthesis
Assembly:  System.Speech (in System.Speech.dll)

public void SpeakAsync(
	Prompt prompt


Type: System.Speech.Synthesis.Prompt

The content to speak.

You can cancel the asynchronous speaking of a prompt with the SpeakAsyncCancel or the SpeakAsyncCancelAll method.

To synchronously speak the contents of a Prompt object, use Speak.

The following example creates a Prompt object from a string and passes the object as an argument to the SpeakAsync method.

using System;
using System.Speech.Synthesis;

namespace SampleSynthesis
  class Program
    static void Main(string[] args)

      // Initialize a new instance of the SpeechSynthesizer.
      SpeechSynthesizer synth = new SpeechSynthesizer();

      // Configure the audio output. 

      // Create a prompt from a string.
      Prompt color = new Prompt("What is your favorite color?");

      // Speak the contents of the prompt asynchronously.

      Console.WriteLine("Press any key to exit...");

.NET Framework
Available since 3.0
Return to top