SpeechSynthesizer..::..SetOutputToWaveFile Method (String, SpeechAudioFormatInfo) |
SpeechSynthesizer Class Example See Also Send Feedback |
Configures the SpeechSynthesizer object to append output to a Waveform audio format file in a specified format.
Namespace:
Microsoft.Speech.Synthesis
Assembly:
Microsoft.Speech (in Microsoft.Speech.dll)
Syntax
Visual Basic (Declaration) |
---|
Public Sub SetOutputToWaveFile ( _ path As String, _ formatInfo As SpeechAudioFormatInfo _ ) |
Visual Basic (Usage) |
---|
Dim instance As SpeechSynthesizer Dim path As String Dim formatInfo As SpeechAudioFormatInfo instance.SetOutputToWaveFile(path, formatInfo) |
C# |
---|
public void SetOutputToWaveFile( string path, SpeechAudioFormatInfo formatInfo ) |
Parameters
- path
- Type: System..::..String
The path to the file.
- formatInfo
- Type: Microsoft.Speech.AudioFormat..::..SpeechAudioFormatInfo
The audio format information.
Examples
The following example specifies the format of the output of speech synthesis and sends it to a WAV file.
Copy Code | |
---|---|
using System; using System.IO; using Microsoft.Speech.Synthesis; using Microsoft.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(8000, AudioBitsPerSample.Eight, 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(); } } } |