通过


PromptBuilder.AppendSsml 方法

定义

将 SSML 文件追加到对象 PromptBuilder

重载

名称 说明
AppendSsml(String)

将 SSML 文件追加到对象的 PromptBuilder 指定路径。

AppendSsml(Uri)

将指定 URI 处的 SSML 文件追加到 PromptBuilder 对象。

AppendSsml(XmlReader)

XMLReader将引用 SSML 提示符的对象追加到PromptBuilder该对象。

AppendSsml(String)

Source:
PromptBuilder.cs
Source:
PromptBuilder.cs
Source:
PromptBuilder.cs
Source:
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 对象,并使用该方法追加 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 格式文件。

还可以使用 AppendSsmlMarkup 将 SSML 标记追加为字符串。

适用于

AppendSsml(Uri)

Source:
PromptBuilder.cs
Source:
PromptBuilder.cs
Source:
PromptBuilder.cs
Source:
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

要追加的 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 格式文件。

还可以使用 AppendSsmlMarkup 将 SSML 标记追加为字符串。

重要

使用不受信任的数据调用此类中的方法存在安全风险。 仅在确保数据受信任的情况下,再从该类调用方法。 有关详细信息,请参阅验证所有输入

适用于

AppendSsml(XmlReader)

Source:
PromptBuilder.cs
Source:
PromptBuilder.cs
Source:
PromptBuilder.cs
Source:
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();
    }
  }
}

注解

重要

将此类型的实例用于不受信任的数据是一种安全风险。 仅将此对象与受信任的数据一起使用。 有关详细信息,请参阅验证所有输入

SSML 文件必须是符合 语音合成标记语言 (SSML) 版本 1.0 规范的 XML 格式文件。

还可以使用 AppendSsmlMarkup 将 SSML 标记追加为字符串。

适用于