Export (0) Print
Expand All

SpeechSynthesizer.Rate Property

Gets or sets the speaking rate of the SpeechSynthesizer object.

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

public int Rate { get; set; }

Property Value

Type: System.Int32
Returns the speaking rate of the SpeechSynthesizer object, from -10 through 10.

The following example speaks a string with the speaking rate set to -2.

using System;
using Microsoft.Speech.Synthesis;

namespace SampleSynthesis
{
  class Program
  {
    static void Main(string[] args)
    {

      // Initialize a new instance of the SpeechSynthesizer.
      SpeechSynthesizer synth = new SpeechSynthesizer();

      // Set the speaking rate.
      synth.Rate = -2;

      // Configure the audio output. 
      synth.SetOutputToWaveFile(@"C:\test\Rate.wav");

      // Create a SoundPlayer instance to play the output audio file.
      System.Media.SoundPlayer m_SoundPlayer =
        new System.Media.SoundPlayer(@"C:\test\Rate.wav");

      // Speak a text string synchronously and play back the output file.
      synth.Speak("This example speaks a string with the speaking rate set to -2.");
      m_SoundPlayer.Play();

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

Show:
© 2014 Microsoft