web-speech-cognitive-services 8.0.0-main.478b2e9 → 8.0.0-main.aa5b13b
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/web-speech-cognitive-services.development.js +99 -110
- package/dist/web-speech-cognitive-services.development.js.map +1 -1
- package/dist/web-speech-cognitive-services.js +78 -78
- package/dist/web-speech-cognitive-services.js.map +1 -1
- package/dist/web-speech-cognitive-services.mjs +76 -76
- package/dist/web-speech-cognitive-services.mjs.map +1 -1
- package/dist/web-speech-cognitive-services.production.min.js +12 -12
- package/dist/web-speech-cognitive-services.production.min.js.map +1 -1
- package/package.json +20 -14
|
@@ -23432,35 +23432,6 @@
|
|
|
23432
23432
|
}
|
|
23433
23433
|
});
|
|
23434
23434
|
|
|
23435
|
-
// node_modules/on-error-resume-next/lib/index.js
|
|
23436
|
-
var require_lib = __commonJS({
|
|
23437
|
-
"node_modules/on-error-resume-next/lib/index.js"(exports, module) {
|
|
23438
|
-
"use strict";
|
|
23439
|
-
Object.defineProperty(exports, "__esModule", {
|
|
23440
|
-
value: true
|
|
23441
|
-
});
|
|
23442
|
-
exports.default = onErrorResumeNext2;
|
|
23443
|
-
function onErrorResumeNext2(fn) {
|
|
23444
|
-
var context = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : null;
|
|
23445
|
-
try {
|
|
23446
|
-
var result = fn.call(context);
|
|
23447
|
-
if (typeof result.then === "function") {
|
|
23448
|
-
return new Promise(function(resolve) {
|
|
23449
|
-
result.then(resolve, function() {
|
|
23450
|
-
return resolve();
|
|
23451
|
-
});
|
|
23452
|
-
});
|
|
23453
|
-
} else {
|
|
23454
|
-
return result;
|
|
23455
|
-
}
|
|
23456
|
-
} catch (err) {
|
|
23457
|
-
}
|
|
23458
|
-
}
|
|
23459
|
-
module.exports = exports.default;
|
|
23460
|
-
module.exports.default = exports.default;
|
|
23461
|
-
}
|
|
23462
|
-
});
|
|
23463
|
-
|
|
23464
23435
|
// ../../node_modules/event-as-promise/lib/external/p-defer.js
|
|
23465
23436
|
var require_p_defer = __commonJS({
|
|
23466
23437
|
"../../node_modules/event-as-promise/lib/external/p-defer.js"(exports, module) {
|
|
@@ -23477,7 +23448,7 @@
|
|
|
23477
23448
|
});
|
|
23478
23449
|
|
|
23479
23450
|
// ../../node_modules/event-as-promise/lib/index.js
|
|
23480
|
-
var
|
|
23451
|
+
var require_lib = __commonJS({
|
|
23481
23452
|
"../../node_modules/event-as-promise/lib/index.js"(exports, module) {
|
|
23482
23453
|
"use strict";
|
|
23483
23454
|
Object.defineProperty(exports, "__esModule", {
|
|
@@ -25083,8 +25054,26 @@
|
|
|
25083
25054
|
// src/SpeechServices/SpeechToText.js
|
|
25084
25055
|
var SpeechToText_default = createSpeechRecognitionPonyfill_default;
|
|
25085
25056
|
|
|
25086
|
-
//
|
|
25087
|
-
|
|
25057
|
+
// ../../node_modules/on-error-resume-next/dist/chunk-MBTBSBLB.mjs
|
|
25058
|
+
function isPromise(value) {
|
|
25059
|
+
return !!((typeof value === "function" || typeof value === "object") && value && "then" in value && typeof value.then === "function");
|
|
25060
|
+
}
|
|
25061
|
+
|
|
25062
|
+
// ../../node_modules/on-error-resume-next/dist/on-error-resume-next.async.mjs
|
|
25063
|
+
function onErrorResumeNext(fn, context) {
|
|
25064
|
+
return new Promise((resolve) => {
|
|
25065
|
+
try {
|
|
25066
|
+
const result = fn.call(context);
|
|
25067
|
+
if (isPromise(result)) {
|
|
25068
|
+
result.then(resolve, () => resolve(void 0));
|
|
25069
|
+
} else {
|
|
25070
|
+
resolve(result);
|
|
25071
|
+
}
|
|
25072
|
+
} catch {
|
|
25073
|
+
resolve(void 0);
|
|
25074
|
+
}
|
|
25075
|
+
});
|
|
25076
|
+
}
|
|
25088
25077
|
|
|
25089
25078
|
// ../../node_modules/memoize-one/dist/memoize-one.esm.js
|
|
25090
25079
|
var safeIsNaN = Number.isNaN || function ponyfill(value) {
|
|
@@ -25206,80 +25195,6 @@
|
|
|
25206
25195
|
}
|
|
25207
25196
|
};
|
|
25208
25197
|
|
|
25209
|
-
// src/SpeechServices/TextToSpeech/SpeechSynthesisVoice.js
|
|
25210
|
-
var SpeechSynthesisVoice_default = class {
|
|
25211
|
-
constructor({ gender, lang, voiceURI }) {
|
|
25212
|
-
this._default = false;
|
|
25213
|
-
this._gender = gender;
|
|
25214
|
-
this._lang = lang;
|
|
25215
|
-
this._localService = false;
|
|
25216
|
-
this._name = voiceURI;
|
|
25217
|
-
this._voiceURI = voiceURI;
|
|
25218
|
-
}
|
|
25219
|
-
get default() {
|
|
25220
|
-
return this._default;
|
|
25221
|
-
}
|
|
25222
|
-
get gender() {
|
|
25223
|
-
return this._gender;
|
|
25224
|
-
}
|
|
25225
|
-
get lang() {
|
|
25226
|
-
return this._lang;
|
|
25227
|
-
}
|
|
25228
|
-
get localService() {
|
|
25229
|
-
return this._localService;
|
|
25230
|
-
}
|
|
25231
|
-
get name() {
|
|
25232
|
-
return this._name;
|
|
25233
|
-
}
|
|
25234
|
-
get voiceURI() {
|
|
25235
|
-
return this._voiceURI;
|
|
25236
|
-
}
|
|
25237
|
-
};
|
|
25238
|
-
|
|
25239
|
-
// src/SpeechServices/TextToSpeech/fetchCustomVoices.js
|
|
25240
|
-
async function fetchCustomVoices({ customVoiceHostname, deploymentId, region, subscriptionKey }) {
|
|
25241
|
-
const hostname = customVoiceHostname || `${region}.customvoice.api.speech.microsoft.com`;
|
|
25242
|
-
const res = await fetch(
|
|
25243
|
-
`https://${encodeURI(hostname)}/api/texttospeech/v2.0/endpoints/${encodeURIComponent(deploymentId)}`,
|
|
25244
|
-
{
|
|
25245
|
-
headers: {
|
|
25246
|
-
accept: "application/json",
|
|
25247
|
-
"ocp-apim-subscription-key": subscriptionKey
|
|
25248
|
-
}
|
|
25249
|
-
}
|
|
25250
|
-
);
|
|
25251
|
-
if (!res.ok) {
|
|
25252
|
-
throw new Error("Failed to fetch custom voices");
|
|
25253
|
-
}
|
|
25254
|
-
return res.json();
|
|
25255
|
-
}
|
|
25256
|
-
async function fetchCustomVoices_default({ customVoiceHostname, deploymentId, region, subscriptionKey }) {
|
|
25257
|
-
const { models } = await fetchCustomVoices({ customVoiceHostname, deploymentId, region, subscriptionKey });
|
|
25258
|
-
return models.map(
|
|
25259
|
-
({ properties: { Gender: gender }, locale: lang, name: voiceURI }) => new SpeechSynthesisVoice_default({ gender, lang, voiceURI })
|
|
25260
|
-
).sort(({ name: x }, { name: y }) => x > y ? 1 : x < y ? -1 : 0);
|
|
25261
|
-
}
|
|
25262
|
-
|
|
25263
|
-
// src/SpeechServices/TextToSpeech/fetchVoices.js
|
|
25264
|
-
async function fetchVoices({ authorizationToken, region, speechSynthesisHostname, subscriptionKey }) {
|
|
25265
|
-
const hostname = speechSynthesisHostname || `${encodeURI(region)}.tts.speech.microsoft.com`;
|
|
25266
|
-
const res = await fetch(`https://${hostname}/cognitiveservices/voices/list`, {
|
|
25267
|
-
headers: {
|
|
25268
|
-
"content-type": "application/json",
|
|
25269
|
-
...authorizationToken ? {
|
|
25270
|
-
authorization: `Bearer ${authorizationToken}`
|
|
25271
|
-
} : {
|
|
25272
|
-
"Ocp-Apim-Subscription-Key": subscriptionKey
|
|
25273
|
-
}
|
|
25274
|
-
}
|
|
25275
|
-
});
|
|
25276
|
-
if (!res.ok) {
|
|
25277
|
-
throw new Error("Failed to fetch voices");
|
|
25278
|
-
}
|
|
25279
|
-
const voices = await res.json();
|
|
25280
|
-
return voices.map(({ Gender: gender, Locale: lang, Name: voiceURI }) => new SpeechSynthesisVoice_default({ gender, lang, voiceURI })).sort(({ name: x }, { name: y }) => x > y ? 1 : x < y ? -1 : 0);
|
|
25281
|
-
}
|
|
25282
|
-
|
|
25283
25198
|
// src/SpeechServices/TextToSpeech/SpeechSynthesisEvent.js
|
|
25284
25199
|
var SpeechSynthesisEvent = class extends Event {
|
|
25285
25200
|
constructor(type) {
|
|
@@ -25288,7 +25203,7 @@
|
|
|
25288
25203
|
};
|
|
25289
25204
|
|
|
25290
25205
|
// src/SpeechServices/TextToSpeech/SpeechSynthesisUtterance.js
|
|
25291
|
-
var import_event_as_promise = __toESM(
|
|
25206
|
+
var import_event_as_promise = __toESM(require_lib());
|
|
25292
25207
|
|
|
25293
25208
|
// ../../node_modules/base64-arraybuffer/dist/base64-arraybuffer.es5.js
|
|
25294
25209
|
var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
@@ -25550,6 +25465,80 @@
|
|
|
25550
25465
|
};
|
|
25551
25466
|
var SpeechSynthesisUtterance_default = SpeechSynthesisUtterance;
|
|
25552
25467
|
|
|
25468
|
+
// src/SpeechServices/TextToSpeech/SpeechSynthesisVoice.js
|
|
25469
|
+
var SpeechSynthesisVoice_default = class {
|
|
25470
|
+
constructor({ gender, lang, voiceURI }) {
|
|
25471
|
+
this._default = false;
|
|
25472
|
+
this._gender = gender;
|
|
25473
|
+
this._lang = lang;
|
|
25474
|
+
this._localService = false;
|
|
25475
|
+
this._name = voiceURI;
|
|
25476
|
+
this._voiceURI = voiceURI;
|
|
25477
|
+
}
|
|
25478
|
+
get default() {
|
|
25479
|
+
return this._default;
|
|
25480
|
+
}
|
|
25481
|
+
get gender() {
|
|
25482
|
+
return this._gender;
|
|
25483
|
+
}
|
|
25484
|
+
get lang() {
|
|
25485
|
+
return this._lang;
|
|
25486
|
+
}
|
|
25487
|
+
get localService() {
|
|
25488
|
+
return this._localService;
|
|
25489
|
+
}
|
|
25490
|
+
get name() {
|
|
25491
|
+
return this._name;
|
|
25492
|
+
}
|
|
25493
|
+
get voiceURI() {
|
|
25494
|
+
return this._voiceURI;
|
|
25495
|
+
}
|
|
25496
|
+
};
|
|
25497
|
+
|
|
25498
|
+
// src/SpeechServices/TextToSpeech/fetchCustomVoices.js
|
|
25499
|
+
async function fetchCustomVoices({ customVoiceHostname, deploymentId, region, subscriptionKey }) {
|
|
25500
|
+
const hostname = customVoiceHostname || `${region}.customvoice.api.speech.microsoft.com`;
|
|
25501
|
+
const res = await fetch(
|
|
25502
|
+
`https://${encodeURI(hostname)}/api/texttospeech/v2.0/endpoints/${encodeURIComponent(deploymentId)}`,
|
|
25503
|
+
{
|
|
25504
|
+
headers: {
|
|
25505
|
+
accept: "application/json",
|
|
25506
|
+
"ocp-apim-subscription-key": subscriptionKey
|
|
25507
|
+
}
|
|
25508
|
+
}
|
|
25509
|
+
);
|
|
25510
|
+
if (!res.ok) {
|
|
25511
|
+
throw new Error("Failed to fetch custom voices");
|
|
25512
|
+
}
|
|
25513
|
+
return res.json();
|
|
25514
|
+
}
|
|
25515
|
+
async function fetchCustomVoices_default({ customVoiceHostname, deploymentId, region, subscriptionKey }) {
|
|
25516
|
+
const { models } = await fetchCustomVoices({ customVoiceHostname, deploymentId, region, subscriptionKey });
|
|
25517
|
+
return models.map(
|
|
25518
|
+
({ properties: { Gender: gender }, locale: lang, name: voiceURI }) => new SpeechSynthesisVoice_default({ gender, lang, voiceURI })
|
|
25519
|
+
).sort(({ name: x }, { name: y }) => x > y ? 1 : x < y ? -1 : 0);
|
|
25520
|
+
}
|
|
25521
|
+
|
|
25522
|
+
// src/SpeechServices/TextToSpeech/fetchVoices.js
|
|
25523
|
+
async function fetchVoices({ authorizationToken, region, speechSynthesisHostname, subscriptionKey }) {
|
|
25524
|
+
const hostname = speechSynthesisHostname || `${encodeURI(region)}.tts.speech.microsoft.com`;
|
|
25525
|
+
const res = await fetch(`https://${hostname}/cognitiveservices/voices/list`, {
|
|
25526
|
+
headers: {
|
|
25527
|
+
"content-type": "application/json",
|
|
25528
|
+
...authorizationToken ? {
|
|
25529
|
+
authorization: `Bearer ${authorizationToken}`
|
|
25530
|
+
} : {
|
|
25531
|
+
"Ocp-Apim-Subscription-Key": subscriptionKey
|
|
25532
|
+
}
|
|
25533
|
+
}
|
|
25534
|
+
});
|
|
25535
|
+
if (!res.ok) {
|
|
25536
|
+
throw new Error("Failed to fetch voices");
|
|
25537
|
+
}
|
|
25538
|
+
const voices = await res.json();
|
|
25539
|
+
return voices.map(({ Gender: gender, Locale: lang, Name: voiceURI }) => new SpeechSynthesisVoice_default({ gender, lang, voiceURI })).sort(({ name: x }, { name: y }) => x > y ? 1 : x < y ? -1 : 0);
|
|
25540
|
+
}
|
|
25541
|
+
|
|
25553
25542
|
// src/SpeechServices/TextToSpeech/createSpeechSynthesisPonyfill.js
|
|
25554
25543
|
var DEFAULT_OUTPUT_FORMAT2 = "audio-24khz-160kbitrate-mono-mp3";
|
|
25555
25544
|
var EMPTY_ARRAY = [];
|
|
@@ -25626,7 +25615,7 @@
|
|
|
25626
25615
|
console.warn(
|
|
25627
25616
|
"web-speech-cognitive-services: Listing of custom voice models are only available when using subscription key."
|
|
25628
25617
|
);
|
|
25629
|
-
await (
|
|
25618
|
+
await onErrorResumeNext(async () => {
|
|
25630
25619
|
const voices = await fetchCustomVoices_default({
|
|
25631
25620
|
customVoiceHostname,
|
|
25632
25621
|
deploymentId: speechSynthesisDeploymentId,
|
|
@@ -25638,7 +25627,7 @@
|
|
|
25638
25627
|
});
|
|
25639
25628
|
}
|
|
25640
25629
|
} else {
|
|
25641
|
-
await (
|
|
25630
|
+
await onErrorResumeNext(async () => {
|
|
25642
25631
|
const voices = await fetchVoices(await fetchCredentials());
|
|
25643
25632
|
this.getVoices = () => voices;
|
|
25644
25633
|
});
|
|
@@ -25665,7 +25654,7 @@
|
|
|
25665
25654
|
}
|
|
25666
25655
|
var meta = document.createElement("meta");
|
|
25667
25656
|
meta.setAttribute("name", "web-speech-cognitive-services");
|
|
25668
|
-
meta.setAttribute("content", `version=${"8.0.0-main.
|
|
25657
|
+
meta.setAttribute("content", `version=${"8.0.0-main.aa5b13b"}`);
|
|
25669
25658
|
document.head.appendChild(meta);
|
|
25670
25659
|
|
|
25671
25660
|
// src/index.umd.js
|