Dela via


PromptBuilder.AppendBreak Method

Definition

Inserts a break (pause) in the content of a PromptBuilder object.

Overloads

AppendBreak()

Appends a break to the PromptBuilder object.

AppendBreak(PromptBreak)

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

AppendBreak(TimeSpan)

Appends a break of the specified duration to the PromptBuilder object.

AppendBreak()

Source:
PromptBuilder.cs
Source:
PromptBuilder.cs
Source:
PromptBuilder.cs

Appends a break to the PromptBuilder object.

public:
 void AppendBreak();
public void AppendBreak ();
member this.AppendBreak : unit -> unit
Public Sub AppendBreak ()

Examples

The following example builds a prompt containing two sentences separated by a break and speaks the prompt to the default audio device on the computer.

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();  

        // 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();  
        builder.AppendText(  
          "Tonight's movie showings in theater B are at 5:15, 7:30, and 9:15.");  

        // Speak the prompt.  
        synth.Speak(builder);  
      }  

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

Remarks

This method does not specify a duration for the break. The SpeechSynthesizer will determine a duration value based on the linguistic context.

Applies to

AppendBreak(PromptBreak)

Source:
PromptBuilder.cs
Source:
PromptBuilder.cs
Source:
PromptBuilder.cs

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

public:
 void AppendBreak(System::Speech::Synthesis::PromptBreak strength);
public void AppendBreak (System.Speech.Synthesis.PromptBreak strength);
member this.AppendBreak : System.Speech.Synthesis.PromptBreak -> unit
Public Sub AppendBreak (strength As PromptBreak)

Parameters

strength
PromptBreak

Indicates the duration of the break.

Examples

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();  
    }  
  }  
}  

Remarks

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.

Applies to

AppendBreak(TimeSpan)

Source:
PromptBuilder.cs
Source:
PromptBuilder.cs
Source:
PromptBuilder.cs

Appends a break of the specified duration to the PromptBuilder object.

public:
 void AppendBreak(TimeSpan duration);
public void AppendBreak (TimeSpan duration);
member this.AppendBreak : TimeSpan -> unit
Public Sub AppendBreak (duration As TimeSpan)

Parameters

duration
TimeSpan

The time in ticks, where one tick equals 100 nanoseconds.

Examples

The following example builds a prompt containing two sentences separated by a break of 15,000,000 ticks (1.5 seconds), and speaks the prompt to the default audio device on the computer.

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();  

        // 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(new TimeSpan(15000000));  
        builder.AppendText(  
          "Tonight's movie showings in theater B are at 5:15, 7:15, and 9:15");  

        // Speak the prompt.  
        synth.Speak(builder);  
      }  

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

Remarks

A break can be used to control pauses or other prosodic boundaries between words. A break is optional. If a break is not present, the synthesizer determines the break between words depending on the linguistic context.

Applies to