PromptBuilder.StartStyle(PromptStyle) 方法

定义

指定 PromptBuilder 对象中的样式开始。Specifies the start of a style in the PromptBuilder object.

public:
 void StartStyle(System::Speech::Synthesis::PromptStyle ^ style);
public void StartStyle (System.Speech.Synthesis.PromptStyle style);
member this.StartStyle : System.Speech.Synthesis.PromptStyle -> unit
Public Sub StartStyle (style As PromptStyle)

参数

style
PromptStyle

要开始的样式。The style to start.

示例

下面的示例创建一个 PromptBuilder 对象并追加文本字符串。The following example creates a PromptBuilder object and appends text strings. 该示例使用 StartStyle 方法为正在添加的字符串指定速度较慢的速度,这会枚举顺序的内容。The example uses the StartStyle 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 style = new PromptBuilder();  
        style.AppendText("Your order for");  
        style.StartStyle(new PromptStyle(PromptRate.Slow));  
        style.AppendText("one kitchen sink and one faucet");  
        style.EndStyle();  
        style.AppendText("has been confirmed.");  
  
        // Speak the contents of the SSML prompt.  
        synth.Speak(style);  
      }  
  
      Console.WriteLine();  
      Console.WriteLine("Press any key to exit...");  
      Console.ReadKey();  
    }  
  }  
}  

注解

StartStyle 方法采用 PromptStyle 对象作为其参数。The StartStyle method takes a PromptStyle object as its argument. 可以使用 PromptStyle 对象的属性来设置在样式生效时要应用于语音输出的强调、语速和音量(响度)。You can use the properties of the PromptStyle object to set the emphasis, speaking rate, and volume (loudness) to apply to speech output while the style is in effect. 若要停止使用当前样式,请调用 EndStyle 方法。To stop using the current style, call the EndStyle method.

备注

  • 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.
  • PromptVolumeDefault 设置是全卷,这与 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.

适用于