@jambonz/speech-utils 0.0.37 → 0.0.38

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.
@@ -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
- const key = makeSynthKey({
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 false;
23
+ return;
23
24
  }
24
25
 
25
- logger.debug(`addFileToCache: added ${path} to cache`);
26
- return true;
26
+ logger.debug(`addFileToCache: added ${path} to cache with key ${key}`);
27
+ return key;
27
28
  }
28
29
 
29
30
  module.exports = addFileToCache;
@@ -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`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jambonz/speech-utils",
3
- "version": "0.0.37",
3
+ "version": "0.0.38",
4
4
  "description": "TTS-related speech utilities for jambonz",
5
5
  "main": "index.js",
6
6
  "author": "Dave Horton",