@jambonz/speech-utils 0.0.11 → 0.0.13
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 +17 -14
- package/package.json +1 -1
- package/test/synth.js +2 -2
package/lib/synth-audio.js
CHANGED
|
@@ -81,7 +81,7 @@ async function synthAudio(client, logger, stats, { account_sid,
|
|
|
81
81
|
else if ('nvidia' === vendor) {
|
|
82
82
|
assert.ok(voice, 'synthAudio requires voice when nvidia is used');
|
|
83
83
|
assert.ok(language, 'synthAudio requires language when nvidia is used');
|
|
84
|
-
assert.ok(credentials.
|
|
84
|
+
assert.ok(credentials.riva_server_uri, 'synthAudio requires riva_server_uri in credentials when nvidia is used');
|
|
85
85
|
}
|
|
86
86
|
else if ('ibm' === vendor) {
|
|
87
87
|
assert.ok(voice, 'synthAudio requires voice when ibm is used');
|
|
@@ -170,8 +170,6 @@ async function synthAudio(client, logger, stats, { account_sid,
|
|
|
170
170
|
|
|
171
171
|
client.setexAsync(key, EXPIRES, audioBuffer.toString('base64'))
|
|
172
172
|
.catch((err) => logger.error(err, `error calling setex on key ${key}`));
|
|
173
|
-
|
|
174
|
-
if (['microsoft'].includes(vendor)) return {filePath, servedFromCache, rtt};
|
|
175
173
|
}
|
|
176
174
|
|
|
177
175
|
return new Promise((resolve, reject) => {
|
|
@@ -325,9 +323,9 @@ const synthMicrosoft = async(logger, {
|
|
|
325
323
|
reject(cancellation.errorDetails);
|
|
326
324
|
break;
|
|
327
325
|
case ResultReason.SynthesizingAudioCompleted:
|
|
328
|
-
stats.increment('tts.count', ['vendor:microsoft', 'accepted:yes']);
|
|
329
326
|
resolve(Buffer.from(result.audioData));
|
|
330
327
|
synthesizer.close();
|
|
328
|
+
stats.increment('tts.count', ['vendor:microsoft', 'accepted:yes']);
|
|
331
329
|
break;
|
|
332
330
|
default:
|
|
333
331
|
logger.info({result}, 'synthAudio: (Microsoft) unexpected result');
|
|
@@ -427,20 +425,25 @@ const synthNuance = async(client, logger, {credentials, stats, voice, model, tex
|
|
|
427
425
|
};
|
|
428
426
|
|
|
429
427
|
const synthNvidia = async(client, logger, {credentials, stats, language, voice, model, text}) => {
|
|
430
|
-
const {
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
428
|
+
const {riva_server_uri} = credentials;
|
|
429
|
+
let rivaClient, request;
|
|
430
|
+
try {
|
|
431
|
+
rivaClient = await createRivaClient(riva_server_uri);
|
|
432
|
+
request = new SynthesizeSpeechRequest();
|
|
433
|
+
request.setVoiceName(voice);
|
|
434
|
+
request.setLanguageCode(language);
|
|
435
|
+
request.setSampleRateHz(8000);
|
|
436
|
+
request.setEncoding(AudioEncoding.LINEAR_PCM);
|
|
437
|
+
request.setText(text);
|
|
438
|
+
} catch (err) {
|
|
439
|
+
logger.info({err}, 'error creating riva client');
|
|
440
|
+
return Promise.reject(err);
|
|
441
|
+
}
|
|
439
442
|
|
|
440
443
|
return new Promise((resolve, reject) => {
|
|
441
444
|
rivaClient.synthesize(request, (err, response) => {
|
|
442
445
|
if (err) {
|
|
443
|
-
|
|
446
|
+
logger.info({err, voice, language}, 'error synthesizing speech using Nvidia');
|
|
444
447
|
return reject(err);
|
|
445
448
|
}
|
|
446
449
|
resolve(Buffer.from(response.getAudio()));
|
package/package.json
CHANGED
package/test/synth.js
CHANGED
|
@@ -300,7 +300,7 @@ test('Nvidia speech synth tests', async(t) => {
|
|
|
300
300
|
let opts = await synthAudio(stats, {
|
|
301
301
|
vendor: 'nvidia',
|
|
302
302
|
credentials: {
|
|
303
|
-
|
|
303
|
+
riva_server_uri: process.env.RIVA_URI,
|
|
304
304
|
},
|
|
305
305
|
language: 'en-US',
|
|
306
306
|
voice: 'English-US.Female-1',
|
|
@@ -311,7 +311,7 @@ test('Nvidia speech synth tests', async(t) => {
|
|
|
311
311
|
opts = await synthAudio(stats, {
|
|
312
312
|
vendor: 'nvidia',
|
|
313
313
|
credentials: {
|
|
314
|
-
|
|
314
|
+
riva_server_uri: process.env.RIVA_URI,
|
|
315
315
|
},
|
|
316
316
|
language: 'en-US',
|
|
317
317
|
voice: 'English-US.Female-1',
|