语言

PromptBuilder.AppendText 方法

定义

将文本追加到 PromptBuilder 对象。

重载

名称 说明
AppendText(String)

指定要追加到 PromptBuilder 对象的文本。

AppendText(String, PromptEmphasis)

将文本追加到 PromptBuilder 对象,并指定文本的强调程度。

AppendText(String, PromptRate)

将文本追加到 PromptBuilder 对象,并指定文本的说话速率。

AppendText(String, PromptVolume)

将文本追加到 PromptBuilder 对象,并指定要朗讲文本的音量。

AppendText(String)

Source:
PromptBuilder.cs
Source:
PromptBuilder.cs
Source:
PromptBuilder.cs
Source:
PromptBuilder.cs

指定要追加到 PromptBuilder 对象的文本。

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

参数

textToSpeak
String

包含要说出的文本的字符串。

示例

以下示例创建一个 PromptBuilder 对象,并使用该方法追加文本字符串 AppendText 。

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 text string.
        PromptBuilder speakText = new PromptBuilder();
        speakText.AppendText("Say the name of the song you want to hear");

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

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

注解

若要追加格式为 SSML 标记语言的文本,请使用 AppendSsmlMarkup。

适用于

AppendText(String, PromptEmphasis)

Source:
PromptBuilder.cs
Source:
PromptBuilder.cs
Source:
PromptBuilder.cs
Source:
PromptBuilder.cs

将文本追加到 PromptBuilder 对象,并指定文本的强调程度。

public:
 void AppendText(System::String ^ textToSpeak, System::Speech::Synthesis::PromptEmphasis emphasis);
public void AppendText(string textToSpeak, System.Speech.Synthesis.PromptEmphasis emphasis);
member this.AppendText : string * System.Speech.Synthesis.PromptEmphasis -> unit
Public Sub AppendText (textToSpeak As String, emphasis As PromptEmphasis)

参数

textToSpeak
String

包含要说出的文本的字符串。

emphasis
PromptEmphasis

要应用于文本的强调或强调的值。

注解

Windows中的语音合成引擎目前不支持强调参数。 设置强调参数的值不会在合成语音输出中产生任何声音变化。

适用于

AppendText(String, PromptRate)

Source:
PromptBuilder.cs
Source:
PromptBuilder.cs
Source:
PromptBuilder.cs
Source:
PromptBuilder.cs

将文本追加到 PromptBuilder 对象,并指定文本的说话速率。

public:
 void AppendText(System::String ^ textToSpeak, System::Speech::Synthesis::PromptRate rate);
public void AppendText(string textToSpeak, System.Speech.Synthesis.PromptRate rate);
member this.AppendText : string * System.Speech.Synthesis.PromptRate -> unit
Public Sub AppendText (textToSpeak As String, rate As PromptRate)

参数

textToSpeak
String

包含要说出的文本的字符串。

rate
PromptRate

要应用于文本的说话率的值。

示例

以下示例创建一个 PromptBuilder 对象并追加文本字符串。 该示例使用 AppendText 该方法为要添加的字符串指定慢语音速率,该速率枚举顺序的内容。

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 speakRate = new PromptBuilder();
        speakRate.AppendText("Your order for");
        speakRate.AppendText("one kitchen sink and one faucet", PromptRate.Slow);
        speakRate.AppendText("has been confirmed.");

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

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

适用于

AppendText(String, PromptVolume)

Source:
PromptBuilder.cs
Source:
PromptBuilder.cs
Source:
PromptBuilder.cs
Source:
PromptBuilder.cs

将文本追加到 PromptBuilder 对象,并指定要朗讲文本的音量。

public:
 void AppendText(System::String ^ textToSpeak, System::Speech::Synthesis::PromptVolume volume);
public void AppendText(string textToSpeak, System.Speech.Synthesis.PromptVolume volume);
member this.AppendText : string * System.Speech.Synthesis.PromptVolume -> unit
Public Sub AppendText (textToSpeak As String, volume As PromptVolume)

参数

textToSpeak
String

包含要说出的文本的字符串。

volume
PromptVolume

要应用于文本的说话音量(音量)的值。

示例

以下示例使用 AppendText 该方法指定应应用于语音输出的 SpeechSynthesizer 音量设置。

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

        // Build a prompt that applies different volume settings.
        PromptBuilder builder = new PromptBuilder();
        builder.AppendText("This is the default speaking volume.", PromptVolume.Default);
        builder.AppendBreak();
        builder.AppendText("This is the extra loud speaking volume.", PromptVolume.ExtraLoud);
        builder.AppendBreak();
        builder.AppendText("This is the medium speaking volume.", PromptVolume.Medium);

        // Speak the prompt.
        synth.Speak(builder);
      }

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

注解

其 Default 设置 PromptVolume 是完整卷,与 ExtraLoud. 其他设置将语音输出量相对于完整音量减少。

适用于