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

# Iterators

Use these keys with [forEach](https://doc.sensory.com/tnl/7.8/api/inference.md#foreach) to loop over lists of values.
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 the loop
functions vary by iterator. See the descriptions below for details on
what these are.

Iterators are available only in the
[&bull; events](https://doc.sensory.com/tnl/7.8/api/setting-keys/events.md#events) listed, except for
those marked as &bull; _all_, which you can use outside of event callbacks too.

Most applications don't use iterators directly — recognition results
arrive via [^result](https://doc.sensory.com/tnl/7.8/api/setting-keys/events.md#result) without iteration. The two most useful when you
do reach for them are [word-iterator](https://doc.sensory.com/tnl/7.8/api/setting-keys/iterators.md#word-iterator) (per-word alignments and scores)
and [vocab-iterator](https://doc.sensory.com/tnl/7.8/api/setting-keys/iterators.md#vocab-iterator) (model introspection); see the descriptions below
for the rest.

<!-- 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).

## Wake word & command set

### model-iterator
- iterator
- handle
- write-only

<!-- tab: c -->

**C/C++**

```c
snsrForEach(s, SNSR_MODEL_LIST, snsrCallback(on_item, NULL, NULL));
```
<!-- /tab -->

<!-- tab: java -->

**Java**

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

<!-- tab: py -->

**Python**

```python
s.for_each(snsr.MODEL_LIST, on_item)
```
<!-- /tab -->

Iterate over the phoneme parts in a result.

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

**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), [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:** _none_

**Also see these related items:** [^phone-iterator](https://doc.sensory.com/tnl/7.8/api/setting-keys/iterators.md#phone-iterator), [word-iterator](https://doc.sensory.com/tnl/7.8/api/setting-keys/iterators.md#word-iterator)

### operating-point-iterator
- iterator
- handle
- write-only

<!-- tab: c -->

**C/C++**

```c
snsrForEach(s, SNSR_OPERATING_POINT_LIST, snsrCallback(on_item, NULL, NULL));
```
<!-- /tab -->

<!-- tab: java -->

**Java**

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

<!-- tab: py -->

**Python**

```python
s.for_each(snsr.OPERATING_POINT_LIST, on_item)
```
<!-- /tab -->

Iterate over available spotter operating points.

**Available in these events:** _all_

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

**Available iterators:** _none_

### phone-iterator
- iterator
- handle
- write-only

<!-- tab: c -->

**C/C++**

```c
snsrForEach(s, SNSR_PHONE_LIST, snsrCallback(on_item, NULL, NULL));
```
<!-- /tab -->

<!-- tab: java -->

**Java**

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

<!-- tab: py -->

**Python**

```python
s.for_each(snsr.PHONE_LIST, on_item)
```
<!-- /tab -->

Iterate over the phonemes in a result.

STT models do not report any sub-word unit hypotheses.

**Available in these events:** [^result](https://doc.sensory.com/tnl/7.8/api/setting-keys/events.md#result), [^result-partial](https://doc.sensory.com/tnl/7.8/api/setting-keys/events.md#result-partial)

**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), [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:** _none_

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

### vocab-iterator
- iterator
- handle
- write-only

<!-- tab: c -->

**C/C++**

```c
snsrForEach(s, SNSR_VOCAB_LIST, snsrCallback(on_item, NULL, NULL));
```
<!-- /tab -->

<!-- tab: java -->

**Java**

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

<!-- tab: py -->

**Python**

```python
s.for_each(snsr.VOCAB_LIST, on_item)
```
<!-- /tab -->

Iterate over the vocabulary available in a keyword spotter.

**Available in these events:** _all_

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

**Available iterators:** _none_

### word-iterator
- iterator
- handle
- write-only

<!-- tab: c -->

**C/C++**

```c
snsrForEach(s, SNSR_WORD_LIST, snsrCallback(on_item, NULL, NULL));
```
<!-- /tab -->

<!-- tab: java -->

**Java**

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

<!-- tab: py -->

**Python**

```python
s.for_each(snsr.WORD_LIST, on_item)
```
<!-- /tab -->

Iterate over the words in a result.

User-defined enrolled results are modeled as a single word.

**Available in these events:** [^result](https://doc.sensory.com/tnl/7.8/api/setting-keys/events.md#result), [^result-partial](https://doc.sensory.com/tnl/7.8/api/setting-keys/events.md#result-partial)

**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), [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:** _none_

## LVCSR & STT

### model-iterator
- iterator
- handle
- write-only

Documented under **Wake word & command set** ([model-iterator](https://doc.sensory.com/tnl/7.8/api/setting-keys/iterators.md#model-iterator)).

### phone-iterator
- iterator
- handle
- write-only

Documented under **Wake word & command set** ([phone-iterator](https://doc.sensory.com/tnl/7.8/api/setting-keys/iterators.md#phone-iterator)).

### phrase-iterator
- iterator
- handle
- write-only
- TrulyNatural only
<!-- tab: c -->

**C/C++**

```c
snsrForEach(s, SNSR_PHRASE_LIST, snsrCallback(on_item, NULL, NULL));
```
<!-- /tab -->

<!-- tab: java -->

**Java**

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

<!-- tab: py -->

**Python**

```python
s.for_each(snsr.PHRASE_LIST, on_item)
```
<!-- /tab -->

Iterate over recognition phrase hypotheses.

Most recognizers provide only the top-scoring recognition result.
`phrase-iterator` is useful only when an LVCSR recognizer is
configured to provide N-best results; when [result-max](https://doc.sensory.com/tnl/7.8/api/setting-keys/configuration.md#result-max) `> 1`.

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

**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), [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:** _none_

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

### word-iterator
- iterator
- handle
- write-only

Documented under **Wake word & command set** ([word-iterator](https://doc.sensory.com/tnl/7.8/api/setting-keys/iterators.md#word-iterator)).

## NLU & SLM

### nlu-entity-iterator
- iterator
- handle
- write-only
_(TrulyNatural only)_ _(STT only)_
<!-- tab: c -->

**C/C++**

```c
snsrForEach(s, SNSR_NLU_ENTITY_LIST, snsrCallback(on_item, NULL, NULL));
```
<!-- /tab -->

<!-- tab: java -->

**Java**

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

<!-- tab: py -->

**Python**

```python
s.for_each(snsr.NLU_ENTITY_LIST, on_item)
```
<!-- /tab -->

Iterate over NLU entities in the current intent.

This iterator invokes the specified handler for each of the
[nlu-entity-count](https://doc.sensory.com/tnl/7.8/api/setting-keys/results.md#nlu-entity-count) entities found for the current intent.

**Available in these events:** [^nlu-intent](https://doc.sensory.com/tnl/7.8/api/setting-keys/events.md#nlu-intent)

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

**Available iterators:** _none_

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

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

**C/C++**

```c
snsrForEach(s, SNSR_NLU_SLOT_LIST, snsrCallback(on_item, NULL, NULL));
```
<!-- /tab -->

<!-- tab: java -->

**Java**

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

<!-- tab: py -->

**Python**

```python
s.for_each(snsr.NLU_SLOT_LIST, on_item)
```
<!-- /tab -->

Iterate over NLU child result slots.

This iterator invokes the specified handler for each of the NLU result
slots found in the current NLU slot value, [nlu-slot-value](https://doc.sensory.com/tnl/7.8/api/setting-keys/results.md#nlu-slot-value).

**Available in these events:** [^nlu-slot](https://doc.sensory.com/tnl/7.8/api/setting-keys/events.md#nlu-slot)

**Available results:** [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)

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

### nlu-word-iterator
- iterator
- handle
- write-only
_(TrulyNatural only)_ _(STT only)_
<!-- tab: c -->

**C/C++**

```c
snsrForEach(s, SNSR_NLU_WORD_LIST, snsrCallback(on_item, NULL, NULL));
```
<!-- /tab -->

<!-- tab: java -->

**Java**

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

<!-- tab: py -->

**Python**

```python
s.for_each(snsr.NLU_WORD_LIST, on_item)
```
<!-- /tab -->

Iterate over the words in an NLU result.

Valid only for LVCSR recognizers that include NLU post-processing.
This post-processing can insert, delete, or change words in the
recognition result and those changes are available here.

**Available in these events:** [^nlu-intent](https://doc.sensory.com/tnl/7.8/api/setting-keys/events.md#nlu-intent), [^nlu-slot](https://doc.sensory.com/tnl/7.8/api/setting-keys/events.md#nlu-slot)

**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), [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:** _none_

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

## Enrollment & adaptation

### enrollment-iterator
- iterator
- handle
- write-only

<!-- tab: c -->

**C/C++**

```c
snsrForEach(s, SNSR_ENROLLMENT_LIST, snsrCallback(on_item, NULL, NULL));
```
<!-- /tab -->

<!-- tab: java -->

**Java**

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

<!-- tab: py -->

**Python**

```python
s.for_each(snsr.ENROLLMENT_LIST, on_item)
```
<!-- /tab -->

Iterate over all wake word enrollments for the current user.

This can be used to retrieve enrollment audio if
[save-enroll-audio](https://doc.sensory.com/tnl/7.8/api/setting-keys/configuration.md#save-enroll-audio) is enabled.

**Available in these events:** _all_

**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), [user](https://doc.sensory.com/tnl/7.8/api/setting-keys/configuration.md#user)

**Available iterators:** _none_

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

### reason-iterator
- iterator
- handle
- write-only

<!-- tab: c -->

**C/C++**

```c
snsrForEach(s, SNSR_REASON_LIST, snsrCallback(on_item, NULL, NULL));
```
<!-- /tab -->

<!-- tab: java -->

**Java**

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

<!-- tab: py -->

**Python**

```python
s.for_each(snsr.REASON_LIST, on_item)
```
<!-- /tab -->

Iterate over all reasons for wake word enrollment failure.

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

**Available results:** [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)

**Available iterators:** _none_

### user-iterator
- iterator
- handle
- write-only

<!-- tab: c -->

**C/C++**

```c
snsrForEach(s, SNSR_USER_LIST, snsrCallback(on_item, NULL, NULL));
```
<!-- /tab -->

<!-- tab: java -->

**Java**

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

<!-- tab: py -->

**Python**

```python
s.for_each(snsr.USER_LIST, on_item)
```
<!-- /tab -->

Iterate over all enrolled users.

Sets [user](https://doc.sensory.com/tnl/7.8/api/setting-keys/configuration.md#user) to each of the enrolled users before invoking the
callback.

**Available in these events:** _all_

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

**Available iterators:** _none_

<!-- 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
*[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
