diff --git a/lib/tasks/gather.js b/lib/tasks/gather.js index 65e882eb..befd0bba 100644 --- a/lib/tasks/gather.js +++ b/lib/tasks/gather.js @@ -534,7 +534,7 @@ class TaskGather extends SttTask { this._clearAsrTimer(); this._asrTimer = setTimeout(() => { this.logger.debug('_startAsrTimer - asr timer went off'); - const evt = this.consolidateTranscripts(this._bufferedTranscripts, 1, this.language); + const evt = this.consolidateTranscripts(this._bufferedTranscripts, 1, this.language, this.vendor); this._resolve(this._bufferedTranscripts.length > 0 ? 'speech' : 'timeout', evt); }, this.asrTimeout); this.logger.debug(`_startAsrTimer: set for ${this.asrTimeout}ms`); @@ -663,7 +663,7 @@ class TaskGather extends SttTask { this._clearFinalAsrTimer(); this._finalAsrTimer = setTimeout(() => { this.logger.debug('_startFinalAsrTimer - final asr timer went off'); - const evt = this.consolidateTranscripts(this._bufferedTranscripts, 1, this.language); + const evt = this.consolidateTranscripts(this._bufferedTranscripts, 1, this.language, this.vendor); this._resolve(this._bufferedTranscripts.length > 0 ? 'speech' : 'timeout', evt); }, 1000); this.logger.debug('_startFinalAsrTimer: set for 1 second'); @@ -712,7 +712,7 @@ class TaskGather extends SttTask { } else { this.logger.debug('Gather:_onTranscription - got UtteranceEnd event from deepgram, return buffered transcript'); - evt = this.consolidateTranscripts(this._bufferedTranscripts, 1, this.language); + evt = this.consolidateTranscripts(this._bufferedTranscripts, 1, this.language, this.vendor); this._bufferedTranscripts = []; this._resolve('speech', evt); } @@ -782,7 +782,7 @@ class TaskGather extends SttTask { this._clearTimer(); if (this._finalAsrTimer) { this._clearFinalAsrTimer(); - const evt = this.consolidateTranscripts(this._bufferedTranscripts, 1, this.language); + const evt = this.consolidateTranscripts(this._bufferedTranscripts, 1, this.language, this.vendor); return this._resolve(this._bufferedTranscripts.length > 0 ? 'speech' : 'timeout', evt); } this._startAsrTimer(); @@ -811,7 +811,7 @@ class TaskGather extends SttTask { /* deepgram can send an empty and final transcript; only if we have any buffered should we resolve */ if (this._bufferedTranscripts.length === 0) return; - evt = this.consolidateTranscripts(this._bufferedTranscripts, 1, this.language); + evt = this.consolidateTranscripts(this._bufferedTranscripts, 1, this.language, this.vendor); this._bufferedTranscripts = []; } diff --git a/lib/tasks/transcribe.js b/lib/tasks/transcribe.js index 5f632aef..32059980 100644 --- a/lib/tasks/transcribe.js +++ b/lib/tasks/transcribe.js @@ -318,7 +318,7 @@ class TaskTranscribe extends SttTask { } else { this.logger.debug('Gather:_onTranscription - got UtteranceEnd event from deepgram, return buffered transcript'); - evt = this.consolidateTranscripts(this._bufferedTranscripts, 1, this.language); + evt = this.consolidateTranscripts(this._bufferedTranscripts, 1, this.language, this.vendor); this._bufferedTranscripts = []; this._resolve('speech', evt); } @@ -511,7 +511,7 @@ class TaskTranscribe extends SttTask { this._clearAsrTimer(channel); this._asrTimer = setTimeout(() => { this.logger.debug(`TaskTranscribe:_startAsrTimer - asr timer went off for channel: ${channel}`); - const evt = this.consolidateTranscripts(this._bufferedTranscripts, channel, this.language); + const evt = this.consolidateTranscripts(this._bufferedTranscripts, channel, this.language, this.vendor); this._bufferedTranscripts = []; this._resolve(channel, evt); }, this.asrTimeout); diff --git a/lib/utils/transcription-utils.js b/lib/utils/transcription-utils.js index c4ebda33..eea61d59 100644 --- a/lib/utils/transcription-utils.js +++ b/lib/utils/transcription-utils.js @@ -150,7 +150,7 @@ const selectDefaultDeepgramModel = (task, language) => { return 'base'; }; -const consolidateTranscripts = (bufferedTranscripts, channel, language) => { +const consolidateTranscripts = (bufferedTranscripts, channel, language, vendor) => { if (bufferedTranscripts.length === 1) return bufferedTranscripts[0]; let totalConfidence = 0; const finalTranscript = bufferedTranscripts.reduce((acc, evt) => { @@ -191,7 +191,7 @@ const consolidateTranscripts = (bufferedTranscripts, channel, language) => { totalConfidence / bufferedTranscripts.length; finalTranscript.alternatives[0].transcript = finalTranscript.alternatives[0].transcript.trim(); finalTranscript.vendor = { - name: 'deepgram', + name: vendor, evt: bufferedTranscripts }; return finalTranscript;