PromptBuilder.AppendText 方法   
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
将文本追加到 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
指定要追加到 PromptBuilder 对象的文本。
public:
 void AppendText(System::String ^ textToSpeak);public void AppendText (string textToSpeak);member this.AppendText : string -> unitPublic Sub AppendText (textToSpeak As String)参数
- textToSpeak
- String
包含要发言文本的字符串。
示例
下面的示例使用 AppendText 方法创建 PromptBuilder 对象并追加文本字符串。
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
将文本追加到 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 -> unitPublic 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
将文本追加到 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 -> unitPublic 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
将文本追加到 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 -> unitPublic 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();  
    }  
  }  
}  
注解
的 DefaultPromptVolume 设置为完整卷,与 相同 ExtraLoud。 其他设置会相对于完整音量降低语音输出的音量。