@jambonz/speech-utils 0.2.17 → 0.2.19
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 +36 -3
- 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,42 @@ 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
|
+
if (engine) params += `,engine=${engine}`;
|
|
337
|
+
params += '}';
|
|
338
|
+
|
|
339
|
+
return {
|
|
340
|
+
filePath: `say:${params}${text.replace(/\n/g, ' ').replace(/\r/g, ' ')}`,
|
|
341
|
+
servedFromCache: false,
|
|
342
|
+
rtt: 0
|
|
343
|
+
};
|
|
344
|
+
}
|
|
311
345
|
try {
|
|
312
|
-
const {region, accessKeyId, secretAccessKey, roleArn} = credentials;
|
|
313
346
|
let polly;
|
|
314
347
|
if (accessKeyId && secretAccessKey) {
|
|
315
348
|
polly = new PollyClient({
|
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) {
|