This commit is contained in:
Zeeshaun
2026-04-27 15:26:58 +00:00
parent 5f6f132ea2
commit 6291ac76dd
15 changed files with 56 additions and 37 deletions
@@ -214,12 +214,19 @@
return;
}
await JSRuntime.InvokeVoidAsync(
"synthesizeSpeech",
spitConfiguration.SpeechApiKey,
spitConfiguration.Region,
spitConfiguration.ResolveSpeechSdkEndpointUri()?.ToString(),
_textToSpeech.Ssml);
try
{
await JSRuntime.InvokeVoidAsync(
"synthesizeSpeech",
spitConfiguration.SpeechApiKey,
spitConfiguration.Region,
spitConfiguration.ResolveSpeechSdkEndpointUri()?.ToString(),
_textToSpeech.Ssml);
}
catch (Microsoft.JSInterop.JSException)
{
toastService.ShowError("Unable to load the speech playback SDK in the browser. Disable content blocking for this site or reload and try again.");
}
}
public void OpenDirectory(string fileDestination)
@@ -22,6 +22,7 @@ namespace LCU.Webapps.Marketing.SPIT.Services
try
{
var speechConfig = BuildSpeechConfig();
speechConfig.SetSpeechSynthesisOutputFormat(SpeechSynthesisOutputFormat.Riff16Khz16BitMonoPcm);
speechConfig.SpeechSynthesisVoiceName = textToSpeech.SelectedVoiceShortName;
var finalDestination = (_spitConfiguration.FileDestination ?? string.Empty).Trim();
if (string.IsNullOrWhiteSpace(finalDestination))
@@ -1,14 +1,15 @@
function synthesizeSpeech(subscriptionKey, region, endpoint, ssml) {
var SpeechSDK;
if (!!window.SpeechSDK) {
SpeechSDK = window.SpeechSDK;
const speechSdk = window.SpeechSDK;
if (!speechSdk) {
throw new Error("Speech SDK is unavailable. The browser likely blocked the SDK script.");
}
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);
? speechSdk.SpeechConfig.fromEndpoint(new URL(endpoint), subscriptionKey)
: speechSdk.SpeechConfig.fromSubscription(subscriptionKey, region);
const audioConfig = speechSdk.AudioConfig.fromDefaultSpeakerOutput();
let synthesizer = new speechSdk.SpeechSynthesizer(speechConfig, audioConfig);
synthesizer.speakSsmlAsync(
ssml,