improve var naming

This commit is contained in:
akirilyuk
2022-02-03 17:58:26 +01:00
parent 8163c33462
commit 53e5360ab3
4 changed files with 32 additions and 21 deletions

View File

@@ -210,7 +210,7 @@ class Cognigy extends Task {
_makeSayTask({ text, turnConfig } = {}) {
this.logger.debug({text, turnConfig}, '_makeSayTask');
const config = this.config.makeSayTaskConfig({text, turnConfig });
this.logger.debug({config}, "created say task config");
this.logger.debug({config}, 'created say task config');
const say = makeTask(this.logger, { say: config }, this);
return say;
}

View File

@@ -126,7 +126,7 @@ class SpeechConfig extends Emitter {
noInputSpeech,
noInputUrl
},
dontListenAfterSpeech
listenAfterSpeech: !dontListenAfterSpeech
};
const final = stripNulls(config);

View File

@@ -25,7 +25,7 @@ class TaskGather extends Task {
this.minBargeinWordCount = this.data.minBargeinWordCount || 1;
// this is specially for barge in where we want to make a bargebale promt
// to a user without listening after the say task has finished
this.dontListenAfterSpeech = this.data.dontListenAfterSpeech === true;
this.listenAfterSpeech = this.data.listenAfterSpeech === false;
this.timeout = (this.timeout || 15) * 1000;
this.interim = this.partialResultCallback || this.bargein;
if (this.data.recognizer) {
@@ -104,15 +104,27 @@ class TaskGather extends Task {
this.sayTask.on('playDone', async(err) => {
if (err) return this.logger.error({err}, 'Gather:exec Error playing tts');
this.logger.debug('Gather: say task completed');
if (!this.killed || !this.dontListenAfterSpeech) startListening(cs, ep);
if (!this.killed) {
if (this.listenAfterSpeech) {
startListening(cs, ep);
} else {
this.kill(cs);
}
}
});
}
else if (this.playTask) {
this.playTask.exec(cs, ep); // kicked off, _not_ waiting for it to complete
this.playTask.on('playDone', async(err) => {
if (err) return this.logger.error({err}, 'Gather:exec Error playing url');
if (!this.killed || !this.dontListenAfterSpeech) startListening(cs, ep);
});
if (!this.killed) {
if (this.listenAfterSpeech) {
startListening(cs, ep);
} else {
this.kill(cs);
}
}}
);
}
else startListening(cs, ep);

View File

@@ -21,9 +21,8 @@ class TaskSay extends Task {
const {updateSpeechCredentialLastUsed} = require('../utils/db-utils')(this.logger, srf);
const {writeAlerts, AlertType, stats} = srf.locals;
const {synthAudio} = srf.locals.dbHelpers;
const vendor = this.synthesizer.vendor || cs.speechSynthesisVendor;
const language = this.synthesizer.language || cs.speechSynthesisLanguage ;
const vendor = this.synthesizer.vendor || cs.speechSynthesisVendor;
const language = this.synthesizer.language || cs.speechSynthesisLanguage ;
const voice = this.synthesizer.voice || cs.speechSynthesisVoice ;
const engine = this.synthesizer.engine || 'standard';
const salt = cs.callSid;