From 39e0c65671f816f0dfda37c7a30c61d61ba2319e Mon Sep 17 00:00:00 2001 From: Zeeshaun Date: Thu, 23 Apr 2026 14:55:13 +0000 Subject: [PATCH] Updating --- .../Model/SpitConfiguration.cs | 53 +++---------------- .../Services/TextToSpeechService.cs | 23 ++------ 2 files changed, 12 insertions(+), 64 deletions(-) diff --git a/LCU.Webapps.Marketing.SPIT/LCU.Webapps.Marketing.SPIT/LCU.Webapps.Marketing.SPIT/Model/SpitConfiguration.cs b/LCU.Webapps.Marketing.SPIT/LCU.Webapps.Marketing.SPIT/LCU.Webapps.Marketing.SPIT/Model/SpitConfiguration.cs index f641efb..2630952 100644 --- a/LCU.Webapps.Marketing.SPIT/LCU.Webapps.Marketing.SPIT/LCU.Webapps.Marketing.SPIT/Model/SpitConfiguration.cs +++ b/LCU.Webapps.Marketing.SPIT/LCU.Webapps.Marketing.SPIT/LCU.Webapps.Marketing.SPIT/Model/SpitConfiguration.cs @@ -5,8 +5,6 @@ namespace LCU.Webapps.Marketing.SPIT.Model { public class SpitConfiguration { - private const string DefaultSpeechSynthesisPath = "/tts/cognitiveservices/v1"; - public string AppName { get; set; } public string SeqApiKey { get; set; } public string SeqUrl { get; set; } @@ -38,7 +36,7 @@ namespace LCU.Webapps.Marketing.SPIT.Model return new Uri(SpeechEndpoint.Trim(), UriKind.Absolute); } - public Uri ResolveSpeechSynthesisEndpointUri() + public Uri ResolveSpeechSdkEndpointUri() { var endpoint = ResolveSpeechEndpointUri(); if (endpoint == null) @@ -46,35 +44,13 @@ namespace LCU.Webapps.Marketing.SPIT.Model return null; } - var endpointPath = endpoint.AbsolutePath?.Trim() ?? string.Empty; - if (string.IsNullOrWhiteSpace(endpointPath) || endpointPath == "/") + return new UriBuilder(endpoint) { - return new Uri(endpoint, ResolveSpeechSynthesisPath()); - } - - if (endpointPath.EndsWith("/websocket/v1", StringComparison.OrdinalIgnoreCase)) - { - return new UriBuilder(endpoint) - { - Scheme = Uri.UriSchemeHttps, - Port = -1, - Path = endpointPath.Replace("/websocket/v1", "/v1", StringComparison.OrdinalIgnoreCase), - Query = string.Empty - }.Uri; - } - - if (endpointPath.EndsWith("/voices/list", StringComparison.OrdinalIgnoreCase)) - { - return new UriBuilder(endpoint) - { - Scheme = Uri.UriSchemeHttps, - Port = -1, - Path = endpointPath.Replace("/voices/list", "/v1", StringComparison.OrdinalIgnoreCase), - Query = string.Empty - }.Uri; - } - - return endpoint; + Scheme = "wss", + Port = -1, + Path = string.Empty, + Query = string.Empty + }.Uri; } public Uri ResolveSpeechTokenUri() @@ -86,20 +62,5 @@ namespace LCU.Webapps.Marketing.SPIT.Model { return new Uri(ResolveSpeechEndpointUri(), VoicesUrl); } - - private string ResolveSpeechSynthesisPath() - { - if (!string.IsNullOrWhiteSpace(WebsocketUrl)) - { - return WebsocketUrl.Replace("/websocket/v1", "/v1", StringComparison.OrdinalIgnoreCase); - } - - if (!string.IsNullOrWhiteSpace(VoicesUrl)) - { - return VoicesUrl.Replace("/voices/list", "/v1", StringComparison.OrdinalIgnoreCase); - } - - return DefaultSpeechSynthesisPath; - } } } diff --git a/LCU.Webapps.Marketing.SPIT/LCU.Webapps.Marketing.SPIT/LCU.Webapps.Marketing.SPIT/Services/TextToSpeechService.cs b/LCU.Webapps.Marketing.SPIT/LCU.Webapps.Marketing.SPIT/LCU.Webapps.Marketing.SPIT/Services/TextToSpeechService.cs index ebb85a7..e8040ab 100644 --- a/LCU.Webapps.Marketing.SPIT/LCU.Webapps.Marketing.SPIT/LCU.Webapps.Marketing.SPIT/Services/TextToSpeechService.cs +++ b/LCU.Webapps.Marketing.SPIT/LCU.Webapps.Marketing.SPIT/LCU.Webapps.Marketing.SPIT/Services/TextToSpeechService.cs @@ -105,28 +105,15 @@ namespace LCU.Webapps.Marketing.SPIT.Services private SpeechConfig BuildSpeechConfig() { - var speechEndpoint = _spitConfiguration.ResolveSpeechEndpointUri(); - if (speechEndpoint != null) + var sdkEndpoint = _spitConfiguration.ResolveSpeechSdkEndpointUri(); + if (sdkEndpoint != null) { - var endpointPath = speechEndpoint.AbsolutePath?.Trim() ?? string.Empty; - if (string.IsNullOrWhiteSpace(endpointPath) || endpointPath == "/") - { - Log.Information( - "Using speech host {SpeechHost} for file generation.", - speechEndpoint); - - return SpeechConfig.FromHost( - speechEndpoint, - _spitConfiguration.SpeechApiKey); - } - - var synthesisEndpoint = _spitConfiguration.ResolveSpeechSynthesisEndpointUri(); Log.Information( - "Using explicit speech endpoint {SpeechSynthesisEndpoint} for file generation.", - synthesisEndpoint); + "Using speech SDK endpoint {SpeechSdkEndpoint} for file generation.", + sdkEndpoint); return SpeechConfig.FromEndpoint( - synthesisEndpoint, + sdkEndpoint, _spitConfiguration.SpeechApiKey); }