@jambonz/speech-utils 0.2.19 → 0.2.20

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 +31 -20
  2. package/package.json +1 -1
@@ -53,6 +53,8 @@ const EXPIRES = JAMBONES_TTS_CACHE_DURATION_MINS;
53
53
  const OpenAI = require('openai');
54
54
  const getAwsAuthToken = require('./get-aws-sts-token');
55
55
 
56
+ /* counter for playback id */
57
+ let playbackIdCounter = 0;
56
58
 
57
59
  const trimTrailingSilence = (buffer) => {
58
60
  assert.ok(buffer instanceof Buffer, 'trimTrailingSilence - argument is not a Buffer');
@@ -589,8 +591,8 @@ const synthMicrosoft = async(logger, {
589
591
  }
590
592
  if (!JAMBONES_DISABLE_TTS_STREAMING && !JAMBONES_DISABLE_AZURE_TTS_STREAMING &&
591
593
  !renderForCaching && !disableTtsStreaming) {
592
- let params = '';
593
- params += `{api_key=${apiKey}`;
594
+ let params = '{';
595
+ params += `api_key=${apiKey}`;
594
596
  params += `,language=${language}`;
595
597
  params += ',vendor=microsoft';
596
598
  params += `,voice=${voice}`;
@@ -853,8 +855,9 @@ const synthElevenlabs = async(logger, {
853
855
 
854
856
  /* default to using the streaming interface, unless disabled by env var OR we want just a cache file */
855
857
  if (!JAMBONES_DISABLE_TTS_STREAMING && !renderForCaching && !disableTtsStreaming) {
856
- let params = '';
857
- params += `{api_key=${api_key}`;
858
+ let params = '{';
859
+ params += `api_key=${api_key}`;
860
+ params += `,playback_id=${playbackIdCounter++}`;
858
861
  params += ',vendor=elevenlabs';
859
862
  params += `,voice=${voice}`;
860
863
  params += `,model_id=${model_id}`;
@@ -943,8 +946,9 @@ const synthPlayHT = async(client, logger, {
943
946
 
944
947
  /* default to using the streaming interface, unless disabled by env var OR we want just a cache file */
945
948
  if (!JAMBONES_DISABLE_TTS_STREAMING && !renderForCaching && !disableTtsStreaming) {
946
- let params = '';
947
- params += `{api_key=${api_key}`;
949
+ let params = '{';
950
+ params += `api_key=${api_key}`;
951
+ params += `,playback_id=${playbackIdCounter++}`;
948
952
  params += `,user_id=${user_id}`;
949
953
  params += ',vendor=playht';
950
954
  params += `,voice=${voice}`;
@@ -1010,8 +1014,9 @@ const synthInworld = async(logger, {
1010
1014
 
1011
1015
  /* default to using the streaming interface, unless disabled by env var OR we want just a cache file */
1012
1016
  if (!JAMBONES_DISABLE_TTS_STREAMING && !renderForCaching && !disableTtsStreaming) {
1013
- let params = '';
1014
- params += `{api_key=${api_key}`;
1017
+ let params = '{';
1018
+ params += `api_key=${api_key}`;
1019
+ params += `,playback_id=${playbackIdCounter++}`;
1015
1020
  params += `,model_id=${model_id}`;
1016
1021
  params += ',vendor=inworld';
1017
1022
  params += `,voice=${voice}`;
@@ -1074,8 +1079,9 @@ const synthRimelabs = async(logger, {
1074
1079
 
1075
1080
  /* default to using the streaming interface, unless disabled by env var OR we want just a cache file */
1076
1081
  if (!JAMBONES_DISABLE_TTS_STREAMING && !renderForCaching && !disableTtsStreaming) {
1077
- let params = '';
1078
- params += `{api_key=${api_key}`;
1082
+ let params = '{';
1083
+ params += `api_key=${api_key}`;
1084
+ params += `,playback_id=${playbackIdCounter++}`;
1079
1085
  params += `,model_id=${model_id}`;
1080
1086
  params += ',vendor=rimelabs';
1081
1087
  params += `,language=${language}`;
@@ -1130,8 +1136,9 @@ const synthVerbio = async(client, logger, {credentials, stats, voice, text, rend
1130
1136
  }
1131
1137
  const token = await getVerbioAccessToken(client, logger, credentials);
1132
1138
  if (!process.env.JAMBONES_DISABLE_TTS_STREAMING && !renderForCaching && !disableTtsStreaming) {
1133
- let params = '';
1134
- params += `{access_token=${token.access_token}`;
1139
+ let params = '{';
1140
+ params += `access_token=${token.access_token}`;
1141
+ params += `,playback_id=${playbackIdCounter++}`;
1135
1142
  params += ',vendor=verbio';
1136
1143
  params += `,voice=${voice}`;
1137
1144
  params += ',write_cache_file=1';
@@ -1173,8 +1180,9 @@ const synthWhisper = async(logger, {credentials, stats, voice, text, instruction
1173
1180
  const {api_key, model_id, baseURL, timeout, speed} = credentials;
1174
1181
  /* if the env is set to stream then bag out, unless we are specifically rendering to generate a cache file */
1175
1182
  if (!JAMBONES_DISABLE_TTS_STREAMING && !renderForCaching && !disableTtsStreaming) {
1176
- let params = '';
1177
- params += `{api_key=${api_key}`;
1183
+ let params = '{';
1184
+ params += `api_key=${api_key}`;
1185
+ params += `,playback_id=${playbackIdCounter++}`;
1178
1186
  params += `,model_id=${model_id}`;
1179
1187
  params += ',vendor=whisper';
1180
1188
  params += `,voice=${voice}`;
@@ -1219,8 +1227,9 @@ const synthWhisper = async(logger, {credentials, stats, voice, text, instruction
1219
1227
  const synthDeepgram = async(logger, {credentials, stats, model, text, renderForCaching, disableTtsStreaming}) => {
1220
1228
  const {api_key, deepgram_tts_uri} = credentials;
1221
1229
  if (!JAMBONES_DISABLE_TTS_STREAMING && !renderForCaching && !disableTtsStreaming) {
1222
- let params = '';
1223
- params += `{api_key=${api_key}`;
1230
+ let params = '{';
1231
+ params += `api_key=${api_key}`;
1232
+ params += `,playback_id=${playbackIdCounter++}`;
1224
1233
  params += ',vendor=deepgram';
1225
1234
  params += `,voice=${model}`;
1226
1235
  params += ',write_cache_file=1';
@@ -1262,8 +1271,9 @@ const synthCartesia = async(logger, {
1262
1271
  const opts = !!options && Object.keys(options).length !== 0 ? options : JSON.parse(credOpts || '{}');
1263
1272
 
1264
1273
  if (!JAMBONES_DISABLE_TTS_STREAMING && !renderForCaching && !disableTtsStreaming) {
1265
- let params = '';
1266
- params += `{api_key=${api_key}`;
1274
+ let params = '{';
1275
+ params += `api_key=${api_key}`;
1276
+ params += `,playback_id=${playbackIdCounter++}`;
1267
1277
  params += `,model_id=${model_id}`;
1268
1278
  params += ',vendor=cartesia';
1269
1279
  params += `,voice=${voice}`;
@@ -1333,8 +1343,9 @@ const synthResemble = async(logger, {
1333
1343
 
1334
1344
  /* default to using the streaming interface, unless disabled by env var OR we want just a cache file */
1335
1345
  if (!JAMBONES_DISABLE_TTS_STREAMING && !renderForCaching && !disableTtsStreaming) {
1336
- let params = '';
1337
- params += `{api_key=${api_key}`;
1346
+ let params = '{';
1347
+ params += `api_key=${api_key}`;
1348
+ params += `,playback_id=${playbackIdCounter++}`;
1338
1349
  params += ',vendor=resemble';
1339
1350
  params += `,voice=${voice}`;
1340
1351
  params += ',write_cache_file=1';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jambonz/speech-utils",
3
- "version": "0.2.19",
3
+ "version": "0.2.20",
4
4
  "description": "TTS-related speech utilities for jambonz",
5
5
  "main": "index.js",
6
6
  "author": "Dave Horton",