Skip to content

Commit

Permalink
support tts deepgram (#277)
Browse files Browse the repository at this point in the history
  • Loading branch information
xquanluu authored Dec 26, 2023
1 parent 55d8fde commit 997ff05
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 9 deletions.
12 changes: 11 additions & 1 deletion lib/routes/api/speech-credentials.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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});
Expand Down
19 changes: 19 additions & 0 deletions lib/utils/speech-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}});
Expand Down Expand Up @@ -418,6 +436,7 @@ module.exports = {
testSonioxStt,
testElevenlabs,
testAssemblyStt,
testDeepgramTTS,
getSpeechCredential,
decryptCredential,
testWhisper
Expand Down
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 997ff05

Please sign in to comment.