Runtime¶
These settings inspect the state, or change the behavior, of Session object instances. They are not serialized by save or dup.
Most applications will use ->audio-pcm with push or run to present audio samples to a recognition task. Other runtime keys come up only in specific workflows: grammar-stream and phrases-stream for custom LVCSR vocabularies, dsp-target for THF Micro export, and add-context / delete-user / rename-user for enrollment.
Access runtime settings with the Session get or set function that matches the setting type. For example, use setStream to change the input stream for ->audio-pcm.
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.
Audio I/O¶
->audio-pcm¶
runtime input stream write-only
snsrSetStream(s, SNSR_SOURCE_AUDIO_PCM, stream);
s.setStream(Snsr.SOURCE_AUDIO_PCM, stream);
s.set_stream(snsr.SOURCE_AUDIO_PCM, stream)
->feature¶
runtime input stream write-only pre-release
snsrSetStream(s, SNSR_SOURCE_FEATURE, stream);
s.setStream(Snsr.SOURCE_FEATURE, stream);
s.set_stream(snsr.SOURCE_FEATURE, stream)
Input feature stream.
Pre-release
This is an experimental feature. Do not use unless recommended by Sensory.
Source stream in a proprietary Sensory format.
<-audio-pcm¶
runtime output stream write-only
snsrSetStream(s, SNSR_SINK_AUDIO_PCM, stream);
s.setStream(Snsr.SINK_AUDIO_PCM, stream);
s.set_stream(snsr.SINK_AUDIO_PCM, stream)
Output audio stream.
Headerless audio output, 16-bit LPCM-encoded, sampled at 16 kHz, with little-endian byte ordering.
<-feature¶
runtime output stream write-only pre-release
snsrSetStream(s, SNSR_SINK_FEATURE, stream);
s.setStream(Snsr.SINK_FEATURE, stream);
s.set_stream(snsr.SINK_FEATURE, stream)
Output feature stream.
Pre-release
This is an experimental feature. Do not use unless recommended by Sensory.
Headerless feature output in a proprietary Sensory format.
audio-stream-from¶
runtime double read-write
snsrSetDouble(s, SNSR_AUDIO_STREAM_FROM, value);
s.setDouble(Snsr.AUDIO_STREAM_FROM, value);
s.set_double(snsr.AUDIO_STREAM_FROM, value)
Audio stream requested start index.
Start the next audio-stream at this sample index value. Defaults to audio-stream-first.
audio-stream-to¶
runtime double read-write
snsrSetDouble(s, SNSR_AUDIO_STREAM_TO, value);
s.setDouble(Snsr.AUDIO_STREAM_TO, value);
s.set_double(snsr.AUDIO_STREAM_TO, value)
Audio stream requested end index.
End the next audio-stream at this sample index value. Defaults to audio-stream-last.
VAD & endpointing¶
skip-to-ms¶
runtime int write-only
snsrSetInt(s, SNSR_SKIP_TO_MS, value);
s.setInt(Snsr.SKIP_TO_MS, value);
s.set_int(snsr.SKIP_TO_MS, value)
VAD initial ignore duration, in ms.
Ignore the first skip-to-ms ms of the ->audio-pcm input stream. Use this runtime setting to skip over a trigger phrase included in the source audio. The default is to process all audio.
skip-to-sample¶
runtime int write-only
snsrSetInt(s, SNSR_SKIP_TO_SAMPLE, value);
s.setInt(Snsr.SKIP_TO_SAMPLE, value);
s.set_int(snsr.SKIP_TO_SAMPLE, value)
VAD initial ignore duration, in samples.
Ignore the first skip-to-sample samples of the ->audio-pcm input stream. Use this runtime setting to skip over a trigger phrase included in the source audio. The default is to process all audio.
LVCSR & STT¶
grammar-stream.¶
runtime input stream write-only tnl
snsrSetStream(s, SNSR_GRAMMAR_STREAM, stream);
s.setStream(Snsr.GRAMMAR_STREAM, stream);
s.set_stream(snsr.GRAMMAR_STREAM, stream)
Recognition grammar stream.
Creates a recognizer from a grammar specification read from a stream. The grammar must use UTF‑8 encoding. The new model will recognize only those phrases that the grammar generates.
The model will be ready to recognize once setStream returns. For larger grammars the build process can take a significant amount of time.
See grammar syntax for detail on how grammars are structured.
To create a grammar for a class, append the class name to grammar-stream.:
Example
snsrSetStream(session, SNSR_GRAMMAR_STREAM "classname", grammarStream);
session.set(Snsr.GRAMMAR_STREAM + "classname", grammarStream);
Note
Requires a TrulyNatural model that supports building.
nlu-grammar-stream.¶
runtime input stream write-only tnl stt
snsrSetStream(s, SNSR_NLU_GRAMMAR_STREAM, stream);
s.setStream(Snsr.NLU_GRAMMAR_STREAM, stream);
s.set_stream(snsr.NLU_GRAMMAR_STREAM, stream)
NLU grammar stream.
Creates a lightweight NLU parser from a grammar specification read from a stream. It takes precedence over NLU specified with grammar-stream and can be used as an alternative to machine-learned NLU in some STT models.
The grammar must use UTF‑8 encoding. The NLU model will recognize only those phrases that the grammar generates.
The NLU parser is applied to the recognition result, ^result, and generates ^nlu-intent and ^nlu-slot events for each match found.
The model will be ready to recognize once setStream returns. For larger grammars the build process can take a significant amount of time.
See grammar syntax for detail on how grammars are structured.
To create a grammar for a class, append the class name to nlu-grammar-stream.:
Example
snsrSetStream(session, SNSR_NLU_GRAMMAR_STREAM "classname", grammarStream);
SnsrSession.set(Snsr.NLU_GRAMMAR_STREAM + "classname", grammarStream);
Note
- Requires a TrulyNatural model that supports building.
- 7.8.0 If the model includes a machine-learned NLU component and the grammar-based NLU finds a match, this match replaces the machine learned-result completely. Before release 7.8.0 the
nlu-grammar-streamresult replaced the machine-learned result even if it found no matches.
phrases-stream.¶
runtime input stream write-only tnl
snsrSetStream(s, SNSR_PHRASES_STREAM, stream);
s.setStream(Snsr.PHRASES_STREAM, stream);
s.set_stream(snsr.PHRASES_STREAM, stream)
Recognition phrase list stream.
Creates a recognizer from a list of phrases read from a stream. The phrase list must use UTF‑8 encoding. Individual phrases are separated by newlines or semicolons. Comments start with # and run until the end of the phrase. Only the exact phrases in the list will be part of the recognition language.
This utility setting converts the list of phrases into this grammar specification:
g = <s> ( phrase0 | phrase1 | ... | phraseN) </s>;
To create a phrase list for a class, append the class name to phrases-stream.:
Example
const char *phrases = "hello world; this is a test sentence";
snsrSetStream(session, SNSR_PHRASES_STREAM "classname", snsrStreamFromString(phrases));
String phrases = "hello world; this is a test sentence";
session.set(Snsr.PHRASES_STREAM + "classname", SnsrStream.fromString(phrases));
Note
Requires a TrulyNatural model that supports building.
Enrollment & adaptation¶
add-context¶
runtime int read-write
snsrSetInt(s, SNSR_ADD_CONTEXT, value);
s.setInt(Snsr.ADD_CONTEXT, value);
s.set_int(snsr.ADD_CONTEXT, value)
Current enrollment includes trailing context.
Set to 1 if the enrollment recording should include trailing context, for example: "Hey Sensory will it rain tomorrow?"
delete-user¶
runtime string write-only
snsrSetString(s, SNSR_DELETE_USER, "text");
s.setString(Snsr.DELETE_USER, "text");
s.set_string(snsr.DELETE_USER, "text")
re-adapt¶
runtime int write-only
snsrSetInt(s, SNSR_RE_ADAPT, value);
s.setInt(Snsr.RE_ADAPT, value);
s.set_int(snsr.RE_ADAPT, value)
Force re-adaptation of all enrollments.
If all users in an enrollment task have been adapted, the adaptation step is skipped. This is the case when one or more adapted enrollment contexts are loaded, and no new users are added.
Setting re-adapt to 1 changes this behavior to always do the adaptation step.
rename-user¶
runtime string write-only
snsrSetString(s, SNSR_RENAME_USER, "text");
s.setString(Snsr.RENAME_USER, "text");
s.set_string(snsr.RENAME_USER, "text")
Rename an enrolled user.
Changes the recognition result returned for user to the string argument.
This setting is only available in fixed-phrase spotters that support continuous adaptation.
Example
snsrSetString(s, SNSR_USER, "original-user/phrase");
snsrSetString(s, SNSR_RENAME_USER, "new-user/new-phrase");
session.setString(Snsr.USER, "original-user/phrase");
session.setString(Snsr.RENAME_USER, "new-user/new-phrase");
Push / pull execution¶
auto-flush¶
runtime int read-write 6.20.0
snsrSetInt(s, SNSR_AUTO_FLUSH, value);
s.setInt(Snsr.AUTO_FLUSH, value);
s.set_int(snsr.AUTO_FLUSH, value)
Recognition pipeline end-of-stream flush behavior.
This boolean value controls whether run flushes the recognition pipeline when one (or more) of the input streams report an end-of-file condition.
The default value is 1, which enables automatic flushing on EOF. This is appropriate for most applications. Set auto-flush to 0 when audio is presented to run in small segments.
THF Micro DSP¶
dsp-acmodel-stream¶
runtime output stream read-only
SnsrStream stream;
snsrGetStream(s, SNSR_EMBEDDED_ACMODEL_STREAM, &stream);
SnsrStream stream = s.getStream(Snsr.EMBEDDED_ACMODEL_STREAM);
stream = s.get_stream(snsr.EMBEDDED_ACMODEL_STREAM)
Embedded device acoustic model data.
THF Micro, dsp-target, dsp-header-stream, dsp-search-stream, dsp.production-ready, dsp.t-slice-version
dsp-header-stream¶
runtime output stream read-only
SnsrStream stream;
snsrGetStream(s, SNSR_EMBEDDED_HEADER_STREAM, &stream);
SnsrStream stream = s.getStream(Snsr.EMBEDDED_HEADER_STREAM);
stream = s.get_stream(snsr.EMBEDDED_HEADER_STREAM)
Embedded device search header.
dsp-target,dsp-acmodel-stream, dsp-search-stream, dsp.t-slice-version
dsp-search-stream¶
runtime output stream read-only
SnsrStream stream;
snsrGetStream(s, SNSR_EMBEDDED_SEARCH_STREAM, &stream);
SnsrStream stream = s.getStream(Snsr.EMBEDDED_SEARCH_STREAM);
stream = s.get_stream(snsr.EMBEDDED_SEARCH_STREAM)
Embedded device search model data.
dsp-target, dsp-acmodel-stream, dsp-header-stream, dsp.t-slice-version
dsp-target¶
runtime string read-write
snsrSetString(s, SNSR_EMBEDDED_TARGET, "text");
s.setString(Snsr.EMBEDDED_TARGET, "text");
s.set_string(snsr.EMBEDDED_TARGET, "text")
Embedded (DSP) device target name.
THF Micro, dsp-acmodel-stream, dsp-header-stream, dsp-search-stream, dsp.t-slice-version
Identity & metadata¶
model-license-exp-date¶
runtime double read-only
double value;
snsrGetDouble(s, SNSR_MODEL_LICENSE_EXPDATE, &value);
double value = s.getDouble(Snsr.MODEL_LICENSE_EXPDATE);
value = s.get_double(snsr.MODEL_LICENSE_EXPDATE)
Model license expiration date.
Returns the license expiration date of the most recently loaded model in seconds since the epoch, or 0 if no model is loaded.
For production keys, which never expire, the expiration date is 0.
Example
double e;
time_t expdate;
snsrGetDouble(s, SNSR_MODEL_LICENSE_EXPDATE, &e);
expdate = (time_t)e;
model-license-exp-message¶
runtime string read-only
const char * value;
snsrGetString(s, SNSR_MODEL_LICENSE_EXPIRES, &value);
String value = s.getString(Snsr.MODEL_LICENSE_EXPIRES);
value = s.get_string(snsr.MODEL_LICENSE_EXPIRES)
Model license expiration message.
Returns an expiration message string for the most recently loaded model, or NULL if no model is loaded.
The returned string is of the form "Model license expires on <date>", or NULL for model license keys that do not expire.
Example
const char *expires;
snsrGetString(s, SNSR_MODEL_LICENSE_EXPIRES, &expires);
if (expires) fprintf(stderr, "%s\n", expires);
model-license-exp-warn¶
runtime string read-only
const char * value;
snsrGetString(s, SNSR_MODEL_LICENSE_WARNING, &value);
String value = s.getString(Snsr.MODEL_LICENSE_WARNING);
value = s.get_string(snsr.MODEL_LICENSE_WARNING)
Model license expiration warning message.
This value is NULL for models with license keys that either do not expire, or that have an expiration date that is more than 60 days into the future.
For license keys expiring in 60 days or fewer, the returned string will be of the form "License will expire in 37 days.".
model-name¶
runtime string read-write
snsrSetString(s, SNSR_MODEL_NAME, "text");
s.setString(Snsr.MODEL_NAME, "text");
s.set_string(snsr.MODEL_NAME, "text")
Source model name.
The name of the model file used to create:
- ROM-able C code with save and SOURCE.
- A model in one of the supported embedded formats with dsp-header-stream.
This value is included in the comment header of the generated code, for information only.
model:ids¶
runtime string read-write
snsrSetString(s, SNSR_PREPARE_SUBSET_INIT, "text");
s.setString(Snsr.PREPARE_SUBSET_INIT, "text");
s.set_string(snsr.PREPARE_SUBSET_INIT, "text")
Prepares a Session for generating custom initialization code.
Set this value to NULL to enable load instrumentation. This is used by save with SUBSET_INIT to generate custom library initialization code (in C), which references only modules encountered during load.
Linking against only a subset of available modules reduces executable size.
This example will create a custom-init.c file. Add this to the build, and recompile with -DSNSR_USE_SUBSET to enable. The linked executable(s) will contain just the modules required to run model-a.snsr and model-b.snsr.
Example
SnsrSession s;
snsrNew(&s);
snsrSetString(s, SNSR_PREPARE_SUBSET_INIT, NULL);
snsrLoad(s, snsrStreamFromFileName("model-a.snsr", "r"));
snsrLoad(s, snsrStreamFromFileName("model-b.snsr", "r"));
snsrSave(s, SNSR_FM_SUBSET_INIT, snsrStreamFromFileName("custom-init.c", "w"));
snsrRelease(s);
prune:enable¶
runtime string read-write 7.5.0
snsrSetString(s, SNSR_PRUNE_SETTINGS, "text");
s.setString(Snsr.PRUNE_SETTINGS, "text");
s.set_string(snsr.PRUNE_SETTINGS, "text")
Prepare a Session for pruning model settings
Pruning unused settings from a model reduces peak RAM requirements. This is typically only useful on platforms where heap memory is constrained.
Set prune:enable to yes to instrument model loading and running. This instrumentation:
- Keeps track of which configuration settings the application accesses during model evaluation,
- adds a list of these settings to the model upon saving, and
- configures the model to prune settings not on this list from the runtime directly after loading.
Set prune:enable to no to disable pruning. This is the default.
Note
Pruned models do not contain enough information to be re-saved.
tag-identifier¶
runtime string read-write
snsrSetString(s, SNSR_TAG_IDENTIFIER, "text");
s.setString(Snsr.TAG_IDENTIFIER, "text");
s.set_string(snsr.TAG_IDENTIFIER, "text")
Exported identifier in ROM C code.
When text segment C code is created with save and SOURCE, this setting specifies the name of the exported data structure.
The value must start with an ASCII alphabetic character or _, and contain only alphanumerics and _; it must match regular expression [A-Za-z_][A-Za-z0-9_]*