dialogflow tts fix and gather fix

This commit is contained in:
Dave Horton
2021-02-21 11:30:55 -05:00
parent 82768a0442
commit 70e4e10a70
2 changed files with 13 additions and 11 deletions

View File

@@ -214,27 +214,27 @@ class Dialogflow extends Task {
salt: cs.callSid salt: cs.callSid
}; };
this.logger.debug({obj}, 'Dialogflow:_onIntent - playing message via tts'); this.logger.debug({obj}, 'Dialogflow:_onIntent - playing message via tts');
const {filepath} = await synthAudio(obj); const {filePath} = await synthAudio(obj);
if (filepath) cs.trackTmpFile(filepath); if (filePath) cs.trackTmpFile(filePath);
if (this.playInProgress) { if (this.playInProgress) {
await ep.api('uuid_break', ep.uuid).catch((err) => this.logger.info(err, 'Error killing audio')); await ep.api('uuid_break', ep.uuid).catch((err) => this.logger.info(err, 'Error killing audio'));
} }
this.playInProgress = true; this.playInProgress = true;
this.curentAudioFile = filepath; this.curentAudioFile = filePath;
this.logger.debug(`starting to play tts ${filepath}`); this.logger.debug(`starting to play tts ${filePath}`);
if (this.events.includes('start-play')) { if (this.events.includes('start-play')) {
this._performHook(cs, this.eventHook, {event: 'start-play', data: {path: filepath}}); this._performHook(cs, this.eventHook, {event: 'start-play', data: {path: filePath}});
} }
await ep.play(filepath); await ep.play(filePath);
if (this.events.includes('stop-play')) { if (this.events.includes('stop-play')) {
this._performHook(cs, this.eventHook, {event: 'stop-play', data: {path: filepath}}); this._performHook(cs, this.eventHook, {event: 'stop-play', data: {path: filePath}});
} }
this.logger.debug(`finished ${filepath}`); this.logger.debug(`finished ${filePath}`);
if (this.curentAudioFile === filepath) { if (this.curentAudioFile === filePath) {
this.playInProgress = false; this.playInProgress = false;
if (this.queuedTasks) { if (this.queuedTasks) {
this.logger.debug('finished playing audio and we have queued tasks'); this.logger.debug('finished playing audio and we have queued tasks');

View File

@@ -113,8 +113,10 @@ class TaskGather extends Task {
GOOGLE_SPEECH_SINGLE_UTTERANCE: true, GOOGLE_SPEECH_SINGLE_UTTERANCE: true,
GOOGLE_SPEECH_MODEL: 'command_and_search' GOOGLE_SPEECH_MODEL: 'command_and_search'
}); });
if (this.hints.length > 1) opts.GOOGLE_SPEECH_HINTS = this.hints.join(','); if (this.hints && this.hints.length > 1) opts.GOOGLE_SPEECH_HINTS = this.hints.join(',');
if (this.altLanguages.length > 1) opts.GOOGLE_SPEECH_ALTERNATIVE_LANGUAGE_CODES = this.altLanguages.join(','); if (this.altLanguages && this.altLanguages.length > 1) {
opts.GOOGLE_SPEECH_ALTERNATIVE_LANGUAGE_CODES = this.altLanguages.join(',');
}
if (this.profanityFilter === true) { if (this.profanityFilter === true) {
Object.assign(opts, {'GOOGLE_SPEECH_PROFANITY_FILTER': true}); Object.assign(opts, {'GOOGLE_SPEECH_PROFANITY_FILTER': true});
} }