feat: nvidia speech credential (#105)

* feat: nvidia speech credential

* fix: riva_server_uri

* fix: riva_server_uri

---------

Co-authored-by: Quan HL <quanluuhoang8@gmail.com>
This commit is contained in:
Hoan Luu HuuandQuan HL authored and GitHub committed 2023-02-10 08:31:49 -05:00
1 parent d4f2be3dc1
commit f46be95551
4 files changed
+48 -3

No files matched your search

+15 -2
View File
@@ -51,6 +51,7 @@ const encryptCredential = (obj) => {
tts_region,
stt_api_key,
stt_region,
riva_server_uri,
instance_id
} = obj;
@@ -106,6 +107,11 @@ const encryptCredential = (obj) => {
const ibmData = JSON.stringify({tts_api_key, tts_region, stt_api_key, stt_region, instance_id});
return encrypt(ibmData);
case 'nvidia':
assert(riva_server_uri, 'invalid riva server uri: riva_server_uri is required');
const nvidiaData = JSON.stringify({ riva_server_uri });
return encrypt(nvidiaData);
default:
assert(false, `invalid or missing vendor: ${vendor}`);
}
@@ -210,6 +216,9 @@ router.get('/', async(req, res) => {
obj.stt_api_key = obscureKey(o.stt_api_key);
obj.stt_region = o.stt_region;
obj.instance_id = o.instance_id;
} else if ('nvidia' == obj.vendor) {
const o = JSON.parse(decrypt(credential));
obj.riva_server_uri = o.riva_server_uri;
}
return obj;
}));
@@ -272,6 +281,9 @@ router.get('/:sid', async(req, res) => {
obj.stt_api_key = obscureKey(o.stt_api_key);
obj.stt_region = o.stt_region;
obj.instance_id = o.instance_id;
} else if ('nvidia' == obj.vendor) {
const o = JSON.parse(decrypt(credential));
obj.riva_server_uri = o.riva_server_uri;
}
res.status(200).json(obj);
} catch (err) {
@@ -302,7 +314,7 @@ router.put('/:sid', async(req, res) => {
const sid = req.params.sid;
const logger = req.app.locals.logger;
try {
const {use_for_tts, use_for_stt, region, aws_region, stt_region, tts_region} = req.body;
const {use_for_tts, use_for_stt, region, aws_region, stt_region, tts_region, riva_server_uri} = req.body;
if (typeof use_for_tts === 'undefined' && typeof use_for_stt === 'undefined') {
throw new DbErrorUnprocessableRequest('use_for_tts and use_for_stt are the only updateable fields');
}
@@ -337,7 +349,8 @@ router.put('/:sid', async(req, res) => {
use_custom_stt,
custom_stt_endpoint,
stt_region,
tts_region
tts_region,
riva_server_uri
};
logger.info({o, newCred}, 'updating speech credential with this new credential');
obj.credential = encryptCredential(newCred);