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

@@ -189,18 +189,18 @@ class Cognigy extends Task {
* Creates a promt which will be sent to the consumer. We will create a say task if bargein is disabled
* for session and nextTurn, else create a gather task.
*/
_createPromtTask({text, url, turnConfig, dontListenAfterSpeech} = {}) {
_createPromtTask({text, url, turnConfig, listenAfterSpeech} = {}) {
const bargeInOnNextTurn = turnConfig?.bargein?.enable?.length > 0;
const bargeInSession = this.config.bargeInEnabled;
if (bargeInOnNextTurn || bargeInSession) {
return this._makeGatherTask({textPrompt: text, url, turnConfig, dontListenAfterSpeech});
return this._makeGatherTask({textPrompt: text, url, turnConfig, listenAfterSpeech});
}
return this._makeSayTask({text, turnConfig});
}
_makeGatherTask({textPrompt, urlPrompt, turnConfig} = {}) {
_makeGatherTask({textPrompt, urlPrompt, turnConfig, listenAfterSpeech} = {}) {
this.logger.debug({textPrompt, urlPrompt, turnConfig}, '_makeGatherTask');
const config = this.config.makeGatherTaskConfig({textPrompt, urlPrompt, turnConfig});
const config = this.config.makeGatherTaskConfig({textPrompt, urlPrompt, turnConfig, listenAfterSpeech});
const {retry, ...rest} = config;
this.retry = retry;
const gather = makeTask(this.logger, {gather: rest}, this);
@@ -305,7 +305,7 @@ class Cognigy extends Task {
this.logger.info({text}, 'received text');
this._enqueueTask(async() => {
// todo inject the session config into the say task
const promtTask = this._createPromtTask({ text, dontListenAfterSpeech: true });
const promtTask = this._createPromtTask({ text, listenAfterSpeech: false });
await promtTask.exec(cs, ep, this);
this.logger.debug({text}, 'executed say task');
});
@@ -369,7 +369,7 @@ class Cognigy extends Task {
//then stop execution of currently queues bot output before sending the
//response to waiting bot since otherwise we could stop upcoming bot output
if (this.config.bargeInEnabled && this.config.skipUntilBotInput) {
if (this.config.bargeInEnabled && this.config.skipToBotOutputEnd !== false) {
// clear task queue, resolve the last promise and cleanup;
this.taskQueue.lastPromise.resolve();
this.taskQueue.end();