PromptBuilder.AppendSsml 方法

定義

將 SSML 檔案附加到 PromptBuilder 物件上。

多載

名稱 Description
AppendSsml(String)

將指定路徑的 SSML 檔案附加到物件上 PromptBuilder

AppendSsml(Uri)

將指定 URI 處的 SSML 檔案附加到物件上 PromptBuilder

AppendSsml(XmlReader)

XMLReader 參考 SSML 提示詞的物件附加到該 PromptBuilder 物件上。

AppendSsml(String)

來源:
PromptBuilder.cs
來源:
PromptBuilder.cs
來源:
PromptBuilder.cs
來源:
PromptBuilder.cs

將指定路徑的 SSML 檔案附加到物件上 PromptBuilder

public:
 void AppendSsml(System::String ^ path);
public void AppendSsml(string path);
member this.AppendSsml : string -> unit
Public Sub AppendSsml (path As String)

參數

path
String

一個完整限定的 SSML 檔案路徑可附加。

範例

以下範例是建立一個 PromptBuilder 物件,並使用 該 AppendSsml 方法附加 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 append a file that defines an SSML prompt.
        PromptBuilder ssmlFile = new PromptBuilder();
        ssmlFile.AppendSsml("c:\\test\\Weather.ssml");

        // Speak the contents of the SSML prompt.
        synth.Speak(ssmlFile);
      }

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

以下是前述範例所引用的 SSML 檔案。

<?xml version="1.0" encoding="ISO-8859-1"?>
<speak version="1.0"
 xmlns="http://www.w3.org/2001/10/synthesis"
 xml:lang="en-US">

  <s> The weather forecast for today is partly cloudy with some sun breaks. </s>

</speak>

備註

SSML 檔案必須是符合 語音合成標記語言(SSML)版本 1.0 規範的 XML 格式檔案。

你也可以用 AppendSsmlMarkupS 將 SSML 標記作為字串附加。

適用於

AppendSsml(Uri)

來源:
PromptBuilder.cs
來源:
PromptBuilder.cs
來源:
PromptBuilder.cs
來源:
PromptBuilder.cs

將指定 URI 處的 SSML 檔案附加到物件上 PromptBuilder

public:
 void AppendSsml(Uri ^ ssmlFile);
public void AppendSsml(Uri ssmlFile);
member this.AppendSsml : Uri -> unit
Public Sub AppendSsml (ssmlFile As Uri)

參數

ssmlFile
Uri

一個完全合格的 URI 可以附加到 SSML 檔案中。

範例

以下範例是建立一個 PromptBuilder 物件,並使用 該 AppendSsml 方法附加 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 append a file that defines an SSML prompt.
        PromptBuilder ssmlFile = new PromptBuilder();
        ssmlFile.AppendSsml(new Uri("c:\\test\\Weather.ssml"));

        // Speak the contents of the SSML prompt.
        synth.Speak(ssmlFile);
      }

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

以下是前述範例所引用的 SSML 檔案。

<?xml version="1.0" encoding="ISO-8859-1"?>
<speak version="1.0"
 xmlns="http://www.w3.org/2001/10/synthesis"
 xml:lang="en-US">

  <s> The weather forecast for today is partly cloudy with some sun breaks. </s>

</speak>

備註

SSML 檔案必須是符合 語音合成標記語言(SSML)版本 1.0 規範的 XML 格式檔案。

你也可以用 AppendSsmlMarkupS 將 SSML 標記作為字串附加。

Important

從這個類別使用不受信任的數據呼叫方法構成安全性風險。 僅使用信任的數據呼叫來自這個類別的方法。 如需詳細資訊,請參閱 驗證所有輸入

適用於

AppendSsml(XmlReader)

來源:
PromptBuilder.cs
來源:
PromptBuilder.cs
來源:
PromptBuilder.cs
來源:
PromptBuilder.cs

XMLReader 參考 SSML 提示詞的物件附加到該 PromptBuilder 物件上。

public:
 void AppendSsml(System::Xml::XmlReader ^ ssmlFile);
public void AppendSsml(System.Xml.XmlReader ssmlFile);
member this.AppendSsml : System.Xml.XmlReader -> unit
Public Sub AppendSsml (ssmlFile As XmlReader)

參數

ssmlFile
XmlReader

在 XML 檔案中加上一個完全限定的名稱。

範例

以下範例是從XmlReader一個引用包含語音合成標記語言(SSML)標記的檔案的物件建立PromptBuilder一個物件。

using System;
using System.Xml;
using System.IO;
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.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();
    }
  }
}

備註

Important

使用這種類型的實例與不受信任的資料存在安全風險。 此物件僅用於受信任的資料。 如需詳細資訊,請參閱 驗證所有輸入

SSML 檔案必須是符合 語音合成標記語言(SSML)版本 1.0 規範的 XML 格式檔案。

你也可以用 AppendSsmlMarkupS 將 SSML 標記作為字串附加。

適用於