From 7f7c26e982cd8f0e1eb3be635d2f76ad3249d93b Mon Sep 17 00:00:00 2001 From: Dave Horton Date: Wed, 25 Sep 2024 20:13:56 -0400 Subject: [PATCH] fix for https://github.com/jambonz/freeswitch-modules/issues/117 (#912) --- lib/session/call-session.js | 9 --------- lib/tasks/tts-task.js | 15 +++++++++++++-- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/lib/session/call-session.js b/lib/session/call-session.js index 1da224dc..e1b8d905 100644 --- a/lib/session/call-session.js +++ b/lib/session/call-session.js @@ -520,15 +520,6 @@ class CallSession extends Emitter { this._actionHookDelayRetries = e; } - // Getter/setter for current tts vendor - get currentTtsVendor() { - return this._currentTtsVendor; - } - - set currentTtsVendor(vendor) { - this._currentTtsVendor = vendor; - } - get actionHookDelayProcessor() { return this._actionHookDelayProcessor; } diff --git a/lib/tasks/tts-task.js b/lib/tasks/tts-task.js index 583b522d..be085841 100644 --- a/lib/tasks/tts-task.js +++ b/lib/tasks/tts-task.js @@ -95,14 +95,25 @@ class TtsTask extends Task { credentials.voice_engine = this.options.voice_engine || credentials.voice_engine; } + /** + * note on cache_speech_handles. This was found to be risky. + * It can cause a crash in the following sequence on a single call: + * 1. Stream tts on vendor A with cache_speech_handles=1, then + * 2. Stream tts on vendor B with cache_speech_handles=1 + * + * we previously tried to track when vendors were switched and manage the flag accordingly, + * but it difficult to track all the scenarios and the benefit (slightly faster start to tts playout) + * is probably minimal. DH. + */ ep.set({ tts_engine: vendor.startsWith('custom:') ? 'custom' : vendor, tts_voice: voice, - cache_speech_handles: !cs.currentTtsVendor || cs.currentTtsVendor === vendor ? 1 : 0, + //cache_speech_handles: !cs.currentTtsVendor || cs.currentTtsVendor === vendor ? 1 : 0, + cache_speech_handles: 0, }).catch((err) => this.logger.info({err}, 'Error setting tts_engine on endpoint')); // set the current vendor on the call session // If vendor is changed from the previous one, then reset the cache_speech_handles flag - cs.currentTtsVendor = vendor; + //cs.currentTtsVendor = vendor; if (!preCache && !this._disableTracing) this.logger.info({vendor, language, voice, model}, 'TaskSay:exec'); try {