From 3bb33f24c231f1ccc4d6f2a4d5cbf2e96164d323 Mon Sep 17 00:00:00 2001 From: Hoan Luu Huu <110280845+xquanluu@users.noreply.github.com> Date: Mon, 1 Jun 2026 19:38:21 +0700 Subject: [PATCH] fix microsoft SST endpoint id is failed on validating speech credential (#554) --- lib/routes/api/speech-credentials.js | 3 ++- lib/utils/speech-utils.js | 17 +++++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/lib/routes/api/speech-credentials.js b/lib/routes/api/speech-credentials.js index 28eff1e..64cdbdd 100644 --- a/lib/routes/api/speech-credentials.js +++ b/lib/routes/api/speech-credentials.js @@ -747,7 +747,8 @@ router.get('/:sid/test', async(req, res) => { } if (cred.use_for_stt) { try { - await testMicrosoftStt(logger, {api_key, region, use_custom_stt, custom_stt_endpoint_url}); + await testMicrosoftStt(logger, + {api_key, region, use_custom_stt, custom_stt_endpoint, custom_stt_endpoint_url}); results.stt.status = 'ok'; SpeechCredential.sttTestResult(sid, true); } catch (err) { diff --git a/lib/utils/speech-utils.js b/lib/utils/speech-utils.js index 8ee8cbd..4e0498b 100644 --- a/lib/utils/speech-utils.js +++ b/lib/utils/speech-utils.js @@ -262,10 +262,19 @@ const testDeepgramStt = async(logger, credentials) => { }; const testMicrosoftStt = async(logger, credentials) => { - 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 {api_key, region, use_custom_stt, custom_stt_endpoint, custom_stt_endpoint_url} = credentials; + // custom_stt_endpoint_url is a custom service host URL (fromEndpoint), + // custom_stt_endpoint is a custom model/deployment id (endpointId on a region-based config) + let speechConfig; + if (use_custom_stt && custom_stt_endpoint_url) { + speechConfig = sdk.SpeechConfig.fromEndpoint(new URL(custom_stt_endpoint_url), api_key); + } + else { + speechConfig = sdk.SpeechConfig.fromSubscription(api_key, region); + if (use_custom_stt && custom_stt_endpoint) { + speechConfig.endpointId = custom_stt_endpoint; + } + } const audioConfig = sdk.AudioConfig.fromWavFileInput(fs.readFileSync(`${__dirname}/../../data/test_audio.wav`)); speechConfig.speechRecognitionLanguage = 'en-US';