initial changes for microsoft speech support (#11)

* initial changes for microsoft speech support

* remove very wordy log message
This commit is contained in:
Dave Horton
2021-11-17 20:50:26 -05:00
committed by GitHub
parent bc8ff644db
commit f1d7dcc6d2
5 changed files with 148 additions and 36 deletions
+26 -1
View File
@@ -2,6 +2,7 @@ const ttsGoogle = require('@google-cloud/text-to-speech');
const sttGoogle = require('@google-cloud/speech').v1p1beta1;
const Polly = require('aws-sdk/clients/polly');
const AWS = require('aws-sdk');
const bent = require('bent');
const fs = require('fs');
const testGoogleTts = async(logger, credentials) => {
@@ -52,9 +53,33 @@ const testAwsStt = (logger, credentials) => {
});
};
const testMicrosoftTts = async(logger, credentials) => {
const {api_key, region} = credentials;
if (!api_key) throw new Error('testMicrosoftTts: credentials are missing api_key');
if (!region) throw new Error('testMicrosoftTts: credentials are missing region');
try {
const getJSON = bent('json', {
'Ocp-Apim-Subscription-Key': api_key
});
const response = await getJSON(`https://${region}.tts.speech.microsoft.com/cognitiveservices/voices/list`);
return response;
} catch (err) {
logger.info({err}, `testMicrosoftTts - failed to list voices for region ${region}`);
throw err;
}
};
const testMicrosoftStt = async(logger, credentials) => {
//TODO
return true;
};
module.exports = {
testGoogleTts,
testGoogleStt,
testAwsTts,
testAwsStt
testAwsStt,
testMicrosoftTts,
testMicrosoftStt
};