@jambonz/speech-utils 0.2.19 → 0.2.21
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/synth-audio.js +34 -20
- package/package.json +1 -1
package/lib/synth-audio.js
CHANGED
|
@@ -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');
|
|
@@ -313,6 +315,7 @@ const synthPolly = async(createHash, retrieveHash, logger,
|
|
|
313
315
|
|
|
314
316
|
let params = '{';
|
|
315
317
|
params += `language=${language}`;
|
|
318
|
+
params += `,playback_id=${playbackIdCounter++}`;
|
|
316
319
|
params += ',write_cache_file=1';
|
|
317
320
|
params += ',vendor=aws';
|
|
318
321
|
if (accessKeyId && secretAccessKey) {
|
|
@@ -589,8 +592,9 @@ const synthMicrosoft = async(logger, {
|
|
|
589
592
|
}
|
|
590
593
|
if (!JAMBONES_DISABLE_TTS_STREAMING && !JAMBONES_DISABLE_AZURE_TTS_STREAMING &&
|
|
591
594
|
!renderForCaching && !disableTtsStreaming) {
|
|
592
|
-
let params = '';
|
|
593
|
-
params += `
|
|
595
|
+
let params = '{';
|
|
596
|
+
params += `api_key=${apiKey}`;
|
|
597
|
+
params += `,playback_id=${playbackIdCounter++}`;
|
|
594
598
|
params += `,language=${language}`;
|
|
595
599
|
params += ',vendor=microsoft';
|
|
596
600
|
params += `,voice=${voice}`;
|
|
@@ -773,6 +777,7 @@ const synthNvidia = async(client, logger, {
|
|
|
773
777
|
if (!JAMBONES_DISABLE_TTS_STREAMING && !renderForCaching && !disableTtsStreaming) {
|
|
774
778
|
let params = '';
|
|
775
779
|
params += `{riva_server_uri=${riva_server_uri}`;
|
|
780
|
+
params += `,playback_id=${playbackIdCounter++}`;
|
|
776
781
|
params += `,voice=${voice}`;
|
|
777
782
|
params += `,language=${language}`;
|
|
778
783
|
params += ',write_cache_file=1';
|
|
@@ -853,8 +858,9 @@ const synthElevenlabs = async(logger, {
|
|
|
853
858
|
|
|
854
859
|
/* default to using the streaming interface, unless disabled by env var OR we want just a cache file */
|
|
855
860
|
if (!JAMBONES_DISABLE_TTS_STREAMING && !renderForCaching && !disableTtsStreaming) {
|
|
856
|
-
let params = '';
|
|
857
|
-
params += `
|
|
861
|
+
let params = '{';
|
|
862
|
+
params += `api_key=${api_key}`;
|
|
863
|
+
params += `,playback_id=${playbackIdCounter++}`;
|
|
858
864
|
params += ',vendor=elevenlabs';
|
|
859
865
|
params += `,voice=${voice}`;
|
|
860
866
|
params += `,model_id=${model_id}`;
|
|
@@ -943,8 +949,9 @@ const synthPlayHT = async(client, logger, {
|
|
|
943
949
|
|
|
944
950
|
/* default to using the streaming interface, unless disabled by env var OR we want just a cache file */
|
|
945
951
|
if (!JAMBONES_DISABLE_TTS_STREAMING && !renderForCaching && !disableTtsStreaming) {
|
|
946
|
-
let params = '';
|
|
947
|
-
params += `
|
|
952
|
+
let params = '{';
|
|
953
|
+
params += `api_key=${api_key}`;
|
|
954
|
+
params += `,playback_id=${playbackIdCounter++}`;
|
|
948
955
|
params += `,user_id=${user_id}`;
|
|
949
956
|
params += ',vendor=playht';
|
|
950
957
|
params += `,voice=${voice}`;
|
|
@@ -1010,8 +1017,9 @@ const synthInworld = async(logger, {
|
|
|
1010
1017
|
|
|
1011
1018
|
/* default to using the streaming interface, unless disabled by env var OR we want just a cache file */
|
|
1012
1019
|
if (!JAMBONES_DISABLE_TTS_STREAMING && !renderForCaching && !disableTtsStreaming) {
|
|
1013
|
-
let params = '';
|
|
1014
|
-
params += `
|
|
1020
|
+
let params = '{';
|
|
1021
|
+
params += `api_key=${api_key}`;
|
|
1022
|
+
params += `,playback_id=${playbackIdCounter++}`;
|
|
1015
1023
|
params += `,model_id=${model_id}`;
|
|
1016
1024
|
params += ',vendor=inworld';
|
|
1017
1025
|
params += `,voice=${voice}`;
|
|
@@ -1074,8 +1082,9 @@ const synthRimelabs = async(logger, {
|
|
|
1074
1082
|
|
|
1075
1083
|
/* default to using the streaming interface, unless disabled by env var OR we want just a cache file */
|
|
1076
1084
|
if (!JAMBONES_DISABLE_TTS_STREAMING && !renderForCaching && !disableTtsStreaming) {
|
|
1077
|
-
let params = '';
|
|
1078
|
-
params += `
|
|
1085
|
+
let params = '{';
|
|
1086
|
+
params += `api_key=${api_key}`;
|
|
1087
|
+
params += `,playback_id=${playbackIdCounter++}`;
|
|
1079
1088
|
params += `,model_id=${model_id}`;
|
|
1080
1089
|
params += ',vendor=rimelabs';
|
|
1081
1090
|
params += `,language=${language}`;
|
|
@@ -1130,8 +1139,9 @@ const synthVerbio = async(client, logger, {credentials, stats, voice, text, rend
|
|
|
1130
1139
|
}
|
|
1131
1140
|
const token = await getVerbioAccessToken(client, logger, credentials);
|
|
1132
1141
|
if (!process.env.JAMBONES_DISABLE_TTS_STREAMING && !renderForCaching && !disableTtsStreaming) {
|
|
1133
|
-
let params = '';
|
|
1134
|
-
params += `
|
|
1142
|
+
let params = '{';
|
|
1143
|
+
params += `access_token=${token.access_token}`;
|
|
1144
|
+
params += `,playback_id=${playbackIdCounter++}`;
|
|
1135
1145
|
params += ',vendor=verbio';
|
|
1136
1146
|
params += `,voice=${voice}`;
|
|
1137
1147
|
params += ',write_cache_file=1';
|
|
@@ -1173,8 +1183,9 @@ const synthWhisper = async(logger, {credentials, stats, voice, text, instruction
|
|
|
1173
1183
|
const {api_key, model_id, baseURL, timeout, speed} = credentials;
|
|
1174
1184
|
/* if the env is set to stream then bag out, unless we are specifically rendering to generate a cache file */
|
|
1175
1185
|
if (!JAMBONES_DISABLE_TTS_STREAMING && !renderForCaching && !disableTtsStreaming) {
|
|
1176
|
-
let params = '';
|
|
1177
|
-
params += `
|
|
1186
|
+
let params = '{';
|
|
1187
|
+
params += `api_key=${api_key}`;
|
|
1188
|
+
params += `,playback_id=${playbackIdCounter++}`;
|
|
1178
1189
|
params += `,model_id=${model_id}`;
|
|
1179
1190
|
params += ',vendor=whisper';
|
|
1180
1191
|
params += `,voice=${voice}`;
|
|
@@ -1219,8 +1230,9 @@ const synthWhisper = async(logger, {credentials, stats, voice, text, instruction
|
|
|
1219
1230
|
const synthDeepgram = async(logger, {credentials, stats, model, text, renderForCaching, disableTtsStreaming}) => {
|
|
1220
1231
|
const {api_key, deepgram_tts_uri} = credentials;
|
|
1221
1232
|
if (!JAMBONES_DISABLE_TTS_STREAMING && !renderForCaching && !disableTtsStreaming) {
|
|
1222
|
-
let params = '';
|
|
1223
|
-
params += `
|
|
1233
|
+
let params = '{';
|
|
1234
|
+
params += `api_key=${api_key}`;
|
|
1235
|
+
params += `,playback_id=${playbackIdCounter++}`;
|
|
1224
1236
|
params += ',vendor=deepgram';
|
|
1225
1237
|
params += `,voice=${model}`;
|
|
1226
1238
|
params += ',write_cache_file=1';
|
|
@@ -1262,8 +1274,9 @@ const synthCartesia = async(logger, {
|
|
|
1262
1274
|
const opts = !!options && Object.keys(options).length !== 0 ? options : JSON.parse(credOpts || '{}');
|
|
1263
1275
|
|
|
1264
1276
|
if (!JAMBONES_DISABLE_TTS_STREAMING && !renderForCaching && !disableTtsStreaming) {
|
|
1265
|
-
let params = '';
|
|
1266
|
-
params += `
|
|
1277
|
+
let params = '{';
|
|
1278
|
+
params += `api_key=${api_key}`;
|
|
1279
|
+
params += `,playback_id=${playbackIdCounter++}`;
|
|
1267
1280
|
params += `,model_id=${model_id}`;
|
|
1268
1281
|
params += ',vendor=cartesia';
|
|
1269
1282
|
params += `,voice=${voice}`;
|
|
@@ -1333,8 +1346,9 @@ const synthResemble = async(logger, {
|
|
|
1333
1346
|
|
|
1334
1347
|
/* default to using the streaming interface, unless disabled by env var OR we want just a cache file */
|
|
1335
1348
|
if (!JAMBONES_DISABLE_TTS_STREAMING && !renderForCaching && !disableTtsStreaming) {
|
|
1336
|
-
let params = '';
|
|
1337
|
-
params += `
|
|
1349
|
+
let params = '{';
|
|
1350
|
+
params += `api_key=${api_key}`;
|
|
1351
|
+
params += `,playback_id=${playbackIdCounter++}`;
|
|
1338
1352
|
params += ',vendor=resemble';
|
|
1339
1353
|
params += `,voice=${voice}`;
|
|
1340
1354
|
params += ',write_cache_file=1';
|