PromptBuilder.AppendPromptBuilder(PromptBuilder) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
将一个 PromptBuilder 对象追加到另一个 PromptBuilder 对象。
public:
void AppendPromptBuilder(System::Speech::Synthesis::PromptBuilder ^ promptBuilder);
public void AppendPromptBuilder (System.Speech.Synthesis.PromptBuilder promptBuilder);
member this.AppendPromptBuilder : System.Speech.Synthesis.PromptBuilder -> unit
Public Sub AppendPromptBuilder (promptBuilder As PromptBuilder)
参数
- promptBuilder
- PromptBuilder
要追加的内容。
示例
下面的示例创建了两个 PromptBuilder 实例,然后将它们追加到第三个实例 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.SetOutputToWaveFile(@"C:\test\showtimes.wav");
// Create a SoundPlayer instance to play the output audio file.
System.Media.SoundPlayer m_SoundPlayer =
new System.Media.SoundPlayer(@"C:\test\showtimes.wav");
// Build child prompts.
PromptBuilder theatreA = new PromptBuilder();
theatreA.AppendText(
"Tonight's movie showings in theater A are at 5:45, 7:15, and 9:30");
theatreA.AppendBreak(PromptBreak.Large);
PromptBuilder theatreB = new PromptBuilder();
theatreB.AppendText(
"Tonight's movie showings in theater B are at 5:15, 7:15, and 9:15");
// Build the parent prompt and append the two child prompts.
PromptBuilder showTimes = new PromptBuilder(
new System.Globalization.CultureInfo("en-US"));
showTimes.AppendText(
"The following are the show times for tonight's movies:");
showTimes.AppendPromptBuilder(theatreA);
showTimes.AppendPromptBuilder(theatreB);
// Speak the prompt and play back the output file.
synth.Speak(showTimes);
m_SoundPlayer.Play();
}
Console.WriteLine();
Console.WriteLine("Press any key to exit...");
Console.ReadKey();
}
}
}