SpeechSynthesizer::Speak Method (String^)
.NET Framework (current version)
Synchronously speaks the contents of a string.
Assembly: System.Speech (in System.Speech.dll)
Parameters
- textToSpeak
-
Type:
System::String^
The text to speak.
To synchronously speak a string that contains SSML markup, use the SpeakSsml method. To asynchronously speak the contents of a string, use the SpeakAsync method.
As shown in the following example, the Speak method provides the simplest means to generate speech output synchronously.
using System; using System.Speech.Synthesis; namespace SampleSynthesis { class Program { static void Main(string[] args) { // Initialize a new instance of the SpeechSynthesizer. using (SpeechSynthesizer synth = new SpeechSynthesizer()) { // Configure the audio output. synth.SetOutputToDefaultAudioDevice(); // Speak a string synchronously. synth.Speak("What is your favorite color?"); } Console.WriteLine(); Console.WriteLine("Press any key to exit..."); Console.ReadKey(); } } }
.NET Framework
Available since 3.0
Available since 3.0
Show: