Skip to content

Iterators

Use these keys with 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 or dup.

The results and 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 events listed, except for those marked as all, which you can use outside of event callbacks too.

Most applications don't use iterators directly — recognition results arrive via ^result without iteration. The two most useful when you do reach for them are word-iterator (per-word alignments and scores) and vocab-iterator (model introspection); see the descriptions below for the rest.

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, plus value, stream, on_event, or on_item for the operand) to your code. Each example assumes the language's standard prelude:

#include <snsr.h>
import com.sensory.speech.snsr.Snsr;
import com.sensory.speech.snsr.SnsrSession;
import snsr

For the full Session lifecycle (snsrNew, new SnsrSession(), snsr.Session(...)) see Your first program.

Wake word & command set

model-iterator

iterator handle write-only

snsrForEach(s, SNSR_MODEL_LIST, snsrCallback(on_item, NULL, NULL));
s.forEach(Snsr.MODEL_LIST, (session, key) -> { /* ... */ });
s.for_each(snsr.MODEL_LIST, on_item)

Iterate over the phoneme parts in a result.

^result

begin-ms, begin-sample, end-ms, end-sample, score, text

none

^phone-iterator, word-iterator

operating-point-iterator

iterator handle write-only

snsrForEach(s, SNSR_OPERATING_POINT_LIST, snsrCallback(on_item, NULL, NULL));
s.forEach(Snsr.OPERATING_POINT_LIST, (session, key) -> { /* ... */ });
s.for_each(snsr.OPERATING_POINT_LIST, on_item)

Iterate over available spotter operating points.

all

available-point

none

phone-iterator

iterator handle write-only

snsrForEach(s, SNSR_PHONE_LIST, snsrCallback(on_item, NULL, NULL));
s.forEach(Snsr.PHONE_LIST, (session, key) -> { /* ... */ });
s.for_each(snsr.PHONE_LIST, on_item)

Iterate over the phonemes in a result.

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

^result, ^result-partial

begin-ms, begin-sample, end-ms, end-sample, score, text

none

word-iterator

vocab-iterator

iterator handle write-only

snsrForEach(s, SNSR_VOCAB_LIST, snsrCallback(on_item, NULL, NULL));
s.forEach(Snsr.VOCAB_LIST, (session, key) -> { /* ... */ });
s.for_each(snsr.VOCAB_LIST, on_item)

Iterate over the vocabulary available in a keyword spotter.

all

id, text

none

word-iterator

iterator handle write-only

snsrForEach(s, SNSR_WORD_LIST, snsrCallback(on_item, NULL, NULL));
s.forEach(Snsr.WORD_LIST, (session, key) -> { /* ... */ });
s.for_each(snsr.WORD_LIST, on_item)

Iterate over the words in a result.

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

^result, ^result-partial

begin-ms, begin-sample, end-ms, end-sample, score, text

none

LVCSR & STT

model-iterator

iterator handle write-only

Documented under Wake word & command set (model-iterator).

phone-iterator

iterator handle write-only

Documented under Wake word & command set (phone-iterator).

phrase-iterator

iterator handle write-only tnl

snsrForEach(s, SNSR_PHRASE_LIST, snsrCallback(on_item, NULL, NULL));
s.forEach(Snsr.PHRASE_LIST, (session, key) -> { /* ... */ });
s.for_each(snsr.PHRASE_LIST, on_item)

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 > 1.

^result

begin-ms, begin-sample, end-ms, end-sample, score, text

none

result-max

word-iterator

iterator handle write-only

Documented under Wake word & command set (word-iterator).

NLU & SLM

nlu-entity-iterator

iterator handle write-only tnl stt

snsrForEach(s, SNSR_NLU_ENTITY_LIST, snsrCallback(on_item, NULL, NULL));
s.forEach(Snsr.NLU_ENTITY_LIST, (session, key) -> { /* ... */ });
s.for_each(snsr.NLU_ENTITY_LIST, on_item)

Iterate over NLU entities in the current intent.

This iterator invokes the specified handler for each of the nlu-entity-count entities found for the current intent.

^nlu-intent

nlu-entity-count, nlu-entity-name, nlu-entity-score, nlu-entity-value

none

nlu-entity-count

nlu-slot-iterator

iterator handle write-only tnl stt

snsrForEach(s, SNSR_NLU_SLOT_LIST, snsrCallback(on_item, NULL, NULL));
s.forEach(Snsr.NLU_SLOT_LIST, (session, key) -> { /* ... */ });
s.for_each(snsr.NLU_SLOT_LIST, on_item)

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.

^nlu-slot

nlu-slot-count, nlu-slot-name, nlu-slot-score, nlu-slot-value

nlu-slot-iterator

nlu-word-iterator

iterator handle write-only tnl stt

snsrForEach(s, SNSR_NLU_WORD_LIST, snsrCallback(on_item, NULL, NULL));
s.forEach(Snsr.NLU_WORD_LIST, (session, key) -> { /* ... */ });
s.for_each(snsr.NLU_WORD_LIST, on_item)

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.

^nlu-intent, ^nlu-slot

begin-ms, begin-sample, end-ms, end-sample, score, text

none

word-iterator

Enrollment & adaptation

enrollment-iterator

iterator handle write-only

snsrForEach(s, SNSR_ENROLLMENT_LIST, snsrCallback(on_item, NULL, NULL));
s.forEach(Snsr.ENROLLMENT_LIST, (session, key) -> { /* ... */ });
s.for_each(snsr.ENROLLMENT_LIST, on_item)

Iterate over all wake word enrollments for the current user.

This can be used to retrieve enrollment audio if save-enroll-audio is enabled.

all

audio-stream, audio-stream-first, audio-stream-last, begin-sample, end-sample, enrollment-id, user

none

save-enroll-audio, user, user-iterator

reason-iterator

iterator handle write-only

snsrForEach(s, SNSR_REASON_LIST, snsrCallback(on_item, NULL, NULL));
s.forEach(Snsr.REASON_LIST, (session, key) -> { /* ... */ });
s.for_each(snsr.REASON_LIST, on_item)

Iterate over all reasons for wake word enrollment failure.

^fail

reason, reason-guidance, reason-pass, reason-threshold, reason-value

none

user-iterator

iterator handle write-only

snsrForEach(s, SNSR_USER_LIST, snsrCallback(on_item, NULL, NULL));
s.forEach(Snsr.USER_LIST, (session, key) -> { /* ... */ });
s.for_each(snsr.USER_LIST, on_item)

Iterate over all enrolled users.

Sets user to each of the enrolled users before invoking the callback.

all

enrollment-count, user

none