Updating
This commit is contained in:
+6
-14
@@ -214,20 +214,12 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
await JSRuntime.InvokeVoidAsync(
|
||||||
{
|
"synthesizeSpeech",
|
||||||
await JSRuntime.InvokeVoidAsync(
|
spitConfiguration.SpeechApiKey,
|
||||||
"synthesizeSpeech",
|
spitConfiguration.Region,
|
||||||
spitConfiguration.SpeechApiKey,
|
spitConfiguration.SpeechEndpoint,
|
||||||
spitConfiguration.Region,
|
_textToSpeech.Ssml);
|
||||||
spitConfiguration.SpeechEndpoint,
|
|
||||||
_textToSpeech.Ssml);
|
|
||||||
}
|
|
||||||
catch (JSException ex)
|
|
||||||
{
|
|
||||||
Log.Error(ex, "Play sound failed.");
|
|
||||||
toastService.ShowError($"Unable to play sound. {ex.Message}");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OpenDirectory(string fileDestination)
|
public void OpenDirectory(string fileDestination)
|
||||||
|
|||||||
+2
-2
@@ -48,7 +48,7 @@ System.Text.RegularExpressions.Regex.IsMatch(userAgent, @"MSIE \d|Trident.*rv:")
|
|||||||
|
|
||||||
<script src="_framework/blazor.server.js"></script>
|
<script src="_framework/blazor.server.js"></script>
|
||||||
<script src="_content/Blazored.Typeahead/blazored-typeahead.js"></script>
|
<script src="_content/Blazored.Typeahead/blazored-typeahead.js"></script>
|
||||||
<script src="js/microsoft.cognitiveservices.speech.sdk.bundle.js" asp-append-version="true"></script>
|
<script src="js/microsoft.cognitiveservices.speech.sdk.bundle.js"></script>
|
||||||
<script src="js/SpeechFunctions.js" asp-append-version="true"></script>
|
<script src="js/SpeechFunctions.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
+8
-8
@@ -4,15 +4,15 @@
|
|||||||
"AppName": "Speech Production Interface Tool",
|
"AppName": "Speech Production Interface Tool",
|
||||||
"SeqApiKey": "VALUE-IN-KEYVAULT",
|
"SeqApiKey": "VALUE-IN-KEYVAULT",
|
||||||
"SeqUrl": "https://qa-seq.lcu-internal.com",
|
"SeqUrl": "https://qa-seq.lcu-internal.com",
|
||||||
"SpeechApiKey": "VALUE-IN-KEYVAULT",
|
"SpeechApiKey": "ce503e1ea0d94720b4a1f6b66007a2ea",
|
||||||
"SpeechEndpoint": "VALUE-IN-KEYVAULT",
|
"SpeechEndpoint": "https://speech-qa-uscz.cognitiveservices.azure.com",
|
||||||
"FetchTokenUri": "/sts/v1.0/issueToken",
|
"FetchTokenUri": "/sts/v1.0/issueToken",
|
||||||
"VoicesUrl": "/cognitiveservices/voices/list",
|
"VoicesUrl": "/tts/cognitiveservices/voices/list",
|
||||||
"OcpApimSubscriptionKey": "Ocp-Apim-Subscription-Key",
|
"OcpApimSubscriptionKey": "Ocp-Apim-Subscription-Key",
|
||||||
"Region": "eastus",
|
"Region": "eastus",
|
||||||
"FileDestination": "\\\\zeus\\DataIntegrationsQA\\Spit\\Test\\",
|
"FileDestination": "\\\\zeus\\DataIntegrationsQA\\Spit\\Test\\",
|
||||||
"FileExtention": ".wav",
|
"FileExtention": ".wav",
|
||||||
"SpitRoles": "IT Development",
|
"SpitRoles": "SpitUser - QA",
|
||||||
"DefaultLanguageWithCountryCode": "en-US",
|
"DefaultLanguageWithCountryCode": "en-US",
|
||||||
"EnabledLanguageOptionCodes": [ "en", "es" ]
|
"EnabledLanguageOptionCodes": [ "en", "es" ]
|
||||||
},
|
},
|
||||||
@@ -22,8 +22,8 @@
|
|||||||
},
|
},
|
||||||
"AzureAd": {
|
"AzureAd": {
|
||||||
"TenantId": "63cd1554-2783-4a86-ae50-b9e6c21c9499",
|
"TenantId": "63cd1554-2783-4a86-ae50-b9e6c21c9499",
|
||||||
"ClientId": "VALUE-IN-KEYVAULT",
|
"ClientId": "b756f2d1-8f23-4bbe-b183-c98f6931091c",
|
||||||
"ClientSecret": "VALUE-IN-KEYVAULT",
|
"ClientSecret": "HnS8Q~uHMa-hGMEn6tzpTml1AtNow9G.SVBTZaiW",
|
||||||
"Instance": "https://login.microsoftonline.com/",
|
"Instance": "https://login.microsoftonline.com/",
|
||||||
"Domain": "landmarkcu.onmicrosoft.com",
|
"Domain": "landmarkcu.onmicrosoft.com",
|
||||||
"CallbackPath": "/signin-oidc",
|
"CallbackPath": "/signin-oidc",
|
||||||
@@ -31,8 +31,8 @@
|
|||||||
},
|
},
|
||||||
"Security": {
|
"Security": {
|
||||||
"AccessPolicies": {
|
"AccessPolicies": {
|
||||||
"IT Development": {
|
"SpitUser - QA": {
|
||||||
"Groups": "IT Development"
|
"Groups": "SpitUser - QA"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+21
-124
@@ -1,129 +1,26 @@
|
|||||||
function synthesizeSpeech(subscriptionKey, region, endpoint, ssml) {
|
function synthesizeSpeech(subscriptionKey, region, endpoint, ssml) {
|
||||||
return new Promise(function (resolve, reject) {
|
var SpeechSDK;
|
||||||
const SpeechSDK = window.SpeechSDK;
|
if (!!window.SpeechSDK) {
|
||||||
|
SpeechSDK = window.SpeechSDK;
|
||||||
|
}
|
||||||
|
|
||||||
if (!SpeechSDK) {
|
const speechConfig = endpoint
|
||||||
reject(new Error("Speech SDK is not loaded."));
|
? SpeechSDK.SpeechConfig.fromEndpoint(new URL(endpoint), subscriptionKey)
|
||||||
return;
|
: 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 {
|
synthesizer.close();
|
||||||
speechConfig = createSpeechConfig(SpeechSDK, subscriptionKey, region, endpoint);
|
synthesizer = undefined;
|
||||||
} 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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,15 +2,15 @@
|
|||||||
"Primary": {
|
"Primary": {
|
||||||
"FileDestination": "\\\\zeus\\DataIntegrationsQA\\Spit\\",
|
"FileDestination": "\\\\zeus\\DataIntegrationsQA\\Spit\\",
|
||||||
"SeqUrl": "https://qa-seq.lcu-internal.com",
|
"SeqUrl": "https://qa-seq.lcu-internal.com",
|
||||||
"SpitRoles": "IT Development"
|
"SpitRoles": "SpitUser - QA"
|
||||||
},
|
},
|
||||||
"FileOperationsConfiguration": {
|
"FileOperationsConfiguration": {
|
||||||
"Url": "https://qa-fileoperationsapi.lcu-internal.com"
|
"Url": "https://qa-fileoperationsapi.lcu-internal.com"
|
||||||
},
|
},
|
||||||
"Security": {
|
"Security": {
|
||||||
"AccessPolicies": {
|
"AccessPolicies": {
|
||||||
"IT Development": {
|
"SpitUser - QA": {
|
||||||
"Groups": "IT Development"
|
"Groups": "SpitUser - QA"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,15 +2,15 @@
|
|||||||
"Primary": {
|
"Primary": {
|
||||||
"FileDestination": "\\\\zeus\\DataIntegrationsUAT\\Spit\\",
|
"FileDestination": "\\\\zeus\\DataIntegrationsUAT\\Spit\\",
|
||||||
"SeqUrl": "https://uat-seq.lcu-internal.com",
|
"SeqUrl": "https://uat-seq.lcu-internal.com",
|
||||||
"SpitRoles": "IT Development"
|
"SpitRoles": "SpitUser - QA"
|
||||||
},
|
},
|
||||||
"FileOperationsConfiguration": {
|
"FileOperationsConfiguration": {
|
||||||
"Url": "https://uat-fileoperationsapi.lcu-internal.com"
|
"Url": "https://uat-fileoperationsapi.lcu-internal.com"
|
||||||
},
|
},
|
||||||
"Security": {
|
"Security": {
|
||||||
"AccessPolicies": {
|
"AccessPolicies": {
|
||||||
"IT Development": {
|
"SpitUser - QA": {
|
||||||
"Groups": "IT Development"
|
"Groups": "SpitUser - QA"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user