diff --git a/LCU.Webapps.Marketing.SPIT/LCU.Webapps.Marketing.SPIT/LCU.Webapps.Marketing.SPIT/Pages/_Host.cshtml b/LCU.Webapps.Marketing.SPIT/LCU.Webapps.Marketing.SPIT/LCU.Webapps.Marketing.SPIT/Pages/_Host.cshtml index 2e0f431..7815890 100644 --- a/LCU.Webapps.Marketing.SPIT/LCU.Webapps.Marketing.SPIT/LCU.Webapps.Marketing.SPIT/Pages/_Host.cshtml +++ b/LCU.Webapps.Marketing.SPIT/LCU.Webapps.Marketing.SPIT/LCU.Webapps.Marketing.SPIT/Pages/_Host.cshtml @@ -48,7 +48,7 @@ System.Text.RegularExpressions.Regex.IsMatch(userAgent, @"MSIE \d|Trident.*rv:") - - + + diff --git a/LCU.Webapps.Marketing.SPIT/LCU.Webapps.Marketing.SPIT/LCU.Webapps.Marketing.SPIT/wwwroot/js/SpeechFunctions.js b/LCU.Webapps.Marketing.SPIT/LCU.Webapps.Marketing.SPIT/LCU.Webapps.Marketing.SPIT/wwwroot/js/SpeechFunctions.js index f5aee3e..6cd5a1f 100644 --- a/LCU.Webapps.Marketing.SPIT/LCU.Webapps.Marketing.SPIT/LCU.Webapps.Marketing.SPIT/wwwroot/js/SpeechFunctions.js +++ b/LCU.Webapps.Marketing.SPIT/LCU.Webapps.Marketing.SPIT/LCU.Webapps.Marketing.SPIT/wwwroot/js/SpeechFunctions.js @@ -46,18 +46,31 @@ function synthesizeSpeech(subscriptionKey, region, endpoint, ssml) { } function createSpeechConfig(SpeechSDK, subscriptionKey, region, endpoint) { - const trimmedRegion = typeof region === "string" ? region.trim() : ""; const trimmedEndpoint = typeof endpoint === "string" ? endpoint.trim() : ""; + const trimmedRegion = typeof region === "string" ? region.trim() : ""; + + if (trimmedRegion) { + if (!trimmedEndpoint) { + return SpeechSDK.SpeechConfig.fromSubscription(subscriptionKey, trimmedRegion); + } + } + + if (trimmedEndpoint) { + const endpointUrl = new URL(trimmedEndpoint); + const hasCustomPath = endpointUrl.pathname && endpointUrl.pathname !== "/"; + + if (hasCustomPath) { + return SpeechSDK.SpeechConfig.fromEndpoint(endpointUrl, subscriptionKey); + } + + return SpeechSDK.SpeechConfig.fromHost(endpointUrl, subscriptionKey); + } if (trimmedRegion) { return SpeechSDK.SpeechConfig.fromSubscription(subscriptionKey, trimmedRegion); } - if (trimmedEndpoint) { - return SpeechSDK.SpeechConfig.fromEndpoint(new URL(trimmedEndpoint), subscriptionKey); - } - - throw new Error("Speech configuration is missing both region and endpoint."); + throw new Error("Speech configuration is missing both endpoint and region."); } function buildSynthesisErrorMessage(SpeechSDK, result, region, endpoint) {