From 28f12c71df927644b817461c277bec3c495cb1b4 Mon Sep 17 00:00:00 2001 From: "p.souza" Date: Mon, 24 Apr 2023 10:11:28 +0200 Subject: [PATCH] include channel --- lib/tasks/transcribe.js | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/lib/tasks/transcribe.js b/lib/tasks/transcribe.js index f9c85659f..dacc70eae 100644 --- a/lib/tasks/transcribe.js +++ b/lib/tasks/transcribe.js @@ -40,6 +40,7 @@ class TaskTranscribe extends Task { this.language = recognizer.language; this.interim = !!recognizer.interim; this.separateRecognitionPerChannel = recognizer.separateRecognitionPerChannel; + this.recognitionChannel = this.data.channel; /* let credentials be supplied in the recognizer object at runtime */ this.sttCredentials = setSpeechCredentialsAtRuntime(recognizer); @@ -288,23 +289,25 @@ class TaskTranscribe extends Task { if (this.transcriptionHook) { const b3 = this.getTracingPropagation(); const httpHeaders = b3 && {b3}; - try { - const json = await this.cs.requestor.request('verb:hook', this.transcriptionHook, { - ...this.cs.callInfo, - ...httpHeaders, - speech: evt - }); - this.logger.info({json}, 'sent transcriptionHook'); - if (json && Array.isArray(json) && !this.parentTask) { - const makeTask = require('./make_task'); - const tasks = normalizeJambones(this.logger, json).map((tdata) => makeTask(this.logger, tdata)); - if (tasks && tasks.length > 0) { - this.logger.info({tasks: tasks}, `${this.name} replacing application with ${tasks.length} tasks`); - this.cs.replaceApplication(tasks); + if ((this.recognitionChannel && this.recognitionChannel === evt.channel_tag) || this.recognitionChannel === undefined) { + try { + const json = await this.cs.requestor.request('verb:hook', this.transcriptionHook, { + ...this.cs.callInfo, + ...httpHeaders, + speech: evt + }); + this.logger.info({json}, 'sent transcriptionHook'); + if (json && Array.isArray(json) && !this.parentTask) { + const makeTask = require('./make_task'); + const tasks = normalizeJambones(this.logger, json).map((tdata) => makeTask(this.logger, tdata)); + if (tasks && tasks.length > 0) { + this.logger.info({tasks: tasks}, `${this.name} replacing application with ${tasks.length} tasks`); + this.cs.replaceApplication(tasks); + } } + } catch (err) { + this.logger.info(err, 'TranscribeTask:_onTranscription error'); } - } catch (err) { - this.logger.info(err, 'TranscribeTask:_onTranscription error'); } } if (this.parentTask) {