-
-
Notifications
You must be signed in to change notification settings - Fork 1
3. Control
- payload: {...configs, callback})
3rd party module can activate the detector with a notification HOTWORD_ACTIVATE
.
When the
MMM-Hotword2
is already activating (listening to the user's voice) at that moment, this notification would be ignored. (callback
will be called witherror
)
/* MMM-SomeModule */
this.sendNotification('HOTWORD_ACTIVATE', {
config: {
hotwords: [
{
hotword: 'DO_SOMETHING',
onDetect: () => { ... }
},
{
hotword: 'DO_OTHERTHING',
onDetect: () => { ... }
}
],
restart: false,
sensitivity: 0.6, // You can redefine any configs for this activation.
},
callback: ({ error, result, payload }) => {
// This callback is only once executed when any hotword is detected at first.
// Generally, this callback could be used to check whether the module works at first time.
if (error) ...
},
/* asDetected: 'COMPUTER' */
})
This notification can carry some data objects as parameters of payload
during this active session. It would be used for a dedicated hotword detector for the specific 3rd party module. When the payload is omitted, the default configuration of MMM-Hotword2 will be applied.
3rd party module can reconfigure the behaviour of MMM-Hotword2
with this payload.
The result of activation (error or detection) will execute this callback function.
When this parameter is set as one of hotwords, the voice of the user would be recorded directly without hotword detection. It is used when you need only the voice recording. (When the recording ends, onDetect
of that hotword and callback
will be executed.)
- payload: null
3rd party module can deactivate the detector with this notification. Usually, this will be used to release a mic.
/* MMM-SomeModule */
this.sendNotification('HOTWORD_DEACTIVATE')
- payload: null
3rd party module can know that MMM-Hotword2
is ready to work.
- payload: null
3rd party module can know that MMM-Hotword2
is now deactivated. (the mic is released.)
Usually, your device may have only one mic. So you should carefully manage the mic occupation.