Note
Please see Azure Cognitive Services for Speech documentation for the latest supported speech solutions.
SpeechSynthesizer.Skip Method
Skips the specified amount of time in a prompt.
Namespace: Microsoft.Speech.Synthesis
Assembly: Microsoft.Speech (in Microsoft.Speech.dll)
Syntax
'Declaration
Public Sub Skip ( _
timeToSkip As TimeSpan _
)
'Usage
Dim instance As SpeechSynthesizer
Dim timeToSkip As TimeSpan
instance.Skip(timeToSkip)
public void Skip(
TimeSpan timeToSkip
)
Parameters
- timeToSkip
Type: System.TimeSpan
The amount of time to skip.
Examples
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();
}
}
}