mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2025-12-20 16:50:39 +00:00
bugfix: say text continued to play after task was killed
This commit is contained in:
@@ -20,24 +20,27 @@ class TaskSay extends Task {
|
||||
await super.exec(cs);
|
||||
this.ep = ep;
|
||||
try {
|
||||
const filepath = [];
|
||||
while (!this.killed && this.loop-- && this.ep.connected) {
|
||||
let segment = 0;
|
||||
do {
|
||||
if (filepath.length <= segment) {
|
||||
const opts = Object.assign({
|
||||
text: this.text[segment],
|
||||
// synthesize all of the text elements
|
||||
const filepath = (await Promise.all(this.text.map(async(text) => {
|
||||
const fp = await synthAudio({
|
||||
text,
|
||||
vendor: cs.speechSynthesisVendor,
|
||||
language: cs.speechSynthesisLanguage,
|
||||
voice: cs.speechSynthesisVoice,
|
||||
salt: cs.callSid
|
||||
}, this.synthesizer);
|
||||
const path = await synthAudio(opts);
|
||||
filepath.push(path);
|
||||
cs.trackTmpFile(path);
|
||||
}
|
||||
}).catch((err) => this.logger.error(err, 'Error synthesizing text'));
|
||||
if (fp) cs.trackTmpFile(fp);
|
||||
return fp;
|
||||
})))
|
||||
.filter((fp) => fp && fp.length);
|
||||
|
||||
this.logger.debug({filepath}, 'synthesized files for tts');
|
||||
|
||||
while (!this.killed && this.loop-- && this.ep.connected) {
|
||||
let segment = 0;
|
||||
do {
|
||||
await ep.play(filepath[segment]);
|
||||
} while (++segment < this.text.length);
|
||||
} while (!this.killed && ++segment < filepath.length);
|
||||
}
|
||||
} catch (err) {
|
||||
this.logger.info(err, 'TaskSay:exec error');
|
||||
|
||||
Reference in New Issue
Block a user