SpeechSynthesizer Class

SpeechSynthesizer Class

 

Provides access to the functionality of an installed a speech synthesis engine.

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

System.Object
  System.Speech.Synthesis.SpeechSynthesizer

public sealed class SpeechSynthesizer : IDisposable

NameDescription
System_CAPS_pubmethodSpeechSynthesizer()

Initializes a new instance of the SpeechSynthesizer class.

NameDescription
System_CAPS_pubpropertyRate

Gets or sets the speaking rate of the SpeechSynthesizer object.

System_CAPS_pubpropertyState

Gets the current speaking state of the SpeechSynthesizer object.

System_CAPS_pubpropertyVoice

Gets information about the current voice of the SpeechSynthesizer object.

System_CAPS_pubpropertyVolume

Get or sets the output volume of the SpeechSynthesizer object.

NameDescription
System_CAPS_pubmethodAddLexicon(Uri, String)

Adds a lexicon to the SpeechSynthesizer object.

System_CAPS_pubmethodDispose()

Disposes the SpeechSynthesizer object and releases resources used during the session.

System_CAPS_pubmethodEquals(Object)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_protmethodFinalize()

Acts as a safeguard to clean up resources in the event that the Dispose method is not called.(Overrides Object.Finalize().)

System_CAPS_pubmethodGetCurrentlySpokenPrompt()

Gets the prompt that the SpeechSynthesizer is speaking.

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetInstalledVoices()

Returns all of the installed speech synthesis (text-to-speech) voices.

System_CAPS_pubmethodGetInstalledVoices(CultureInfo)

Returns all of the installed speech synthesis (text-to-speech) voices that support a specific locale.

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_pubmethodPause()

Pauses the SpeechSynthesizer object.

System_CAPS_pubmethodRemoveLexicon(Uri)

Removes a lexicon from the SpeechSynthesizer object.

System_CAPS_pubmethodResume()

Resumes the SpeechSynthesizer object after it has been paused.

System_CAPS_pubmethodSelectVoice(String)

Selects a specific voice by name.

System_CAPS_pubmethodSelectVoiceByHints(VoiceGender)

Selects a voice with a specific gender.

System_CAPS_pubmethodSelectVoiceByHints(VoiceGender, VoiceAge)

Selects a voice with a specific gender and age.

System_CAPS_pubmethodSelectVoiceByHints(VoiceGender, VoiceAge, Int32)

Selects a voice with a specific gender and age, based on the position in which the voices are ordered.

System_CAPS_pubmethodSelectVoiceByHints(VoiceGender, VoiceAge, Int32, CultureInfo)

Selects a voice with a specific gender, age, and locale, based on the position in which the voices are ordered.

System_CAPS_pubmethodSetOutputToAudioStream(Stream, SpeechAudioFormatInfo)

Configures the SpeechSynthesizer object to append output to an audio stream.

System_CAPS_pubmethodSetOutputToDefaultAudioDevice()

Configures the SpeechSynthesizer object to send output to the default audio device.

System_CAPS_pubmethodSetOutputToNull()

Configures the SpeechSynthesizer object to not send output from synthesis operations to a device, file, or stream.

System_CAPS_pubmethodSetOutputToWaveFile(String)

Configures the SpeechSynthesizer object to append output to a file that contains Waveform format audio.

System_CAPS_pubmethodSetOutputToWaveFile(String, SpeechAudioFormatInfo)

Configures the SpeechSynthesizer object to append output to a Waveform audio format file in a specified format.

System_CAPS_pubmethodSetOutputToWaveStream(Stream)

Configures the SpeechSynthesizer object to append output to a stream that contains Waveform format audio.

System_CAPS_pubmethodSpeak(Prompt)

Synchronously speaks the contents of a Prompt object.

System_CAPS_pubmethodSpeak(PromptBuilder)

Synchronously speaks the contents of a PromptBuilder object.

System_CAPS_pubmethodSpeak(String)

Synchronously speaks the contents of a string.

System_CAPS_pubmethodSpeakAsync(Prompt)

Asynchronously speaks the contents of a Prompt object.

System_CAPS_pubmethodSpeakAsync(PromptBuilder)

Asynchronously speaks the contents of a PromptBuilder object.

System_CAPS_pubmethodSpeakAsync(String)

Asynchronously speaks the contents of a string.

System_CAPS_pubmethodSpeakAsyncCancel(Prompt)

Cancels the asynchronous synthesis operation for a queued prompt.

System_CAPS_pubmethodSpeakAsyncCancelAll()

Cancels all queued, asynchronous, speech synthesis operations.

System_CAPS_pubmethodSpeakSsml(String)

Synchronously speaks a String that contains SSML markup.

System_CAPS_pubmethodSpeakSsmlAsync(String)

Asynchronously speaks a String that contains SSML markup.

System_CAPS_pubmethodToString()

Returns a string that represents the current object.(Inherited from Object.)

NameDescription
System_CAPS_pubeventBookmarkReached

Raised when the SpeechSynthesizer encounters a bookmark in a prompt.

System_CAPS_pubeventPhonemeReached

Raised when a phoneme is reached.

System_CAPS_pubeventSpeakCompleted

Raised when the SpeechSynthesizer completes the speaking of a prompt.

System_CAPS_pubeventSpeakProgress

Raised after the SpeechSynthesizer speaks each individual word of a prompt.

System_CAPS_pubeventSpeakStarted

Raised when the SpeechSynthesizer begins the speaking of a prompt.

System_CAPS_pubeventStateChanged

Raised when the state of the SpeechSynthesizer changes.

System_CAPS_pubeventVisemeReached

Raised when a viseme is reached.

System_CAPS_pubeventVoiceChange

Raised when the voice of the SpeechSynthesizer changes.

When you create a new SpeechSynthesizer object, it uses the default system voice. To configure the SpeechSynthesizer to use one of the installed speech synthesis (text-to-speech) voices, use the SelectVoice or SelectVoiceByHints method. To get information about which voices are installed, use the GetInstalledVoices method and the VoiceInfo class.

This class also provides control over the following aspects of speech synthesis:

The SpeechSynthesizer raises events when it encounters certain features in prompts: (BookmarkReached, PhonemeReached, VisemeReached, and SpeakProgress). It also raises events that report on the start (SpeakStarted) and end (SpeakCompleted) of speak operations and on the change of the speaking voice (VoiceChange).

System_CAPS_noteNote

Always call Dispose before you release your last reference to the SpeechSynthesizer. Otherwise, the resources it is using will not be freed until the garbage collector calls the SpeechSynthesizer object's Finalize method.

The following example is part of a console application that initializes a SpeechSynthesizer object and speaks a string.


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. 
      synth.SetOutputToDefaultAudioDevice();

      // Speak a string.
      synth.Speak("This example demonstrates a basic use of Speech Synthesizer");

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

.NET Framework
Available since 3.0

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Show:
© 2016 Microsoft