Note

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

PromptBuilder.ToXml Method

Returns the SSML generated from the PromptBuilder object.

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

Syntax

'Declaration
Public Function ToXml As String
'Usage
Dim instance As PromptBuilder
Dim returnValue As String

returnValue = instance.ToXml()
public string ToXml()

Return Value

Type: System.String
Returns the SSML generated from the PromptBuilder object as a single line.

Remarks

The ToXml method makes no attempt to format the returned SSML in any way.

Examples

The following example creates a PromptBuilder object, appends text, and then writes the SSML equivalent of the prompt to the console before speaking the contents of the prompt.

using System;
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\Hardware.wav");

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

        // Create a PromptBuilder object and add content.
        PromptBuilder style = new PromptBuilder();
        style.AppendText("Your order for");
        style.StartStyle(new PromptStyle(PromptRate.Slow));
        style.AppendText("one kitchen sink and one faucet");
        style.EndStyle();
        style.AppendText("has been confirmed.");

        // Write the contents of the PromptBuilder object to the console as
        // an SSML-compatible XML file.
        string myXml = style.ToXml();
        Console.WriteLine("This is the SSML equivalent of the PromptBuilder: \n\n" + myXml);


        // Speak the prompt and play back the output file.
        synth.Speak(style);
        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