From 29dec240954c85ebde18e837962ecff48a6d0b1e Mon Sep 17 00:00:00 2001 From: Dave Horton Date: Wed, 13 Apr 2022 12:07:30 -0400 Subject: [PATCH] bugfix: azure stt - if we get no speech detected, listen again --- lib/tasks/gather.js | 7 +++++-- lib/utils/ws-requestor.js | 3 +++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/tasks/gather.js b/lib/tasks/gather.js index a5b65f0a..20109ceb 100644 --- a/lib/tasks/gather.js +++ b/lib/tasks/gather.js @@ -385,7 +385,7 @@ class TaskGather extends Task { } } if (evt.is_final) { - if (evt.alternatives[0].transcript === '' && !this.callSession.callGonen && !this.killed) { + if (evt.alternatives[0].transcript === '' && !this.callSession.callGone && !this.killed) { this.logger.info({evt}, 'TaskGather:_onTranscription - got empty transcript, listen again'); return this._startTranscribing(ep); } @@ -433,7 +433,10 @@ class TaskGather extends Task { } _onNoSpeechDetected(cs, ep) { - this._resolve('timeout'); + if (!this.callSession.callGone && !this.killed) { + this.logger.debug('TaskGather:_onNoSpeechDetected - listen again'); + return this._startTranscribing(ep); + } } async _resolve(reason, evt) { diff --git a/lib/utils/ws-requestor.js b/lib/utils/ws-requestor.js index 46f8d0ff..f8f0cdee 100644 --- a/lib/utils/ws-requestor.js +++ b/lib/utils/ws-requestor.js @@ -105,6 +105,7 @@ class WsRequestor extends BaseRequestor { /* save the message info for reply */ const startAt = process.hrtime(); this.messagesInFlight.set(msgid, { + timer, success: (response) => { clearTimeout(timer); const rtt = this._roundTrip(startAt); @@ -135,6 +136,8 @@ class WsRequestor extends BaseRequestor { } for (const [msgid, obj] of this.messagesInFlight) { + const {timer} = obj; + clearTimeout(timer); obj.failure(`abandoning msgid ${msgid} since we have closed the socket`); } this.messagesInFlight.clear();