Compare commits

...
5 Commits
Author SHA1 Message Date
Dave Horton 507045dcba 0.0.23 2023-10-29 22:07:02 -04:00
Dave Horton 08758bbbff Merge pull request #38 from jambonz/feat/google_custom_voice
feat support google custom voice
2023-10-29 22:06:41 -04:00
Hoan Luu Huu a3aa1169b8 feat support google custom voice 2023-10-30 01:55:50 +00:00
Hoan Luu Huu 7cae19a4e5 feat support google custom voice 2023-10-30 01:54:02 +00:00
Hoan Luu Huu 8c4d5a7cee feat support google custom voice 2023-10-30 01:52:48 +00:00
4 changed files with 39 additions and 4 deletions
+2 -1
View File
@@ -257,7 +257,8 @@ const synthGoogle = async(logger, {credentials, stats, language, voice, gender,
const client = new ttsGoogle.TextToSpeechClient(credentials);
const opts = {
voice: {
name: voice,
...(typeof voice === 'string' && {name: voice}),
...(typeof voice === 'object' && {custom_voice: voice}),
languageCode: language,
ssmlGender: gender || 'SSML_VOICE_GENDER_UNSPECIFIED'
},
+2 -2
View File
@@ -1,12 +1,12 @@
{
"name": "@jambonz/speech-utils",
"version": "0.0.22",
"version": "0.0.23",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@jambonz/speech-utils",
"version": "0.0.22",
"version": "0.0.23",
"license": "MIT",
"dependencies": {
"@aws-sdk/client-polly": "^3.359.0",
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@jambonz/speech-utils",
"version": "0.0.22",
"version": "0.0.23",
"description": "TTS-related speech utilities for jambonz",
"main": "index.js",
"author": "Dave Horton",
+34
View File
@@ -79,6 +79,40 @@ test('Google speech synth tests', async(t) => {
client.quit();
});
test('Google speech Custom voice synth tests', async(t) => {
const fn = require('..');
const {synthAudio, client} = fn(opts, logger);
if (!process.env.GCP_CUSTOM_VOICE_FILE && !process.env.GCP_CUSTOM_VOICE_JSON_KEY || !process.env.GCP_CUSTOM_VOICE_MODEL) {
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');
return t.end();
}
try {
const str = process.env.GCP_CUSTOM_VOICE_JSON_KEY || fs.readFileSync(process.env.GCP_CUSTOM_VOICE_FILE);
const creds = JSON.parse(str);
let opts = await synthAudio(stats, {
vendor: 'google',
credentials: {
credentials: {
client_email: creds.client_email,
private_key: creds.private_key,
},
},
language: 'en-AU',
text: 'This is a test. This is only a test',
voice: {
reportedUsage:"REALTIME",
model: process.env.GCP_CUSTOM_VOICE_MODEL
}
});
t.ok(!opts.servedFromCache, `successfully synthesized google custom voice audio to ${opts.filePath}`);
} catch (err) {
console.error(err);
t.end(err);
}
client.quit();
});
test('AWS speech synth tests', async(t) => {
const fn = require('..');
const {synthAudio, client} = fn(opts, logger);