PromptBuilder.AppendText 方法

定義

將文字附加至 PromptBuilder 物件。

多載

AppendText(String)

指定要附加至 PromptBuilder 物件的文字。

AppendText(String, PromptEmphasis)

將文字附加至 PromptBuilder 物件,並指定文字的強調程度。

AppendText(String, PromptRate)

將文字附加至 PromptBuilder 物件,並指定文字的讀出速率。

AppendText(String, PromptVolume)

將文字附加至 PromptBuilder 物件,並指定文字的讀出音量。

AppendText(String)

來源:
PromptBuilder.cs
來源:
PromptBuilder.cs
來源:
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)

來源:
PromptBuilder.cs
來源:
PromptBuilder.cs
來源:
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)

來源:
PromptBuilder.cs
來源:
PromptBuilder.cs
來源:
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)

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

備註

DefaultPromptVolume 設定為完整磁片區,與 相同 ExtraLoud 。 其他設定會減少相對於完整音量的語音輸出量。

適用於