@jambonz/speech-utils 0.2.16 → 0.2.18
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 +37 -4
- package/package.json +1 -1
- package/test/synth.js +2 -0
package/lib/synth-audio.js
CHANGED
|
@@ -211,7 +211,7 @@ async function synthAudio(client, createHash, retrieveHash, logger, stats, { acc
|
|
|
211
211
|
case 'polly':
|
|
212
212
|
vendorLabel = 'aws';
|
|
213
213
|
audioData = await synthPolly(createHash, retrieveHash, logger,
|
|
214
|
-
{credentials, stats, language, voice, text, engine});
|
|
214
|
+
{credentials, stats, language, voice, text, engine, renderForCaching, disableTtsStreaming});
|
|
215
215
|
break;
|
|
216
216
|
case 'azure':
|
|
217
217
|
case 'microsoft':
|
|
@@ -307,9 +307,41 @@ async function synthAudio(client, createHash, retrieveHash, logger, stats, { acc
|
|
|
307
307
|
}
|
|
308
308
|
|
|
309
309
|
const synthPolly = async(createHash, retrieveHash, logger,
|
|
310
|
-
{credentials, stats, language, voice, engine, text}) => {
|
|
310
|
+
{credentials, stats, language, voice, engine, text, renderForCaching, disableTtsStreaming}) => {
|
|
311
|
+
const {region, accessKeyId, secretAccessKey, roleArn} = credentials;
|
|
312
|
+
if (!JAMBONES_DISABLE_TTS_STREAMING && !renderForCaching && !disableTtsStreaming) {
|
|
313
|
+
|
|
314
|
+
let params = '{';
|
|
315
|
+
params += `language=${language}`;
|
|
316
|
+
params += ',write_cache_file=1';
|
|
317
|
+
params += ',vendor=aws';
|
|
318
|
+
if (accessKeyId && secretAccessKey) {
|
|
319
|
+
if (accessKeyId) params += `,accessKeyId=${accessKeyId}`;
|
|
320
|
+
if (secretAccessKey) params += `,secretAccessKey=${secretAccessKey}`;
|
|
321
|
+
} else if (roleArn) {
|
|
322
|
+
const cred = await getAwsAuthToken(
|
|
323
|
+
logger, createHash, retrieveHash,
|
|
324
|
+
{
|
|
325
|
+
region,
|
|
326
|
+
roleArn
|
|
327
|
+
});
|
|
328
|
+
|
|
329
|
+
if (cred) {
|
|
330
|
+
params += `,accessKeyId=${cred.accessKeyId}`;
|
|
331
|
+
params += `,secretAccessKey=${cred.secretAccessKey}`;
|
|
332
|
+
params += `,sessionToken=${cred.sessionToken}`;
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
if (region) params += `,region=${region}`;
|
|
336
|
+
params += '}';
|
|
337
|
+
|
|
338
|
+
return {
|
|
339
|
+
filePath: `say:${params}${text.replace(/\n/g, ' ').replace(/\r/g, ' ')}`,
|
|
340
|
+
servedFromCache: false,
|
|
341
|
+
rtt: 0
|
|
342
|
+
};
|
|
343
|
+
}
|
|
311
344
|
try {
|
|
312
|
-
const {region, accessKeyId, secretAccessKey, roleArn} = credentials;
|
|
313
345
|
let polly;
|
|
314
346
|
if (accessKeyId && secretAccessKey) {
|
|
315
347
|
polly = new PollyClient({
|
|
@@ -1295,7 +1327,7 @@ const synthCartesia = async(logger, {
|
|
|
1295
1327
|
const synthResemble = async(logger, {
|
|
1296
1328
|
credentials, options, stats, voice, text, renderForCaching, disableTtsStreaming
|
|
1297
1329
|
}) => {
|
|
1298
|
-
const {api_key, resemble_tts_uri} = credentials;
|
|
1330
|
+
const {api_key, resemble_tts_uri, resemble_tts_use_tls} = credentials;
|
|
1299
1331
|
const {project_uuid, use_hd} = options || {};
|
|
1300
1332
|
|
|
1301
1333
|
/* default to using the streaming interface, unless disabled by env var OR we want just a cache file */
|
|
@@ -1308,6 +1340,7 @@ const synthResemble = async(logger, {
|
|
|
1308
1340
|
if (project_uuid) params += `,project_uuid=${project_uuid}`;
|
|
1309
1341
|
if (use_hd) params += `,use_hd=${use_hd}`;
|
|
1310
1342
|
if (resemble_tts_uri) params += `,endpoint=${resemble_tts_uri}`;
|
|
1343
|
+
if (resemble_tts_use_tls) params += `,use_tls=${resemble_tts_use_tls}`;
|
|
1311
1344
|
|
|
1312
1345
|
params += '}';
|
|
1313
1346
|
|
package/package.json
CHANGED
package/test/synth.js
CHANGED
|
@@ -185,6 +185,7 @@ test('AWS speech synth tests', async(t) => {
|
|
|
185
185
|
language: 'en-US',
|
|
186
186
|
voice: 'Joey',
|
|
187
187
|
text: 'This is a test. This is only a test',
|
|
188
|
+
renderForCaching: true,
|
|
188
189
|
});
|
|
189
190
|
t.ok(!opts.servedFromCache, `successfully synthesized aws audio to ${opts.filePath}`);
|
|
190
191
|
|
|
@@ -198,6 +199,7 @@ test('AWS speech synth tests', async(t) => {
|
|
|
198
199
|
language: 'en-US',
|
|
199
200
|
voice: 'Joey',
|
|
200
201
|
text: 'This is a test. This is only a test',
|
|
202
|
+
renderForCaching: true,
|
|
201
203
|
});
|
|
202
204
|
t.ok(opts.servedFromCache, `successfully retrieved aws audio from cache ${opts.filePath}`);
|
|
203
205
|
} catch (err) {
|