initial changes to support wellsaid tts (#29)

This commit is contained in:
Dave Horton
2022-01-27 08:17:51 -05:00
committed by GitHub
parent 3aac11560a
commit c9bf943656
4 changed files with 78 additions and 4 deletions
+25 -1
View File
@@ -10,7 +10,8 @@ const {
testAwsTts,
testAwsStt,
testMicrosoftStt,
testMicrosoftTts
testMicrosoftTts,
testWellSaidTts
} = require('../../utils/speech-utils');
router.post('/', async(req, res) => {
@@ -66,6 +67,12 @@ router.post('/', async(req, res) => {
});
encrypted_credential = encrypt(data);
}
else if (vendor === 'wellsaid') {
const data = JSON.stringify({
api_key
});
encrypted_credential = encrypt(data);
}
else throw new DbErrorBadRequest(`invalid speech vendor ${vendor}`);
const uuid = await SpeechCredential.make({
account_sid,
@@ -109,6 +116,10 @@ router.get('/', async(req, res) => {
obj.api_key = o.api_key;
obj.region = o.region;
}
else if ('wellsaid' === obj.vendor) {
const o = decrypt(credential);
obj.api_key = o.api_key;
}
return obj;
}));
} catch (err) {
@@ -291,6 +302,19 @@ router.get('/:sid/test', async(req, res) => {
}
}
}
else if (cred.vendor === 'wellsaid') {
const {api_key} = credential;
if (cred.use_for_tts) {
try {
await testWellSaidTts(logger, {api_key});
results.tts.status = 'ok';
SpeechCredential.ttsTestResult(sid, true);
} catch (err) {
results.tts = {status: 'fail', reason: err.message};
SpeechCredential.ttsTestResult(sid, false);
}
}
}
res.status(200).json(results);
} catch (err) {
sysError(logger, res, err);