Skip to content

Trigger sonus manually

Compare
Choose a tag to compare
@evancohen evancohen released this 27 Dec 20:42
· 60 commits to master since this release

Trigger keyword/hotword manually

You can manuall trigger a hotword by passing your initialized sonus object and an index into Sonus.trigger

The indexes of your hotwords are base 1 and are deturmined by the order in which the hotwords are passed into Sonus.init

Exceptions

  • NOT_STARTED - will be thrown if you have not started sonus when this is called.
  • INVALID_INDEX - will be thrown if you pass an invalid index.

Example:

Sonus.trigger(sonus, 1)

sonus will be triggered with a hotword index of 1

You can also optionally specify an index of 0 and an arbitrary hotword that will be returned in the hotword event
Example:

sonus.trigger(sonus, 0, 'some hotword')

sonus will be triggered with a hotword index of 1 and a hotword of some hotword

Passing a hotword with a valid index will override the hotword name and trigger that hotword
Example:

sonus.trigger(sonus, 1, 'override')