fix Speech credential test for azure (#322)

This commit is contained in:
Hoan Luu Huu
2024-05-14 06:56:06 -04:00
committed by GitHub
parent c0fab2880b
commit 82c16380f5
2 changed files with 8 additions and 6 deletions
+1 -1
View File
@@ -613,7 +613,7 @@ router.get('/:sid/test', async(req, res) => {
} }
if (cred.use_for_stt) { if (cred.use_for_stt) {
try { try {
await testMicrosoftStt(logger, {api_key, region}); await testMicrosoftStt(logger, {api_key, region, use_custom_stt, custom_stt_endpoint_url});
results.stt.status = 'ok'; results.stt.status = 'ok';
SpeechCredential.sttTestResult(sid, true); SpeechCredential.sttTestResult(sid, true);
} catch (err) { } catch (err) {
+7 -5
View File
@@ -117,9 +117,10 @@ const testDeepgramStt = async(logger, credentials) => {
}; };
const testMicrosoftStt = async(logger, credentials) => { const testMicrosoftStt = async(logger, credentials) => {
const {api_key, region} = credentials; const {api_key, region, use_custom_stt, custom_stt_endpoint_url} = credentials;
const speechConfig = use_custom_stt ? sdk.SpeechConfig.fromEndpoint(
const speechConfig = sdk.SpeechConfig.fromSubscription(api_key, region); 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`)); const audioConfig = sdk.AudioConfig.fromWavFileInput(fs.readFileSync(`${__dirname}/../../data/test_audio.wav`));
speechConfig.speechRecognitionLanguage = 'en-US'; speechConfig.speechRecognitionLanguage = 'en-US';
@@ -189,7 +190,7 @@ const testAwsStt = async(logger, getAwsAuthToken, credentials) => {
const response = await client.send(command); const response = await client.send(command);
return response; return response;
} catch (err) { } 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; throw err;
} }
}; };
@@ -202,7 +203,8 @@ const testMicrosoftTts = async(logger, synthAudio, credentials) => {
credentials, credentials,
language: 'en-US', language: 'en-US',
voice: 'en-US-JennyMultilingualNeural', voice: 'en-US-JennyMultilingualNeural',
text: 'Hi there and welcome to jambones!' text: 'Hi there and welcome to jambones!',
renderForCaching: true
} }
); );
} catch (err) { } catch (err) {