Events¶
Use setHandler with keys in this section to register callback handlers for events. The values for these settings refer to runtime instances of code objects and are not serialized by save or dup.
The results and iterators available in these handlers vary by event. See the descriptions below for details on what these are.
^result is the most used event by a large margin.
^adapt-started¶
event handle write-only
Wake word model adaptation thread has started.
This handler is called from a thread started to do model adaptation in continuously adapting spotter models. The handle function should return OK to continue with model adaptation, or SKIP to abort adaptation and ignore this enrollment without raising an error.
The handler function's Session argument will be NULL as it is not safe to access this handle from the enrollment thread.
You can use this handler to adjust the adaptation thread priority, or delay the start of adaptation by blocking on a condition variable.
Note
Session teardown waits on joining the adaptation thread. Any handler function registered for this event must return before the associated Session is released.
none
^adapted¶
event handle write-only
Wake word adaptation complete event.
Adaptation is the estimation of spotter model parameters from a number of enrollments for one or more users.
Example
To load a previously saved enrollment context, do so after loading the model that created it.
^begin¶
event handle write-only
Begin point detected VAD event.
Raised when speech has been detected. Use begin-ms or begin-sample to retrieve the start point relative to the beginning of ->audio-pcm.
begin-ms, begin-sample, sample-count
none
^done¶
event handle write-only
Wake word adaptation complete event.
Handler called when adaptation has completed and the model-stream model is available.
This handler typically returns STOP to end processing.
none
^end¶
event handle write-only
Endpoint detected VAD event.
Raised trailing-silence ms after end-of-speech has been detected. Use end-ms or end-sample to retrieve the endpoint relative to the beginning of ->audio-pcm.
begin-ms, begin-sample, end-ms, end-sample, sample-count
none
^enrolled¶
event handle write-only
Wake word enrollment complete event.
Handler called when enrollment is complete, just before model adaptation starts. Use this handler for the earliest possible access to the enrollment context.
Enrollment is the process of taking individual enrollments (audio files or live audio clips), validating them, and adding them to the model. These enrollments are used during the adaptation stage to estimate spotter model parameters.
Example
Add a handler for this event to save enrollment contexts before they are adapted.
none
^fail¶
event handle write-only
Wake word enrollment failed event.
Handler called if an enrollment fails quality checks.
audio-stream, enrollment-id, reason, reason-guidance, reason-pass, reason-threshold, reason-value, sample-count
^limit¶
event handle write-only
Maximum recording reached VAD event.
Raised when max-recording ms of speech has been processed by the VAD before a trailing-silence endpoint is found. Use end-ms or end-sample to retrieve the endpoint relative to the beginning of ->audio-pcm.
begin-ms, begin-sample, end-ms, end-sample, sample-count
none
^listen-begin¶
event handle write-only
Sequential task has started listening on second slot.
Raised in a sequential task when audio focus has shifted from the first slot to the second. This typically happens when the spotter n the first slot has detected the phrase.
This event is ignored for tasks that do not feature sequential behavior.
none
^listen-end¶
event handle write-only
Sequential task has stopped listening on second slot.
Raised in a sequential task when audio focus has shifted from the second slot back to the first.
This event is ignored for tasks that do not feature sequential behavior.
none
^new-user¶
event handle write-only
New user detected event.
Handler called when a continuously adapting spotter model has adapted to a new user.
^next¶
^nlu-intent¶
event handle write-only tnl stt
NLU intent available.
This event is raised when a natural language parse result is available.
Each intent that matched input generates an ^nlu-intent event. Use nlu-entity-iterator in this callback handler to retrieve the names of entities found.
An intent is an action, such as turning on the windshield wipers, or setting a microwave clock.
Intents are exactly the same as the top-level NLU slots reported by ^nlu-slot. The entities available inside the handler for this event, however, are only one level deep. The SDK flattens nested nlu-slot-names by separating each level with a period.
For example: Grammar snippet { date { time {hours} {minutes} } } has intent date with entities time.hours and time.minutes, but slot date has a single child slot time, which in turn has two children, hours and minutes.
See the NLU section in the grammar syntax section for more detail on the {} NLU slot capturing operator.
nlu-intent-name, nlu-intent-score, nlu-intent-value, sample-count
^nlu-slot¶
event handle write-only tnl stt
NLU result available.
This event is raised when a lightweight natural language parse result is available. Each top-level slot that matched input generates a ^nlu-slot event. Use nlu-slot-iterator in this callback handler to retrieve child slot names and values.
See the NLU section in the grammar syntax section for more detail on the {} NLU slot capturing operator.
nlu-match-count, nlu-slot-count, nlu-slot-name, nlu-slot-score, nlu-slot-value, sample-count
^pass¶
event handle write-only
Wake word enrollment succeeded event.
Handler called when an enrollment passes quality checks.
Return SKIP from this event handler to discard an enrollment.
audio-stream, audio-stream-first, audio-stream-last, begin-sample, end-sample, enrollment-id, sample-count
none
^pause¶
event handle write-only
Input stream pause event.
Handler called when a time-consuming processing step is about to start. Use this handler to pause the input stream when doing interactive enrollment.
none
^progress¶
event handle write-only
Wake word adaptation progress event.
Handler called to report adaptation progress.
none
^result¶
event handle write-only
Recognition result available event.
Raised when a final recognition hypothesis is available.
begin-ms, begin-sample, confidence-score, domain, end-ms, end-sample, id, noise-energy, score, signal-energy, snr, sv-score, text
phone-iterator, phrase-iterator, sample-count, word-iterator
^result-partial¶
event handle write-only tnl stt
Partial recognition result available event.
Raised when a preliminary recognition hypothesis is available.
begin-ms, begin-sample, domain, end-ms, end-sample, sample-count, score, text
^resume¶
event handle write-only
Input stream resume event.
Handler called when a time-consuming processing step has completed. Use this handler to restart an input stream that was stopped during a ^pause event handler.
none
^sample-count¶
event handle write-only
Samples available event.
Raised whenever audio samples have been read from the input stream and are about to be processed.
none
^silence¶
event handle write-only
No speech detected event.
Raised if no speech is detected within leading-silence ms from the start of ->audio-pcm, adjusted by skip-to-ms or skip-to-sample
none
^slm-result¶
^slm-result-partial¶
event handle write-only stt 7.4.0