From c3b7ea4cd12c3f8e8904b0f86e0ee7d3bc5744ec Mon Sep 17 00:00:00 2001 From: Dave Horton Date: Fri, 26 Jan 2024 11:08:06 -0500 Subject: [PATCH] fix prev commit --- lib/add-file-to-cache.js | 11 ++++++----- lib/synth-audio.js | 4 ++++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/add-file-to-cache.js b/lib/add-file-to-cache.js index eb3b7c2..0f70f3c 100644 --- a/lib/add-file-to-cache.js +++ b/lib/add-file-to-cache.js @@ -4,10 +4,11 @@ const EXPIRES = (process.env.JAMBONES_TTS_CACHE_DURATION_MINS || 4 * 60) * 60; / async function addFileToCache(client, logger, path, {account_sid, vendor, language, voice, deploymentId, engine, text}) { + let key; logger = logger || noopLogger; try { - const key = makeSynthKey({ + key = makeSynthKey({ account_sid, vendor, language: language || '', @@ -15,15 +16,15 @@ async function addFileToCache(client, logger, path, engine, text, }); - const audioBuffer = fs.readFile(path); + const audioBuffer = await fs.readFile(path); await client.setex(key, EXPIRES, audioBuffer.toString('base64')); } catch (err) { logger.error(err, 'addFileToCache: Error'); - return false; + return; } - logger.debug(`addFileToCache: added ${path} to cache`); - return true; + logger.debug(`addFileToCache: added ${path} to cache with key ${key}`); + return key; } module.exports = addFileToCache; diff --git a/lib/synth-audio.js b/lib/synth-audio.js index 78316bf..101a8c4 100644 --- a/lib/synth-audio.js +++ b/lib/synth-audio.js @@ -143,6 +143,10 @@ async function synthAudio(client, logger, stats, { account_sid, ( process.env.JAMBONES_TTS_TRIM_SILENCE && ['microsoft', 'azure'].includes(vendor) + ) || + ( + process.env.JAMBONES_ELEVENLABS_STREAMING && + vendor === 'elevenlabs' ) ) { filePath = `${TMP_FOLDER}/${key.replace('tts:', `tts-${salt || ''}`)}.r8`;