Share via


Note

Please see Azure Cognitive Services for Speech documentation for the latest supported speech solutions.

Speak the Contents of a String (Microsoft.Speech)

A simple way to generate synthesized speech is to create a SpeechSynthesizer instance, and then call the synthesizer’s Speak(String) method, passing the string to be spoken as an argument.

The following example shows the Main method of a class in a console application. When Main begins to run, the example creates a SpeechSynthesizer instance named synth. Then the example calls the Speak(String) method on synth, and passes in a string literal to be spoken.

using System;
using Microsoft.Speech.Synthesis;

namespace SimpleSpeak
{
  class Program
  {
    static void Main(string[] args)
    {
      SpeechSynthesizer synth = new SpeechSynthesizer();
      synth.Speak("This example speaks the text in a string.");
    }
  }
}