PromptBuilder.AppendText PromptBuilder.AppendText PromptBuilder.AppendText PromptBuilder.AppendText Method

定義

將文字附加至 PromptBuilder 物件。Appends text to the PromptBuilder object.

多載

AppendText(String) AppendText(String) AppendText(String) AppendText(String)

指定要附加至 PromptBuilder 物件的文字。Specifies text to append to the PromptBuilder object.

AppendText(String, PromptEmphasis) AppendText(String, PromptEmphasis) AppendText(String, PromptEmphasis) AppendText(String, PromptEmphasis)

將文字附加至PromptBuilder物件,並指定文字的強調程度。Appends text to the PromptBuilder object and specifies the degree of emphasis for the text.

AppendText(String, PromptRate) AppendText(String, PromptRate) AppendText(String, PromptRate) AppendText(String, PromptRate)

將文字附加至 PromptBuilder 物件,並指定文字的讀出速率。Appends text to the PromptBuilder object and specifies the speaking rate for the text.

AppendText(String, PromptVolume) AppendText(String, PromptVolume) AppendText(String, PromptVolume) AppendText(String, PromptVolume)

將文字附加至 PromptBuilder 物件,並指定文字的讀出音量。Appends text to the PromptBuilder object and specifies the volume to speak the text.

AppendText(String) AppendText(String) AppendText(String) AppendText(String)

指定要附加至 PromptBuilder 物件的文字。Specifies text to append to the PromptBuilder object.

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

參數

textToSpeak
String String String String

字串,包含要讀出的文字。A string containing the text to be spoken.

範例

接下來的範例會建立PromptBuilder物件, 並AppendText使用方法附加文字字串。The example that follows creates a PromptBuilder object and appends a text string using the AppendText method.

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使用。To append text that is formatted as SSML markup language, use AppendSsmlMarkup.

AppendText(String, PromptEmphasis) AppendText(String, PromptEmphasis) AppendText(String, PromptEmphasis) AppendText(String, PromptEmphasis)

將文字附加至PromptBuilder物件,並指定文字的強調程度。Appends text to the PromptBuilder object and specifies the degree of emphasis for the text.

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 String String String

字串,包含要讀出的文字。A string containing the text to be spoken.

emphasis
PromptEmphasis PromptEmphasis PromptEmphasis PromptEmphasis

要套用至文字的強調語氣或重音值。The value for the emphasis or stress to apply to the text.

備註

Windows 中的語音合成引擎目前不支援強調參數。The speech synthesis engines in Windows do not support the emphasis parameter at this time. 設定強調參數的值將不會在合成的語音輸出中產生任何可聽見的變更。Setting values for the emphasis parameter will produce no audible change in the synthesized speech output.

AppendText(String, PromptRate) AppendText(String, PromptRate) AppendText(String, PromptRate) AppendText(String, PromptRate)

將文字附加至 PromptBuilder 物件,並指定文字的讀出速率。Appends text to the PromptBuilder object and specifies the speaking rate for the text.

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 String String String

字串,包含要讀出的文字。A string containing the text to be spoken.

rate
PromptRate PromptRate PromptRate PromptRate

要套用至文字的讀出速率值。The value for the speaking rate to apply to the text.

範例

下列範例會建立PromptBuilder物件, 並附加文字字串。The following example creates a PromptBuilder object and appends text strings. 此範例會使用AppendText方法來指定所要加入字串的緩慢說話速率, 以列舉訂單的內容。The example uses the AppendText method to specify a slow speaking rate for the string being added, which enumerates the contents of an order.

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) AppendText(String, PromptVolume) AppendText(String, PromptVolume) AppendText(String, PromptVolume)

將文字附加至 PromptBuilder 物件,並指定文字的讀出音量。Appends text to the PromptBuilder object and specifies the volume to speak the text.

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 String String String

字串,包含要讀出的文字。A string containing the text to be spoken.

volume
PromptVolume PromptVolume PromptVolume PromptVolume

要套用至文字的讀出音量 (聲音大小) 值。The value for the speaking volume (loudness) to apply to the text.

範例

下列範例AppendText SpeechSynthesizer會使用方法來指定應該套用至語音輸出的磁片區設定。The following example uses the AppendText method to specify volume settings that the SpeechSynthesizer should apply to speech output.

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 ExtraLoud設定是[完整磁片區],PromptVolume這與相同。The Default setting for PromptVolume is full volume, which is the same as ExtraLoud. 其他設定會減少相對於完整磁片區的語音輸出量。The other settings decrease the volume of speech output relative to full volume.

適用於