mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2025-12-21 17:17:58 +00:00
improve var naming
This commit is contained in:
@@ -87,7 +87,7 @@ class Cognigy extends Task {
|
|||||||
}
|
}
|
||||||
this.logger.debug('say task executed from queue');
|
this.logger.debug('say task executed from queue');
|
||||||
});
|
});
|
||||||
if(this.taskQueue.lastPromise){
|
if (this.taskQueue.lastPromise) {
|
||||||
// resolve the previous promise for cleanup
|
// resolve the previous promise for cleanup
|
||||||
this.taskQueue.lastPromise.resolve({});
|
this.taskQueue.lastPromise.resolve({});
|
||||||
}
|
}
|
||||||
@@ -189,10 +189,10 @@ class Cognigy extends Task {
|
|||||||
* Creates a promt which will be sent to the consumer. We will create a say task if bargein is disabled
|
* Creates a promt which will be sent to the consumer. We will create a say task if bargein is disabled
|
||||||
* for session and nextTurn, else create a gather task.
|
* for session and nextTurn, else create a gather task.
|
||||||
*/
|
*/
|
||||||
_createPromtTask({text, url, turnConfig, dontListenAfterSpeech} = {}){
|
_createPromtTask({text, url, turnConfig, dontListenAfterSpeech} = {}) {
|
||||||
const bargeInOnNextTurn = turnConfig?.bargein?.enable?.length>0;
|
const bargeInOnNextTurn = turnConfig?.bargein?.enable?.length > 0;
|
||||||
const bargeInSession = this.config.bargeInEnabled;
|
const bargeInSession = this.config.bargeInEnabled;
|
||||||
if(bargeInOnNextTurn || bargeInSession){
|
if (bargeInOnNextTurn || bargeInSession) {
|
||||||
return this._makeGatherTask({textPrompt: text, url, turnConfig, dontListenAfterSpeech});
|
return this._makeGatherTask({textPrompt: text, url, turnConfig, dontListenAfterSpeech});
|
||||||
}
|
}
|
||||||
return this._makeSayTask({text, turnConfig});
|
return this._makeSayTask({text, turnConfig});
|
||||||
@@ -210,7 +210,7 @@ class Cognigy extends Task {
|
|||||||
_makeSayTask({ text, turnConfig } = {}) {
|
_makeSayTask({ text, turnConfig } = {}) {
|
||||||
this.logger.debug({text, turnConfig}, '_makeSayTask');
|
this.logger.debug({text, turnConfig}, '_makeSayTask');
|
||||||
const config = this.config.makeSayTaskConfig({text, turnConfig });
|
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);
|
const say = makeTask(this.logger, { say: config }, this);
|
||||||
return say;
|
return say;
|
||||||
}
|
}
|
||||||
@@ -261,7 +261,7 @@ class Cognigy extends Task {
|
|||||||
async _onBotFinalPing(cs, ep) {
|
async _onBotFinalPing(cs, ep) {
|
||||||
this.logger.info({prompts: this.prompts}, 'Cognigy:_onBotFinalPing');
|
this.logger.info({prompts: this.prompts}, 'Cognigy:_onBotFinalPing');
|
||||||
try {
|
try {
|
||||||
// lets wait until we have finished processing the speech before
|
// lets wait until we have finished processing the speech before
|
||||||
// starting a gather...
|
// starting a gather...
|
||||||
await this.taskQueue.lastPromise;
|
await this.taskQueue.lastPromise;
|
||||||
const gatherTask = this._makeGatherTask();
|
const gatherTask = this._makeGatherTask();
|
||||||
@@ -357,10 +357,10 @@ class Cognigy extends Task {
|
|||||||
const utterance = evt.alternatives[0].transcript;
|
const utterance = evt.alternatives[0].transcript;
|
||||||
|
|
||||||
//if we have barge in enabled AND we enabled skipping until next question
|
//if we have barge in enabled AND we enabled skipping until next question
|
||||||
//then stop execution of currently queues bot output before sending the
|
//then stop execution of currently queues bot output before sending the
|
||||||
//response to waiting bot since otherwise we could stop upcoming bot output
|
//response to waiting bot since otherwise we could stop upcoming bot output
|
||||||
|
|
||||||
if(this.config.skipUntilBotInput){
|
if (this.config.skipUntilBotInput) {
|
||||||
// clear task queue, resolve the last promise and cleanup;
|
// clear task queue, resolve the last promise and cleanup;
|
||||||
this.taskQueue.end();
|
this.taskQueue.end();
|
||||||
this.taskQueue.lastPromise.resolve();
|
this.taskQueue.lastPromise.resolve();
|
||||||
|
|||||||
@@ -31,13 +31,13 @@ class SpeechConfig extends Emitter {
|
|||||||
/**
|
/**
|
||||||
* check if we should skip all nodes until next bot input
|
* check if we should skip all nodes until next bot input
|
||||||
*/
|
*/
|
||||||
get skipUntilBotInput(){
|
get skipUntilBotInput() {
|
||||||
return this.sessionConfig.bargein?.skipUntilBotInput === false;
|
return this.sessionConfig.bargein?.skipUntilBotInput === false;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Check if barge is enabled on session level
|
* Check if barge is enabled on session level
|
||||||
*/
|
*/
|
||||||
get bargeInEnabled(){
|
get bargeInEnabled() {
|
||||||
return this.sessionConfig.bargein?.enable?.length > 0;
|
return this.sessionConfig.bargein?.enable?.length > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,7 +79,7 @@ class SpeechConfig extends Emitter {
|
|||||||
if (opts.recognizer) input.push('speech');
|
if (opts.recognizer) input.push('speech');
|
||||||
if (hasKeys(opts.dtmf)) input.push('digits');
|
if (hasKeys(opts.dtmf)) input.push('digits');
|
||||||
|
|
||||||
if(opts.synthesizer){
|
if (opts.synthesizer) {
|
||||||
// todo remove this once we add support for disabling tts cache
|
// todo remove this once we add support for disabling tts cache
|
||||||
delete opts.synthesizer.disableTtsCache;
|
delete opts.synthesizer.disableTtsCache;
|
||||||
}
|
}
|
||||||
@@ -126,7 +126,7 @@ class SpeechConfig extends Emitter {
|
|||||||
noInputSpeech,
|
noInputSpeech,
|
||||||
noInputUrl
|
noInputUrl
|
||||||
},
|
},
|
||||||
dontListenAfterSpeech
|
listenAfterSpeech: !dontListenAfterSpeech
|
||||||
};
|
};
|
||||||
|
|
||||||
const final = stripNulls(config);
|
const final = stripNulls(config);
|
||||||
|
|||||||
@@ -23,9 +23,9 @@ class TaskGather extends Task {
|
|||||||
].forEach((k) => this[k] = this.data[k]);
|
].forEach((k) => this[k] = this.data[k]);
|
||||||
this.listenDuringPrompt = this.data.listenDuringPrompt === false ? false : true;
|
this.listenDuringPrompt = this.data.listenDuringPrompt === false ? false : true;
|
||||||
this.minBargeinWordCount = this.data.minBargeinWordCount || 1;
|
this.minBargeinWordCount = this.data.minBargeinWordCount || 1;
|
||||||
// this is specially for barge in where we want to make a bargebale promt
|
// 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
|
// 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.timeout = (this.timeout || 15) * 1000;
|
||||||
this.interim = this.partialResultCallback || this.bargein;
|
this.interim = this.partialResultCallback || this.bargein;
|
||||||
if (this.data.recognizer) {
|
if (this.data.recognizer) {
|
||||||
@@ -104,15 +104,27 @@ class TaskGather extends Task {
|
|||||||
this.sayTask.on('playDone', async(err) => {
|
this.sayTask.on('playDone', async(err) => {
|
||||||
if (err) return this.logger.error({err}, 'Gather:exec Error playing tts');
|
if (err) return this.logger.error({err}, 'Gather:exec Error playing tts');
|
||||||
this.logger.debug('Gather: say task completed');
|
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) {
|
else if (this.playTask) {
|
||||||
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
|
||||||
this.playTask.on('playDone', async(err) => {
|
this.playTask.on('playDone', async(err) => {
|
||||||
if (err) return this.logger.error({err}, 'Gather:exec Error playing url');
|
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);
|
else startListening(cs, ep);
|
||||||
|
|
||||||
|
|||||||
@@ -21,9 +21,8 @@ class TaskSay extends Task {
|
|||||||
const {updateSpeechCredentialLastUsed} = require('../utils/db-utils')(this.logger, srf);
|
const {updateSpeechCredentialLastUsed} = require('../utils/db-utils')(this.logger, srf);
|
||||||
const {writeAlerts, AlertType, stats} = srf.locals;
|
const {writeAlerts, AlertType, stats} = srf.locals;
|
||||||
const {synthAudio} = srf.locals.dbHelpers;
|
const {synthAudio} = srf.locals.dbHelpers;
|
||||||
|
const vendor = this.synthesizer.vendor || cs.speechSynthesisVendor;
|
||||||
const vendor = this.synthesizer.vendor || cs.speechSynthesisVendor;
|
const language = this.synthesizer.language || cs.speechSynthesisLanguage ;
|
||||||
const language = this.synthesizer.language || cs.speechSynthesisLanguage ;
|
|
||||||
const voice = this.synthesizer.voice || cs.speechSynthesisVoice ;
|
const voice = this.synthesizer.voice || cs.speechSynthesisVoice ;
|
||||||
const engine = this.synthesizer.engine || 'standard';
|
const engine = this.synthesizer.engine || 'standard';
|
||||||
const salt = cs.callSid;
|
const salt = cs.callSid;
|
||||||
|
|||||||
Reference in New Issue
Block a user