Share via


BookmarkReachedEventArgs Class

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

Returns data from the BookmarkReached event.

Namespace: Microsoft.SpeechServer.Synthesis
Assembly: Microsoft.SpeechServer (in microsoft.speechserver.dll)

Syntax

'Declaration
<SerializableAttribute> _
Public NotInheritable Class BookmarkReachedEventArgs
    Inherits EventArgs
[SerializableAttribute] 
public sealed class BookmarkReachedEventArgs : EventArgs

Remarks

When a bookmark is reached during prompt playback, the BookmarkReached event is raised and passes the BookmarkReachedEventArgs, which can be used to determine which bookmark is reached.

Inheritance Hierarchy

System.Object
???? System.EventArgs
????????Microsoft.SpeechServer.Synthesis.BookmarkReachedEventArgs

Example

The following code example demonstrates the use of the BookmarkReachedEventArgs and the concurrent use of two event handlers.

using System;
using System.Collections.Generic;
using System.Text;
using System.Workflow.Activities;
using System.Workflow.ComponentModel;
using Microsoft.SpeechServer.Dialog;
using Microsoft.SpeechServer.Recognition;
using Microsoft.SpeechServer.Synthesis;

namespace Bookmarks
{
    /// <summary>
    /// Activity deriving from SpeechCompositeActivity.
    /// </summary>
    public class BookmarkEvents : SpeechCompositeActivity
    {
        PromptBuilder pb1;
        PromptBuilder pb2;

        /// <summary>
        /// Creates a new instance.
        /// </summary>
        public BookmarkEvents()
        {
        }

        /// <summary>
        /// Executes the activity.
        /// </summary>
        /// <param name="executionContext">The execution context</param>
        protected override void ExecuteCore(ActivityExecutionContext executionContext)
        {
            // Prepare a prompt with (or without) a bookmark.
            pb1 = new PromptBuilder();
            pb1.AppendText("This is prompt text that is spoken before the bookmark. ");
            pb1.AppendBreak();
            pb1.AppendBookmark("bookmark01");
            pb1.AppendText("This is prompt text that is spoken after the bookmark. ");
            pb1.AppendBreak();

            // Prepare a prompt to speak the bookmark information
            pb2 = new PromptBuilder();
            pb2.SetText("No bookmark was encountered. ");

            // Specify event-handlers and play until bookmark or end of prompt.
            Workflow.Synthesizer.BookmarkReached += Synthesizer_BookmarkReached;
            Workflow.Synthesizer.SpeakCompleted += Synthesizer_SpeakCompleted;
            Workflow.Synthesizer.SpeakAsync(pb1);
        }
        /// <summary>
        /// Handle BookmarkReached event.
        /// </summary>
        /// <param name="sender">The synthesizer</param>
        /// <param name="e">BookmarkReachedEventArgs</param>
        private void Synthesizer_BookmarkReached(object sender, BookmarkReachedEventArgs e)
        {
            Workflow.Synthesizer.SpeakAsyncCancel();
            pb2.SetText(e.Bookmark + " was encountered at " + e.Offset.Seconds.ToString() + " seconds. ");
            pb2.AppendBreak();
        }

        /// <summary>
        /// Handle the SpeakCompleted event from the first prompt.
        /// </summary>
        /// <param name="sender">The synthesizer</param>
        /// <param name="e">The result of SpeakAsync</param>
        private void Synthesizer_SpeakCompleted(object sender, SpeakCompletedEventArgs e)
        {
            // Remove the event-handlers for the first prompt and the bookmark.
            Workflow.Synthesizer.SpeakCompleted -= Synthesizer_SpeakCompleted;
            Workflow.Synthesizer.BookmarkReached -= Synthesizer_BookmarkReached;

            // Specify the event-handler and play second prompt.
            Workflow.Synthesizer.SpeakCompleted += Synthesizer_SpeakCompleted2;
            Workflow.Synthesizer.SpeakAsync(pb2);
        }

        /// <summary>
        /// Closes the activity.
        /// </summary>
        /// <param name="sender">The synthesizer</param>
        /// <param name="e">The result of SpeakAsync</param>
        private void Synthesizer_SpeakCompleted2(object sender, SpeakCompletedEventArgs e)
        {
            // Remove this event-handler
            Workflow.Synthesizer.SpeakCompleted -= Synthesizer_SpeakCompleted2;
            OnSpeechActivityClosed(e.Error);
        }
    }
}

Thread Safety

All public static (Shared in Visual Basic) members of this type are thread-safe. Instance members are not guaranteed to be thread-safe.

Platforms

Development Platforms

Windows XP Professional with Service Pack 2 (SP2), Windows Server 2003, Windows Vista Ultimate Edition, Windows Vista Business Edition, Windows Vista Enterprise Edition

Target Platforms

Windows Server 2003

See Also

Reference

BookmarkReachedEventArgs Members
Microsoft.SpeechServer.Synthesis Namespace