@jambonz/speech-utils 0.0.33 → 0.0.34

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.
Files changed (2) hide show
  1. package/lib/synth-audio.js +32 -3
  2. package/package.json +13 -13
@@ -76,7 +76,8 @@ const trimTrailingSilence = (buffer) => {
76
76
  * the synthesized audio, and a variable indicating whether it was served from cache
77
77
  */
78
78
  async function synthAudio(client, logger, stats, { account_sid,
79
- vendor, language, voice, gender, text, engine, salt, model, credentials, deploymentId, disableTtsCache, options
79
+ vendor, language, voice, gender, text, engine, salt, model, credentials, deploymentId,
80
+ disableTtsCache, renderForCaching, options
80
81
  }) {
81
82
  let audioBuffer;
82
83
  let servedFromCache = false;
@@ -194,7 +195,15 @@ async function synthAudio(client, logger, stats, { account_sid,
194
195
  audioBuffer = await synthWellSaid(logger, {credentials, stats, language, voice, text, filePath});
195
196
  break;
196
197
  case 'elevenlabs':
197
- audioBuffer = await synthElevenlabs(logger, {credentials, options, stats, language, voice, text, filePath});
198
+ audioBuffer = await synthElevenlabs(logger, {
199
+ credentials, options, stats, language, voice, text, renderForCaching, filePath
200
+ });
201
+ if (typeof audioBuffer === 'object' && audioBuffer.filePath) {
202
+ return audioBuffer;
203
+ }
204
+ else {
205
+ audioBuffer = await synthElevenlabs(logger, {credentials, options, stats, language, voice, text, filePath});
206
+ }
198
207
  break;
199
208
  case 'whisper':
200
209
  audioBuffer = await synthWhisper(logger, {credentials, stats, voice, text});
@@ -594,9 +603,29 @@ const synthCustomVendor = async(logger, {credentials, stats, language, voice, te
594
603
  }
595
604
  };
596
605
 
597
- const synthElevenlabs = async(logger, {credentials, options, stats, language, voice, text}) => {
606
+ const synthElevenlabs = async(logger, {credentials, options, stats, language, voice, text, renderForCaching}) => {
598
607
  const {api_key, model_id, options: credOpts} = credentials;
599
608
  const opts = !!options && Object.keys(options).length !== 0 ? options : JSON.parse(credOpts || '{}');
609
+
610
+ /* if the env is set to stream then bag out, unless we are specifically rendering to generate a cache file */
611
+ if (process.env.JAMBONES_ELEVENLABS_STREAMING && !renderForCaching) {
612
+ let params = '';
613
+ params += `{api_key=${api_key}`;
614
+ params += `,model_id=${model_id}`;
615
+ params += `,optimize_streaming_latency=${opts.optimize_streaming_latency || 2}`;
616
+ if (opts.voice_settings?.similarity_boost) params += `,similarity_boost=${opts.voice_settings.similarity_boost}`;
617
+ if (opts.voice_settings?.stability) params += `,stability=${opts.voice_settings.stability}`;
618
+ if (opts.voice_settings?.style) params += `,style=${opts.voice_settings.style}`;
619
+ if (opts.voice_settings?.use_speaker_boost === false) params += ',use_speaker_boost=false';
620
+ params += '}';
621
+
622
+ return {
623
+ filePath: `say:${params}${text.replace(/\n/g, ' ')}`,
624
+ servedFromCache: false,
625
+ rtt: 0
626
+ };
627
+ }
628
+
600
629
  const optimize_streaming_latency = opts.optimize_streaming_latency ?
601
630
  `?optimize_streaming_latency=${opts.optimize_streaming_latency}` : '';
602
631
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jambonz/speech-utils",
3
- "version": "0.0.33",
3
+ "version": "0.0.34",
4
4
  "description": "TTS-related speech utilities for jambonz",
5
5
  "main": "index.js",
6
6
  "author": "Dave Horton",
@@ -24,26 +24,26 @@
24
24
  },
25
25
  "homepage": "https://github.com/jambonz/speech-utils#readme",
26
26
  "dependencies": {
27
- "@aws-sdk/client-polly": "^3.359.0",
28
- "@aws-sdk/client-sts": "^3.458.0",
29
- "@google-cloud/text-to-speech": "^4.2.1",
30
- "@grpc/grpc-js": "^1.8.13",
27
+ "@aws-sdk/client-polly": "^3.496.0",
28
+ "@aws-sdk/client-sts": "^3.496.0",
29
+ "@google-cloud/text-to-speech": "^5.0.2",
30
+ "@grpc/grpc-js": "^1.9.14",
31
31
  "@jambonz/realtimedb-helpers": "^0.8.7",
32
32
  "bent": "^7.3.12",
33
33
  "debug": "^4.3.4",
34
- "form-urlencoded": "^6.1.0",
34
+ "form-urlencoded": "^6.1.4",
35
35
  "google-protobuf": "^3.21.2",
36
36
  "ibm-watson": "^8.0.0",
37
- "microsoft-cognitiveservices-speech-sdk": "1.32.0",
38
- "openai": "^4.16.2",
39
- "undici": "^5.21.0"
37
+ "microsoft-cognitiveservices-speech-sdk": "1.34.0",
38
+ "openai": "^4.25.0",
39
+ "undici": "^6.4.0"
40
40
  },
41
41
  "devDependencies": {
42
- "config": "^3.3.9",
43
- "eslint": "^8.33.0",
42
+ "config": "^3.3.10",
43
+ "eslint": "^8.56.0",
44
44
  "eslint-plugin-promise": "^6.1.1",
45
45
  "nyc": "^15.1.0",
46
- "pino": "^7.2.0",
47
- "tape": "^5.1.1"
46
+ "pino": "^8.17.0",
47
+ "tape": "^5.7.3"
48
48
  }
49
49
  }