fix prev commit

This commit is contained in:
Dave Horton
2024-01-26 11:08:06 -05:00
parent 4b5430d61d
commit c3b7ea4cd1
2 changed files with 10 additions and 5 deletions
+6 -5
View File
@@ -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;
+4
View File
@@ -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`;