PromptBuilder.ToXml 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
回傳從 PromptBuilder 物件產生的 SSML。
public:
System::String ^ ToXml();
public string ToXml();
member this.ToXml : unit -> string
Public Function ToXml () As String
傳回
會以單一行回傳從物件產生的 PromptBuilder SSML。
範例
以下範例是建立一個 PromptBuilder 物件,附加文字,然後在講出提示詞內容前,先寫入 SSML 等同於提示詞的指令。
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();
}
}
}
備註
此 ToXml 方法不會嘗試格式化回傳的 SSML。