@jambonz/speech-utils 0.0.37 → 0.0.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/add-file-to-cache.js +6 -5
- package/lib/synth-audio.js +5 -1
- package/package.json +1 -1
package/lib/add-file-to-cache.js
CHANGED
|
@@ -4,10 +4,11 @@ const EXPIRES = (process.env.JAMBONES_TTS_CACHE_DURATION_MINS || 4 * 60) * 60; /
|
|
|
4
4
|
|
|
5
5
|
async function addFileToCache(client, logger, path,
|
|
6
6
|
{account_sid, vendor, language, voice, deploymentId, engine, text}) {
|
|
7
|
+
let key;
|
|
7
8
|
logger = logger || noopLogger;
|
|
8
9
|
|
|
9
10
|
try {
|
|
10
|
-
|
|
11
|
+
key = makeSynthKey({
|
|
11
12
|
account_sid,
|
|
12
13
|
vendor,
|
|
13
14
|
language: language || '',
|
|
@@ -15,15 +16,15 @@ async function addFileToCache(client, logger, path,
|
|
|
15
16
|
engine,
|
|
16
17
|
text,
|
|
17
18
|
});
|
|
18
|
-
const audioBuffer = fs.readFile(path);
|
|
19
|
+
const audioBuffer = await fs.readFile(path);
|
|
19
20
|
await client.setex(key, EXPIRES, audioBuffer.toString('base64'));
|
|
20
21
|
} catch (err) {
|
|
21
22
|
logger.error(err, 'addFileToCache: Error');
|
|
22
|
-
return
|
|
23
|
+
return;
|
|
23
24
|
}
|
|
24
25
|
|
|
25
|
-
logger.debug(`addFileToCache: added ${path} to cache`);
|
|
26
|
-
return
|
|
26
|
+
logger.debug(`addFileToCache: added ${path} to cache with key ${key}`);
|
|
27
|
+
return key;
|
|
27
28
|
}
|
|
28
29
|
|
|
29
30
|
module.exports = addFileToCache;
|
package/lib/synth-audio.js
CHANGED
|
@@ -143,6 +143,10 @@ async function synthAudio(client, logger, stats, { account_sid,
|
|
|
143
143
|
(
|
|
144
144
|
process.env.JAMBONES_TTS_TRIM_SILENCE &&
|
|
145
145
|
['microsoft', 'azure'].includes(vendor)
|
|
146
|
+
) ||
|
|
147
|
+
(
|
|
148
|
+
process.env.JAMBONES_ELEVENLABS_STREAMING &&
|
|
149
|
+
vendor === 'elevenlabs'
|
|
146
150
|
)
|
|
147
151
|
) {
|
|
148
152
|
filePath = `${TMP_FOLDER}/${key.replace('tts:', `tts-${salt || ''}`)}.r8`;
|
|
@@ -621,7 +625,7 @@ const synthElevenlabs = async(logger, {credentials, options, stats, language, vo
|
|
|
621
625
|
params += '}';
|
|
622
626
|
|
|
623
627
|
return {
|
|
624
|
-
filePath: `say:${params}${text.replace(/\n/g, ' ')}`,
|
|
628
|
+
filePath: `say:${params}${text.replace(/\n/g, ' ').replace(/\r/g, ' ')}`,
|
|
625
629
|
servedFromCache: false,
|
|
626
630
|
rtt: 0
|
|
627
631
|
};
|