PromptBuilder.AppendText 方法
定义
将文本追加到 PromptBuilder 对象。Appends text to the PromptBuilder object.
重载
| AppendText(String) |
指定要追加到 PromptBuilder 对象的文本。Specifies text to append to the PromptBuilder object. |
| AppendText(String, PromptEmphasis) |
将文本追加到 PromptBuilder 对象,并为该文本指定强调程度。Appends text to the PromptBuilder object and specifies the degree of emphasis for the text. |
| AppendText(String, PromptRate) |
将文本追加到 PromptBuilder 对象,并为该文本指定语速。Appends text to the PromptBuilder object and specifies the speaking rate for the text. |
| AppendText(String, PromptVolume) |
将文本追加到 PromptBuilder 对象,并指定朗读该文本的音量。Appends text to the PromptBuilder object and specifies the volume to speak the text. |
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
包含要发言文本的字符串。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)
将文本追加到 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
包含要发言文本的字符串。A string containing the text to be spoken.
- emphasis
- 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)
将文本追加到 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
包含要发言文本的字符串。A string containing the text to be spoken.
- rate
- 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)
将文本追加到 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
包含要发言文本的字符串。A string containing the text to be spoken.
- volume
- 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 设置为 PromptVolume full volume,这与相同 ExtraLoud 。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.