@jambonz/speech-utils 0.0.12 → 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 +16 -11
- 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');
|
|
@@ -425,20 +425,25 @@ const synthNuance = async(client, logger, {credentials, stats, voice, model, tex
|
|
|
425
425
|
};
|
|
426
426
|
|
|
427
427
|
const synthNvidia = async(client, logger, {credentials, stats, language, voice, model, text}) => {
|
|
428
|
-
const {
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
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
|
+
}
|
|
437
442
|
|
|
438
443
|
return new Promise((resolve, reject) => {
|
|
439
444
|
rivaClient.synthesize(request, (err, response) => {
|
|
440
445
|
if (err) {
|
|
441
|
-
|
|
446
|
+
logger.info({err, voice, language}, 'error synthesizing speech using Nvidia');
|
|
442
447
|
return reject(err);
|
|
443
448
|
}
|
|
444
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',
|