Skip to content

Commit

Permalink
[Add] variable for hotword id
Browse files Browse the repository at this point in the history
  • Loading branch information
CoorFun committed Nov 7, 2018
1 parent 0de9033 commit c354e60
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 3 deletions.
32 changes: 30 additions & 2 deletions snips/core/class/snips.class.php
Expand Up @@ -136,6 +136,7 @@ function mqttClient()
}
$client->subscribe('hermes/dialogueManager/sessionStarted', 0);
$client->subscribe('hermes/dialogueManager/sessionEnded', 0);
$client->subscribe('hermes/hotword/default/detected', 0);
$client->loopForever();
}

Expand Down Expand Up @@ -208,6 +209,14 @@ function message($_message)
snips::debug(__FUNCTION__, 'Set '.$var->getValue().' => snipsMsgSession');
}
}
if ($_message->topic == 'hermes/hotword/default/detected'){
$var = dataStore::byTypeLinkIdKey('scenario', -1, 'snipsMsgHotwordId');
if (is_object($var)) {
$var->setValue($payload->{'modelId'});
$var->save();
snips::debug(__FUNCTION__, 'Set '.$var->getValue().' => snipsMsgHotwordId');
}
}
if (in_array($_message->topic, $topics) == false) {
return;
}
Expand Down Expand Up @@ -855,8 +864,8 @@ function executeCallbackScenario($_parameters, $_slots_values_org, $_payload){
if (is_string($execution_return_msg) &&
$execution_return_msg!='' &&
config::byKey('dynamicSnipsTTS', 'snips', 0)) {
snips::playTTS('#[Snips-Intents][Snips-TTS-'.$_payload->{'siteId'}.'][say]#', $execution_return_msg);

snips::playTTS('#[Snips-Intents][Snips-TTS-'.$_payload->{'siteId'}.'][say]#', $execution_return_msg, $_payload->{'sessionId'});
}
return $execution_return_msg;
}
Expand Down Expand Up @@ -1173,6 +1182,25 @@ function postConfiguration(){
$var->setLink_id(-1);
$var->save();
}

if(!config::byKey('isVarMsgHotwordId', 'snips', 0)){
$var = dataStore::byTypeLinkIdKey('scenario', -1, 'snipsMsgHotwordId');
if (is_object($var)) {
$var->remove();
}
snips::debug(__FUNCTION__, 'Removed variable snipsMsgHotwordId');
}else{
$var = dataStore::byTypeLinkIdKey('scenario', -1, 'snipsMsgHotwordId');
if (!is_object($var)) {
$var = new dataStore();
$var->setKey('snipsMsgHotwordId');
snips::debug(__FUNCTION__, 'Created variable snipsMsgHotwordId');
}
$var->setValue('');
$var->setType('scenario');
$var->setLink_id(-1);
$var->save();
}
}

public
Expand Down
3 changes: 2 additions & 1 deletion snips/core/i18n/fr_FR.json
Expand Up @@ -113,6 +113,7 @@
"When selecting a snips tts command in binding configuration with this option checked, the reply tts will be played on the device which received the command.": "Lorsque vous sélectionnez une commande snips tts dans la configuration de liaison avec cette option cochée, les réponses tts seront lues sur le périphérique qui a reçu la commande.",
"Multi-dialog conversation": "conversation à dialogue multiple",
"Updated when a session is started and ended.": "Mis à jour lorsqu'une session est démarrée et terminée.",
"Assigned with snips device id which received the command when triggered.": "Attribué avec l'identifiant de périphérique snips qui a reçu la commande lorsqu'il est déclenché."
"Assigned with snips device id which received the command when triggered.": "Attribué avec l'identifiant de périphérique snips qui a reçu la commande lorsqu'il est déclenché.",
"Assigned with detected hotword model id when triggered.": "Attribué avec l'ID de modèle de mot faible détecté lorsqu'il est déclenché."
}
}
6 changes: 6 additions & 0 deletions snips/plugin_info/configuration.php
Expand Up @@ -70,6 +70,12 @@ function snips_postSaveConfiguration(){
<input type="checkbox" class="configKey" data-l1key="isVarMsgSiteId"> {{snipsMsgSiteId}}</input>
</div>
<div class="alert alert-info col-lg-3" role="alert"> {{Assigned with snips device id which received the command when triggered.}}</div>

<label class="col-lg-4 control-label" ></label>
<div class="col-lg-4">
<input type="checkbox" class="configKey" data-l1key="isVarMsgHotwordId"> {{snipsMsgHotwordId}}</input>
</div>
<div class="alert alert-info col-lg-3" role="alert"> {{Assigned with detected hotword model id when triggered.}}</div>
</div>

<!-- <div class="form-group">
Expand Down
3 changes: 3 additions & 0 deletions snips/plugin_info/install.php
Expand Up @@ -40,6 +40,7 @@ function snips_install() {

config::save('isVarMsgSession',0,'snips');
config::save('isVarMsgSiteId',0,'snips');
config::save('isVarMsgHotwordId',0,'snips');
}

function snips_update() {
Expand All @@ -59,6 +60,8 @@ function snips_update() {
config::save('isVarMsgSession',0,'snips');
if (config::byKey('isVarMsgSiteId', 'snips', "NULL") == "NULL")
config::save('isVarMsgSiteId',0,'snips');
if (config::byKey('isVarMsgHotwordId', 'snips', "NULL") == "NULL")
config::save('isVarMsgHotwordId',0,'snips');
}

function snips_remove() {
Expand Down

0 comments on commit c354e60

Please sign in to comment.