mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2025-12-20 08:40:38 +00:00
feat pause resume transcribe (#438)
* feat pause resume transcribe * wip * fix jslint * update fsmrf
This commit is contained in:
@@ -1075,6 +1075,24 @@ ${credential.label ? `, label: ${credential.label}` : ''} is chosen`);
|
|||||||
listenTask.updateListen(opts.listen_status);
|
listenTask.updateListen(opts.listen_status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* perform live call control -- change Transcribe status
|
||||||
|
* @param {object} opts
|
||||||
|
* @param {string} opts.transcribe_status - 'pause' or 'resume'
|
||||||
|
*/
|
||||||
|
async _lccTranscribeStatus(opts) {
|
||||||
|
const task = this.currentTask;
|
||||||
|
if (!task || ![TaskName.Dial, TaskName.Transcribe].includes(task.name)) {
|
||||||
|
return this.logger.info(`CallSession:_lccTranscribeStatus - invalid transcribe_status in task ${task.name}`);
|
||||||
|
}
|
||||||
|
const transcribeTask = task.name === TaskName.Transcribe ? task : task.transcribeTask;
|
||||||
|
if (!transcribeTask) {
|
||||||
|
return this.logger
|
||||||
|
.info('CallSession:_lccTranscribeStatus - invalid transcribe_status: Dial does not have a Transcribe');
|
||||||
|
}
|
||||||
|
transcribeTask.updateTranscribe(opts.transcribe_status);
|
||||||
|
}
|
||||||
|
|
||||||
async _lccMuteStatus(callSid, mute) {
|
async _lccMuteStatus(callSid, mute) {
|
||||||
// this whole thing requires us to be in a Dial or Conference verb
|
// this whole thing requires us to be in a Dial or Conference verb
|
||||||
const task = this.currentTask;
|
const task = this.currentTask;
|
||||||
@@ -1193,6 +1211,9 @@ ${credential.label ? `, label: ${credential.label}` : ''} is chosen`);
|
|||||||
if (opts.listen_status) {
|
if (opts.listen_status) {
|
||||||
await this._lccListenStatus(opts);
|
await this._lccListenStatus(opts);
|
||||||
}
|
}
|
||||||
|
if (opts.transcribe_status) {
|
||||||
|
await this._lccTranscribeStatus(opts);
|
||||||
|
}
|
||||||
else if (opts.mute_status) {
|
else if (opts.mute_status) {
|
||||||
await this._lccMuteStatus(callSid, opts.mute_status === 'mute');
|
await this._lccMuteStatus(callSid, opts.mute_status === 'mute');
|
||||||
}
|
}
|
||||||
@@ -1369,6 +1390,10 @@ ${credential.label ? `, label: ${credential.label}` : ''} is chosen`);
|
|||||||
this._lccListenStatus(data);
|
this._lccListenStatus(data);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'transcribe:status':
|
||||||
|
this._lccTranscribeStatus(data);
|
||||||
|
break;
|
||||||
|
|
||||||
case 'whisper':
|
case 'whisper':
|
||||||
this._lccWhisper(data, call_sid);
|
this._lccWhisper(data, call_sid);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -9,7 +9,8 @@ const {
|
|||||||
SonioxTranscriptionEvents,
|
SonioxTranscriptionEvents,
|
||||||
IbmTranscriptionEvents,
|
IbmTranscriptionEvents,
|
||||||
NvidiaTranscriptionEvents,
|
NvidiaTranscriptionEvents,
|
||||||
JambonzTranscriptionEvents
|
JambonzTranscriptionEvents,
|
||||||
|
TranscribeStatus
|
||||||
} = require('../utils/constants');
|
} = require('../utils/constants');
|
||||||
const { normalizeJambones } = require('@jambonz/verb-specifications');
|
const { normalizeJambones } = require('@jambonz/verb-specifications');
|
||||||
const SttTask = require('./stt-task');
|
const SttTask = require('./stt-task');
|
||||||
@@ -119,8 +120,7 @@ class TaskTranscribe extends SttTask {
|
|||||||
this.removeSpeechListeners(ep);
|
this.removeSpeechListeners(ep);
|
||||||
}
|
}
|
||||||
|
|
||||||
async kill(cs) {
|
async _stopTranscription() {
|
||||||
super.kill(cs);
|
|
||||||
let stopTranscription = false;
|
let stopTranscription = false;
|
||||||
if (this.ep?.connected) {
|
if (this.ep?.connected) {
|
||||||
stopTranscription = true;
|
stopTranscription = true;
|
||||||
@@ -132,6 +132,13 @@ class TaskTranscribe extends SttTask {
|
|||||||
this.ep2.stopTranscription({vendor: this.vendor})
|
this.ep2.stopTranscription({vendor: this.vendor})
|
||||||
.catch((err) => this.logger.info(err, 'Error TaskTranscribe:kill'));
|
.catch((err) => this.logger.info(err, 'Error TaskTranscribe:kill'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return stopTranscription;
|
||||||
|
}
|
||||||
|
|
||||||
|
async kill(cs) {
|
||||||
|
super.kill(cs);
|
||||||
|
const stopTranscription = this._stopTranscription();
|
||||||
// hangup after 1 sec if we don't get a final transcription
|
// hangup after 1 sec if we don't get a final transcription
|
||||||
if (stopTranscription) this._timer = setTimeout(() => this.notifyTaskDone(), 1500);
|
if (stopTranscription) this._timer = setTimeout(() => this.notifyTaskDone(), 1500);
|
||||||
else this.notifyTaskDone();
|
else this.notifyTaskDone();
|
||||||
@@ -139,6 +146,23 @@ class TaskTranscribe extends SttTask {
|
|||||||
await this.awaitTaskDone();
|
await this.awaitTaskDone();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async updateTranscribe(status) {
|
||||||
|
if (!this.killed && this.ep && this.ep.connected) {
|
||||||
|
this.logger.info(`TaskTranscribe:updateTranscribe status ${status}`);
|
||||||
|
switch (status) {
|
||||||
|
case TranscribeStatus.Pause:
|
||||||
|
await this._stopTranscription();
|
||||||
|
break;
|
||||||
|
case TranscribeStatus.Resume:
|
||||||
|
await this._startTranscribing(this.cs, this.ep, 1);
|
||||||
|
if (this.separateRecognitionPerChannel && this.ep2) {
|
||||||
|
await this._startTranscribing(this.cs, this.ep2, 2);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async _startTranscribing(cs, ep, channel) {
|
async _startTranscribing(cs, ep, channel) {
|
||||||
const opts = this.setChannelVarsForStt(this, this.sttCredentials, this.data.recognizer);
|
const opts = this.setChannelVarsForStt(this, this.sttCredentials, this.data.recognizer);
|
||||||
switch (this.vendor) {
|
switch (this.vendor) {
|
||||||
|
|||||||
@@ -51,6 +51,11 @@
|
|||||||
"Silence": "silence",
|
"Silence": "silence",
|
||||||
"Resume": "resume"
|
"Resume": "resume"
|
||||||
},
|
},
|
||||||
|
"TranscribeStatus": {
|
||||||
|
"Pause": "pause",
|
||||||
|
"Silence": "silence",
|
||||||
|
"Resume": "resume"
|
||||||
|
},
|
||||||
"TaskPreconditions": {
|
"TaskPreconditions": {
|
||||||
"None": "none",
|
"None": "none",
|
||||||
"Endpoint": "endpoint",
|
"Endpoint": "endpoint",
|
||||||
|
|||||||
14
package-lock.json
generated
14
package-lock.json
generated
@@ -30,7 +30,7 @@
|
|||||||
"bent": "^7.3.12",
|
"bent": "^7.3.12",
|
||||||
"debug": "^4.3.4",
|
"debug": "^4.3.4",
|
||||||
"deepcopy": "^2.1.0",
|
"deepcopy": "^2.1.0",
|
||||||
"drachtio-fsmrf": "^3.0.23",
|
"drachtio-fsmrf": "^3.0.24",
|
||||||
"drachtio-srf": "^4.5.26",
|
"drachtio-srf": "^4.5.26",
|
||||||
"express": "^4.18.2",
|
"express": "^4.18.2",
|
||||||
"ip": "^1.1.8",
|
"ip": "^1.1.8",
|
||||||
@@ -5152,9 +5152,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/drachtio-fsmrf": {
|
"node_modules/drachtio-fsmrf": {
|
||||||
"version": "3.0.23",
|
"version": "3.0.24",
|
||||||
"resolved": "https://registry.npmjs.org/drachtio-fsmrf/-/drachtio-fsmrf-3.0.23.tgz",
|
"resolved": "https://registry.npmjs.org/drachtio-fsmrf/-/drachtio-fsmrf-3.0.24.tgz",
|
||||||
"integrity": "sha512-ElruNKuPzFiMOUH06PUd3dR9tElEGRhbP/gXxai58qhrqRQNLJxzCRJkbgbjrZdYWFQPHOAzy4ZQb7+qq0AUPw==",
|
"integrity": "sha512-MsTwHDOOg5yrKCcQ2buNTVSEwoMZzTcVeU5/BZ2Km0TPxBI1lErW6IiyZxA5pyoLfSdBtbqSh9ZwXrtxWTp6kA==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"camel-case": "^4.1.2",
|
"camel-case": "^4.1.2",
|
||||||
"debug": "^2.6.9",
|
"debug": "^2.6.9",
|
||||||
@@ -14610,9 +14610,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"drachtio-fsmrf": {
|
"drachtio-fsmrf": {
|
||||||
"version": "3.0.23",
|
"version": "3.0.24",
|
||||||
"resolved": "https://registry.npmjs.org/drachtio-fsmrf/-/drachtio-fsmrf-3.0.23.tgz",
|
"resolved": "https://registry.npmjs.org/drachtio-fsmrf/-/drachtio-fsmrf-3.0.24.tgz",
|
||||||
"integrity": "sha512-ElruNKuPzFiMOUH06PUd3dR9tElEGRhbP/gXxai58qhrqRQNLJxzCRJkbgbjrZdYWFQPHOAzy4ZQb7+qq0AUPw==",
|
"integrity": "sha512-MsTwHDOOg5yrKCcQ2buNTVSEwoMZzTcVeU5/BZ2Km0TPxBI1lErW6IiyZxA5pyoLfSdBtbqSh9ZwXrtxWTp6kA==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"camel-case": "^4.1.2",
|
"camel-case": "^4.1.2",
|
||||||
"debug": "^2.6.9",
|
"debug": "^2.6.9",
|
||||||
|
|||||||
@@ -46,7 +46,7 @@
|
|||||||
"bent": "^7.3.12",
|
"bent": "^7.3.12",
|
||||||
"debug": "^4.3.4",
|
"debug": "^4.3.4",
|
||||||
"deepcopy": "^2.1.0",
|
"deepcopy": "^2.1.0",
|
||||||
"drachtio-fsmrf": "^3.0.23",
|
"drachtio-fsmrf": "^3.0.24",
|
||||||
"drachtio-srf": "^4.5.26",
|
"drachtio-srf": "^4.5.26",
|
||||||
"express": "^4.18.2",
|
"express": "^4.18.2",
|
||||||
"ip": "^1.1.8",
|
"ip": "^1.1.8",
|
||||||
|
|||||||
Reference in New Issue
Block a user