mirror of
https://github.com/jambonz/jambonz-api-server.git
synced 2026-10-04 02:04:18 +00:00
add support for custom speech api (#121)
This commit is contained in:
@@ -53,7 +53,8 @@ const encryptCredential = (obj) => {
|
|||||||
stt_api_key,
|
stt_api_key,
|
||||||
stt_region,
|
stt_region,
|
||||||
riva_server_uri,
|
riva_server_uri,
|
||||||
instance_id
|
instance_id,
|
||||||
|
auth_token = ''
|
||||||
} = obj;
|
} = obj;
|
||||||
|
|
||||||
switch (vendor) {
|
switch (vendor) {
|
||||||
@@ -119,7 +120,11 @@ const encryptCredential = (obj) => {
|
|||||||
return encrypt(sonioxData);
|
return encrypt(sonioxData);
|
||||||
|
|
||||||
default:
|
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));
|
const o = JSON.parse(decrypt(credential));
|
||||||
obj.api_key = obscureKey(o.api_key);
|
obj.api_key = obscureKey(o.api_key);
|
||||||
}
|
}
|
||||||
|
else if (obj.vendor.startsWith('custom:')) {
|
||||||
|
const o = JSON.parse(decrypt(credential));
|
||||||
|
return {...obj, ...o};
|
||||||
|
}
|
||||||
return obj;
|
return obj;
|
||||||
}));
|
}));
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@@ -295,6 +304,10 @@ router.get('/:sid', async(req, res) => {
|
|||||||
const o = JSON.parse(decrypt(credential));
|
const o = JSON.parse(decrypt(credential));
|
||||||
obj.riva_server_uri = o.riva_server_uri;
|
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);
|
res.status(200).json(obj);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
sysError(logger, res, err);
|
sysError(logger, res, err);
|
||||||
@@ -592,7 +605,8 @@ router.get('/:sid/test', async(req, res) => {
|
|||||||
SpeechCredential.sttTestResult(sid, false);
|
SpeechCredential.sttTestResult(sid, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (cred.vendor === 'soniox') {
|
}
|
||||||
|
else if (cred.vendor === 'soniox') {
|
||||||
const {api_key} = credential;
|
const {api_key} = credential;
|
||||||
if (cred.use_for_stt) {
|
if (cred.use_for_stt) {
|
||||||
try {
|
try {
|
||||||
@@ -607,6 +621,7 @@ router.get('/:sid/test', async(req, res) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
res.status(200).json(results);
|
res.status(200).json(results);
|
||||||
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
sysError(logger, res, err);
|
sysError(logger, res, err);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user