From f0533c881be16eb86a1f2a741238da153a19fb56 Mon Sep 17 00:00:00 2001 From: Dave Horton Date: Mon, 12 Feb 2024 12:32:43 -0500 Subject: [PATCH] =?UTF-8?q?deepgram=20gather:=20if=20both=20endpointing=20?= =?UTF-8?q?and=20utterance=5Fend=5Fms=20are=20set=20(bu=E2=80=A6=20(#644)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * deepgram gather: if both endpointing and utterance_end_ms are set (but not continous asr) return either when we get speech_final or UtteranceEnd. This is the belt-and-suspenders apprach deepgram is recommending * include verb id in action hook if one was provided in the verb set * minor --- lib/tasks/gather.js | 11 +---------- lib/tasks/task.js | 1 + 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/lib/tasks/gather.js b/lib/tasks/gather.js index daf15ffe..ffed44d9 100644 --- a/lib/tasks/gather.js +++ b/lib/tasks/gather.js @@ -355,9 +355,6 @@ class TaskGather extends SttTask { this.addCustomEventListener(ep, DeepgramTranscriptionEvents.Connect, this._onVendorConnect.bind(this, cs, ep)); this.addCustomEventListener(ep, DeepgramTranscriptionEvents.ConnectFailure, this._onVendorConnectFailure.bind(this, cs, ep)); - - /* if app sets deepgramOptions.utteranceEndMs they essentially want continuous asr */ - if (opts.DEEPGRAM_SPEECH_UTTERANCE_END_MS) this.isContinuousAsr = true; break; case 'soniox': @@ -676,7 +673,7 @@ class TaskGather extends SttTask { this.logger.debug({evt, words, bufferedWords}, 'TaskGather:_onTranscription - final transcript but < min barge words'); this._bufferedTranscripts.push(evt); - this._startTranscribing(ep); + if (!['soniox', 'aws', 'microsoft', 'deepgram'].includes(this.vendor)) this._startTranscribing(ep); return; } else { @@ -689,17 +686,11 @@ class TaskGather extends SttTask { else if (this.vendor === 'deepgram') { /* compile transcripts into one */ if (!emptyTranscript) this._bufferedTranscripts.push(evt); - if (this.data.recognizer?.deepgramOptions?.utteranceEndMs) { - this.logger.debug('TaskGather:_onTranscription - got speech_final waiting for UtteranceEnd event'); - return; - } /* deepgram can send an empty and final transcript; only if we have any buffered should we resolve */ if (this._bufferedTranscripts.length === 0) return; - this.logger.debug({evt}, 'TaskGather:_onTranscription - compiling deepgram transcripts'); evt = this.consolidateTranscripts(this._bufferedTranscripts, 1, this.language); this._bufferedTranscripts = []; - this.logger.debug({evt}, 'TaskGather:_onTranscription - compiled deepgram transcripts'); } /* here is where we return a final transcript */ diff --git a/lib/tasks/task.js b/lib/tasks/task.js index 139f2bf2..15877d04 100644 --- a/lib/tasks/task.js +++ b/lib/tasks/task.js @@ -160,6 +160,7 @@ class Task extends Emitter { const httpHeaders = b3 && {b3}; span.setAttributes({'http.body': JSON.stringify(params)}); try { + if (this.id) params.verb_id = this.id; const json = await this.cs.requestor.request(type, this.actionHook, params, httpHeaders); span.setAttributes({'http.statusCode': 200}); const isWsConnection = this.cs.requestor instanceof WsRequestor;