SpeechSynthesizer::SetOutputToWaveFile Method (String^, SpeechAudioFormatInfo^)
.NET Framework (current version)
Configures the SpeechSynthesizer object to append output to a Waveform audio format file in a specified format.
Assembly: System.Speech (in System.Speech.dll)
Parameters
- path
-
Type:
System::String^
The path to the file.
- formatInfo
-
Type:
System.Speech.AudioFormat::SpeechAudioFormatInfo^
The audio format information.
The following example specifies the format of the output of speech synthesis and sends it to a WAV file.
using System; using System.IO; using System.Speech.Synthesis; using System.Speech.AudioFormat; 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.SetOutputToWaveFile(@"C:\temp\test.wav", new SpeechAudioFormatInfo(32000, AudioBitsPerSample.Sixteen, AudioChannel.Mono)); // Create a SoundPlayer instance to play output audio file. System.Media.SoundPlayer m_SoundPlayer = new System.Media.SoundPlayer(@"C:\temp\test.wav"); // Build a prompt. PromptBuilder builder = new PromptBuilder(); builder.AppendText("This is sample output to a WAVE file."); // Speak the prompt. synth.Speak(builder); m_SoundPlayer.Play(); } Console.WriteLine(); Console.WriteLine("Press any key to exit..."); Console.ReadKey(); } } }
.NET Framework
Available since 3.0
Available since 3.0
Show: