add support for custom speech api (#121)

This commit is contained in:
Dave Horton
2023-03-02 14:13:41 -05:00
committed by GitHub
parent cc384995ea
commit 4934e2a1ca
+18 -3
View File
@@ -53,7 +53,8 @@ const encryptCredential = (obj) => {
stt_api_key,
stt_region,
riva_server_uri,
instance_id
instance_id,
auth_token = ''
} = obj;
switch (vendor) {
@@ -119,7 +120,11 @@ const encryptCredential = (obj) => {
return encrypt(sonioxData);
default:
assert(false, `invalid or missing vendor: ${vendor}`);
if (vendor.startsWith('custom:')) {
const customData = JSON.stringify({auth_token});
return encrypt(customData);
}
else assert(false, `invalid or missing vendor: ${vendor}`);
}
};
@@ -230,6 +235,10 @@ router.get('/', async(req, res) => {
const o = JSON.parse(decrypt(credential));
obj.api_key = obscureKey(o.api_key);
}
else if (obj.vendor.startsWith('custom:')) {
const o = JSON.parse(decrypt(credential));
return {...obj, ...o};
}
return obj;
}));
} catch (err) {
@@ -295,6 +304,10 @@ router.get('/:sid', async(req, res) => {
const o = JSON.parse(decrypt(credential));
obj.riva_server_uri = o.riva_server_uri;
}
else if (obj.vendor.startsWith('custom:')) {
const o = JSON.parse(decrypt(credential));
obj.auth_token = obscureKey(o.auth_token);
}
res.status(200).json(obj);
} catch (err) {
sysError(logger, res, err);
@@ -592,7 +605,8 @@ router.get('/:sid/test', async(req, res) => {
SpeechCredential.sttTestResult(sid, false);
}
}
} else if (cred.vendor === 'soniox') {
}
else if (cred.vendor === 'soniox') {
const {api_key} = credential;
if (cred.use_for_stt) {
try {
@@ -607,6 +621,7 @@ router.get('/:sid/test', async(req, res) => {
}
res.status(200).json(results);
} catch (err) {
sysError(logger, res, err);
}