From c874ab8100a29b7e42c311c12d6046922ec4ee3f Mon Sep 17 00:00:00 2001 From: rammohan-y <37395033+rammohan-y@users.noreply.github.com> Date: Tue, 26 Nov 2024 18:53:11 +0530 Subject: [PATCH] =?UTF-8?q?feat/975:=20fixed=20continuous=20asr=20not=20st?= =?UTF-8?q?opping=20when=20asrDtmfTerminationDi=E2=80=A6=20(#977)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat/975: fixed continuous asr not stopping when asrDtmfTerminationDigit is configured * feat/975: giving first preference to asrDtmfTerminationDigit if there is already ASR happened --- lib/tasks/gather.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) 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;