PromptBuilder.AppendSsml Method

Appends the specified XML file containing SSML to the PromptBuilder object.

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

public void AppendSsml(
	XmlReader ssmlFile
)

Parameters

ssmlFile
Type: System.Xml.XmlReader
A fully qualified name to the XML file to append.

The following example creates a PromptBuilder object from an XmlReader object that references a file containing Speech Synthesis Markup Language (SSML) markup.

using System;
using System.Xml;
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:\test\Weather.wav");

        // Create a SoundPlayer instance to play the output audio file.
        System.Media.SoundPlayer m_SoundPlayer =
          new System.Media.SoundPlayer(@"C:\test\Weather.wav");

        // Create the path to the SSML file.
        string weatherFile = Path.GetFullPath("c:\\test\\Weather.xml");
        PromptBuilder builder = null;

        // Create an XML Reader from the file, create a PromptBuilder and 
        // append the XmlReader.
        if (File.Exists(weatherFile))
        {
          XmlReader reader = XmlReader.Create(weatherFile);
          builder = new PromptBuilder();
          builder.AppendSsml(reader);
          reader.Close();
        }

        // Speak the prompt and play back the output file.
        synth.Speak(builder);
        m_SoundPlayer.Play();
      }

      Console.WriteLine();
      Console.WriteLine("Press any key to exit...");
      Console.ReadKey();
    }
  }
}

Show: