Export (0) Print
Expand All

SpeechSynthesizer.Skip Method

Skips the specified amount of time in a prompt.

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

public void Skip(
	TimeSpan timeToSkip
)

Parameters

timeToSkip
Type: System.TimeSpan
The amount of time to skip.

The following example uses SpeakAsync(String) to initiate the speaking of a prompt, and then calls Skip(TimeSpan) to omit speaking the first 1.5 seconds of the prompt. The synth then speaks the remainder of the prompt to a WAV file, which is played back in the handler for the SpeakCompleted event.

using System;
using Microsoft.Speech.Synthesis;

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

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

      // Configure the synthesizer to send output to a WAV file. 
      synth.SetOutputToWaveFile(@"C:\Test\Skip.wav");

      // Register for the SpeakCompleted event.
      synth.SpeakCompleted += new EventHandler<SpeakCompletedEventArgs>(synth_SpeakCompleted);

      // Speak a phrase.
      synth.SpeakAsync("This is sample text-to-speech output.");
      synth.Skip(new TimeSpan(15000000));

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

    // Handle the SpeakCompleted event.
    static void synth_SpeakCompleted(object sender, SpeakCompletedEventArgs e)
    {

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

      //  Play the output file.
      m_SoundPlayer.Play();
    }
  }
}

Show:
© 2014 Microsoft