This commit is contained in:
Zeeshaun
2026-04-22 19:54:26 +00:00
parent 75ad412ed8
commit ce7775dc43
2 changed files with 21 additions and 8 deletions
@@ -48,7 +48,7 @@ System.Text.RegularExpressions.Regex.IsMatch(userAgent, @"MSIE \d|Trident.*rv:")
<script src="_framework/blazor.server.js"></script>
<script src="_content/Blazored.Typeahead/blazored-typeahead.js"></script>
<script src="js/microsoft.cognitiveservices.speech.sdk.bundle.js"></script>
<script src="js/SpeechFunctions.js"></script>
<script src="js/microsoft.cognitiveservices.speech.sdk.bundle.js" asp-append-version="true"></script>
<script src="js/SpeechFunctions.js" asp-append-version="true"></script>
</body>
</html>
@@ -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) {