SpeechSynthesizer.SetOutputToDefaultAudioDevice Metoda

Definicja

Konfiguruje SpeechSynthesizer obiekt do wysyłania danych wyjściowych do domyślnego urządzenia audio.

public:
 void SetOutputToDefaultAudioDevice();
public void SetOutputToDefaultAudioDevice ();
member this.SetOutputToDefaultAudioDevice : unit -> unit
Public Sub SetOutputToDefaultAudioDevice ()

Przykłady

W poniższym przykładzie użyto syntetyzatora, aby mówić frazę do domyślnych danych wyjściowych dźwięku.

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();
    }
  }
}

Uwagi

Możesz użyć okna Dźwięk w systemie Windows Panel sterowania, aby skonfigurować domyślne urządzenie audio dla komputera.

Aby uzyskać inne opcje konfiguracji danych wyjściowych, zobacz SetOutputToAudioStreammetody , SetOutputToNull, SetOutputToWaveFilei SetOutputToWaveStream .

Dotyczy