---
source_path: "models/tpl/tpl-spot-select.md"
canonical_url: "https://doc.sensory.com/tnl/7.8/models/tpl/tpl-spot-select/"
---

# tpl-spot-select

This [template](https://doc.sensory.com/tnl/7.8/models/tpl/index.md#template-type) allows you to dynamically select which of the
two embedded [wake word](https://doc.sensory.com/tnl/7.8/models/types/wake-word.md#wake-word-type) models to run.

`tpl-spot-select` has [task-type](https://doc.sensory.com/tnl/7.8/api/setting-keys/configuration.md#task-type)` == `[phrasespot](https://doc.sensory.com/tnl/7.8/api/setting-keys/values.md#phrasespot).

Expected [task types](https://doc.sensory.com/tnl/7.8/api/setting-keys/configuration.md#task-type):

* **Slot 0:** [phrasespot](https://doc.sensory.com/tnl/7.8/api/setting-keys/values.md#phrasespot)
* **Slot 1:** [phrasespot](https://doc.sensory.com/tnl/7.8/api/setting-keys/values.md#phrasespot)

**Also see these related items:** [tpl-spot-select-1.4.0.snsr](https://doc.sensory.com/tnl/7.8/models/index.md#tpl-spot-select)

## Operation

```mermaid
flowchart TD
    start((start))
    fetch[/samples from ->audio-pcm/]
    audio(^sample-count)
    join@{ shape: f-circ }

    start --> fetch
    fetch --> audio
    audio -->|slot == 0| start0
    audio -->|slot == 1| start1

    end0 --> join
    end1 --> join
    join ----> fetch

    subgraph slot0[<b>slot 0</b> &lpar;phrasespot&rpar;]
      start0((start))
      process0[process]
      result0(^result)
      end0((stop))
      start0 --> process0
      process0 --> end0
      process0 -->|recognize| result0
      result0 --> end0
    end

    subgraph slot1[<b>slot 1</b> &lpar;phrasespot&rpar;]
      start1((start))
      process1[process]
      result1(^result)
      end1((stop))
      start1 --> process1
      process1 --> end1
      process1 -->|recognize| result1
      result1 --> end1
    end
```

Operation flow.

1. Read audio data from [->audio-pcm](https://doc.sensory.com/tnl/7.8/api/setting-keys/runtime.md#-audio-pcm).
2. Invoke [^sample-count](https://doc.sensory.com/tnl/7.8/api/setting-keys/events.md#sample-count-event).
3. Send audio to the recognizer specified by [slot](https://doc.sensory.com/tnl/7.8/api/setting-keys/configuration.md#slot).
5. Invoke [^result](https://doc.sensory.com/tnl/7.8/api/setting-keys/events.md#result) if processing detects a vocabulary phrase.
6. Continue processing until [STREAM_END](https://doc.sensory.com/tnl/7.8/api/inference.md#rc_stream_end) occurs on [->audio-pcm](https://doc.sensory.com/tnl/7.8/api/setting-keys/runtime.md#-audio-pcm),
   or one of the event handlers returns a code other than [OK](https://doc.sensory.com/tnl/7.8/api/inference.md#rc_ok).

Register callback handlers with [setHandler](https://doc.sensory.com/tnl/7.8/api/inference.md#sethandler) only for those events you're interested in.

## Settings

**Available events:** [^adapt-started](https://doc.sensory.com/tnl/7.8/api/setting-keys/events.md#adapt-started), [^adapted](https://doc.sensory.com/tnl/7.8/api/setting-keys/events.md#adapted), [^new-user](https://doc.sensory.com/tnl/7.8/api/setting-keys/events.md#new-user), [^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), [^sample-count](https://doc.sensory.com/tnl/7.8/api/setting-keys/events.md#sample-count-event)

**Available iterators:** _none_

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

**Available runtime settings:** [->audio-pcm](https://doc.sensory.com/tnl/7.8/api/setting-keys/runtime.md#-audio-pcm), [audio-stream-from](https://doc.sensory.com/tnl/7.8/api/setting-keys/runtime.md#audio-stream-from), [audio-stream-to](https://doc.sensory.com/tnl/7.8/api/setting-keys/runtime.md#audio-stream-to), [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)

**Available configuration settings:** [0](https://doc.sensory.com/tnl/7.8/api/setting-keys/configuration.md#0), [1](https://doc.sensory.com/tnl/7.8/api/setting-keys/configuration.md#1), [audio-stream-size](https://doc.sensory.com/tnl/7.8/api/setting-keys/configuration.md#audio-stream-size), [samples-per-second](https://doc.sensory.com/tnl/7.8/api/setting-keys/configuration.md#samples-per-second), [slot](https://doc.sensory.com/tnl/7.8/api/setting-keys/configuration.md#slot)

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

**Also see these related items:** [live-spot.c](https://doc.sensory.com/tnl/7.8/api/sample/c/live-spot.md#live-spot-code), [snsr-eval.c](https://doc.sensory.com/tnl/7.8/api/sample/c/snsr-eval.md#snsr-eval-code), [PhraseSpot.java](https://doc.sensory.com/tnl/7.8/api/sample/android/enroll-trigger.md#et-code), [segmentSpottedAudio.java](https://doc.sensory.com/tnl/7.8/api/sample/java/segmentSpottedAudio.md#segmentspottedaudio-code)

## Notes

Use [slot](https://doc.sensory.com/tnl/7.8/api/setting-keys/configuration.md#slot) to select either the spotter in slot [0](https://doc.sensory.com/tnl/7.8/api/setting-keys/configuration.md#0) or slot [1](https://doc.sensory.com/tnl/7.8/api/setting-keys/configuration.md#1).

Use this template to reduce the model size when an application uses variants
of the same recognizer in different contexts. This reduces the overall model
size and RAM requirements as identical objects are shared between the slots.

The combined model is a [wake word](https://doc.sensory.com/tnl/7.8/models/types/wake-word.md#wake-word-type), and can be used
in any application that expects such a model without API changes.

Configuration settings and iterators are not available in the
combined model. You can access these for the individual models
by prefixing the setting path with the slot. For example,
use `1.operating-point` to read or change the [operating-point](https://doc.sensory.com/tnl/7.8/api/setting-keys/configuration.md#operating-point)
of the second spotter.

Change individual settings at runtime by prefixing the
setting name with the slot:
<!-- tab: c -->

**C/C++**

```c
/* Set the operating point for spotter 0 only. */
snsrSetInt(session, SNSR_SLOT_0 SNSR_OPERATING_POINT, 7);
```
<!-- /tab -->

<!-- tab: java -->

**Java**

```java
/* Set the operating point for spotter 0 only. */
session.setInt(Snsr.SLOT_0 + Snsr.OPERATING_POINT, 7);
```
<!-- /tab -->

<!-- tab: py -->

**Python**

```python
# Set the operating point for spotter 0 only.
session.set_int(snsr.SLOT_0 + snsr.OPERATING_POINT, 7)
```
<!-- /tab -->

## Examples

```console
% cd $HOME/Sensory/TrulyNaturalSDK/7.9.0-pre.0

% bin/snsr-edit -o vg-hbg-select.snsr\
    -t model/tpl-spot-select-1.4.0.snsr\
    -f 0 model/spot-voicegenie-enUS-6.5.1-m.snsr\
    -f 1 model/spot-hbg-enUS-1.4.0-m.snsr

# repeat "hello blue genie" and "voice genie"
% bin/snsr-eval -t vg-hbg-select.snsr -s slot=0
  3480   4140 voicegenie
  9945  10545 voicegenie
^C

# repeat "hello blue genie" and "voice genie"
% bin/snsr-eval -t vg-hbg-select.snsr -s slot=1
  1635   2460 hello blue genie
  6210   6870 hello blue genie
^C
```

<!-- Abbreviation definitions from includes/abbreviations.md -->
*[API]: Application Programming Interface
*[RAM]: Random Access Memory
*[TNL]: TrulyNatural, Sensory's large-vocabulary speech recognition technology
