How Tos
Last reviewed:
3/31/2009
Article ID:
H030902
HOW: Retaining callback events for speech recognition and synthesis
The information in this article applies to:
Summary
Callback events are fired by audio devices, speech recognition, and synthesis
engines to notify applications of processing states and to return data
asynchronously.
The ChantAudio, ChantSR, and ChantTTS classes maintain event queues that enable
applications to access event objects with event data.
More Information
Events are accessed from the event queue using the
event object accessor methods such as GetResource, GetChantAudioEvent,
GetChantSREvent, and GetChantTTSEvent depending on your programming language
and environment.
The event queue is a read-only queue and only allows the application to access
the oldest event on the queue. That event must be removed from the
queue before the next event object may be accessed.
For some application scenarios, event data needs to be used asynchronously from
when the event actually occurs. For example, in speech recognition, you may
want to use event information to correct recognized speech. For speech
synthesis, you may want to process the audio buffers through a device-specific
handler.
To address these application scenarios, events can be persisted on a retention
queue and accessed randomly via their identifier. To do this, applications use
RetainResource rather than RemoveResource to remove the event from the queue.
RetainResource removes the event object from the event queue and places it on a
retention queue that the application can access and remove as needed.
A resource identifier (index token) is returned to the application on
RetainResource. The application must maintain the identifier for accessing the
event from the retention queue using the same event object accessor methods:
GetResource, GetChantAudioEvent, GetChantSREvent, and GetChantTTSEvent. The
difference is that the retained event identifier is passed with these methods
to access a specific event object on the retention queue rather than the oldest event.
Once the event object is no longer needed, it may be destroyed and removed using
the RemoveResource method with the retained event identifier.