Skip to content

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.

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.

->audio-pcm

runtime input stream write-only

#define SNSR_SOURCE_AUDIO_PCM "->audio-pcm"
public class Snsr {
  public final static String SOURCE_AUDIO_PCM = "->audio-pcm";
}

Input audio stream.

This audio stream must be headerless, 16-bit LPCM-encoded, sampled at 16 kHz, with little-endian byte ordering.

push, run

->feature

runtime input stream write-only pre-release

#define SNSR_SOURCE_FEATURE "->feature"
public class Snsr {
  public final static String SOURCE_FEATURE = "->feature";
}

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

#define SNSR_SINK_AUDIO_PCM "<-audio-pcm"
public class Snsr {
  public final static String SINK_AUDIO_PCM = "<-audio-pcm";
}

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

#define SNSR_SINK_FEATURE "<-feature"
public class Snsr {
  public final static String SINK_FEATURE = "<-feature";
}

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.

add-context

runtime int read-write

#define SNSR_ADD_CONTEXT "add-context"
public class Snsr {
  public final static String ADD_CONTEXT = "add-context";
}

Current enrollment includes trailing context.

Set to 1 if the enrollment recording should include trailing context, for example: "Hey Sensory will it rain tomorrow?"

^resume

audio-stream-from

runtime double read-write

#define SNSR_AUDIO_STREAM_FROM "audio-stream-from"
public class Snsr {
  public final static String AUDIO_STREAM_FROM = "audio-stream-from";
}

Audio stream requested start index.

Start the next audio-stream at this sample index value. Defaults to audio-stream-first.

audio-stream, audio-stream-size

audio-stream-to

runtime double read-write

#define SNSR_AUDIO_STREAM_TO "audio-stream-to"
public class Snsr {
  public final static String AUDIO_STREAM_TO = "audio-stream-to";
}

Audio stream requested end index.

End the next audio-stream at this sample index value. Defaults to audio-stream-last.

audio-stream, audio-stream-size

auto-flush

runtime int read-write 6.20.0

#define SNSR_AUTO_FLUSH "auto-flush"
public class Snsr {
  public final static String AUTO_FLUSH = "auto-flush";
}

Recognition pipeline end-of-stream flush behavior.

Deprecated

Use push and stop in new code instead.

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.

run, push, stop

delete-user

runtime string write-only

#define SNSR_DELETE_USER "delete-user"
public class Snsr {
  public final static String DELETE_USER = "delete-user";
}

Delete an enrolled user.

Deletes the named user, then:

^adapted, ^done, ^enrolled

dsp-acmodel-stream

runtime output stream read-only

#define SNSR_EMBEDDED_ACMODEL_STREAM "dsp-acmodel-stream"
public class Snsr {
  public final static String EMBEDDED_ACMODEL_STREAM = "dsp-acmodel-stream";
}

dsp-header-stream

runtime output stream read-only

#define SNSR_EMBEDDED_HEADER_STREAM "dsp-header-stream"
public class Snsr {
  public final static String EMBEDDED_HEADER_STREAM = "dsp-header-stream";
}

dsp-search-stream

runtime output stream read-only

#define SNSR_EMBEDDED_SEARCH_STREAM "dsp-search-stream"
public class Snsr {
  public final static String EMBEDDED_SEARCH_STREAM = "dsp-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

#define SNSR_EMBEDDED_TARGET "dsp-target"
public class Snsr {
  public final static String EMBEDDED_TARGET = "dsp-target";
}

grammar-stream.

runtime input stream write-only tnl

#define SNSR_GRAMMAR_STREAM "grammar-stream."
public class Snsr {
  public final static String GRAMMAR_STREAM = "grammar-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.

Stream, phrases-stream

model-license-exp-date

runtime double read-only

#define SNSR_MODEL_LICENSE_EXPDATE "model-license-exp-date"
public class Snsr {
  public final static String MODEL_LICENSE_EXPDATE = "model-license-exp-date";
}

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

model-license-exp-message

runtime string read-only

#define SNSR_MODEL_LICENSE_EXPIRES "model-license-exp-message"
public class Snsr {
  public final static String MODEL_LICENSE_EXPIRES = "model-license-exp-message";
}

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-date, model-license-exp-warn

model-license-exp-warn

runtime string read-only

#define SNSR_MODEL_LICENSE_WARNING "model-license-exp-warn"
public class Snsr {
  public final static String MODEL_LICENSE_WARNING = "model-license-exp-warn";
}

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-license-exp-date, model-license-exp-message

model-name

runtime string read-write

#define SNSR_MODEL_NAME "model-name"
public class Snsr {
  public final static String MODEL_NAME = "model-name";
}

Source model name.

The name of the model file used to create:

This value is included in the comment header of the generated code, for information only.

model:ids

runtime string read-write

#define SNSR_PREPARE_SUBSET_INIT "model:ids"
public class Snsr {
  public final static String PREPARE_SUBSET_INIT = "model:ids";
}

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);

load, save, SUBSET_INIT

nlu-grammar-stream.

runtime input stream write-only tnl stt

#define SNSR_NLU_GRAMMAR_STREAM "nlu-grammar-stream."
public class Snsr {
  public final static String NLU_GRAMMAR_STREAM = "nlu-grammar-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.

grammar-stream, ^nlu-intent, ^nlu-slot

phrases-stream.

runtime input stream write-only tnl

#define SNSR_PHRASES_STREAM "phrases-stream."
public class Snsr {
  public final static String PHRASES_STREAM = "phrases-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.

Stream, grammar-stream

prune:enable

runtime string read-write 7.5.0

#define SNSR_PRUNE_SETTINGS "prune:enable"
public class Snsr {
  public final static String PRUNE_SETTINGS = "prune:enable";
}

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.

load, save

re-adapt

runtime int write-only

#define SNSR_RE_ADAPT "re-adapt"
public class Snsr {
  public final static String RE_ADAPT = "re-adapt";
}

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.

^adapted

rename-user

runtime string write-only

#define SNSR_RENAME_USER "rename-user"
public class Snsr {
  public final static String RENAME_USER = "rename-user";
}

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");

^adapted, ^new-user

skip-to-ms

runtime int write-only

#define SNSR_SKIP_TO_MS "skip-to-ms"
public class Snsr {
  public final static String SKIP_TO_MS = "skip-to-ms";
}

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

skip-to-sample

runtime int write-only

#define SNSR_SKIP_TO_SAMPLE "skip-to-sample"
public class Snsr {
  public final static String SKIP_TO_SAMPLE = "skip-to-sample";
}

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.

skip-to-ms

tag-identifier

runtime string read-write

#define SNSR_TAG_IDENTIFIER "tag-identifier"
public class Snsr {
  public final static String TAG_IDENTIFIER = "tag-identifier";
}

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_]*