mirror of
https://github.com/jambonz/jambonz-api-server.git
synced 2025-12-19 05:47:46 +00:00
support tts deepgram (#277)
This commit is contained in:
@@ -5,7 +5,7 @@ const SpeechCredential = require('../../models/speech-credential');
|
||||
const sysError = require('../error');
|
||||
const {decrypt, encrypt} = require('../../utils/encrypt-decrypt');
|
||||
const {parseAccountSid, parseServiceProviderSid, parseSpeechCredentialSid} = require('./utils');
|
||||
const {decryptCredential, testWhisper} = require('../../utils/speech-utils');
|
||||
const {decryptCredential, testWhisper, testDeepgramTTS} = require('../../utils/speech-utils');
|
||||
const {DbErrorUnprocessableRequest, DbErrorForbidden} = require('../../utils/errors');
|
||||
const {
|
||||
testGoogleTts,
|
||||
@@ -637,6 +637,16 @@ router.get('/:sid/test', async(req, res) => {
|
||||
}
|
||||
else if (cred.vendor === 'deepgram') {
|
||||
const {api_key} = credential;
|
||||
if (cred.use_for_tts) {
|
||||
try {
|
||||
await testDeepgramTTS(logger, synthAudio, credential);
|
||||
results.tts.status = 'ok';
|
||||
SpeechCredential.ttsTestResult(sid, true);
|
||||
} catch (err) {
|
||||
results.tts = {status: 'fail', reason: err.message};
|
||||
SpeechCredential.ttsTestResult(sid, false);
|
||||
}
|
||||
}
|
||||
if (cred.use_for_stt) {
|
||||
try {
|
||||
await testDeepgramStt(logger, {api_key});
|
||||
|
||||
@@ -233,6 +233,24 @@ const testWhisper = async(logger, synthAudio, credentials) => {
|
||||
}
|
||||
};
|
||||
|
||||
const testDeepgramTTS = async(logger, synthAudio, credentials) => {
|
||||
try {
|
||||
await synthAudio({increment: () => {}, histogram: () => {}},
|
||||
{
|
||||
vendor: 'deepgram',
|
||||
credentials,
|
||||
language: 'en-US',
|
||||
voice: 'alpha-aurora-en-v2',
|
||||
model: 'alpha-aurora-en-v2',
|
||||
text: 'Hi there and welcome to jambones!'
|
||||
}
|
||||
);
|
||||
} catch (err) {
|
||||
logger.info({err}, 'testDeepgramTTS returned error');
|
||||
throw err;
|
||||
}
|
||||
};
|
||||
|
||||
const testIbmTts = async(logger, getTtsVoices, credentials) => {
|
||||
const {tts_api_key, tts_region} = credentials;
|
||||
const voices = await getTtsVoices({vendor: 'ibm', credentials: {tts_api_key, tts_region}});
|
||||
@@ -418,6 +436,7 @@ module.exports = {
|
||||
testSonioxStt,
|
||||
testElevenlabs,
|
||||
testAssemblyStt,
|
||||
testDeepgramTTS,
|
||||
getSpeechCredential,
|
||||
decryptCredential,
|
||||
testWhisper
|
||||
|
||||
14
package-lock.json
generated
14
package-lock.json
generated
@@ -19,7 +19,7 @@
|
||||
"@jambonz/lamejs": "^1.2.2",
|
||||
"@jambonz/mw-registrar": "^0.2.7",
|
||||
"@jambonz/realtimedb-helpers": "^0.8.7",
|
||||
"@jambonz/speech-utils": "^0.0.32",
|
||||
"@jambonz/speech-utils": "^0.0.33",
|
||||
"@jambonz/time-series": "^0.2.8",
|
||||
"@jambonz/verb-specifications": "^0.0.45",
|
||||
"@soniox/soniox-node": "^1.1.1",
|
||||
@@ -2255,9 +2255,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@jambonz/speech-utils": {
|
||||
"version": "0.0.32",
|
||||
"resolved": "https://registry.npmjs.org/@jambonz/speech-utils/-/speech-utils-0.0.32.tgz",
|
||||
"integrity": "sha512-5NrsuWX6Oq9RMieIaAZYJMXLQVYuXPLY2vG04b9yufpDdAd4ah50DOSIztXZBy+mV8CCyAyB1S3NNGu28QnJFQ==",
|
||||
"version": "0.0.33",
|
||||
"resolved": "https://registry.npmjs.org/@jambonz/speech-utils/-/speech-utils-0.0.33.tgz",
|
||||
"integrity": "sha512-dJnOSbmPIPCdy1CUweTE9B5tNhC9I6NjcVY/X2I0S+Ao3jzQdZLXCMlKsaswDQ72eCh0YyMs4ZORV05ummBelg==",
|
||||
"dependencies": {
|
||||
"@aws-sdk/client-polly": "^3.359.0",
|
||||
"@aws-sdk/client-sts": "^3.458.0",
|
||||
@@ -12947,9 +12947,9 @@
|
||||
}
|
||||
},
|
||||
"@jambonz/speech-utils": {
|
||||
"version": "0.0.32",
|
||||
"resolved": "https://registry.npmjs.org/@jambonz/speech-utils/-/speech-utils-0.0.32.tgz",
|
||||
"integrity": "sha512-5NrsuWX6Oq9RMieIaAZYJMXLQVYuXPLY2vG04b9yufpDdAd4ah50DOSIztXZBy+mV8CCyAyB1S3NNGu28QnJFQ==",
|
||||
"version": "0.0.33",
|
||||
"resolved": "https://registry.npmjs.org/@jambonz/speech-utils/-/speech-utils-0.0.33.tgz",
|
||||
"integrity": "sha512-dJnOSbmPIPCdy1CUweTE9B5tNhC9I6NjcVY/X2I0S+Ao3jzQdZLXCMlKsaswDQ72eCh0YyMs4ZORV05ummBelg==",
|
||||
"requires": {
|
||||
"@aws-sdk/client-polly": "^3.359.0",
|
||||
"@aws-sdk/client-sts": "^3.458.0",
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
"@jambonz/lamejs": "^1.2.2",
|
||||
"@jambonz/mw-registrar": "^0.2.7",
|
||||
"@jambonz/realtimedb-helpers": "^0.8.7",
|
||||
"@jambonz/speech-utils": "^0.0.32",
|
||||
"@jambonz/speech-utils": "^0.0.33",
|
||||
"@jambonz/time-series": "^0.2.8",
|
||||
"@jambonz/verb-specifications": "^0.0.45",
|
||||
"@soniox/soniox-node": "^1.1.1",
|
||||
|
||||
Reference in New Issue
Block a user