---
source_path: "api/setting-keys/events.md"
canonical_url: "https://doc.sensory.com/tnl/7.8/api/setting-keys/events/"
---

# Events

Use [setHandler](https://doc.sensory.com/tnl/7.8/api/inference.md#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](https://doc.sensory.com/tnl/7.8/api/inference.md#save) or [dup](https://doc.sensory.com/tnl/7.8/api/inference.md#dup).

The [&bull; results](https://doc.sensory.com/tnl/7.8/api/setting-keys/results.md#results)
and [&bull; iterators](https://doc.sensory.com/tnl/7.8/api/setting-keys/iterators.md#iterators) available in these handlers
vary by event. See the descriptions below for details on what these are.

[^result](https://doc.sensory.com/tnl/7.8/api/setting-keys/events.md#result) is the most used event by a large margin.
<!-- Setting-key page conventions: shared admonition for all docs/api/setting-keys/*.md pages. -->
### Details: Page conventions

Settings are grouped by concern. Within each group they're listed
alphabetically. A setting that serves more than one concern appears once
under its primary group; secondary groups link to it.

The code tabs on each setting show one paste-able call site per language.
Adapt the placeholder names (`s` for the [Session](https://doc.sensory.com/tnl/7.8/api/inference.md#session), plus `value`,
`stream`, `on_event`, or `on_item` for the operand) to your code. Each
example assumes the language's standard prelude:

<!-- tab: c -->

**C/C++**

```c
#include <snsr.h>
```
<!-- /tab -->

<!-- tab: java -->

**Java**

```java
import com.sensory.speech.snsr.Snsr;
import com.sensory.speech.snsr.SnsrSession;
```
<!-- /tab -->

<!-- tab: py -->

**Python**

```python
import snsr
```
<!-- /tab -->

For the full Session lifecycle (`snsrNew`, `new SnsrSession()`,
`snsr.Session(...)`) see [Your first program](https://doc.sensory.com/tnl/7.8/getting-started/your-first-program.md#your-first-program).

## Audio I/O

### ^sample-count
- event
- handle
- write-only

<!-- tab: c -->

**C/C++**

```c
snsrSetHandler(s, SNSR_SAMPLES_EVENT, snsrCallback(on_event, NULL, NULL));
```
<!-- /tab -->

<!-- tab: java -->

**Java**

```java
s.setHandler(Snsr.SAMPLES_EVENT, (session, key) -> { /* ... */ });
```
<!-- /tab -->

<!-- tab: py -->

**Python**

```python
s.set_handler(snsr.SAMPLES_EVENT, on_event)
```
<!-- /tab -->

Samples available event.

Raised whenever audio samples have been read from the input stream and
are about to be processed.

**Available results:** [sample-count](https://doc.sensory.com/tnl/7.8/api/setting-keys/results.md#sample-count)

**Available iterators:** _none_

## VAD & endpointing

### ^begin
- event
- handle
- write-only

<!-- tab: c -->

**C/C++**

```c
snsrSetHandler(s, SNSR_BEGIN_EVENT, snsrCallback(on_event, NULL, NULL));
```
<!-- /tab -->

<!-- tab: java -->

**Java**

```java
s.setHandler(Snsr.BEGIN_EVENT, (session, key) -> { /* ... */ });
```
<!-- /tab -->

<!-- tab: py -->

**Python**

```python
s.set_handler(snsr.BEGIN_EVENT, on_event)
```
<!-- /tab -->

Begin point detected VAD event.

Raised when speech has been detected. Use [begin-ms](https://doc.sensory.com/tnl/7.8/api/setting-keys/results.md#begin-ms) or
[begin-sample](https://doc.sensory.com/tnl/7.8/api/setting-keys/results.md#begin-sample) to retrieve the start point relative to the beginning
of [->audio-pcm](https://doc.sensory.com/tnl/7.8/api/setting-keys/runtime.md#-audio-pcm).

**Available results:** [begin-ms](https://doc.sensory.com/tnl/7.8/api/setting-keys/results.md#begin-ms), [begin-sample](https://doc.sensory.com/tnl/7.8/api/setting-keys/results.md#begin-sample), [sample-count](https://doc.sensory.com/tnl/7.8/api/setting-keys/results.md#sample-count)

**Available iterators:** _none_

**Also see these related items:** [backoff](https://doc.sensory.com/tnl/7.8/api/setting-keys/configuration.md#backoff), [end](https://doc.sensory.com/tnl/7.8/api/setting-keys/events.md#end), [limit](https://doc.sensory.com/tnl/7.8/api/setting-keys/events.md#limit), [silence](https://doc.sensory.com/tnl/7.8/api/setting-keys/events.md#silence)

### ^end
- event
- handle
- write-only

<!-- tab: c -->

**C/C++**

```c
snsrSetHandler(s, SNSR_END_EVENT, snsrCallback(on_event, NULL, NULL));
```
<!-- /tab -->

<!-- tab: java -->

**Java**

```java
s.setHandler(Snsr.END_EVENT, (session, key) -> { /* ... */ });
```
<!-- /tab -->

<!-- tab: py -->

**Python**

```python
s.set_handler(snsr.END_EVENT, on_event)
```
<!-- /tab -->

Endpoint detected VAD event.

Raised [trailing-silence](https://doc.sensory.com/tnl/7.8/api/setting-keys/configuration.md#trailing-silence) ms after end-of-speech has been detected.
Use [end-ms](https://doc.sensory.com/tnl/7.8/api/setting-keys/results.md#end-ms) or [end-sample](https://doc.sensory.com/tnl/7.8/api/setting-keys/results.md#end-sample) to retrieve the endpoint
relative to the beginning of [->audio-pcm](https://doc.sensory.com/tnl/7.8/api/setting-keys/runtime.md#-audio-pcm).

**Available results:** [begin-ms](https://doc.sensory.com/tnl/7.8/api/setting-keys/results.md#begin-ms), [begin-sample](https://doc.sensory.com/tnl/7.8/api/setting-keys/results.md#begin-sample), [end-ms](https://doc.sensory.com/tnl/7.8/api/setting-keys/results.md#end-ms), [end-sample](https://doc.sensory.com/tnl/7.8/api/setting-keys/results.md#end-sample), [sample-count](https://doc.sensory.com/tnl/7.8/api/setting-keys/results.md#sample-count)

**Available iterators:** _none_

**Also see these related items:** [begin](https://doc.sensory.com/tnl/7.8/api/setting-keys/events.md#begin), [limit](https://doc.sensory.com/tnl/7.8/api/setting-keys/events.md#limit), [silence](https://doc.sensory.com/tnl/7.8/api/setting-keys/events.md#silence), [hold-over](https://doc.sensory.com/tnl/7.8/api/setting-keys/configuration.md#hold-over), [trailing-silence](https://doc.sensory.com/tnl/7.8/api/setting-keys/configuration.md#trailing-silence)

### ^limit
- event
- handle
- write-only

<!-- tab: c -->

**C/C++**

```c
snsrSetHandler(s, SNSR_LIMIT_EVENT, snsrCallback(on_event, NULL, NULL));
```
<!-- /tab -->

<!-- tab: java -->

**Java**

```java
s.setHandler(Snsr.LIMIT_EVENT, (session, key) -> { /* ... */ });
```
<!-- /tab -->

<!-- tab: py -->

**Python**

```python
s.set_handler(snsr.LIMIT_EVENT, on_event)
```
<!-- /tab -->

Maximum recording reached VAD event.

Raised when [max-recording](https://doc.sensory.com/tnl/7.8/api/setting-keys/configuration.md#max-recording) ms of speech has been processed by the
VAD before a trailing-silence endpoint is found.
Use [end-ms](https://doc.sensory.com/tnl/7.8/api/setting-keys/results.md#end-ms) or [end-sample](https://doc.sensory.com/tnl/7.8/api/setting-keys/results.md#end-sample) to retrieve the endpoint
relative to the beginning of [->audio-pcm](https://doc.sensory.com/tnl/7.8/api/setting-keys/runtime.md#-audio-pcm).

**Available results:** [begin-ms](https://doc.sensory.com/tnl/7.8/api/setting-keys/results.md#begin-ms), [begin-sample](https://doc.sensory.com/tnl/7.8/api/setting-keys/results.md#begin-sample), [end-ms](https://doc.sensory.com/tnl/7.8/api/setting-keys/results.md#end-ms), [end-sample](https://doc.sensory.com/tnl/7.8/api/setting-keys/results.md#end-sample), [sample-count](https://doc.sensory.com/tnl/7.8/api/setting-keys/results.md#sample-count)

**Available iterators:** _none_

**Also see these related items:** [^begin](https://doc.sensory.com/tnl/7.8/api/setting-keys/events.md#begin), [^end](https://doc.sensory.com/tnl/7.8/api/setting-keys/events.md#end), [^silence](https://doc.sensory.com/tnl/7.8/api/setting-keys/events.md#silence), [max-recording](https://doc.sensory.com/tnl/7.8/api/setting-keys/configuration.md#max-recording)

### ^silence
- event
- handle
- write-only

<!-- tab: c -->

**C/C++**

```c
snsrSetHandler(s, SNSR_SILENCE_EVENT, snsrCallback(on_event, NULL, NULL));
```
<!-- /tab -->

<!-- tab: java -->

**Java**

```java
s.setHandler(Snsr.SILENCE_EVENT, (session, key) -> { /* ... */ });
```
<!-- /tab -->

<!-- tab: py -->

**Python**

```python
s.set_handler(snsr.SILENCE_EVENT, on_event)
```
<!-- /tab -->

No speech detected event.

Raised if no speech is detected within [leading-silence](https://doc.sensory.com/tnl/7.8/api/setting-keys/configuration.md#leading-silence) ms from the
start of [->audio-pcm](https://doc.sensory.com/tnl/7.8/api/setting-keys/runtime.md#-audio-pcm), adjusted by [skip-to-ms](https://doc.sensory.com/tnl/7.8/api/setting-keys/runtime.md#skip-to-ms) or [skip-to-sample](https://doc.sensory.com/tnl/7.8/api/setting-keys/runtime.md#skip-to-sample)

**Available results:** [sample-count](https://doc.sensory.com/tnl/7.8/api/setting-keys/results.md#sample-count)

**Available iterators:** _none_

**Also see these related items:** [leading-silence](https://doc.sensory.com/tnl/7.8/api/setting-keys/configuration.md#leading-silence), [skip-to-ms](https://doc.sensory.com/tnl/7.8/api/setting-keys/runtime.md#skip-to-ms), [skip-to-sample](https://doc.sensory.com/tnl/7.8/api/setting-keys/runtime.md#skip-to-sample)

## Wake word & command set

### ^result
- event
- handle
- write-only

<!-- tab: c -->

**C/C++**

```c
snsrSetHandler(s, SNSR_RESULT_EVENT, snsrCallback(on_event, NULL, NULL));
```
<!-- /tab -->

<!-- tab: java -->

**Java**

```java
s.setHandler(Snsr.RESULT_EVENT, (session, key) -> { /* ... */ });
```
<!-- /tab -->

<!-- tab: py -->

**Python**

```python
s.set_handler(snsr.RESULT_EVENT, on_event)
```
<!-- /tab -->

Recognition result available event.

Raised when a final recognition hypothesis is available.

**Available results:** [begin-ms](https://doc.sensory.com/tnl/7.8/api/setting-keys/results.md#begin-ms), [begin-sample](https://doc.sensory.com/tnl/7.8/api/setting-keys/results.md#begin-sample), [confidence-score](https://doc.sensory.com/tnl/7.8/api/setting-keys/results.md#confidence-score), [domain](https://doc.sensory.com/tnl/7.8/api/setting-keys/results.md#domain), [end-ms](https://doc.sensory.com/tnl/7.8/api/setting-keys/results.md#end-ms), [end-sample](https://doc.sensory.com/tnl/7.8/api/setting-keys/results.md#end-sample), [id](https://doc.sensory.com/tnl/7.8/api/setting-keys/results.md#id), [noise-energy](https://doc.sensory.com/tnl/7.8/api/setting-keys/results.md#noise-energy), [score](https://doc.sensory.com/tnl/7.8/api/setting-keys/results.md#score), [signal-energy](https://doc.sensory.com/tnl/7.8/api/setting-keys/results.md#signal-energy), [snr](https://doc.sensory.com/tnl/7.8/api/setting-keys/results.md#snr), [sv-score](https://doc.sensory.com/tnl/7.8/api/setting-keys/results.md#sv-score), [text](https://doc.sensory.com/tnl/7.8/api/setting-keys/results.md#text)

**Available iterators:** [phone-iterator](https://doc.sensory.com/tnl/7.8/api/setting-keys/iterators.md#phone-iterator), [phrase-iterator](https://doc.sensory.com/tnl/7.8/api/setting-keys/iterators.md#phrase-iterator), [sample-count](https://doc.sensory.com/tnl/7.8/api/setting-keys/results.md#sample-count), [word-iterator](https://doc.sensory.com/tnl/7.8/api/setting-keys/iterators.md#word-iterator)

**Also see these related items:** [^result-partial](https://doc.sensory.com/tnl/7.8/api/setting-keys/events.md#result-partial)

## Templates & slots

### ^listen-begin
- event
- handle
- write-only

<!-- tab: c -->

**C/C++**

```c
snsrSetHandler(s, SNSR_LISTEN_BEGIN_EVENT, snsrCallback(on_event, NULL, NULL));
```
<!-- /tab -->

<!-- tab: java -->

**Java**

```java
s.setHandler(Snsr.LISTEN_BEGIN_EVENT, (session, key) -> { /* ... */ });
```
<!-- /tab -->

<!-- tab: py -->

**Python**

```python
s.set_handler(snsr.LISTEN_BEGIN_EVENT, on_event)
```
<!-- /tab -->

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.

**Available results:** [sample-count](https://doc.sensory.com/tnl/7.8/api/setting-keys/results.md#sample-count)

**Available iterators:** _none_

**Also see these related items:** [^listen-end](https://doc.sensory.com/tnl/7.8/api/setting-keys/events.md#listen-end)

### ^listen-end
- event
- handle
- write-only

<!-- tab: c -->

**C/C++**

```c
snsrSetHandler(s, SNSR_LISTEN_END_EVENT, snsrCallback(on_event, NULL, NULL));
```
<!-- /tab -->

<!-- tab: java -->

**Java**

```java
s.setHandler(Snsr.LISTEN_END_EVENT, (session, key) -> { /* ... */ });
```
<!-- /tab -->

<!-- tab: py -->

**Python**

```python
s.set_handler(snsr.LISTEN_END_EVENT, on_event)
```
<!-- /tab -->

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.

**Available results:** [sample-count](https://doc.sensory.com/tnl/7.8/api/setting-keys/results.md#sample-count)

**Available iterators:** _none_

**Also see these related items:** [^listen-begin](https://doc.sensory.com/tnl/7.8/api/setting-keys/events.md#listen-begin)

## LVCSR & STT

### ^result
- event
- handle
- write-only

Documented under **Wake word & command set** ([^result](https://doc.sensory.com/tnl/7.8/api/setting-keys/events.md#result)). Emitted by
every recognizer with a final result.

### ^result-partial
- event
- handle
- write-only
_(TrulyNatural only)_ _(STT only)_
<!-- tab: c -->

**C/C++**

```c
snsrSetHandler(s, SNSR_PARTIAL_RESULT_EVENT, snsrCallback(on_event, NULL, NULL));
```
<!-- /tab -->

<!-- tab: java -->

**Java**

```java
s.setHandler(Snsr.PARTIAL_RESULT_EVENT, (session, key) -> { /* ... */ });
```
<!-- /tab -->

<!-- tab: py -->

**Python**

```python
s.set_handler(snsr.PARTIAL_RESULT_EVENT, on_event)
```
<!-- /tab -->

Partial recognition result available event.

Raised when a preliminary recognition hypothesis is available.

**Available results:** [begin-ms](https://doc.sensory.com/tnl/7.8/api/setting-keys/results.md#begin-ms), [begin-sample](https://doc.sensory.com/tnl/7.8/api/setting-keys/results.md#begin-sample), [domain](https://doc.sensory.com/tnl/7.8/api/setting-keys/results.md#domain), [end-ms](https://doc.sensory.com/tnl/7.8/api/setting-keys/results.md#end-ms), [end-sample](https://doc.sensory.com/tnl/7.8/api/setting-keys/results.md#end-sample), [sample-count](https://doc.sensory.com/tnl/7.8/api/setting-keys/results.md#sample-count), [score](https://doc.sensory.com/tnl/7.8/api/setting-keys/results.md#score), [text](https://doc.sensory.com/tnl/7.8/api/setting-keys/results.md#text)

**Available iterators:** [phone-iterator](https://doc.sensory.com/tnl/7.8/api/setting-keys/iterators.md#phone-iterator), [phrase-iterator](https://doc.sensory.com/tnl/7.8/api/setting-keys/iterators.md#phrase-iterator), [word-iterator](https://doc.sensory.com/tnl/7.8/api/setting-keys/iterators.md#word-iterator)

**Also see these related items:** [^result](https://doc.sensory.com/tnl/7.8/api/setting-keys/events.md#result)

## NLU & SLM

### ^nlu-intent
- event
- handle
- write-only
_(TrulyNatural only)_ _(STT only)_
<!-- tab: c -->

**C/C++**

```c
snsrSetHandler(s, SNSR_NLU_INTENT_EVENT, snsrCallback(on_event, NULL, NULL));
```
<!-- /tab -->

<!-- tab: java -->

**Java**

```java
s.setHandler(Snsr.NLU_INTENT_EVENT, (session, key) -> { /* ... */ });
```
<!-- /tab -->

<!-- tab: py -->

**Python**

```python
s.set_handler(snsr.NLU_INTENT_EVENT, on_event)
```
<!-- /tab -->

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](https://doc.sensory.com/tnl/7.8/api/setting-keys/iterators.md#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](https://doc.sensory.com/tnl/7.8/api/setting-keys/events.md#nlu-slot). The entities available inside the handler for this
event, however, are only one level deep. The SDK flattens nested
[nlu-slot-name](https://doc.sensory.com/tnl/7.8/api/setting-keys/results.md#nlu-slot-name)s 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](https://doc.sensory.com/tnl/7.8/models/types/lvcsr.md#nlu-markup) in the [grammar syntax](https://doc.sensory.com/tnl/7.8/models/types/lvcsr.md#grammar-syntax) section
for more detail on the `{}` NLU slot capturing operator.

**Available results:** [nlu-intent-name](https://doc.sensory.com/tnl/7.8/api/setting-keys/results.md#nlu-intent-name), [nlu-intent-score](https://doc.sensory.com/tnl/7.8/api/setting-keys/results.md#nlu-intent-score), [nlu-intent-value](https://doc.sensory.com/tnl/7.8/api/setting-keys/results.md#nlu-intent-value), [sample-count](https://doc.sensory.com/tnl/7.8/api/setting-keys/results.md#sample-count)

**Available iterators:** [nlu-entity-iterator](https://doc.sensory.com/tnl/7.8/api/setting-keys/iterators.md#nlu-entity-iterator)

**Also see these related items:** [^nlu-slot](https://doc.sensory.com/tnl/7.8/api/setting-keys/events.md#nlu-slot), [grammar syntax](https://doc.sensory.com/tnl/7.8/models/types/lvcsr.md#grammar-syntax)

### ^nlu-slot
- event
- handle
- write-only
_(TrulyNatural only)_ _(STT only)_
<!-- tab: c -->

**C/C++**

```c
snsrSetHandler(s, SNSR_NLU_SLOT_EVENT, snsrCallback(on_event, NULL, NULL));
```
<!-- /tab -->

<!-- tab: java -->

**Java**

```java
s.setHandler(Snsr.NLU_SLOT_EVENT, (session, key) -> { /* ... */ });
```
<!-- /tab -->

<!-- tab: py -->

**Python**

```python
s.set_handler(snsr.NLU_SLOT_EVENT, on_event)
```
<!-- /tab -->

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](https://doc.sensory.com/tnl/7.8/api/setting-keys/iterators.md#nlu-slot-iterator) in this callback handler to retrieve
child slot names and values.

See the [NLU section](https://doc.sensory.com/tnl/7.8/models/types/lvcsr.md#nlu-markup) in the [grammar syntax](https://doc.sensory.com/tnl/7.8/models/types/lvcsr.md#grammar-syntax) section
for more detail on the `{}` NLU slot capturing operator.

**Available results:** [nlu-match-count](https://doc.sensory.com/tnl/7.8/api/setting-keys/results.md#nlu-match-count), [nlu-slot-count](https://doc.sensory.com/tnl/7.8/api/setting-keys/results.md#nlu-slot-count), [nlu-slot-name](https://doc.sensory.com/tnl/7.8/api/setting-keys/results.md#nlu-slot-name), [nlu-slot-score](https://doc.sensory.com/tnl/7.8/api/setting-keys/results.md#nlu-slot-score), [nlu-slot-value](https://doc.sensory.com/tnl/7.8/api/setting-keys/results.md#nlu-slot-value), [sample-count](https://doc.sensory.com/tnl/7.8/api/setting-keys/results.md#sample-count)

**Available iterators:** [nlu-slot-iterator](https://doc.sensory.com/tnl/7.8/api/setting-keys/iterators.md#nlu-slot-iterator)

**Also see these related items:** [^nlu-intent](https://doc.sensory.com/tnl/7.8/api/setting-keys/events.md#nlu-intent), [grammar syntax](https://doc.sensory.com/tnl/7.8/models/types/lvcsr.md#grammar-syntax)

### ^slm-result
- event
- handle
- write-only
_(STT only)_ 
<!-- tab: c -->

**C/C++**

```c
snsrSetHandler(s, SNSR_SLM_RESULT_EVENT, snsrCallback(on_event, NULL, NULL));
```
<!-- /tab -->

<!-- tab: java -->

**Java**

```java
s.setHandler(Snsr.SLM_RESULT_EVENT, (session, key) -> { /* ... */ });
```
<!-- /tab -->

<!-- tab: py -->

**Python**

```python
s.set_handler(snsr.SLM_RESULT_EVENT, on_event)
```
<!-- /tab -->

SLM final output available

This event is raised when an optional SLM has
a complete result available.

In the handler for this callback [text](https://doc.sensory.com/tnl/7.8/api/setting-keys/results.md#text) holds the entire
SLM response.

**Available results:** [sample-count](https://doc.sensory.com/tnl/7.8/api/setting-keys/results.md#sample-count), [text](https://doc.sensory.com/tnl/7.8/api/setting-keys/results.md#text)

**Available iterators:** _none_

**Also see these related items:** [^slm-result-partial](https://doc.sensory.com/tnl/7.8/api/setting-keys/events.md#slm-result-partial)

### ^slm-result-partial
- event
- handle
- write-only
_(STT only)_ 
<!-- tab: c -->

**C/C++**

```c
snsrSetHandler(s, SNSR_SLM_PARTIAL_RESULT_EVENT, snsrCallback(on_event, NULL, NULL));
```
<!-- /tab -->

<!-- tab: java -->

**Java**

```java
s.setHandler(Snsr.SLM_PARTIAL_RESULT_EVENT, (session, key) -> { /* ... */ });
```
<!-- /tab -->

<!-- tab: py -->

**Python**

```python
s.set_handler(snsr.SLM_PARTIAL_RESULT_EVENT, on_event)
```
<!-- /tab -->

SLM partial output available

This event is raised when an optional SLM has a new word prediction available.

In the handler for this callback [text](https://doc.sensory.com/tnl/7.8/api/setting-keys/results.md#text) holds the next word
prediction. Return [STOP](https://doc.sensory.com/tnl/7.8/api/inference.md#rc_stop) from the callback to abort further
SLM generation; this will not stop the overall recognition pipeline.

**Available results:** [sample-count](https://doc.sensory.com/tnl/7.8/api/setting-keys/results.md#sample-count), [text](https://doc.sensory.com/tnl/7.8/api/setting-keys/results.md#text)

**Available iterators:** _none_

**Also see these related items:** [^slm-result](https://doc.sensory.com/tnl/7.8/api/setting-keys/events.md#slm-result)

### ^slm-start
- event
- handle
- write-only
_(STT only)_ 
<!-- tab: c -->

**C/C++**

```c
snsrSetHandler(s, SNSR_SLM_START_EVENT, snsrCallback(on_event, NULL, NULL));
```
<!-- /tab -->

<!-- tab: java -->

**Java**

```java
s.setHandler(Snsr.SLM_START_EVENT, (session, key) -> { /* ... */ });
```
<!-- /tab -->

<!-- tab: py -->

**Python**

```python
s.set_handler(snsr.SLM_START_EVENT, on_event)
```
<!-- /tab -->

SLM processing is about to start

Return [STOP](https://doc.sensory.com/tnl/7.8/api/inference.md#rc_stop) from the callback handler to avoid doing SLM processing.

**Available results:** [sample-count](https://doc.sensory.com/tnl/7.8/api/setting-keys/results.md#sample-count)

**Available iterators:** _none_

**Also see these related items:** [^slm-result](https://doc.sensory.com/tnl/7.8/api/setting-keys/events.md#slm-result), [^slm-result-partial](https://doc.sensory.com/tnl/7.8/api/setting-keys/events.md#slm-result-partial)

## Enrollment & adaptation

### ^adapt-started
- event
- handle
- write-only

<!-- tab: c -->

**C/C++**

```c
snsrSetHandler(s, SNSR_ADAPT_STARTED_EVENT, snsrCallback(on_event, NULL, NULL));
```
<!-- /tab -->

<!-- tab: java -->

**Java**

```java
s.setHandler(Snsr.ADAPT_STARTED_EVENT, (session, key) -> { /* ... */ });
```
<!-- /tab -->

<!-- tab: py -->

**Python**

```python
s.set_handler(snsr.ADAPT_STARTED_EVENT, on_event)
```
<!-- /tab -->

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](https://doc.sensory.com/tnl/7.8/api/inference.md#rc_ok) to continue with model adaptation, or [SKIP](https://doc.sensory.com/tnl/7.8/api/inference.md#rc_skip) to
abort adaptation and ignore this enrollment without raising an error.

The handler function's [Session](https://doc.sensory.com/tnl/7.8/api/inference.md#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](https://doc.sensory.com/tnl/7.8/api/inference.md#session) teardown waits on joining the adaptation thread. Any
handler function registered for this event must return before the
associated [Session](https://doc.sensory.com/tnl/7.8/api/inference.md#session) is released.

**Available results:** [sample-count](https://doc.sensory.com/tnl/7.8/api/setting-keys/results.md#sample-count)

**Available iterators:** _none_

**Also see these related items:** [^adapted](https://doc.sensory.com/tnl/7.8/api/setting-keys/events.md#adapted)

### ^adapted
- event
- handle
- write-only

<!-- tab: c -->

**C/C++**

```c
snsrSetHandler(s, SNSR_ADAPTED_EVENT, snsrCallback(on_event, NULL, NULL));
```
<!-- /tab -->

<!-- tab: java -->

**Java**

```java
s.setHandler(Snsr.ADAPTED_EVENT, (session, key) -> { /* ... */ });
```
<!-- /tab -->

<!-- tab: py -->

**Python**

```python
s.set_handler(snsr.ADAPTED_EVENT, on_event)
```
<!-- /tab -->

Wake word adaptation complete event.

Adaptation is the estimation of spotter model parameters from
a number of enrollments for one or more users.

**Example:**

Add a handler for this event to save adapted enrollment contexts.

<!-- tab: c -->

**C/C++**

```c
snsrSave(session, SNSR_FM_RUNTIME, snsrStreamFromFileName("context.snsr", "w"));
```
<!-- /tab -->

<!-- tab: java -->

**Java**

```java
session.save(Snsr.FM_RUNTIME, SnsrStream.fromFileName("context.snsr", "w"));
```
<!-- /tab -->

<!-- tab: py -->

**Python**

```python
session.save(
    snsr.DataFormat.RUNTIME,
    snsr.Stream.from_filename("context.snsr", "w"),
)
```
<!-- /tab -->

To load a previously saved enrollment context, do so _after_ loading
the model that created it.

**Available results:** [sample-count](https://doc.sensory.com/tnl/7.8/api/setting-keys/results.md#sample-count), [user](https://doc.sensory.com/tnl/7.8/api/setting-keys/configuration.md#user), [user-count](https://doc.sensory.com/tnl/7.8/api/setting-keys/results.md#user-count)

**Available iterators:** [user-iterator](https://doc.sensory.com/tnl/7.8/api/setting-keys/iterators.md#user-iterator)

**Also see these related items:** [^enrolled](https://doc.sensory.com/tnl/7.8/api/setting-keys/events.md#enrolled), [save](https://doc.sensory.com/tnl/7.8/api/inference.md#save), [RUNTIME](https://doc.sensory.com/tnl/7.8/api/inference.md#fm_runtime)

### ^done
- event
- handle
- write-only

<!-- tab: c -->

**C/C++**

```c
snsrSetHandler(s, SNSR_DONE_EVENT, snsrCallback(on_event, NULL, NULL));
```
<!-- /tab -->

<!-- tab: java -->

**Java**

```java
s.setHandler(Snsr.DONE_EVENT, (session, key) -> { /* ... */ });
```
<!-- /tab -->

<!-- tab: py -->

**Python**

```python
s.set_handler(snsr.DONE_EVENT, on_event)
```
<!-- /tab -->

Wake word adaptation complete event.

Handler called when adaptation has completed and
the [model-stream](https://doc.sensory.com/tnl/7.8/api/setting-keys/results.md#model-stream) model is available.

This handler typically returns [STOP](https://doc.sensory.com/tnl/7.8/api/inference.md#rc_stop) to end processing.

**Available results:** [model-stream](https://doc.sensory.com/tnl/7.8/api/setting-keys/results.md#model-stream), [sample-count](https://doc.sensory.com/tnl/7.8/api/setting-keys/results.md#sample-count)

**Available iterators:** _none_

### ^enrolled
- event
- handle
- write-only

<!-- tab: c -->

**C/C++**

```c
snsrSetHandler(s, SNSR_ENROLLED_EVENT, snsrCallback(on_event, NULL, NULL));
```
<!-- /tab -->

<!-- tab: java -->

**Java**

```java
s.setHandler(Snsr.ENROLLED_EVENT, (session, key) -> { /* ... */ });
```
<!-- /tab -->

<!-- tab: py -->

**Python**

```python
s.set_handler(snsr.ENROLLED_EVENT, on_event)
```
<!-- /tab -->

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.
<!-- tab: c -->

**C/C++**

```c
snsrSave(session, SNSR_FM_RUNTIME, snsrStreamFromFileName("enrollments.snsr", "w"));
```
<!-- /tab -->

<!-- tab: java -->

**Java**

```java
session.save(Snsr.FM_RUNTIME, SnsrStream.fromFileName("enrollments.snsr", "w"));
```
<!-- /tab -->

<!-- tab: py -->

**Python**

```python
session.save(
    snsr.DataFormat.RUNTIME,
    snsr.Stream.from_filename("enrollments.snsr", "w"),
)
```
<!-- /tab -->

**Available results:** [sample-count](https://doc.sensory.com/tnl/7.8/api/setting-keys/results.md#sample-count)

**Available iterators:** _none_

**Also see these related items:** [^adapted](https://doc.sensory.com/tnl/7.8/api/setting-keys/events.md#adapted), [^done](https://doc.sensory.com/tnl/7.8/api/setting-keys/events.md#done), [save](https://doc.sensory.com/tnl/7.8/api/inference.md#save), [RUNTIME](https://doc.sensory.com/tnl/7.8/api/inference.md#fm_runtime)

### ^fail
- event
- handle
- write-only

<!-- tab: c -->

**C/C++**

```c
snsrSetHandler(s, SNSR_FAIL_EVENT, snsrCallback(on_event, NULL, NULL));
```
<!-- /tab -->

<!-- tab: java -->

**Java**

```java
s.setHandler(Snsr.FAIL_EVENT, (session, key) -> { /* ... */ });
```
<!-- /tab -->

<!-- tab: py -->

**Python**

```python
s.set_handler(snsr.FAIL_EVENT, on_event)
```
<!-- /tab -->

Wake word enrollment failed event.

Handler called if an enrollment fails quality checks.

**Available results:** [audio-stream](https://doc.sensory.com/tnl/7.8/api/setting-keys/results.md#audio-stream), [enrollment-id](https://doc.sensory.com/tnl/7.8/api/setting-keys/results.md#enrollment-id), [reason](https://doc.sensory.com/tnl/7.8/api/setting-keys/results.md#reason), [reason-guidance](https://doc.sensory.com/tnl/7.8/api/setting-keys/results.md#reason-guidance), [reason-pass](https://doc.sensory.com/tnl/7.8/api/setting-keys/results.md#reason-pass), [reason-threshold](https://doc.sensory.com/tnl/7.8/api/setting-keys/results.md#reason-threshold), [reason-value](https://doc.sensory.com/tnl/7.8/api/setting-keys/results.md#reason-value), [sample-count](https://doc.sensory.com/tnl/7.8/api/setting-keys/results.md#sample-count)

**Available iterators:** [reason-iterator](https://doc.sensory.com/tnl/7.8/api/setting-keys/iterators.md#reason-iterator)

**Also see these related items:** [^pass](https://doc.sensory.com/tnl/7.8/api/setting-keys/events.md#pass)

### ^new-user
- event
- handle
- write-only

<!-- tab: c -->

**C/C++**

```c
snsrSetHandler(s, SNSR_NEW_USER_EVENT, snsrCallback(on_event, NULL, NULL));
```
<!-- /tab -->

<!-- tab: java -->

**Java**

```java
s.setHandler(Snsr.NEW_USER_EVENT, (session, key) -> { /* ... */ });
```
<!-- /tab -->

<!-- tab: py -->

**Python**

```python
s.set_handler(snsr.NEW_USER_EVENT, on_event)
```
<!-- /tab -->

New user detected event.

Handler called when a continuously adapting spotter model has adapted
to a new user.

**Available results:** [sample-count](https://doc.sensory.com/tnl/7.8/api/setting-keys/results.md#sample-count), [user](https://doc.sensory.com/tnl/7.8/api/setting-keys/configuration.md#user), [user-count](https://doc.sensory.com/tnl/7.8/api/setting-keys/results.md#user-count)

**Available iterators:** [user-iterator](https://doc.sensory.com/tnl/7.8/api/setting-keys/iterators.md#user-iterator)

**Also see these related items:** [^adapted](https://doc.sensory.com/tnl/7.8/api/setting-keys/events.md#adapted), [delete-user](https://doc.sensory.com/tnl/7.8/api/setting-keys/runtime.md#delete-user), [rename-user](https://doc.sensory.com/tnl/7.8/api/setting-keys/runtime.md#rename-user), [user](https://doc.sensory.com/tnl/7.8/api/setting-keys/configuration.md#user)

### ^next
- event
- handle
- write-only

<!-- tab: c -->

**C/C++**

```c
snsrSetHandler(s, SNSR_NEXT_EVENT, snsrCallback(on_event, NULL, NULL));
```
<!-- /tab -->

<!-- tab: java -->

**Java**

```java
s.setHandler(Snsr.NEXT_EVENT, (session, key) -> { /* ... */ });
```
<!-- /tab -->

<!-- tab: py -->

**Python**

```python
s.set_handler(snsr.NEXT_EVENT, on_event)
```
<!-- /tab -->

Next user event.

Handler called during interactive enrollment to prompt the end-user
for a new enrollment phrase.
This handler should set [user](https://doc.sensory.com/tnl/7.8/api/setting-keys/configuration.md#user) to the tag associated with the new
user. Leave [user](https://doc.sensory.com/tnl/7.8/api/setting-keys/configuration.md#user) if there are no more users or phrases
to enroll.

**Available results:** [sample-count](https://doc.sensory.com/tnl/7.8/api/setting-keys/results.md#sample-count)

**Available iterators:** _none_

**Also see these related items:** [user](https://doc.sensory.com/tnl/7.8/api/setting-keys/configuration.md#user)

### ^pass
- event
- handle
- write-only

<!-- tab: c -->

**C/C++**

```c
snsrSetHandler(s, SNSR_PASS_EVENT, snsrCallback(on_event, NULL, NULL));
```
<!-- /tab -->

<!-- tab: java -->

**Java**

```java
s.setHandler(Snsr.PASS_EVENT, (session, key) -> { /* ... */ });
```
<!-- /tab -->

<!-- tab: py -->

**Python**

```python
s.set_handler(snsr.PASS_EVENT, on_event)
```
<!-- /tab -->

Wake word enrollment succeeded event.

Handler called when an enrollment passes quality checks.

Return [SKIP](https://doc.sensory.com/tnl/7.8/api/inference.md#rc_skip) from this event handler to discard an enrollment.

**Available results:** [audio-stream](https://doc.sensory.com/tnl/7.8/api/setting-keys/results.md#audio-stream), [audio-stream-first](https://doc.sensory.com/tnl/7.8/api/setting-keys/results.md#audio-stream-first), [audio-stream-last](https://doc.sensory.com/tnl/7.8/api/setting-keys/results.md#audio-stream-last), [begin-sample](https://doc.sensory.com/tnl/7.8/api/setting-keys/results.md#begin-sample), [end-sample](https://doc.sensory.com/tnl/7.8/api/setting-keys/results.md#end-sample), [enrollment-id](https://doc.sensory.com/tnl/7.8/api/setting-keys/results.md#enrollment-id), [sample-count](https://doc.sensory.com/tnl/7.8/api/setting-keys/results.md#sample-count)

**Available iterators:** _none_

**Also see these related items:** [^fail](https://doc.sensory.com/tnl/7.8/api/setting-keys/events.md#fail)

### ^pause
- event
- handle
- write-only

<!-- tab: c -->

**C/C++**

```c
snsrSetHandler(s, SNSR_PAUSE_EVENT, snsrCallback(on_event, NULL, NULL));
```
<!-- /tab -->

<!-- tab: java -->

**Java**

```java
s.setHandler(Snsr.PAUSE_EVENT, (session, key) -> { /* ... */ });
```
<!-- /tab -->

<!-- tab: py -->

**Python**

```python
s.set_handler(snsr.PAUSE_EVENT, on_event)
```
<!-- /tab -->

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.

**Available results:** [sample-count](https://doc.sensory.com/tnl/7.8/api/setting-keys/results.md#sample-count)

**Available iterators:** _none_

**Also see these related items:** [^resume](https://doc.sensory.com/tnl/7.8/api/setting-keys/events.md#resume)

### ^progress
- event
- handle
- write-only

<!-- tab: c -->

**C/C++**

```c
snsrSetHandler(s, SNSR_PROG_EVENT, snsrCallback(on_event, NULL, NULL));
```
<!-- /tab -->

<!-- tab: java -->

**Java**

```java
s.setHandler(Snsr.PROG_EVENT, (session, key) -> { /* ... */ });
```
<!-- /tab -->

<!-- tab: py -->

**Python**

```python
s.set_handler(snsr.PROG_EVENT, on_event)
```
<!-- /tab -->

Wake word adaptation progress event.

Handler called to report adaptation progress.

**Available results:** [percent-done](https://doc.sensory.com/tnl/7.8/api/setting-keys/results.md#percent-done), [sample-count](https://doc.sensory.com/tnl/7.8/api/setting-keys/results.md#sample-count)

**Available iterators:** _none_

**Also see these related items:** [^adapted](https://doc.sensory.com/tnl/7.8/api/setting-keys/events.md#adapted)

### ^resume
- event
- handle
- write-only

<!-- tab: c -->

**C/C++**

```c
snsrSetHandler(s, SNSR_RESUME_EVENT, snsrCallback(on_event, NULL, NULL));
```
<!-- /tab -->

<!-- tab: java -->

**Java**

```java
s.setHandler(Snsr.RESUME_EVENT, (session, key) -> { /* ... */ });
```
<!-- /tab -->

<!-- tab: py -->

**Python**

```python
s.set_handler(snsr.RESUME_EVENT, on_event)
```
<!-- /tab -->

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](https://doc.sensory.com/tnl/7.8/api/setting-keys/events.md#pause) event handler.

**Available results:** [sample-count](https://doc.sensory.com/tnl/7.8/api/setting-keys/results.md#sample-count)

**Available iterators:** _none_

**Also see these related items:** [^pause](https://doc.sensory.com/tnl/7.8/api/setting-keys/events.md#pause)

<!-- Abbreviation definitions from includes/abbreviations.md -->
*[API]: Application Programming Interface
*[LVCSR]: Large Vocabulary Continuous Speech Recognition model, feed-forward neural net acoustic model with FST decoder
*[NLU]: Natural Language Understanding model
*[SDK]: Software Development Kit
*[SLM]: Generative Small Language Model
*[STT]: Speech To Text: transformers with language model and CTC decoding
*[TNL]: TrulyNatural, Sensory's large-vocabulary speech recognition technology
*[VAD]: Voice Activity Detector
