Buffer Notifications

An application can receive notifications about the status of the buffers that it places in the engine's speaking queue. For example, the engine can notify the application when a particular buffer starts playing or when the audio for certain words is played.

To receive buffer notifications from the engine, the application must create a COM object that supports the ITTSBufNotifySink interface and specify the address of the interface when calling the ITTSCentral::TextData member function. When a buffer-related event occurs, the engine calls the member function of the ITTSBufNotifySink interface that corresponds to the event. The application developer determines how the member function responds to the notification.

When the engine starts playing a text buffer, it calls the ITTSBufNotifySink::TextDataStarted member function, which receives a QWORD value indicating the time when the engine started reading text from the buffer. The engine calls the ITTSBufNotifySink::TextDataDone member function when it finishes processing the last text-to-speech buffer. The engine does not wait for the audio object to finish speaking the audio before sending the notification. The function receives a QWORD value that indicates the time when the engine finished sending text to the audio-destination object and a flag indicating the reason that the engine finished sending the text. The flag is the TTSBNS_ABORTED value if the application called the ITTSCentral::AudioReset member function.

Some text-to-speech engines notify the application as each word is being spoken by calling the ITTSBufNotifySink::WordPosition member function. The notification includes a QWORD value that indicates the time when the engine started playing the word and the offset from the beginning of the buffer to the word that is currently being played. An application can use this information to highlight the word being played.

An application can use the ITTSCentral::ToFileTime member function to convert QWORD values to Win32 FILETIME structures.

The engine calls the ITTSBufNotifySink::Bookmark member function when it encounters a bookmark in the text. An application can tag text with bookmarks to receive Bookmark notifications when the engine plays the text. These bookmarks can be used as cues for animation or other actions.