SpeechSynthesizer.SetOutputToDefaultAudioDevice Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Configures the SpeechSynthesizer object to send output to the default audio device.
public:
void SetOutputToDefaultAudioDevice();
public void SetOutputToDefaultAudioDevice ();
member this.SetOutputToDefaultAudioDevice : unit -> unit
Public Sub SetOutputToDefaultAudioDevice ()
Examples
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();
}
}
}
Remarks
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.
Applies to
Commentaires
https://aka.ms/ContentUserFeedback.
Bientôt disponible : Tout au long de 2024, nous allons supprimer progressivement GitHub Issues comme mécanisme de commentaires pour le contenu et le remplacer par un nouveau système de commentaires. Pour plus d’informations, consultezEnvoyer et afficher des commentaires pour