mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2025-12-21 09:08:02 +00:00
feat fallback speech
This commit is contained in:
@@ -133,7 +133,7 @@ class Dialogflow extends Task {
|
||||
this.fallbackVoice = cs.fallbackSpeechSynthesisVoice;
|
||||
this.fallbackLabel = cs.fallbackSpeechSynthesisLabel;
|
||||
}
|
||||
this.ttsCredentials = cs.getSpeechCredentials(this.vendor, 'tts',this.speechSynthesisLabel);
|
||||
this.ttsCredentials = cs.getSpeechCredentials(this.vendor, 'tts', this.speechSynthesisLabel);
|
||||
|
||||
this.ep.addCustomEventListener('dialogflow::intent', this._onIntent.bind(this, ep, cs));
|
||||
this.ep.addCustomEventListener('dialogflow::transcription', this._onTranscription.bind(this, ep, cs));
|
||||
@@ -235,7 +235,7 @@ class Dialogflow extends Task {
|
||||
}
|
||||
|
||||
try {
|
||||
const {filePath, servedFromCache} = await this.fallbackSynthAudio(cs, intent, stats);
|
||||
const {filePath, servedFromCache} = await this.fallbackSynthAudio(cs, intent, stats, synthAudio);
|
||||
if (filePath) cs.trackTmpFile(filePath);
|
||||
if (!this.ttsCredentials && !servedFromCache) cs.billForTts(intent.fulfillmentText.length);
|
||||
|
||||
@@ -281,7 +281,7 @@ class Dialogflow extends Task {
|
||||
}
|
||||
}
|
||||
|
||||
async fallbackSynthAudio(cs, intent, stats) {
|
||||
async fallbackSynthAudio(cs, intent, stats, synthAudio) {
|
||||
try {
|
||||
const obj = {
|
||||
account_sid: cs.accountSid,
|
||||
@@ -299,7 +299,7 @@ class Dialogflow extends Task {
|
||||
this.logger.info({error}, 'Failed to synthesize audio from primary vendor');
|
||||
|
||||
try {
|
||||
if(this.fallbackVendor) {
|
||||
if (this.fallbackVendor) {
|
||||
const credentials = cs.getSpeechCredentials(this.fallbackVendor, 'tts', this.fallbackLabel);
|
||||
const obj = {
|
||||
account_sid: cs.accountSid,
|
||||
@@ -313,7 +313,7 @@ class Dialogflow extends Task {
|
||||
this.logger.debug({obj}, 'Dialogflow:_onIntent - playing message via fallback tts');
|
||||
return await synthAudio(stats, obj);
|
||||
}
|
||||
} catch(err) {
|
||||
} catch (err) {
|
||||
this.logger.info({err}, 'Failed to synthesize audio from falllback vendor');
|
||||
throw err;
|
||||
}
|
||||
|
||||
@@ -210,7 +210,7 @@ class Lex extends Task {
|
||||
credentials: credential
|
||||
});
|
||||
return filePath;
|
||||
} catch(err) {
|
||||
} catch (err) {
|
||||
this.logger.info({err}, 'failed to synth audio from fallback vendor');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -200,7 +200,7 @@ class TaskSay extends Task {
|
||||
executedVendor = fallbackVendor;
|
||||
executedLanguage = fallbackLanguage;
|
||||
|
||||
} catch (err){
|
||||
} catch (err) {
|
||||
this.logger.info({err}, 'fallback Speech failed to synthesize audio');
|
||||
fallbackSpan.end();
|
||||
writeAlerts({
|
||||
|
||||
Reference in New Issue
Block a user