From a8646548cd81ce5d8ef12a347829cbcf2a11620e Mon Sep 17 00:00:00 2001 From: Dave Horton Date: Thu, 31 Mar 2022 14:18:09 -0400 Subject: [PATCH] bugfix: vad was not enabled on config verb, restart STT on empty transcript in gather --- lib/session/call-session.js | 1 - lib/tasks/config.js | 1 + lib/tasks/gather.js | 9 ++++++++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/session/call-session.js b/lib/session/call-session.js index bec86df3..b679590f 100644 --- a/lib/session/call-session.js +++ b/lib/session/call-session.js @@ -236,7 +236,6 @@ class CallSession extends Emitter { async enableBotMode(gather, autoEnable) { try { - gather.timeout = 0; // background gathers should not timeout const t = normalizeJambones(this.logger, [gather]); this.backgroundGatherTask = makeTask(this.logger, t[0]); this.backgroundGatherTask diff --git a/lib/tasks/config.js b/lib/tasks/config.js index cdf18f3f..79becf9e 100644 --- a/lib/tasks/config.js +++ b/lib/tasks/config.js @@ -75,6 +75,7 @@ class TaskConfig extends Task { cs.speechRecognizerLanguage = this.recognizer.language !== 'default' ? this.recognizer.language : cs.speechRecognizerLanguage; + this.gatherOpts.recognizer = this.recognizer; this.logger.info({recognizer: this.recognizer}, 'Config: updated recognizer'); } if (this.hasBargeIn) { diff --git a/lib/tasks/gather.js b/lib/tasks/gather.js index 1cee2f5c..79cc44d2 100644 --- a/lib/tasks/gather.js +++ b/lib/tasks/gather.js @@ -283,6 +283,7 @@ class TaskGather extends Task { if (this.profanityOption && this.profanityOption !== 'raw') opts.AZURE_PROFANITY_OPTION = this.profanityOption; if (this.azureServiceEndpoint) opts.AZURE_SERVICE_ENDPOINT = this.azureServiceEndpoint; if (this.initialSpeechTimeoutMs > 0) opts.AZURE_INITIAL_SPEECH_TIMEOUT_MS = this.initialSpeechTimeoutMs; + else if (this.timeout === 0) opts.AZURE_INITIAL_SPEECH_TIMEOUT_MS = 120000; // lengthy opts.AZURE_USE_OUTPUT_FORMAT_DETAILED = 1; ep.addCustomEventListener(AzureTranscriptionEvents.Transcription, this._onTranscription.bind(this, cs, ep)); @@ -382,7 +383,13 @@ class TaskGather extends Task { }; } } - if (evt.is_final) this._resolve('speech', evt); + if (evt.is_final) { + if (evt.alternatives[0].transcript === '') { + this.logger.info({evt}, 'TaskGather:_onTranscription - got empty transcript, listen again'); + this._startTranscribing(ep); + } + this._resolve('speech', evt); + } else { /* google has a measure of stability: https://cloud.google.com/speech-to-text/docs/basics#streaming_responses