mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2025-12-21 17:17:58 +00:00
race condition where gather transcribe is restarted after final transcript
This commit is contained in:
@@ -877,6 +877,7 @@ class CallSession extends Emitter {
|
|||||||
const taskNum = ++this.taskIdx;
|
const taskNum = ++this.taskIdx;
|
||||||
const stackNum = this.stackIdx;
|
const stackNum = this.stackIdx;
|
||||||
const task = this.tasks.shift();
|
const task = this.tasks.shift();
|
||||||
|
task._stackNum = `${stackNum}:${taskNum}`;
|
||||||
this.logger.info(`CallSession:exec starting task #${stackNum}:${taskNum}: ${task.name}`);
|
this.logger.info(`CallSession:exec starting task #${stackNum}:${taskNum}: ${task.name}`);
|
||||||
this._notifyTaskStatus(task, {event: 'starting'});
|
this._notifyTaskStatus(task, {event: 'starting'});
|
||||||
// Register verbhook span wait for end
|
// Register verbhook span wait for end
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ class TaskGather extends SttTask {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async exec(cs, {ep}) {
|
async exec(cs, {ep}) {
|
||||||
this.logger.debug({options: this.data}, 'Gather:exec');
|
this.logger.debug({options: this.data}, `Gather:exec ${this.stackNum}`);
|
||||||
await super.exec(cs, {ep});
|
await super.exec(cs, {ep});
|
||||||
const {updateSpeechCredentialLastUsed} = require('../utils/db-utils')(this.logger, cs.srf);
|
const {updateSpeechCredentialLastUsed} = require('../utils/db-utils')(this.logger, cs.srf);
|
||||||
|
|
||||||
@@ -236,10 +236,15 @@ class TaskGather extends SttTask {
|
|||||||
|
|
||||||
if (this.input.includes('speech') && this.listenDuringPrompt) {
|
if (this.input.includes('speech') && this.listenDuringPrompt) {
|
||||||
await this._setSpeechHandlers(cs, ep);
|
await this._setSpeechHandlers(cs, ep);
|
||||||
this.logger.debug('Gather:exec - going to start transcribing (listenDuringPrompt)');
|
if (!this.resolved && !this.killed) {
|
||||||
this._startTranscribing(ep);
|
this.logger.debug(`Gather:exec ${this.stackNum} - going to start transcribing (listenDuringPrompt)`);
|
||||||
updateSpeechCredentialLastUsed(this.sttCredentials.speech_credential_sid)
|
this._startTranscribing(ep);
|
||||||
.catch(() => {/*already logged error */});
|
updateSpeechCredentialLastUsed(this.sttCredentials.speech_credential_sid)
|
||||||
|
.catch(() => {/*already logged error */});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.logger.info(`Gather:exec ${this.stackNum} - task was killed or resolved before starting transcription`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.input.includes('digits') || this.dtmfBargein || this.asrDtmfTerminationDigit) {
|
if (this.input.includes('digits') || this.dtmfBargein || this.asrDtmfTerminationDigit) {
|
||||||
@@ -484,7 +489,7 @@ class TaskGather extends SttTask {
|
|||||||
locale: this.language,
|
locale: this.language,
|
||||||
interim: this.interim,
|
interim: this.interim,
|
||||||
bugname: this.bugname
|
bugname: this.bugname
|
||||||
}, 'Gather:_startTranscribing');
|
}, `Gather:_startTranscribing ${this.stackNum}`);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Note: we don't need to ask deepgram for interim results, because they
|
* Note: we don't need to ask deepgram for interim results, because they
|
||||||
@@ -702,7 +707,12 @@ 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, vendor: this.vendor}, 'Gather:_onTranscription raw transcript');
|
this.logger.debug({
|
||||||
|
evt,
|
||||||
|
bugname,
|
||||||
|
finished,
|
||||||
|
vendor: this.vendor
|
||||||
|
}, `Gather:_onTranscription ${this.stackNum} 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;
|
||||||
@@ -875,7 +885,7 @@ class TaskGather extends SttTask {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
_onEndOfUtterance(cs, ep) {
|
_onEndOfUtterance(cs, ep) {
|
||||||
this.logger.debug('TaskGather:_onEndOfUtterance');
|
this.logger.debug(`TaskGather:_onEndOfUtterance ${this.stackNum}`);
|
||||||
if (this.bargein && this.minBargeinWordCount === 0) {
|
if (this.bargein && this.minBargeinWordCount === 0) {
|
||||||
this._killAudio(cs);
|
this._killAudio(cs);
|
||||||
}
|
}
|
||||||
@@ -974,7 +984,7 @@ class TaskGather extends SttTask {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async _resolve(reason, evt) {
|
async _resolve(reason, evt) {
|
||||||
this.logger.debug(`TaskGather:resolve with reason ${reason}`);
|
this.logger.debug(`TaskGather:resolve ${this.stackNum} with reason ${reason}`);
|
||||||
if (this.needsStt && this.ep && this.ep.connected) {
|
if (this.needsStt && this.ep && this.ep.connected) {
|
||||||
this.ep.stopTranscription({
|
this.ep.stopTranscription({
|
||||||
vendor: this.vendor,
|
vendor: this.vendor,
|
||||||
|
|||||||
Reference in New Issue
Block a user