@jambonz/speech-utils 0.0.22 → 0.0.23
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 +2 -1
- package/package.json +1 -1
- package/test/synth.js +34 -0
package/lib/synth-audio.js
CHANGED
|
@@ -257,7 +257,8 @@ const synthGoogle = async(logger, {credentials, stats, language, voice, gender,
|
|
|
257
257
|
const client = new ttsGoogle.TextToSpeechClient(credentials);
|
|
258
258
|
const opts = {
|
|
259
259
|
voice: {
|
|
260
|
-
name: voice,
|
|
260
|
+
...(typeof voice === 'string' && {name: voice}),
|
|
261
|
+
...(typeof voice === 'object' && {custom_voice: voice}),
|
|
261
262
|
languageCode: language,
|
|
262
263
|
ssmlGender: gender || 'SSML_VOICE_GENDER_UNSPECIFIED'
|
|
263
264
|
},
|
package/package.json
CHANGED
package/test/synth.js
CHANGED
|
@@ -79,6 +79,40 @@ test('Google speech synth tests', async(t) => {
|
|
|
79
79
|
client.quit();
|
|
80
80
|
});
|
|
81
81
|
|
|
82
|
+
test('Google speech Custom voice synth tests', async(t) => {
|
|
83
|
+
const fn = require('..');
|
|
84
|
+
const {synthAudio, client} = fn(opts, logger);
|
|
85
|
+
|
|
86
|
+
if (!process.env.GCP_CUSTOM_VOICE_FILE && !process.env.GCP_CUSTOM_VOICE_JSON_KEY || !process.env.GCP_CUSTOM_VOICE_MODEL) {
|
|
87
|
+
t.pass('skipping google speech synth tests since neither GCP_CUSTOM_VOICE_FILE nor GCP_CUSTOM_VOICE_JSON_KEY provided, GCP_CUSTOM_VOICE_MODEL is not provided');
|
|
88
|
+
return t.end();
|
|
89
|
+
}
|
|
90
|
+
try {
|
|
91
|
+
const str = process.env.GCP_CUSTOM_VOICE_JSON_KEY || fs.readFileSync(process.env.GCP_CUSTOM_VOICE_FILE);
|
|
92
|
+
const creds = JSON.parse(str);
|
|
93
|
+
let opts = await synthAudio(stats, {
|
|
94
|
+
vendor: 'google',
|
|
95
|
+
credentials: {
|
|
96
|
+
credentials: {
|
|
97
|
+
client_email: creds.client_email,
|
|
98
|
+
private_key: creds.private_key,
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
language: 'en-AU',
|
|
102
|
+
text: 'This is a test. This is only a test',
|
|
103
|
+
voice: {
|
|
104
|
+
reportedUsage:"REALTIME",
|
|
105
|
+
model: process.env.GCP_CUSTOM_VOICE_MODEL
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
t.ok(!opts.servedFromCache, `successfully synthesized google custom voice audio to ${opts.filePath}`);
|
|
109
|
+
} catch (err) {
|
|
110
|
+
console.error(err);
|
|
111
|
+
t.end(err);
|
|
112
|
+
}
|
|
113
|
+
client.quit();
|
|
114
|
+
});
|
|
115
|
+
|
|
82
116
|
test('AWS speech synth tests', async(t) => {
|
|
83
117
|
const fn = require('..');
|
|
84
118
|
const {synthAudio, client} = fn(opts, logger);
|