mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2026-02-13 01:39:26 +00:00
Fix/replace application issue (#692)
* fix scenario where ws replace application from gather while awaiting command and no tasks on execution stack * lint * remove some debug logging
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -42,3 +42,4 @@ ecosystem.config.js
|
|||||||
test/credentials/*.json
|
test/credentials/*.json
|
||||||
run-tests.sh
|
run-tests.sh
|
||||||
run-coverage.sh
|
run-coverage.sh
|
||||||
|
.vscode
|
||||||
17
.vscode/launch.json
vendored
17
.vscode/launch.json
vendored
@@ -1,17 +0,0 @@
|
|||||||
{
|
|
||||||
// Use IntelliSense to learn about possible attributes.
|
|
||||||
// Hover to view descriptions of existing attributes.
|
|
||||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
|
||||||
"version": "0.2.0",
|
|
||||||
"configurations": [
|
|
||||||
{
|
|
||||||
"type": "node",
|
|
||||||
"request": "launch",
|
|
||||||
"name": "Launch Program",
|
|
||||||
"program": "${workspaceFolder}/test/index.js",
|
|
||||||
"env": {
|
|
||||||
"NODE_ENV": "test"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -1447,6 +1447,11 @@ Duration=${duration} `
|
|||||||
this.currentTask.kill(this, KillReason.Replaced);
|
this.currentTask.kill(this, KillReason.Replaced);
|
||||||
this.currentTask = null;
|
this.currentTask = null;
|
||||||
}
|
}
|
||||||
|
else if (this.wakeupResolver) {
|
||||||
|
this.logger.debug('CallSession:replaceApplication - waking up');
|
||||||
|
this.wakeupResolver({reason: 'new tasks'});
|
||||||
|
this.wakeupResolver = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
kill(onBackgroundGatherBargein = false) {
|
kill(onBackgroundGatherBargein = false) {
|
||||||
@@ -1471,7 +1476,8 @@ Duration=${duration} `
|
|||||||
this.logger.info('CallSession:kill - found bargein disabled in the stack, clearing to that point');
|
this.logger.info('CallSession:kill - found bargein disabled in the stack, clearing to that point');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
this.tasks.shift();
|
const rem = this.tasks.shift();
|
||||||
|
this.logger.debug(`CallSession:kill - clearing task ${rem.summary}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else this.tasks = [];
|
else this.tasks = [];
|
||||||
|
|||||||
@@ -700,11 +700,10 @@ class TaskGather extends SttTask {
|
|||||||
// make sure this is not a transcript from answering machine detection
|
// make sure this is not a transcript from answering machine detection
|
||||||
const bugname = fsEvent.getHeader('media-bugname');
|
const bugname = fsEvent.getHeader('media-bugname');
|
||||||
const finished = fsEvent.getHeader('transcription-session-finished');
|
const finished = fsEvent.getHeader('transcription-session-finished');
|
||||||
this.logger.debug({evt, bugname, finished}, `Gather:_onTranscription for vendor ${this.vendor}`);
|
this.logger.debug({evt, bugname, finished, vendor: this.vendor}, 'Gather:_onTranscription raw transcript');
|
||||||
if (bugname && this.bugname !== bugname) return;
|
if (bugname && this.bugname !== bugname) return;
|
||||||
|
|
||||||
if (this.vendor === 'ibm' && evt?.state === 'listening') return;
|
if (this.vendor === 'ibm' && evt?.state === 'listening') return;
|
||||||
|
|
||||||
if (this.vendor === 'deepgram' && evt.type === 'UtteranceEnd') {
|
if (this.vendor === 'deepgram' && evt.type === 'UtteranceEnd') {
|
||||||
/* we will only get this when we have set utterance_end_ms */
|
/* we will only get this when we have set utterance_end_ms */
|
||||||
if (this._bufferedTranscripts.length === 0) {
|
if (this._bufferedTranscripts.length === 0) {
|
||||||
@@ -718,9 +717,15 @@ class TaskGather extends SttTask {
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (this.vendor === 'deepgram' && evt.type === 'Metadata') {
|
||||||
|
this.logger.debug('Gather:_onTranscription - discarding Metadata event from deepgram');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
evt = this.normalizeTranscription(evt, this.vendor, 1, this.language,
|
evt = this.normalizeTranscription(evt, this.vendor, 1, this.language,
|
||||||
this.shortUtterance, this.data.recognizer.punctuation);
|
this.shortUtterance, this.data.recognizer.punctuation);
|
||||||
|
//this.logger.debug({evt, bugname, finished, vendor: this.vendor}, 'Gather:_onTranscription normalized transcript');
|
||||||
|
|
||||||
if (evt.alternatives.length === 0) {
|
if (evt.alternatives.length === 0) {
|
||||||
this.logger.info({evt}, 'TaskGather:_onTranscription - got empty transcript, continue listening');
|
this.logger.info({evt}, 'TaskGather:_onTranscription - got empty transcript, continue listening');
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -133,8 +133,7 @@ class BackgroundTaskManager extends Emitter {
|
|||||||
async _initRecord() {
|
async _initRecord() {
|
||||||
if (this.cs.accountInfo.account.record_all_calls || this.cs.application.record_all_calls) {
|
if (this.cs.accountInfo.account.record_all_calls || this.cs.application.record_all_calls) {
|
||||||
if (!JAMBONZ_RECORD_WS_BASE_URL || !this.cs.accountInfo.account.bucket_credential) {
|
if (!JAMBONZ_RECORD_WS_BASE_URL || !this.cs.accountInfo.account.bucket_credential) {
|
||||||
this.logger.error(`_initRecord: invalid configuration,
|
this.logger.error('_initRecord: invalid cfg - missing JAMBONZ_RECORD_WS_BASE_URL or bucket config');
|
||||||
missing JAMBONZ_RECORD_WS_BASE_URL or bucket configuration`);
|
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
const listenOpts = {
|
const listenOpts = {
|
||||||
@@ -175,7 +174,7 @@ class BackgroundTaskManager extends Emitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_taskCompleted(type, task) {
|
_taskCompleted(type, task) {
|
||||||
this.logger.debug({type, task}, 'BackgroundTaskManager:_taskCompleted: task completed');
|
this.logger.debug({type, task}, `BackgroundTaskManager:_taskCompleted: task completed, sticky: ${task.sticky}`);
|
||||||
task.removeAllListeners();
|
task.removeAllListeners();
|
||||||
task.span.end();
|
task.span.end();
|
||||||
this.tasks.delete(type);
|
this.tasks.delete(type);
|
||||||
@@ -188,7 +187,8 @@ class BackgroundTaskManager extends Emitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_bargeInTaskCompleted(evt) {
|
_bargeInTaskCompleted(evt) {
|
||||||
this.logger.debug({evt}, 'BackgroundTaskManager:_bargeInTaskCompleted on event from background bargeIn');
|
this.logger.debug({evt},
|
||||||
|
'BackgroundTaskManager:_bargeInTaskCompleted on event from background bargeIn, emitting bargein-done event');
|
||||||
this.emit('bargeIn-done', evt);
|
this.emit('bargeIn-done', evt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -488,6 +488,13 @@ module.exports = (logger) => {
|
|||||||
|
|
||||||
if ('google' === vendor) {
|
if ('google' === vendor) {
|
||||||
const model = task.name === TaskName.Gather ? 'command_and_search' : 'latest_long';
|
const model = task.name === TaskName.Gather ? 'command_and_search' : 'latest_long';
|
||||||
|
/**
|
||||||
|
* When we support google v2 the models are different and we will want something like:
|
||||||
|
* const useV2 = sttCredentials?.credentials?.project_id; //TODO: v2 pref should be set in googleOptions
|
||||||
|
* const model = task.name === TaskName.Gather ?
|
||||||
|
* (useV2 ? 'telephony_short' : 'command_and_search') :
|
||||||
|
* (useV2 ? 'long' : 'latest_long');
|
||||||
|
*/
|
||||||
opts = {
|
opts = {
|
||||||
...opts,
|
...opts,
|
||||||
...(sttCredentials && {GOOGLE_APPLICATION_CREDENTIALS: JSON.stringify(sttCredentials.credentials)}),
|
...(sttCredentials && {GOOGLE_APPLICATION_CREDENTIALS: JSON.stringify(sttCredentials.credentials)}),
|
||||||
@@ -520,6 +527,12 @@ module.exports = (logger) => {
|
|||||||
...{GOOGLE_SPEECH_MODEL: rOpts.model || model},
|
...{GOOGLE_SPEECH_MODEL: rOpts.model || model},
|
||||||
...(rOpts.naicsCode > 0 && {GOOGLE_SPEECH_METADATA_INDUSTRY_NAICS_CODE: rOpts.naicsCode}),
|
...(rOpts.naicsCode > 0 && {GOOGLE_SPEECH_METADATA_INDUSTRY_NAICS_CODE: rOpts.naicsCode}),
|
||||||
GOOGLE_SPEECH_METADATA_RECORDING_DEVICE_TYPE: 'phone_line',
|
GOOGLE_SPEECH_METADATA_RECORDING_DEVICE_TYPE: 'phone_line',
|
||||||
|
/*
|
||||||
|
...(useV2 && {
|
||||||
|
GOOGLE_SPEECH_RECOGNIZER_PARENT: `projects/${sttCredentials.credentials.project_id}/locations/global`,
|
||||||
|
GOOGLE_SPEECH_CLOUD_SERVICES_VERSION: 'v2'
|
||||||
|
}),
|
||||||
|
*/
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
else if (['aws', 'polly'].includes(vendor)) {
|
else if (['aws', 'polly'].includes(vendor)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user