From 70e4e10a70ba127694a9aa484a4f55b7738cdd60 Mon Sep 17 00:00:00 2001 From: Dave Horton Date: Sun, 21 Feb 2021 11:30:55 -0500 Subject: [PATCH] dialogflow tts fix and gather fix --- lib/tasks/dialogflow/index.js | 18 +++++++++--------- lib/tasks/gather.js | 6 ++++-- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/lib/tasks/dialogflow/index.js b/lib/tasks/dialogflow/index.js index 5cd75b6d..dc43a569 100644 --- a/lib/tasks/dialogflow/index.js +++ b/lib/tasks/dialogflow/index.js @@ -214,27 +214,27 @@ class Dialogflow extends Task { salt: cs.callSid }; this.logger.debug({obj}, 'Dialogflow:_onIntent - playing message via tts'); - const {filepath} = await synthAudio(obj); - if (filepath) cs.trackTmpFile(filepath); + const {filePath} = await synthAudio(obj); + if (filePath) cs.trackTmpFile(filePath); if (this.playInProgress) { await ep.api('uuid_break', ep.uuid).catch((err) => this.logger.info(err, 'Error killing audio')); } 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')) { - 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')) { - 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; if (this.queuedTasks) { this.logger.debug('finished playing audio and we have queued tasks'); diff --git a/lib/tasks/gather.js b/lib/tasks/gather.js index 34979b1c..9bda6fe5 100644 --- a/lib/tasks/gather.js +++ b/lib/tasks/gather.js @@ -113,8 +113,10 @@ class TaskGather extends Task { GOOGLE_SPEECH_SINGLE_UTTERANCE: true, GOOGLE_SPEECH_MODEL: 'command_and_search' }); - if (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.hints && this.hints.length > 1) opts.GOOGLE_SPEECH_HINTS = this.hints.join(','); + if (this.altLanguages && this.altLanguages.length > 1) { + opts.GOOGLE_SPEECH_ALTERNATIVE_LANGUAGE_CODES = this.altLanguages.join(','); + } if (this.profanityFilter === true) { Object.assign(opts, {'GOOGLE_SPEECH_PROFANITY_FILTER': true}); }