Export (0) Print
Expand All

SpeechSynthesizer.SetOutputToDefaultAudioDevice Method

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

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

public void SetOutputToDefaultAudioDevice()

You can use the Sound window in the Windows Control Panel to configure the default audio device for the computer.

For other output configuration options, see the SetOutputToAudioStream, SetOutputToNull, SetOutputToWaveFile, and SetOutputToWaveStream methods.

The following example uses the synthesizer to speak a phrase to the default audio output.

using System;
using System.Speech.Synthesis;

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

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

        // Configure the synthesizer to send output to the default audio device.
        synth.SetOutputToDefaultAudioDevice();

        // Speak a phrase.
        synth.Speak("This is sample text-to-speech output.");
      }

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

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4
Show:
© 2015 Microsoft