SpeechSynthesizer.SetOutputToDefaultAudioDevice Metodo

Definizione

Configura l'oggetto SpeechSynthesizer per inviare l'output al dispositivo audio predefinito.

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

Esempio

Nell'esempio seguente viene usato il sintetizzatore per pronunciare una frase nell'output audio predefinito.

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

Commenti

È possibile utilizzare la finestra audio nel pannello di controllo di Windows per configurare il dispositivo audio predefinito per il computer.

Per altre opzioni di configurazione di output, vedere i SetOutputToAudioStream metodi,, SetOutputToNull SetOutputToWaveFile e SetOutputToWaveStream .

Si applica a