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

Poniższy przykład używa syntezatora do wymawiania frazy z domyślnym wyjściem audio.

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 Panelu sterowania systemu Windows, aby skonfigurować domyślne urządzenie audio dla komputera.

Aby poznać inne opcje konfiguracji wyjściowej, SetOutputToAudioStream Zobacz SetOutputToNull metody,, SetOutputToWaveFile , i SetOutputToWaveStream .

Dotyczy