mirror of
https://github.com/jambonz/speech-utils.git
synced 2026-10-03 23:33:59 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6c5c8e734f | ||
|
|
4349cd7e40 | ||
|
|
b6058ca242 | ||
|
|
68cbd63bbd | ||
|
|
521560e276 | ||
|
|
d606141f57 | ||
|
|
0d58954537 | ||
|
|
7c0eafded3 | ||
|
|
ab7d145288 |
+18
-15
@@ -81,7 +81,7 @@ async function synthAudio(client, logger, stats, { account_sid,
|
||||
else if ('nvidia' === vendor) {
|
||||
assert.ok(voice, 'synthAudio requires voice when nvidia is used');
|
||||
assert.ok(language, 'synthAudio requires language when nvidia is used');
|
||||
assert.ok(credentials.riva_uri, 'synthAudio requires riva_uri in credentials when nuance is used');
|
||||
assert.ok(credentials.riva_server_uri, 'synthAudio requires riva_server_uri in credentials when nvidia is used');
|
||||
}
|
||||
else if ('ibm' === vendor) {
|
||||
assert.ok(voice, 'synthAudio requires voice when ibm is used');
|
||||
@@ -170,8 +170,6 @@ async function synthAudio(client, logger, stats, { account_sid,
|
||||
|
||||
client.setexAsync(key, EXPIRES, audioBuffer.toString('base64'))
|
||||
.catch((err) => logger.error(err, `error calling setex on key ${key}`));
|
||||
|
||||
if (['microsoft'].includes(vendor)) return {filePath, servedFromCache, rtt};
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
@@ -325,9 +323,9 @@ const synthMicrosoft = async(logger, {
|
||||
reject(cancellation.errorDetails);
|
||||
break;
|
||||
case ResultReason.SynthesizingAudioCompleted:
|
||||
stats.increment('tts.count', ['vendor:microsoft', 'accepted:yes']);
|
||||
resolve(result.audioData);
|
||||
resolve(Buffer.from(result.audioData));
|
||||
synthesizer.close();
|
||||
stats.increment('tts.count', ['vendor:microsoft', 'accepted:yes']);
|
||||
break;
|
||||
default:
|
||||
logger.info({result}, 'synthAudio: (Microsoft) unexpected result');
|
||||
@@ -427,20 +425,25 @@ const synthNuance = async(client, logger, {credentials, stats, voice, model, tex
|
||||
};
|
||||
|
||||
const synthNvidia = async(client, logger, {credentials, stats, language, voice, model, text}) => {
|
||||
const {riva_uri} = credentials;
|
||||
const rivaClient = await createRivaClient(riva_uri);
|
||||
|
||||
const request = new SynthesizeSpeechRequest();
|
||||
request.setVoiceName(voice);
|
||||
request.setLanguageCode(language);
|
||||
request.setSampleRateHz(8000);
|
||||
request.setEncoding(AudioEncoding.LINEAR_PCM);
|
||||
request.setText(text);
|
||||
const {riva_server_uri} = credentials;
|
||||
let rivaClient, request;
|
||||
try {
|
||||
rivaClient = await createRivaClient(riva_server_uri);
|
||||
request = new SynthesizeSpeechRequest();
|
||||
request.setVoiceName(voice);
|
||||
request.setLanguageCode(language);
|
||||
request.setSampleRateHz(8000);
|
||||
request.setEncoding(AudioEncoding.LINEAR_PCM);
|
||||
request.setText(text);
|
||||
} catch (err) {
|
||||
logger.info({err}, 'error creating riva client');
|
||||
return Promise.reject(err);
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
rivaClient.synthesize(request, (err, response) => {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
logger.info({err, voice, language}, 'error synthesizing speech using Nvidia');
|
||||
return reject(err);
|
||||
}
|
||||
resolve(Buffer.from(response.getAudio()));
|
||||
|
||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "@jambonz/speech-utils",
|
||||
"version": "0.0.10",
|
||||
"version": "0.0.13",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@jambonz/speech-utils",
|
||||
"version": "0.0.10",
|
||||
"version": "0.0.13",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@aws-sdk/client-polly": "^3.303.0",
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@jambonz/speech-utils",
|
||||
"version": "0.0.10",
|
||||
"version": "0.0.13",
|
||||
"description": "TTS-related speech utilities for jambonz",
|
||||
"main": "index.js",
|
||||
"author": "Dave Horton",
|
||||
|
||||
+2
-2
@@ -300,7 +300,7 @@ test('Nvidia speech synth tests', async(t) => {
|
||||
let opts = await synthAudio(stats, {
|
||||
vendor: 'nvidia',
|
||||
credentials: {
|
||||
riva_uri: process.env.RIVA_URI,
|
||||
riva_server_uri: process.env.RIVA_URI,
|
||||
},
|
||||
language: 'en-US',
|
||||
voice: 'English-US.Female-1',
|
||||
@@ -311,7 +311,7 @@ test('Nvidia speech synth tests', async(t) => {
|
||||
opts = await synthAudio(stats, {
|
||||
vendor: 'nvidia',
|
||||
credentials: {
|
||||
riva_uri: process.env.RIVA_URI,
|
||||
riva_server_uri: process.env.RIVA_URI,
|
||||
},
|
||||
language: 'en-US',
|
||||
voice: 'English-US.Female-1',
|
||||
|
||||
Reference in New Issue
Block a user