fix azure tts test from speech-utils (#272)

* fix azure tts test from speech-utils

* wip
This commit is contained in:
Hoan Luu Huu
2023-12-07 10:10:55 +07:00
committed by GitHub
parent 7a558c7349
commit 10159a0ba6
2 changed files with 12 additions and 31 deletions

View File

@@ -556,7 +556,7 @@ router.get('/:sid/test', async(req, res) => {
} = credential;
if (cred.use_for_tts) {
try {
await testMicrosoftTts(logger, {
await testMicrosoftTts(logger, synthAudio, {
api_key,
region,
use_custom_tts,

View File

@@ -150,38 +150,19 @@ const testAwsStt = async(logger, credentials) => {
}
};
const testMicrosoftTts = async(logger, credentials) => {
const {
api_key,
region,
// eslint-disable-next-line no-unused-vars
use_custom_tts,
// eslint-disable-next-line no-unused-vars
custom_tts_endpoint,
// eslint-disable-next-line no-unused-vars
use_custom_stt,
// eslint-disable-next-line no-unused-vars
custom_stt_endpoint
} = credentials;
logger.info({
api_key,
region,
use_custom_tts,
custom_tts_endpoint,
use_custom_stt,
custom_stt_endpoint
}, 'testing microsoft tts');
if (!api_key) throw new Error('testMicrosoftTts: credentials are missing api_key');
if (!region) throw new Error('testMicrosoftTts: credentials are missing region');
const testMicrosoftTts = async(logger, synthAudio, credentials) => {
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;
await synthAudio({increment: () => {}, histogram: () => {}},
{
vendor: 'microsoft',
credentials,
language: 'en-US',
voice: 'en-US-JennyMultilingualNeural',
text: 'Hi there and welcome to jambones!'
}
);
} catch (err) {
logger.info({err}, `testMicrosoftTts - failed to list voices for region ${region}`);
logger.info({err}, 'testMicrosoftTts returned error');
throw err;
}
};