Share via


Note

Please see Azure Cognitive Services for Speech documentation for the latest supported speech solutions.

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)

Syntax

'Declaration
Public Sub AppendSsml ( _
    ssmlFile As XmlReader _
)
'Usage
Dim instance As PromptBuilder
Dim ssmlFile As XmlReader

instance.AppendSsml(ssmlFile)
public void AppendSsml(
    XmlReader ssmlFile
)

Parameters

Examples

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();
    }
  }
}

See Also

Reference

PromptBuilder Class

PromptBuilder Members

Microsoft.Speech.Synthesis Namespace