diff --git a/lib/synth-audio.js b/lib/synth-audio.js index 89ab5d7..0e3b274 100644 --- a/lib/synth-audio.js +++ b/lib/synth-audio.js @@ -86,7 +86,7 @@ const trimTrailingSilence = (buffer) => { */ async function synthAudio(client, createHash, retrieveHash, logger, stats, { account_sid, vendor, language, voice, gender, text, engine, salt, model, credentials, deploymentId, - disableTtsCache, renderForCaching, disableTtsStreaming, options, preCache = false + disableTtsCache, renderForCaching = false, disableTtsStreaming, options }) { let audioBuffer; let servedFromCache = false; @@ -165,7 +165,7 @@ async function synthAudio(client, createHash, retrieveHash, logger, stats, { acc voice: voice || deploymentId, engine, text, - preCache: true + renderForCaching: true }); const key = makeSynthKey({ @@ -175,10 +175,10 @@ async function synthAudio(client, createHash, retrieveHash, logger, stats, { acc voice: voice || deploymentId, engine, text, - preCache + renderForCaching }); let filePath; - filePath = makeFilePath({vendor, key, salt, preCache}); + filePath = makeFilePath({vendor, key, salt, renderForCaching}); debug(`synth key is ${key}`); let cached; if (!disableTtsCache) { @@ -187,7 +187,7 @@ async function synthAudio(client, createHash, retrieveHash, logger, stats, { acc cached = await client.get(preCachekey); if (cached) { // Precache audio is available update filpath with precache file extension. - filePath = makeFilePath({vendor, key, salt, preCache: true}); + filePath = makeFilePath({vendor, key, salt, renderForCaching: true}); } else { cached = await client.get(key); } diff --git a/lib/utils.js b/lib/utils.js index 0390910..9d088c1 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -18,29 +18,29 @@ const debug = require('debug')('jambonz:realtimedb-helpers'); function makeSynthKey({ account_sid = '', vendor, language, voice, engine = '', text, - preCache = false}) { + renderForCaching = false}) { const hash = crypto.createHash('sha1'); hash.update(`${language}:${vendor}:${voice}:${engine}:${text}`); const hexHashKey = hash.digest('hex'); const accountKey = account_sid ? `:${account_sid}` : ''; - const namespace = vendor.startsWith('custom') ? vendor : getFileExtension({vendor, preCache}); + const namespace = vendor.startsWith('custom') ? vendor : getFileExtension({vendor, renderForCaching}); const key = `tts${accountKey}:${namespace}:${hexHashKey}`; return key; } -function makeFilePath({vendor, key, salt = '', preCache = false}) { - const extension = getFileExtension({vendor, preCache}); +function makeFilePath({vendor, key, salt = '', renderForCaching = false}) { + const extension = getFileExtension({vendor, renderForCaching}); return `${TMP_FOLDER}/${key.replace('tts:', `tts-${salt}`)}.${extension}`; } -function getFileExtension({vendor, preCache = false}) { +function getFileExtension({vendor, renderForCaching = false}) { const mp3Extension = 'mp3'; const r8Extension = 'r8'; switch (vendor) { case 'azure': case 'microsoft': - if (!preCache && !JAMBONES_DISABLE_TTS_STREAMING || JAMBONES_TTS_TRIM_SILENCE) { + if (!renderForCaching && !JAMBONES_DISABLE_TTS_STREAMING || JAMBONES_TTS_TRIM_SILENCE) { return r8Extension; } else { return mp3Extension; @@ -48,7 +48,7 @@ function getFileExtension({vendor, preCache = false}) { case 'deepgram': case 'elevenlabs': case 'rimlabs': - if (!preCache && !JAMBONES_DISABLE_TTS_STREAMING) { + if (!renderForCaching && !JAMBONES_DISABLE_TTS_STREAMING) { return r8Extension; } else { return mp3Extension;