diff --git a/lib/tasks/gather.js b/lib/tasks/gather.js index b3118227..6aaba5fb 100644 --- a/lib/tasks/gather.js +++ b/lib/tasks/gather.js @@ -400,15 +400,22 @@ class TaskGather extends SttTask { break; case 'cobalt': - this.bugname = 'cobalt_speech'; + this.bugname = 'cobalt_transcribe'; ep.addCustomEventListener(CobaltTranscriptionEvents.Transcription, this._onTranscription.bind(this, cs, ep)); + /* cobalt doesnt have language, it has model, which is required */ + if (!this.data.recognizer.model) { + throw new Error('Cobalt requires a model to be specified'); + } + this.language = this.data.recognizer.model; + /* special case: if using hints with cobalt we need to compile them */ + this.hostport = opts.COBALT_SERVER_URI; if (this.vendor === 'cobalt' && opts.COBALT_SPEECH_HINTS) { try { const context = await this.compileHintsForCobalt( ep, - opts.COBALT_SERVER_URI, + this.hostport, this.data.recognizer.model, opts.COBALT_CONTEXT_TOKEN, opts.COBALT_SPEECH_HINTS @@ -419,6 +426,7 @@ class TaskGather extends SttTask { this.logger.error({err}, 'Error compiling hints for cobalt'); } } + delete opts.COBALT_SERVER_URI; break; case 'ibm': @@ -480,6 +488,7 @@ class TaskGather extends SttTask { locale: this.language, interim: this.interim, bugname: this.bugname, + hostport: this.hostport, }).catch((err) => { const {writeAlerts, AlertType} = this.cs.srf.locals; this.logger.error(err, 'TaskGather:_startTranscribing error'); @@ -729,16 +738,16 @@ class TaskGather extends SttTask { _onJambonzConnect(_cs, _ep) { this.logger.debug('TaskGather:_onJambonzConnect'); } - async _onJambonzError(cs, _ep, evt) { + async _onJambonzError(cs, ep, evt) { this.logger.info({evt}, 'TaskGather:_onJambonzError'); if (this.isHandledByPrimaryProvider && this.fallbackVendor) { - _ep.stopTranscription({vendor: this.vendor}) + ep.stopTranscription({vendor: this.vendor}) .catch((err) => this.logger.error({err}, `Error stopping transcription for primary vendor ${this.vendor}`)); const {updateSpeechCredentialLastUsed} = require('../utils/db-utils')(this.logger, cs.srf); try { await this._fallback(); - await this._initSpeech(cs, _ep); - this._startTranscribing(_ep); + await this._initSpeech(cs, ep); + this._startTranscribing(ep); updateSpeechCredentialLastUsed(this.sttCredentials.speech_credential_sid); return; } catch (error) { diff --git a/lib/tasks/transcribe.js b/lib/tasks/transcribe.js index 987abe63..1d1ec1d0 100644 --- a/lib/tasks/transcribe.js +++ b/lib/tasks/transcribe.js @@ -230,7 +230,14 @@ class TaskTranscribe extends SttTask { ep.addCustomEventListener(CobaltTranscriptionEvents.Transcription, this._onTranscription.bind(this, cs, ep, channel)); + /* cobalt doesnt have language, it has model, which is required */ + if (!this.data.recognizer.model) { + throw new Error('Cobalt requires a model to be specified'); + } + this.language = this.data.recognizer.model; + /* special case: if using hints with cobalt we need to compile them */ + this.hostport = opts.COBALT_SERVER_URI; if (this.vendor === 'cobalt' && opts.COBALT_SPEECH_HINTS) { try { const context = await this.compileHintsForCobalt( @@ -308,7 +315,8 @@ class TaskTranscribe extends SttTask { interim: this.interim ? true : false, locale: this.language, channels: /*this.separateRecognitionPerChannel ? 2 : */ 1, - bugname: this.bugname + bugname: this.bugname, + hostport: this.hostport }); } diff --git a/package-lock.json b/package-lock.json index a8aa413f..acfe19ff 100644 --- a/package-lock.json +++ b/package-lock.json @@ -30,7 +30,7 @@ "bent": "^7.3.12", "debug": "^4.3.4", "deepcopy": "^2.1.0", - "drachtio-fsmrf": "^3.0.26", + "drachtio-fsmrf": "^3.0.27", "drachtio-srf": "^4.5.26", "express": "^4.18.2", "ip": "^1.1.8", @@ -5152,9 +5152,9 @@ } }, "node_modules/drachtio-fsmrf": { - "version": "3.0.26", - "resolved": "https://registry.npmjs.org/drachtio-fsmrf/-/drachtio-fsmrf-3.0.26.tgz", - "integrity": "sha512-QoXa+lQ6j7NIIVhWq/oL5qHl/RokaxixJ7IhuuYmfCU+LsGdjFqPib8JEsieCXcp2qF98lOrEytJ5RESvWQGYQ==", + "version": "3.0.27", + "resolved": "https://registry.npmjs.org/drachtio-fsmrf/-/drachtio-fsmrf-3.0.27.tgz", + "integrity": "sha512-k5jwc6RpiSoasKEMq0ROxXVga+yaMplujNUKjAidKjheso+PijdQtjEwNANl0F+JyTBELaRe81PEgeRHuAdv1w==", "dependencies": { "camel-case": "^4.1.2", "debug": "^2.6.9", @@ -14610,9 +14610,9 @@ } }, "drachtio-fsmrf": { - "version": "3.0.26", - "resolved": "https://registry.npmjs.org/drachtio-fsmrf/-/drachtio-fsmrf-3.0.26.tgz", - "integrity": "sha512-QoXa+lQ6j7NIIVhWq/oL5qHl/RokaxixJ7IhuuYmfCU+LsGdjFqPib8JEsieCXcp2qF98lOrEytJ5RESvWQGYQ==", + "version": "3.0.27", + "resolved": "https://registry.npmjs.org/drachtio-fsmrf/-/drachtio-fsmrf-3.0.27.tgz", + "integrity": "sha512-k5jwc6RpiSoasKEMq0ROxXVga+yaMplujNUKjAidKjheso+PijdQtjEwNANl0F+JyTBELaRe81PEgeRHuAdv1w==", "requires": { "camel-case": "^4.1.2", "debug": "^2.6.9", diff --git a/package.json b/package.json index d8735af1..a74b7809 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "bent": "^7.3.12", "debug": "^4.3.4", "deepcopy": "^2.1.0", - "drachtio-fsmrf": "^3.0.26", + "drachtio-fsmrf": "^3.0.27", "drachtio-srf": "^4.5.26", "express": "^4.18.2", "ip": "^1.1.8",