diff --git a/lib/tasks/config.js b/lib/tasks/config.js index d2182188..7478b52d 100644 --- a/lib/tasks/config.js +++ b/lib/tasks/config.js @@ -101,7 +101,7 @@ class TaskConfig extends Task { cs.disableBotMode(); } } - if (this.record) cs.notifyRecordOptions(this.record); + if (this.record.action) cs.notifyRecordOptions(this.record); } async kill(cs) { diff --git a/lib/tasks/gather.js b/lib/tasks/gather.js index ccd679ad..9d02b1f7 100644 --- a/lib/tasks/gather.js +++ b/lib/tasks/gather.js @@ -251,7 +251,8 @@ class TaskGather extends Task { this.logger.info(`continuousAsr triggered with dtmf ${this.asrDtmfTerminationDigit}`); this._clearAsrTimer(); this._clearTimer(); - this._resolve(this._bufferedTranscripts.length > 0 ? 'speech' : 'timeout'); + this._startFinalAsrTimer(); + return; } if (!resolved && this.interDigitTimeout > 0 && this.digitBuffer.length >= this.minDigits) { /* start interDigitTimer */ @@ -403,6 +404,20 @@ class TaskGather extends Task { this._asrTimer = null; } + _startFinalAsrTimer() { + this._clearFinalAsrTimer(); + this._finalAsrTimer = setTimeout(() => { + this.logger.debug('_startFinalAsrTimer - final asr timer went off'); + this._resolve(this._bufferedTranscripts.length > 0 ? 'speech' : 'timeout'); + }, 1000); + this.logger.debug('_startFinalAsrTimer: set for 1 second'); + } + + _clearFinalAsrTimer() { + if (this._finalAsrTimer) clearTimeout(this._finalAsrTimer); + this._finalAsrTimer = null; + } + _killAudio(cs) { if (!this.sayTask && !this.playTask && this.bargein) { if (this.ep?.connected && !this.playComplete) { @@ -466,6 +481,10 @@ class TaskGather extends Task { this.logger.info({evt}, 'TaskGather:_onTranscription - got transcript during continous asr'); this._bufferedTranscripts.push(evt); this._clearTimer(); + if (this._finalAsrTimer) { + this._clearFinalAsrTimer(); + return this._resolve(this._bufferedTranscripts.length > 0 ? 'speech' : 'timeout'); + } this._startAsrTimer(); return this._startTranscribing(ep); }