diff --git a/lib/tasks/gather.js b/lib/tasks/gather.js index 8db6eae2..d710be91 100644 --- a/lib/tasks/gather.js +++ b/lib/tasks/gather.js @@ -342,6 +342,13 @@ class TaskGather extends SttTask { this._killAudio(cs); this.emit('dtmf', evt); } + if (this.isContinuousAsr && evt.dtmf === this.asrDtmfTerminationDigit && this._bufferedTranscripts.length > 0) { + this.logger.info(`continuousAsr triggered with dtmf ${this.asrDtmfTerminationDigit}`); + this._clearAsrTimer(); + this._clearTimer(); + this._startFinalAsrTimer(); + return; + } if (evt.dtmf === this.finishOnKey && this.input.includes('digits')) { resolved = true; this._resolve('dtmf-terminator-key'); @@ -364,13 +371,6 @@ class TaskGather extends SttTask { this._resolve('dtmf-num-digits'); } } - else if (this.isContinuousAsr && evt.dtmf === this.asrDtmfTerminationDigit) { - this.logger.info(`continuousAsr triggered with dtmf ${this.asrDtmfTerminationDigit}`); - this._clearAsrTimer(); - this._clearTimer(); - this._startFinalAsrTimer(); - return; - } if (!resolved && this.interDigitTimeout > 0 && this.digitBuffer.length >= this.minDigits) { /* start interDigitTimer */ const ms = this.interDigitTimeout * 1000;