Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

PromptBuilder.AppendBreak Method (PromptBreak)

Appends a break to the PromptBuilder object and specifies its strength (duration).

Namespace:  System.Speech.Synthesis
Assembly:  System.Speech (in System.Speech.dll)
public void AppendBreak(
	PromptBreak strength
)

Parameters

strength
Type: System.Speech.Synthesis.PromptBreak

Indicates the duration of the break, with the following increasing values:

The values in the PromptBreak enumeration represent a range of separation intervals (pauses) between word boundaries. The speech synthesis engine determines the exact duration of the interval. When a break is requested, one of these values is passed to the text-to-speech (TTS) engine, which contains a mapping between these values and the corresponding millisecond break values.

The following example builds a prompt containing two sentences separated by a break and sends the output to a WAV file for playback.

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\weather.wav");

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

        // Build a prompt with two sentences separated by a break.
        PromptBuilder builder = new PromptBuilder(
          new System.Globalization.CultureInfo("en-US"));
        builder.AppendText(
          "Tonight's movie showings in theater A are at 5:45, 7:15, and 8:45");
        builder.AppendBreak(PromptBreak.Medium);
        builder.AppendText(
          "Tonight's movie showings in theater B are at 5:15, 7:15, and 9:15");

        // Speak the prompt and play back the output file.
        synth.Speak(builder);
        m_SoundPlayer.Play();
      }

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

.NET Framework

Supported in: 4.5.1, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.