fixed gather does not start timeout on bargin (#1421)

* fixed gather does not start timeout on bargin

* with previous change, no need to emit playDone since no where in the code are we listening for it

---------

Co-authored-by: Dave Horton <daveh@beachdognet.com>
This commit is contained in:
Hoan Luu Huu
2025-11-04 01:11:59 +07:00
committed by GitHub
parent a884880321
commit 2de24af169
2 changed files with 17 additions and 17 deletions

View File

@@ -270,19 +270,21 @@ class TaskGather extends SttTask {
}; };
this.sayTask.span = span; this.sayTask.span = span;
this.sayTask.ctx = ctx; this.sayTask.ctx = ctx;
this.sayTask.exec(cs, {ep}) // kicked off, _not_ waiting for it to complete this.sayTask
.exec(cs, {ep}) // kicked off, _not_ waiting for it to complete
.then(() => {
if (this.sayTask.isStreamingTts) return;
this.logger.debug('Gather:exec - nested say task completed');
span.end();
process();
return;
})
.catch((err) => { .catch((err) => {
process(); process();
}); });
if (this.sayTask.isStreamingTts && !this.sayTask.closeOnStreamEmpty) { if (this.sayTask.isStreamingTts && !this.sayTask.closeOnStreamEmpty) {
// if streaming tts, we do not wait for it to complete if it is not closing the stream automatically // if streaming tts, we do not wait for it to complete if it is not closing the stream automatically
process(); process();
} else {
this.sayTask.on('playDone', (err) => {
span.end();
if (err) this.logger.error({err}, 'Gather:exec Error playing tts');
process();
});
} }
} }
else if (this.playTask) { else if (this.playTask) {
@@ -306,15 +308,17 @@ class TaskGather extends SttTask {
}; };
this.playTask.span = span; this.playTask.span = span;
this.playTask.ctx = ctx; this.playTask.ctx = ctx;
this.playTask.exec(cs, {ep}) // kicked off, _not_ waiting for it to complete this.playTask
.exec(cs, {ep}) // kicked off, _not_ waiting for it to complete
.then(() => {
this.logger.debug('Gather:exec - nested play task completed');
span.end();
process();
return;
})
.catch((err) => { .catch((err) => {
process(); process();
}); });
this.playTask.on('playDone', (err) => {
span.end();
if (err) this.logger.error({err}, 'Gather:exec Error playing url');
process();
});
} }
else { else {
if (this.killed) { if (this.killed) {
@@ -882,12 +886,10 @@ class TaskGather extends SttTask {
return; return;
} }
if (this.sayTask && !this.sayTask.killed) { if (this.sayTask && !this.sayTask.killed) {
this.sayTask.removeAllListeners('playDone');
this.sayTask.kill(cs); this.sayTask.kill(cs);
this.sayTask = null; this.sayTask = null;
} }
if (this.playTask && !this.playTask.killed) { if (this.playTask && !this.playTask.killed) {
this.playTask.removeAllListeners('playDone');
this.playTask.kill(cs); this.playTask.kill(cs);
this.playTask = null; this.playTask = null;
} }

View File

@@ -120,13 +120,11 @@ class TaskSay extends TtsTask {
} }
if (this.isStreamingTts) await this.handlingStreaming(cs, obj); if (this.isStreamingTts) await this.handlingStreaming(cs, obj);
else await this.handling(cs, obj); else await this.handling(cs, obj);
this.emit('playDone');
} catch (error) { } catch (error) {
if (error instanceof SpeechCredentialError) { if (error instanceof SpeechCredentialError) {
// if say failed due to speech credentials, alarm is writtern and error notification is sent // if say failed due to speech credentials, alarm is writtern and error notification is sent
// finished this say to move to next task. // finished this say to move to next task.
this.logger.info({error}, 'Say failed due to SpeechCredentialError, finished!'); this.logger.info({error}, 'Say failed due to SpeechCredentialError, finished!');
this.emit('playDone');
return; return;
} }
throw error; throw error;