PromptBuilder.AppendSsml 方法

定義

將 SSML 檔案附加至 PromptBuilder 物件。

多載

AppendSsml(String)

將位於指定路徑的 SSML 檔案附加至 PromptBuilder 物件。

AppendSsml(Uri)

將位於指定 URI 的 SSML 檔案附加至 PromptBuilder 物件。

AppendSsml(XmlReader)

附加 XMLReader 物件,其參考 PromptBuilder 物件的 SSML 提示。

AppendSsml(String)

將位於指定路徑的 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 物件,並使用方法附加 SSML 檔案的內容 AppendSsml

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 格式檔案。

您也可以使用將 SSML 標記附加為字串 AppendSsmlMarkup

適用於

AppendSsml(Uri)

將位於指定 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

要附加之 SSML 檔案的完整 URI。

範例

接下來的範例會建立 PromptBuilder 物件,並使用方法附加 SSML 檔案的內容 AppendSsml

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 格式檔案。

您也可以使用將 SSML 標記附加為字串 AppendSsmlMarkup

適用於

AppendSsml(XmlReader)

附加 XMLReader 物件,其參考 PromptBuilder 物件的 SSML 提示。

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 檔案的完整名稱。

範例

下列範例 PromptBuilder 會從物件中建立物件 XmlReader ,該物件會參考包含語音合成標記語言 (SSML) 標記的檔案。

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

備註

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

您也可以使用將 SSML 標記附加為字串 AppendSsmlMarkup

適用於