Speak the Contents of a String (Microsoft.Speech)

Microsoft Speech Platform SDK 11

Collapse image Expand Image Copy image CopyHover image

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, a SpeechSynthesizer instance named s is created, and then the Speak(String) method on s is called. The string literal to be spoken is passed in the call.

C#  Copy imageCopy Code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Speech.Synthesis;

namespace SimpleSpeak
{
  class Program
  {
    static void Main(string[] args)
    {
      SpeechSynthesizer s = new SpeechSynthesizer();
      s.Speak("Hello. My name is Microsoft Server Speech Text to Speech Voice (en-US, Helen).");
    }
  }
}