From fce40a47ce9ca8aed4e1029489ff8608f167b48c Mon Sep 17 00:00:00 2001 From: akirilyuk Date: Thu, 3 Feb 2022 19:14:37 +0100 Subject: [PATCH] try a different approach --- lib/tasks/cognigy/index.js | 7 +++---- lib/tasks/gather.js | 12 +++++++----- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/lib/tasks/cognigy/index.js b/lib/tasks/cognigy/index.js index c4d3aabc..5a77e679 100644 --- a/lib/tasks/cognigy/index.js +++ b/lib/tasks/cognigy/index.js @@ -305,8 +305,8 @@ class Cognigy extends Task { this.logger.info({text}, 'received text'); this._enqueueTask(async() => { // todo inject the session config into the say task - const sayTask = this._createPromtTask({ text, dontListenAfterSpeech: true }); - await sayTask.exec(cs, ep, this); + const promtTask = this._createPromtTask({ text, dontListenAfterSpeech: true }); + await promtTask.exec(cs, ep, this); this.logger.debug({text}, 'executed say task'); }); } @@ -369,11 +369,10 @@ 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.skipUntilBotInput) { + if (this.config.bargeInEnabled && this.config.skipUntilBotInput) { // clear task queue, resolve the last promise and cleanup; this.taskQueue.lastPromise.resolve(); this.taskQueue.end(); - //this._killSayTasks(); this.taskQueue.autostart = true; } diff --git a/lib/tasks/gather.js b/lib/tasks/gather.js index aceb5d02..94588157 100644 --- a/lib/tasks/gather.js +++ b/lib/tasks/gather.js @@ -104,10 +104,12 @@ class TaskGather extends Task { this.sayTask.on('playDone', async(err) => { if (err) return this.logger.error({err}, 'Gather:exec Error playing tts'); this.logger.debug('Gather: say task completed'); - if (!this.killed) { - if(this.listenAfterSpeech){ - startListening(cs, ep); - } + if (!this.killed) { + if (this.listenAfterSpeech) { + startListening(cs, ep); + } else { + this.notifyTaskDone(); + } } }); } @@ -116,7 +118,7 @@ class TaskGather extends Task { this.playTask.on('playDone', async(err) => { if (err) return this.logger.error({err}, 'Gather:exec Error playing url'); if (!this.killed) { - startListening(cs, ep); + startListening(cs, ep); }} ); }