@jambonz/speech-utils 0.2.18 → 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.
- package/lib/synth-audio.js +32 -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');
|
|
@@ -333,6 +335,7 @@ const synthPolly = async(createHash, retrieveHash, logger,
|
|
|
333
335
|
}
|
|
334
336
|
}
|
|
335
337
|
if (region) params += `,region=${region}`;
|
|
338
|
+
if (engine) params += `,engine=${engine}`;
|
|
336
339
|
params += '}';
|
|
337
340
|
|
|
338
341
|
return {
|
|
@@ -588,8 +591,8 @@ const synthMicrosoft = async(logger, {
|
|
|
588
591
|
}
|
|
589
592
|
if (!JAMBONES_DISABLE_TTS_STREAMING && !JAMBONES_DISABLE_AZURE_TTS_STREAMING &&
|
|
590
593
|
!renderForCaching && !disableTtsStreaming) {
|
|
591
|
-
let params = '';
|
|
592
|
-
params += `
|
|
594
|
+
let params = '{';
|
|
595
|
+
params += `api_key=${apiKey}`;
|
|
593
596
|
params += `,language=${language}`;
|
|
594
597
|
params += ',vendor=microsoft';
|
|
595
598
|
params += `,voice=${voice}`;
|
|
@@ -852,8 +855,9 @@ const synthElevenlabs = async(logger, {
|
|
|
852
855
|
|
|
853
856
|
/* default to using the streaming interface, unless disabled by env var OR we want just a cache file */
|
|
854
857
|
if (!JAMBONES_DISABLE_TTS_STREAMING && !renderForCaching && !disableTtsStreaming) {
|
|
855
|
-
let params = '';
|
|
856
|
-
params += `
|
|
858
|
+
let params = '{';
|
|
859
|
+
params += `api_key=${api_key}`;
|
|
860
|
+
params += `,playback_id=${playbackIdCounter++}`;
|
|
857
861
|
params += ',vendor=elevenlabs';
|
|
858
862
|
params += `,voice=${voice}`;
|
|
859
863
|
params += `,model_id=${model_id}`;
|
|
@@ -942,8 +946,9 @@ const synthPlayHT = async(client, logger, {
|
|
|
942
946
|
|
|
943
947
|
/* default to using the streaming interface, unless disabled by env var OR we want just a cache file */
|
|
944
948
|
if (!JAMBONES_DISABLE_TTS_STREAMING && !renderForCaching && !disableTtsStreaming) {
|
|
945
|
-
let params = '';
|
|
946
|
-
params += `
|
|
949
|
+
let params = '{';
|
|
950
|
+
params += `api_key=${api_key}`;
|
|
951
|
+
params += `,playback_id=${playbackIdCounter++}`;
|
|
947
952
|
params += `,user_id=${user_id}`;
|
|
948
953
|
params += ',vendor=playht';
|
|
949
954
|
params += `,voice=${voice}`;
|
|
@@ -1009,8 +1014,9 @@ const synthInworld = async(logger, {
|
|
|
1009
1014
|
|
|
1010
1015
|
/* default to using the streaming interface, unless disabled by env var OR we want just a cache file */
|
|
1011
1016
|
if (!JAMBONES_DISABLE_TTS_STREAMING && !renderForCaching && !disableTtsStreaming) {
|
|
1012
|
-
let params = '';
|
|
1013
|
-
params += `
|
|
1017
|
+
let params = '{';
|
|
1018
|
+
params += `api_key=${api_key}`;
|
|
1019
|
+
params += `,playback_id=${playbackIdCounter++}`;
|
|
1014
1020
|
params += `,model_id=${model_id}`;
|
|
1015
1021
|
params += ',vendor=inworld';
|
|
1016
1022
|
params += `,voice=${voice}`;
|
|
@@ -1073,8 +1079,9 @@ const synthRimelabs = async(logger, {
|
|
|
1073
1079
|
|
|
1074
1080
|
/* default to using the streaming interface, unless disabled by env var OR we want just a cache file */
|
|
1075
1081
|
if (!JAMBONES_DISABLE_TTS_STREAMING && !renderForCaching && !disableTtsStreaming) {
|
|
1076
|
-
let params = '';
|
|
1077
|
-
params += `
|
|
1082
|
+
let params = '{';
|
|
1083
|
+
params += `api_key=${api_key}`;
|
|
1084
|
+
params += `,playback_id=${playbackIdCounter++}`;
|
|
1078
1085
|
params += `,model_id=${model_id}`;
|
|
1079
1086
|
params += ',vendor=rimelabs';
|
|
1080
1087
|
params += `,language=${language}`;
|
|
@@ -1129,8 +1136,9 @@ const synthVerbio = async(client, logger, {credentials, stats, voice, text, rend
|
|
|
1129
1136
|
}
|
|
1130
1137
|
const token = await getVerbioAccessToken(client, logger, credentials);
|
|
1131
1138
|
if (!process.env.JAMBONES_DISABLE_TTS_STREAMING && !renderForCaching && !disableTtsStreaming) {
|
|
1132
|
-
let params = '';
|
|
1133
|
-
params += `
|
|
1139
|
+
let params = '{';
|
|
1140
|
+
params += `access_token=${token.access_token}`;
|
|
1141
|
+
params += `,playback_id=${playbackIdCounter++}`;
|
|
1134
1142
|
params += ',vendor=verbio';
|
|
1135
1143
|
params += `,voice=${voice}`;
|
|
1136
1144
|
params += ',write_cache_file=1';
|
|
@@ -1172,8 +1180,9 @@ const synthWhisper = async(logger, {credentials, stats, voice, text, instruction
|
|
|
1172
1180
|
const {api_key, model_id, baseURL, timeout, speed} = credentials;
|
|
1173
1181
|
/* if the env is set to stream then bag out, unless we are specifically rendering to generate a cache file */
|
|
1174
1182
|
if (!JAMBONES_DISABLE_TTS_STREAMING && !renderForCaching && !disableTtsStreaming) {
|
|
1175
|
-
let params = '';
|
|
1176
|
-
params += `
|
|
1183
|
+
let params = '{';
|
|
1184
|
+
params += `api_key=${api_key}`;
|
|
1185
|
+
params += `,playback_id=${playbackIdCounter++}`;
|
|
1177
1186
|
params += `,model_id=${model_id}`;
|
|
1178
1187
|
params += ',vendor=whisper';
|
|
1179
1188
|
params += `,voice=${voice}`;
|
|
@@ -1218,8 +1227,9 @@ const synthWhisper = async(logger, {credentials, stats, voice, text, instruction
|
|
|
1218
1227
|
const synthDeepgram = async(logger, {credentials, stats, model, text, renderForCaching, disableTtsStreaming}) => {
|
|
1219
1228
|
const {api_key, deepgram_tts_uri} = credentials;
|
|
1220
1229
|
if (!JAMBONES_DISABLE_TTS_STREAMING && !renderForCaching && !disableTtsStreaming) {
|
|
1221
|
-
let params = '';
|
|
1222
|
-
params += `
|
|
1230
|
+
let params = '{';
|
|
1231
|
+
params += `api_key=${api_key}`;
|
|
1232
|
+
params += `,playback_id=${playbackIdCounter++}`;
|
|
1223
1233
|
params += ',vendor=deepgram';
|
|
1224
1234
|
params += `,voice=${model}`;
|
|
1225
1235
|
params += ',write_cache_file=1';
|
|
@@ -1261,8 +1271,9 @@ const synthCartesia = async(logger, {
|
|
|
1261
1271
|
const opts = !!options && Object.keys(options).length !== 0 ? options : JSON.parse(credOpts || '{}');
|
|
1262
1272
|
|
|
1263
1273
|
if (!JAMBONES_DISABLE_TTS_STREAMING && !renderForCaching && !disableTtsStreaming) {
|
|
1264
|
-
let params = '';
|
|
1265
|
-
params += `
|
|
1274
|
+
let params = '{';
|
|
1275
|
+
params += `api_key=${api_key}`;
|
|
1276
|
+
params += `,playback_id=${playbackIdCounter++}`;
|
|
1266
1277
|
params += `,model_id=${model_id}`;
|
|
1267
1278
|
params += ',vendor=cartesia';
|
|
1268
1279
|
params += `,voice=${voice}`;
|
|
@@ -1332,8 +1343,9 @@ const synthResemble = async(logger, {
|
|
|
1332
1343
|
|
|
1333
1344
|
/* default to using the streaming interface, unless disabled by env var OR we want just a cache file */
|
|
1334
1345
|
if (!JAMBONES_DISABLE_TTS_STREAMING && !renderForCaching && !disableTtsStreaming) {
|
|
1335
|
-
let params = '';
|
|
1336
|
-
params += `
|
|
1346
|
+
let params = '{';
|
|
1347
|
+
params += `api_key=${api_key}`;
|
|
1348
|
+
params += `,playback_id=${playbackIdCounter++}`;
|
|
1337
1349
|
params += ',vendor=resemble';
|
|
1338
1350
|
params += `,voice=${voice}`;
|
|
1339
1351
|
params += ',write_cache_file=1';
|