From 2fc3febcf6f482dde89c70698260097ad8d03f8e Mon Sep 17 00:00:00 2001 From: akirilyuk Date: Thu, 3 Feb 2022 18:42:03 +0100 Subject: [PATCH] kill only after 2s --- lib/tasks/gather.js | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/lib/tasks/gather.js b/lib/tasks/gather.js index 39e22547..e9c84ce2 100644 --- a/lib/tasks/gather.js +++ b/lib/tasks/gather.js @@ -100,21 +100,20 @@ class TaskGather extends Task { try { if (this.sayTask) { this.logger.debug('Gather: kicking off say task'); - this.sayTask.exec(cs, ep).then(() => { - this.logger.debug('Gather: completed say task promise'); - if (!this.killed) { - if (this.listenAfterSpeech) { - startListening(cs, ep); - } else { - this.kill(cs); - } - } - return; - }).catch(err => this.logger.error({err}, 'Gather: failed to play say task')); // kicked off, _not_ waiting for it to complete + this.sayTask.exec(cs, ep); 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); + } else { + setTimeout(()=>{ + this.kill(cs); + },2000) + + } + } }); } else if (this.playTask) {