mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2025-12-20 08:40:38 +00:00
google custom voice (#506)
* google custom voice * fixed * wip * wip * wip * wip
This commit is contained in:
@@ -28,7 +28,7 @@ module.exports = function(srf, logger) {
|
|||||||
writeAlerts,
|
writeAlerts,
|
||||||
AlertType
|
AlertType
|
||||||
} = srf.locals;
|
} = srf.locals;
|
||||||
const {lookupAccountDetails} = dbUtils(logger, srf);
|
const {lookupAccountDetails, lookupGoogleCustomVoice} = dbUtils(logger, srf);
|
||||||
|
|
||||||
async function initLocals(req, res, next) {
|
async function initLocals(req, res, next) {
|
||||||
const callId = req.get('Call-ID');
|
const callId = req.get('Call-ID');
|
||||||
@@ -299,6 +299,21 @@ module.exports = function(srf, logger) {
|
|||||||
else app2.notifier = {request: () => {}, close: () => {}};
|
else app2.notifier = {request: () => {}, close: () => {}};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Resolve application.speech_synthesis_voice if it's custom voice
|
||||||
|
if (app2.speech_synthesis_vendor === 'google' && app2.speech_synthesis_voice.startsWith('custom_')) {
|
||||||
|
const arr = /custom_(.*)/.exec(app2.speech_synthesis_voice);
|
||||||
|
if (arr) {
|
||||||
|
const google_custom_voice_sid = arr[1];
|
||||||
|
const [custom_voice] = await lookupGoogleCustomVoice(google_custom_voice_sid);
|
||||||
|
if (custom_voice) {
|
||||||
|
app2.speech_synthesis_voice = {
|
||||||
|
reportedUsage: custom_voice.reported_usage,
|
||||||
|
model: custom_voice.model
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
req.locals.application = app2;
|
req.locals.application = app2;
|
||||||
|
|
||||||
// eslint-disable-next-line no-unused-vars
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
|||||||
@@ -27,6 +27,9 @@ WHERE pn.account_sid IS NULL
|
|||||||
AND pn.service_provider_sid =
|
AND pn.service_provider_sid =
|
||||||
(SELECT service_provider_sid from accounts where account_sid = ?)
|
(SELECT service_provider_sid from accounts where account_sid = ?)
|
||||||
AND pn.number = ?`;
|
AND pn.number = ?`;
|
||||||
|
const sqlQueryGoogleCustomVoices = `SELECT *
|
||||||
|
FROM google_custom_voices
|
||||||
|
WHERE google_custom_voice_sid = ?`;
|
||||||
|
|
||||||
const speechMapper = (cred) => {
|
const speechMapper = (cred) => {
|
||||||
const {credential, ...obj} = cred;
|
const {credential, ...obj} = cred;
|
||||||
@@ -161,10 +164,22 @@ module.exports = (logger, srf) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const lookupGoogleCustomVoice = async(google_custom_voice_sid) => {
|
||||||
|
const pp = pool.promise();
|
||||||
|
try {
|
||||||
|
const [r] = await pp.query(sqlQueryGoogleCustomVoices, [google_custom_voice_sid]);
|
||||||
|
return r;
|
||||||
|
|
||||||
|
} catch (err) {
|
||||||
|
logger.error({err}, `lookupGoogleCustomVoices: Error ${google_custom_voice_sid}`);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
lookupAccountDetails,
|
lookupAccountDetails,
|
||||||
updateSpeechCredentialLastUsed,
|
updateSpeechCredentialLastUsed,
|
||||||
lookupCarrier,
|
lookupCarrier,
|
||||||
lookupCarrierByPhoneNumber
|
lookupCarrierByPhoneNumber,
|
||||||
|
lookupGoogleCustomVoice
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
14
package-lock.json
generated
14
package-lock.json
generated
@@ -15,7 +15,7 @@
|
|||||||
"@jambonz/http-health-check": "^0.0.1",
|
"@jambonz/http-health-check": "^0.0.1",
|
||||||
"@jambonz/mw-registrar": "^0.2.4",
|
"@jambonz/mw-registrar": "^0.2.4",
|
||||||
"@jambonz/realtimedb-helpers": "^0.8.6",
|
"@jambonz/realtimedb-helpers": "^0.8.6",
|
||||||
"@jambonz/speech-utils": "^0.0.22",
|
"@jambonz/speech-utils": "^0.0.24",
|
||||||
"@jambonz/stats-collector": "^0.1.9",
|
"@jambonz/stats-collector": "^0.1.9",
|
||||||
"@jambonz/time-series": "^0.2.8",
|
"@jambonz/time-series": "^0.2.8",
|
||||||
"@jambonz/verb-specifications": "^0.0.44",
|
"@jambonz/verb-specifications": "^0.0.44",
|
||||||
@@ -3145,9 +3145,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@jambonz/speech-utils": {
|
"node_modules/@jambonz/speech-utils": {
|
||||||
"version": "0.0.22",
|
"version": "0.0.24",
|
||||||
"resolved": "https://registry.npmjs.org/@jambonz/speech-utils/-/speech-utils-0.0.22.tgz",
|
"resolved": "https://registry.npmjs.org/@jambonz/speech-utils/-/speech-utils-0.0.24.tgz",
|
||||||
"integrity": "sha512-+gFWDTNUbf3RwG9a7PInJom0YKiGgW8i2m6WFRjJuSk1StiY4BKWr+sE6JL9SBHz9UrjyLb8P2tfJKwoo/JKSA==",
|
"integrity": "sha512-FpywxkjohC7wBBS9Xz9pRYXyO9D/tt2xgHFseWSoe0kO/6DbFudoLAI5uGB7AyUbTeGeKBiVZDJSNadsM4Iv4A==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@aws-sdk/client-polly": "^3.359.0",
|
"@aws-sdk/client-polly": "^3.359.0",
|
||||||
"@google-cloud/text-to-speech": "^4.2.1",
|
"@google-cloud/text-to-speech": "^4.2.1",
|
||||||
@@ -13239,9 +13239,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@jambonz/speech-utils": {
|
"@jambonz/speech-utils": {
|
||||||
"version": "0.0.22",
|
"version": "0.0.24",
|
||||||
"resolved": "https://registry.npmjs.org/@jambonz/speech-utils/-/speech-utils-0.0.22.tgz",
|
"resolved": "https://registry.npmjs.org/@jambonz/speech-utils/-/speech-utils-0.0.24.tgz",
|
||||||
"integrity": "sha512-+gFWDTNUbf3RwG9a7PInJom0YKiGgW8i2m6WFRjJuSk1StiY4BKWr+sE6JL9SBHz9UrjyLb8P2tfJKwoo/JKSA==",
|
"integrity": "sha512-FpywxkjohC7wBBS9Xz9pRYXyO9D/tt2xgHFseWSoe0kO/6DbFudoLAI5uGB7AyUbTeGeKBiVZDJSNadsM4Iv4A==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"@aws-sdk/client-polly": "^3.359.0",
|
"@aws-sdk/client-polly": "^3.359.0",
|
||||||
"@google-cloud/text-to-speech": "^4.2.1",
|
"@google-cloud/text-to-speech": "^4.2.1",
|
||||||
|
|||||||
@@ -31,7 +31,7 @@
|
|||||||
"@jambonz/http-health-check": "^0.0.1",
|
"@jambonz/http-health-check": "^0.0.1",
|
||||||
"@jambonz/mw-registrar": "^0.2.4",
|
"@jambonz/mw-registrar": "^0.2.4",
|
||||||
"@jambonz/realtimedb-helpers": "^0.8.6",
|
"@jambonz/realtimedb-helpers": "^0.8.6",
|
||||||
"@jambonz/speech-utils": "^0.0.22",
|
"@jambonz/speech-utils": "^0.0.24",
|
||||||
"@jambonz/stats-collector": "^0.1.9",
|
"@jambonz/stats-collector": "^0.1.9",
|
||||||
"@jambonz/time-series": "^0.2.8",
|
"@jambonz/time-series": "^0.2.8",
|
||||||
"@jambonz/verb-specifications": "^0.0.44",
|
"@jambonz/verb-specifications": "^0.0.44",
|
||||||
|
|||||||
Reference in New Issue
Block a user