mirror of
https://github.com/jambonz/speech-utils.git
synced 2026-07-04 19:31:49 +00:00
fix prev commit
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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`;
|
||||
|
||||
Reference in New Issue
Block a user