Share via


Note

Please see Azure Cognitive Services for Speech documentation for the latest supported speech solutions.

PromptStyle Constructor (PromptRate)

Initializes a new instance of the PromptStyle class and specifies the setting for the speaking rate of the style.

Namespace:  Microsoft.Speech.Synthesis
Assembly:  Microsoft.Speech (in Microsoft.Speech.dll)

Syntax

'Declaration
Public Sub New ( _
    rate As PromptRate _
)
'Usage
Dim rate As PromptRate

Dim instance As New PromptStyle(rate)
public PromptStyle(
    PromptRate rate
)

Parameters

Examples

The following example creates a PromptBuilder object and appends text strings. The example uses the PromptStyle(PromptRate) constructor as an argument to the StartStyle(PromptStyle) method to specify a slow speaking rate for the string being added, which enumerates the contents of an order.

using System;
using Microsoft.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\Hardware.wav");

        // Create a SoundPlayer instance to play the output audio file.
        System.Media.SoundPlayer m_SoundPlayer =
          new System.Media.SoundPlayer(@"C:\test\Hardware.wav");        
        
        // 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 prompt and play back the output file.
        synth.Speak(style);
        m_SoundPlayer.Play();
      }

      Console.WriteLine();
      Console.WriteLine("Press any key to exit...");
      Console.ReadKey();
    }
  }
}

See Also

Reference

PromptStyle Class

PromptStyle Members

PromptStyle Overload

Microsoft.Speech.Synthesis Namespace