feat azure fromhost (#214)

* feat azure fromhost

* wip

* wip

* wip
This commit is contained in:
Hoan Luu Huu
2023-08-31 08:06:03 +07:00
committed by GitHub
parent 9002bacf8f
commit 6d3bfd527e

View File

@@ -114,8 +114,10 @@ const encryptCredential = (obj) => {
nuance_stt_uri,
use_custom_tts,
custom_tts_endpoint,
custom_tts_endpoint_url,
use_custom_stt,
custom_stt_endpoint,
custom_stt_endpoint_url,
tts_api_key,
tts_region,
stt_api_key,
@@ -147,15 +149,19 @@ const encryptCredential = (obj) => {
return encrypt(awsData);
case 'microsoft':
assert(region, 'invalid azure speech credential: region is required');
assert(api_key, 'invalid azure speech credential: api_key is required');
if (!custom_tts_endpoint_url && !custom_stt_endpoint_url) {
assert(region, 'invalid azure speech credential: region is required');
assert(api_key, 'invalid azure speech credential: api_key is required');
}
const azureData = JSON.stringify({
region,
api_key,
...(region && {region}),
...(api_key && {api_key}),
use_custom_tts,
custom_tts_endpoint,
custom_tts_endpoint_url,
use_custom_stt,
custom_stt_endpoint
custom_stt_endpoint,
custom_stt_endpoint_url
});
return encrypt(azureData);
@@ -295,8 +301,10 @@ router.get('/', async(req, res) => {
obj.region = o.region;
obj.use_custom_tts = o.use_custom_tts;
obj.custom_tts_endpoint = o.custom_tts_endpoint;
obj.custom_tts_endpoint_url = o.custom_tts_endpoint_url;
obj.use_custom_stt = o.use_custom_stt;
obj.custom_stt_endpoint = o.custom_stt_endpoint;
obj.custom_stt_endpoint_url = o.custom_stt_endpoint_url;
logger.info({obj, o}, 'retrieving azure speech credential');
}
else if ('wellsaid' === obj.vendor) {
@@ -383,8 +391,10 @@ router.get('/:sid', async(req, res) => {
obj.region = o.region;
obj.use_custom_tts = o.use_custom_tts;
obj.custom_tts_endpoint = o.custom_tts_endpoint;
obj.custom_tts_endpoint_url = o.custom_tts_endpoint_url;
obj.use_custom_stt = o.use_custom_stt;
obj.custom_stt_endpoint = o.custom_stt_endpoint;
obj.custom_stt_endpoint_url = o.custom_stt_endpoint_url;
}
else if ('wellsaid' === obj.vendor) {
const o = JSON.parse(decrypt(credential));
@@ -488,8 +498,10 @@ router.put('/:sid', async(req, res) => {
const {
use_custom_tts,
custom_tts_endpoint,
custom_tts_endpoint_url,
use_custom_stt,
custom_stt_endpoint,
custom_stt_endpoint_url,
custom_stt_url,
custom_tts_url
} = req.body;
@@ -501,8 +513,10 @@ router.put('/:sid', async(req, res) => {
aws_region,
use_custom_tts,
custom_tts_endpoint,
custom_tts_endpoint_url,
use_custom_stt,
custom_stt_endpoint,
custom_stt_endpoint_url,
stt_region,
tts_region,
riva_server_uri,
@@ -622,8 +636,10 @@ router.get('/:sid/test', async(req, res) => {
region,
use_custom_tts,
custom_tts_endpoint,
custom_tts_endpoint_url,
use_custom_stt,
custom_stt_endpoint
custom_stt_endpoint,
custom_stt_endpoint_url
} = credential;
if (cred.use_for_tts) {
try {
@@ -632,8 +648,10 @@ router.get('/:sid/test', async(req, res) => {
region,
use_custom_tts,
custom_tts_endpoint,
custom_tts_endpoint_url,
use_custom_stt,
custom_stt_endpoint
custom_stt_endpoint,
custom_stt_endpoint_url
});
results.tts.status = 'ok';
SpeechCredential.ttsTestResult(sid, true);