Sprache

PromptBuilder.ToXml Methode

Definition

Gibt das aus dem PromptBuilder Objekt generierte SSML zurück.

public:
 System::String ^ ToXml();
public string ToXml();
member this.ToXml : unit -> string
Public Function ToXml () As String

Gibt zurück

Gibt das aus dem PromptBuilder Objekt generierte SSML als einzelne Zeile zurück.

Beispiele

Im folgenden Beispiel wird ein PromptBuilder Objekt erstellt, Text angefügt und anschließend die SSML-Entsprechung der Eingabeaufforderung in die Konsole geschrieben, bevor der Inhalt der Eingabeaufforderung gesprochen wird.

using System;
using System.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.SetOutputToDefaultAudioDevice();

        // 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 contents of the SSML prompt.
        synth.Speak(style);
      }

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

Hinweise

Die ToXml Methode versucht nicht, das zurückgegebene SSML auf irgendeine Weise zu formatieren.

Gilt für: