get an aws security token for STT

This commit is contained in:
Dave Horton
2023-11-29 13:34:17 -05:00
parent 86a14daf79
commit 864a673ea0
2 changed files with 10 additions and 1 deletions

View File

@@ -53,7 +53,7 @@ class SttTask extends Task {
}
async _initSpeechCredentials(cs, vendor, label) {
const {getNuanceAccessToken, getIbmAccessToken} = this.cs.srf.locals.dbHelpers;
const {getNuanceAccessToken, getIbmAccessToken, getAwsAuthToken} = this.cs.srf.locals.dbHelpers;
let credentials = cs.getSpeechCredentials(vendor, 'stt', label);
if (!credentials) {
@@ -87,6 +87,13 @@ class SttTask extends Task {
this.logger.debug({stt_api_key}, `got ibm access token ${servedFromCache ? 'from cache' : ''}`);
credentials = {...credentials, access_token, stt_region};
}
else if (vendor == 'aws') {
/* get AWS access token */
const {accessKeyId, secretAccessKey, region } = credentials;
const { servedFromCache, ...newCredentials} = await getAwsAuthToken(accessKeyId, secretAccessKey, region);
this.logger.debug({newCredentials}, `got aws security token ${servedFromCache ? 'from cache' : ''}`);
credentials = newCredentials;
}
return credentials;
}