fix Speech credential test for azure (#322)

This commit is contained in:
Hoan Luu Huu
2024-05-14 17:56:06 +07:00
committed by GitHub
parent c0fab2880b
commit 82c16380f5
2 changed files with 8 additions and 6 deletions

View File

@@ -613,7 +613,7 @@ router.get('/:sid/test', async(req, res) => {
}
if (cred.use_for_stt) {
try {
await testMicrosoftStt(logger, {api_key, region});
await testMicrosoftStt(logger, {api_key, region, use_custom_stt, custom_stt_endpoint_url});
results.stt.status = 'ok';
SpeechCredential.sttTestResult(sid, true);
} catch (err) {

View File

@@ -117,9 +117,10 @@ const testDeepgramStt = async(logger, credentials) => {
};
const testMicrosoftStt = async(logger, credentials) => {
const {api_key, region} = credentials;
const speechConfig = sdk.SpeechConfig.fromSubscription(api_key, region);
const {api_key, region, use_custom_stt, custom_stt_endpoint_url} = credentials;
const speechConfig = use_custom_stt ? sdk.SpeechConfig.fromEndpoint(
new URL(custom_stt_endpoint_url), api_key) :
sdk.SpeechConfig.fromSubscription(api_key, region);
const audioConfig = sdk.AudioConfig.fromWavFileInput(fs.readFileSync(`${__dirname}/../../data/test_audio.wav`));
speechConfig.speechRecognitionLanguage = 'en-US';
@@ -189,7 +190,7 @@ const testAwsStt = async(logger, getAwsAuthToken, credentials) => {
const response = await client.send(command);
return response;
} catch (err) {
logger.info({err}, 'testMicrosoftTts - failed to list voices for region ${region}');
logger.info({err}, 'testAwsStt - failed to list voices for region ${region}');
throw err;
}
};
@@ -202,7 +203,8 @@ const testMicrosoftTts = async(logger, synthAudio, credentials) => {
credentials,
language: 'en-US',
voice: 'en-US-JennyMultilingualNeural',
text: 'Hi there and welcome to jambones!'
text: 'Hi there and welcome to jambones!',
renderForCaching: true
}
);
} catch (err) {