PromptBuilder.AppendText 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
將文字附加到物件上 PromptBuilder 。
多載
| 名稱 | Description |
|---|---|
| AppendText(String) |
指定要附加到物件上的 PromptBuilder 文字。 |
| AppendText(String, PromptEmphasis) |
將文字附加於 PromptBuilder 物件上,並指定文本的強調程度。 |
| AppendText(String, PromptRate) |
將文字附加於 PromptBuilder 物件上,並指定該文字的語音速率。 |
| AppendText(String, PromptVolume) |
將文字附加到物件上 PromptBuilder ,並指定要播放該文字的音量。 |
AppendText(String)
指定要附加到物件上的 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 物件上,並指定文本的強調程度。
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 物件上,並指定該文字的語音速率。
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 ,並指定要播放該文字的音量。
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設定是 Full volume,這和 ExtraLoud。 其他設定則是將語音輸出音量相較於最大音量降低。