SetOutputToWaveFile Method (String)

Microsoft Speech Platform SDK 11

Collapse imageExpand ImageCopy imageCopyHover image

Configures the SpeechSynthesizer object to append output to a file that contains Waveform format audio.

Namespace:  Microsoft.Speech.Synthesis
Assembly:  Microsoft.Speech (in Microsoft.Speech.dll)

Syntax

Visual Basic (Declaration)
Public Sub SetOutputToWaveFile ( _
	path As String _
)
Visual Basic (Usage)
Dim instance As SpeechSynthesizer
Dim path As String

instance.SetOutputToWaveFile(path)
C#
public void SetOutputToWaveFile(
	string path
)

Parameters

path
Type: System..::..String

The path to the file.

Remarks

To configure the output and specify the audio format, use the SetOutputToWaveFile(String, SpeechAudioFormatInfo) method.

Examples

The following example uses an instance of SoundPlayer to play a prompt that has been output to a .wav file.

 Copy imageCopy Code
using System;
using System.IO;
using Microsoft.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.SetOutputToWaveFile(@"C:\temp\test.wav");

        // Create a SoundPlayer instance to play the 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();
    }
  }
}

See Also