Share via


SpeechSynthesizer.SetOutputToDefaultAudioDevice Méthode

Définition

Configure l'objet SpeechSynthesizer pour envoyer la sortie au périphérique audio par défaut.

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

Exemples

L’exemple suivant utilise le synthétiseur pour prononcer une expression sur la sortie audio par défaut.

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

Remarques

Vous pouvez utiliser la fenêtre son dans le panneau de configuration Windows pour configurer le périphérique audio par défaut de l’ordinateur.

Pour d’autres options de configuration de sortie, consultez les SetOutputToAudioStream méthodes,, SetOutputToNull SetOutputToWaveFile et SetOutputToWaveStream .

S’applique à