@jambonz/speech-utils 0.2.24 → 0.2.26

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.
@@ -11,7 +11,7 @@ jobs:
11
11
  - uses: actions/checkout@v4
12
12
  - uses: actions/setup-node@v4
13
13
  with:
14
- node-version: lts/*
14
+ node-version: '20'
15
15
  - run: npm install
16
16
  - name: Install Docker Compose
17
17
  run: |
@@ -877,7 +877,7 @@ const synthCustomVendor = async(logger, {credentials, stats, language, voice,
877
877
  const synthElevenlabs = async(logger, {
878
878
  credentials, options, stats, voice, key, text, renderForCaching, disableTtsStreaming, disableTtsCache
879
879
  }) => {
880
- const {api_key, model_id, options: credOpts} = credentials;
880
+ const {api_key, model_id, api_uri, options: credOpts} = credentials;
881
881
  const opts = !!options && Object.keys(options).length !== 0 ? options : JSON.parse(credOpts || '{}');
882
882
 
883
883
  /* default to using the streaming interface, unless disabled by env var OR we want just a cache file */
@@ -889,6 +889,7 @@ const synthElevenlabs = async(logger, {
889
889
  params += `,voice=${voice}`;
890
890
  params += `,model_id=${model_id}`;
891
891
  params += `,write_cache_file=${disableTtsCache ? 0 : 1}`;
892
+ if (api_uri) params += `,api_uri=${api_uri}`;
892
893
  if (opts.optimize_streaming_latency !== null && opts.optimize_streaming_latency !== undefined) {
893
894
  params += `,optimize_streaming_latency=${opts.optimize_streaming_latency}`;
894
895
  }
@@ -914,7 +915,7 @@ const synthElevenlabs = async(logger, {
914
915
  const optimize_streaming_latency = opts.optimize_streaming_latency ?
915
916
  `?optimize_streaming_latency=${opts.optimize_streaming_latency}` : '';
916
917
  try {
917
- const post = bent('https://api.elevenlabs.io', 'POST', 'buffer', {
918
+ const post = bent(`https://${api_uri}`, 'POST', 'buffer', {
918
919
  'xi-api-key': api_key,
919
920
  'Accept': 'audio/mpeg',
920
921
  'Content-Type': 'application/json'
@@ -1315,6 +1316,7 @@ const synthCartesia = async(logger, {
1315
1316
  if (embedding) params += `,embedding=${embedding}`;
1316
1317
  if (opts.speed) params += `,speed=${opts.speed}`;
1317
1318
  if (opts.emotion) params += `,emotion=${opts.emotion}`;
1319
+ if (opts.volume) params += `,volume=${opts.volume}`;
1318
1320
  params += '}';
1319
1321
 
1320
1322
  return {
@@ -1340,13 +1342,20 @@ const synthCartesia = async(logger, {
1340
1342
  id: voice
1341
1343
  }
1342
1344
  ),
1343
- ...(opts.speed || opts.emotion && {
1345
+ ...(model_id === 'sonic-2' && (opts.speed || opts.emotion) && {
1344
1346
  experimentalControls: {
1345
1347
  ...(opts.speed !== null && opts.speed !== undefined && {speed: opts.speed}),
1346
- ...(opts.emotion && {emotion: opts.emotion}),
1348
+ ...(opts.emotion && {emotion: [opts.emotion]}),
1347
1349
  }
1348
- })
1350
+ }),
1349
1351
  },
1352
+ ...(model_id === 'sonic-3' && (opts.speed || opts.emotion || opts.volume) && {
1353
+ generationConfig: {
1354
+ ...(opts.volume !== null && opts.volume !== undefined && {volume: opts.volume}),
1355
+ ...(opts.speed !== null && opts.speed !== undefined && {speed: opts.speed}),
1356
+ ...(opts.emotion !== null && opts.emotion !== undefined && {emotion: opts.emotion}),
1357
+ }
1358
+ }),
1350
1359
  language: language,
1351
1360
  outputFormat: {
1352
1361
  container: 'mp3',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jambonz/speech-utils",
3
- "version": "0.2.24",
3
+ "version": "0.2.26",
4
4
  "description": "TTS-related speech utilities for jambonz",
5
5
  "main": "index.js",
6
6
  "author": "Dave Horton",
@@ -29,7 +29,7 @@
29
29
  "23": "^0.0.0",
30
30
  "@aws-sdk/client-polly": "^3.496.0",
31
31
  "@aws-sdk/client-sts": "^3.496.0",
32
- "@cartesia/cartesia-js": "^2.1.0",
32
+ "@cartesia/cartesia-js": "^2.2.7",
33
33
  "@google-cloud/text-to-speech": "^5.5.0",
34
34
  "@grpc/grpc-js": "^1.9.14",
35
35
  "@jambonz/realtimedb-helpers": "^0.8.7",