From 0f2cccbc305ccebe48b3ec8c89e12fa5d16e7024 Mon Sep 17 00:00:00 2001 From: Zeeshaun Date: Wed, 22 Apr 2026 15:13:45 -0500 Subject: [PATCH] Updating --- LCU.Webapps.Marketing.SPIT/.codex | 0 .../Pages/Index.razor | 20 +-- .../Pages/_Host.cshtml | 4 +- .../appsettings.json | 16 +- .../wwwroot/js/SpeechFunctions.js | 145 +++--------------- .../overlays/qa/appsettings/appsettings.json | 6 +- .../overlays/uat/appsettings/appsettings.json | 6 +- 7 files changed, 43 insertions(+), 154 deletions(-) delete mode 100644 LCU.Webapps.Marketing.SPIT/.codex diff --git a/LCU.Webapps.Marketing.SPIT/.codex b/LCU.Webapps.Marketing.SPIT/.codex deleted file mode 100644 index e69de29..0000000 diff --git a/LCU.Webapps.Marketing.SPIT/LCU.Webapps.Marketing.SPIT/LCU.Webapps.Marketing.SPIT/Pages/Index.razor b/LCU.Webapps.Marketing.SPIT/LCU.Webapps.Marketing.SPIT/LCU.Webapps.Marketing.SPIT/Pages/Index.razor index 6fcf1fe..8d0daa6 100644 --- a/LCU.Webapps.Marketing.SPIT/LCU.Webapps.Marketing.SPIT/LCU.Webapps.Marketing.SPIT/Pages/Index.razor +++ b/LCU.Webapps.Marketing.SPIT/LCU.Webapps.Marketing.SPIT/LCU.Webapps.Marketing.SPIT/Pages/Index.razor @@ -214,20 +214,12 @@ return; } - try - { - await JSRuntime.InvokeVoidAsync( - "synthesizeSpeech", - spitConfiguration.SpeechApiKey, - spitConfiguration.Region, - spitConfiguration.SpeechEndpoint, - _textToSpeech.Ssml); - } - catch (JSException ex) - { - Log.Error(ex, "Play sound failed."); - toastService.ShowError($"Unable to play sound. {ex.Message}"); - } + await JSRuntime.InvokeVoidAsync( + "synthesizeSpeech", + spitConfiguration.SpeechApiKey, + spitConfiguration.Region, + spitConfiguration.SpeechEndpoint, + _textToSpeech.Ssml); } public void OpenDirectory(string fileDestination) 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 7815890..2e0f431 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/appsettings.json b/LCU.Webapps.Marketing.SPIT/LCU.Webapps.Marketing.SPIT/LCU.Webapps.Marketing.SPIT/appsettings.json index c2d5c46..bff01da 100644 --- a/LCU.Webapps.Marketing.SPIT/LCU.Webapps.Marketing.SPIT/LCU.Webapps.Marketing.SPIT/appsettings.json +++ b/LCU.Webapps.Marketing.SPIT/LCU.Webapps.Marketing.SPIT/LCU.Webapps.Marketing.SPIT/appsettings.json @@ -4,15 +4,15 @@ "AppName": "Speech Production Interface Tool", "SeqApiKey": "VALUE-IN-KEYVAULT", "SeqUrl": "https://qa-seq.lcu-internal.com", - "SpeechApiKey": "VALUE-IN-KEYVAULT", - "SpeechEndpoint": "VALUE-IN-KEYVAULT", + "SpeechApiKey": "ce503e1ea0d94720b4a1f6b66007a2ea", + "SpeechEndpoint": "https://speech-qa-uscz.cognitiveservices.azure.com", "FetchTokenUri": "/sts/v1.0/issueToken", - "VoicesUrl": "/cognitiveservices/voices/list", + "VoicesUrl": "/tts/cognitiveservices/voices/list", "OcpApimSubscriptionKey": "Ocp-Apim-Subscription-Key", "Region": "eastus", "FileDestination": "\\\\zeus\\DataIntegrationsQA\\Spit\\Test\\", "FileExtention": ".wav", - "SpitRoles": "IT Development", + "SpitRoles": "SpitUser - QA", "DefaultLanguageWithCountryCode": "en-US", "EnabledLanguageOptionCodes": [ "en", "es" ] }, @@ -22,8 +22,8 @@ }, "AzureAd": { "TenantId": "63cd1554-2783-4a86-ae50-b9e6c21c9499", - "ClientId": "VALUE-IN-KEYVAULT", - "ClientSecret": "VALUE-IN-KEYVAULT", + "ClientId": "b756f2d1-8f23-4bbe-b183-c98f6931091c", + "ClientSecret": "HnS8Q~uHMa-hGMEn6tzpTml1AtNow9G.SVBTZaiW", "Instance": "https://login.microsoftonline.com/", "Domain": "landmarkcu.onmicrosoft.com", "CallbackPath": "/signin-oidc", @@ -31,8 +31,8 @@ }, "Security": { "AccessPolicies": { - "IT Development": { - "Groups": "IT Development" + "SpitUser - QA": { + "Groups": "SpitUser - QA" } } } 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 6cd5a1f..388f615 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 @@ -1,129 +1,26 @@ function synthesizeSpeech(subscriptionKey, region, endpoint, ssml) { - return new Promise(function (resolve, reject) { - const SpeechSDK = window.SpeechSDK; + var SpeechSDK; + if (!!window.SpeechSDK) { + SpeechSDK = window.SpeechSDK; + } - if (!SpeechSDK) { - reject(new Error("Speech SDK is not loaded.")); - return; - } + const speechConfig = endpoint + ? SpeechSDK.SpeechConfig.fromEndpoint(new URL(endpoint), subscriptionKey) + : SpeechSDK.SpeechConfig.fromSubscription(subscriptionKey, region); + const audioConfig = SpeechSDK.AudioConfig.fromDefaultSpeakerOutput(); + let synthesizer = new SpeechSDK.SpeechSynthesizer(speechConfig, audioConfig); - let speechConfig; + synthesizer.speakSsmlAsync( + ssml, + function (result) { + window.console.log(result); + synthesizer.close(); + synthesizer = undefined; + }, + function (err) { + window.console.log(err); - try { - speechConfig = createSpeechConfig(SpeechSDK, subscriptionKey, region, endpoint); - } catch (error) { - reject(error); - return; - } - - const audioConfig = SpeechSDK.AudioConfig.fromDefaultSpeakerOutput(); - let synthesizer = new SpeechSDK.SpeechSynthesizer(speechConfig, audioConfig); - - synthesizer.speakSsmlAsync( - ssml, - function (result) { - try { - if (result.reason !== SpeechSDK.ResultReason.SynthesizingAudioCompleted) { - reject(new Error(buildSynthesisErrorMessage(SpeechSDK, result, region, endpoint))); - return; - } - - resolve(); - } finally { - synthesizer.close(); - synthesizer = undefined; - } - }, - function (error) { - try { - reject(new Error(normalizeSpeechError(error, region, endpoint))); - } finally { - synthesizer.close(); - synthesizer = undefined; - } - }); - }); -} - -function createSpeechConfig(SpeechSDK, subscriptionKey, region, endpoint) { - 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); - } - - throw new Error("Speech configuration is missing both endpoint and region."); -} - -function buildSynthesisErrorMessage(SpeechSDK, result, region, endpoint) { - const cancellation = SpeechSDK.CancellationDetails.fromResult(result); - const parts = [ - "Speech synthesis failed.", - "Reason: " + result.reason - ]; - - if (cancellation) { - if (cancellation.reason !== undefined) { - parts.push("CancellationReason: " + cancellation.reason); - } - - if (cancellation.errorCode !== undefined) { - parts.push("CancellationErrorCode: " + cancellation.errorCode); - } - - if (cancellation.errorDetails) { - parts.push("ErrorDetails: " + cancellation.errorDetails); - } - } - - appendConnectionDetails(parts, region, endpoint); - return parts.join(" "); -} - -function normalizeSpeechError(error, region, endpoint) { - const parts = ["Speech synthesis connection failed."]; - - if (error instanceof Error && error.message) { - parts.push(error.message); - } else if (typeof error === "string" && error.trim()) { - parts.push(error.trim()); - } else if (error && error.toString) { - parts.push(error.toString()); - } else { - parts.push("No error details were provided."); - } - - appendConnectionDetails(parts, region, endpoint); - return parts.join(" "); -} - -function appendConnectionDetails(parts, region, endpoint) { - const trimmedRegion = typeof region === "string" ? region.trim() : ""; - const trimmedEndpoint = typeof endpoint === "string" ? endpoint.trim() : ""; - - if (trimmedRegion) { - parts.push("Region: " + trimmedRegion); - } - - if (trimmedEndpoint) { - parts.push("Endpoint: " + trimmedEndpoint); - } + synthesizer.close(); + synthesizer = undefined; + }); } diff --git a/LCU.Webapps.Marketing.SPIT/kustomize/overlays/qa/appsettings/appsettings.json b/LCU.Webapps.Marketing.SPIT/kustomize/overlays/qa/appsettings/appsettings.json index 01c4d6d..ae4473a 100644 --- a/LCU.Webapps.Marketing.SPIT/kustomize/overlays/qa/appsettings/appsettings.json +++ b/LCU.Webapps.Marketing.SPIT/kustomize/overlays/qa/appsettings/appsettings.json @@ -2,15 +2,15 @@ "Primary": { "FileDestination": "\\\\zeus\\DataIntegrationsQA\\Spit\\", "SeqUrl": "https://qa-seq.lcu-internal.com", - "SpitRoles": "IT Development" + "SpitRoles": "SpitUser - QA" }, "FileOperationsConfiguration": { "Url": "https://qa-fileoperationsapi.lcu-internal.com" }, "Security": { "AccessPolicies": { - "IT Development": { - "Groups": "IT Development" + "SpitUser - QA": { + "Groups": "SpitUser - QA" } } } diff --git a/LCU.Webapps.Marketing.SPIT/kustomize/overlays/uat/appsettings/appsettings.json b/LCU.Webapps.Marketing.SPIT/kustomize/overlays/uat/appsettings/appsettings.json index 205e8c9..14744f5 100644 --- a/LCU.Webapps.Marketing.SPIT/kustomize/overlays/uat/appsettings/appsettings.json +++ b/LCU.Webapps.Marketing.SPIT/kustomize/overlays/uat/appsettings/appsettings.json @@ -2,15 +2,15 @@ "Primary": { "FileDestination": "\\\\zeus\\DataIntegrationsUAT\\Spit\\", "SeqUrl": "https://uat-seq.lcu-internal.com", - "SpitRoles": "IT Development" + "SpitRoles": "SpitUser - QA" }, "FileOperationsConfiguration": { "Url": "https://uat-fileoperationsapi.lcu-internal.com" }, "Security": { "AccessPolicies": { - "IT Development": { - "Groups": "IT Development" + "SpitUser - QA": { + "Groups": "SpitUser - QA" } } }