make barge in disableable

This commit is contained in:
akirilyuk
2022-02-04 08:05:11 +01:00
parent 91108fa3ef
commit 3a791a67b5
2 changed files with 22 additions and 27 deletions

View File

@@ -16,14 +16,23 @@ class SpeechConfig extends Emitter {
this.update(opts);
}
update(session) {
// TODO validation of session params?
if (session) {
this.sessionConfig = lodash.merge(
_mergeConfig(changedConfig = {}){
const merged = lodash.merge(
{},
this.sessionConfig,
session
);
merged.bargein.enable = changedConfig.bargein?.enable?.length === 0 ? [] : changedConfig.bargein?.enable;
// should we override hints with empty array or leave it as it is once saved?
// merged.recognizer.hints = changedConfig.recognizer?.hints
}
update(session) {
// TODO validation of session params?
if (session) {
this.sessionConfig = this._mergeConfig(session);
}
this.logger.debug({sessionLevel: this.sessionConfig}, 'SpeechConfig updated');
}
@@ -49,24 +58,10 @@ class SpeechConfig extends Emitter {
};
}
makeGatherTaskConfig({textPrompt, urlPrompt, turnConfig = {}, dontListenAfterSpeech} = {}) {
makeGatherTaskConfig({textPrompt, urlPrompt, turnConfig = {}, listenAfterSpeech} = {}) {
// we merge from top to bottom deeply so we wil have
// defaults from session config and then will override them via turn config
const opts = lodash.merge(
{},
this.sessionConfig || {}, // this should not be undefined ever
turnConfig
);
/*
const nextTurnKeys = Object.keys(this.turnConfig || {});
const newKeys = nextTurnKeys.filter((k) => !(k in opts));
const bothKeys = nextTurnKeys.filter((k) => k in opts);
for (const key of newKeys) opts[key] = this.turnConfig[key];
for (const key of bothKeys) opts[key] = {...opts[key], ...this.turnConfig[key]};
*/
const opts = this._mergeConfig(turnConfig);
this.logger.debug({
opts,
@@ -126,7 +121,7 @@ class SpeechConfig extends Emitter {
noInputSpeech,
noInputUrl
},
listenAfterSpeech: !dontListenAfterSpeech
listenAfterSpeech
};
const final = stripNulls(config);