SpeechSynthesizer.Speak Method (String)


The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Synchronously speaks the contents of a string.

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

member Speak : 
        textToSpeak:string -> unit


Type: System.String

The text to speak.

To synchronously speak a string that contains SSML markup, use the SpeakSsml method. To asynchronously speak the contents of a string, use the SpeakAsync method.

As shown in the following example, the Speak method provides the simplest means to generate speech output synchronously.

using System;
using System.Speech.Synthesis;

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

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

        // Configure the audio output. 

        // Speak a string synchronously.
        synth.Speak("What is your favorite color?");

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

.NET Framework
Available since 3.0
Return to top