@readium/speech 0.13.0 → 0.14.0
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/build/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { DecorationController as
|
|
1
|
+
import { DecorationController as yn, DirectCommsChannel as Sn, Decorator as bn } from "@readium/decorator";
|
|
2
2
|
export * from "@readium/decorator";
|
|
3
|
-
import { LocatorText as
|
|
4
|
-
import { Locator as
|
|
5
|
-
import { startsWithBindingPunct as
|
|
6
|
-
import
|
|
7
|
-
import { decodeTextref as
|
|
8
|
-
import { DomRange as
|
|
9
|
-
const
|
|
3
|
+
import { LocatorText as wn, LocatorLocations as kn, Locator as Cn } from "@readium/shared";
|
|
4
|
+
import { Locator as ma, LocatorLocations as va, LocatorText as ya } from "@readium/shared";
|
|
5
|
+
import { startsWithBindingPunct as te, ssmlTextEscape as B, BINDING_PUNCT_CLASS as K } from "@readium/helpers";
|
|
6
|
+
import En from "i18next";
|
|
7
|
+
import { decodeTextref as et, combineDomRangeTextrefs as Rn, substitutedOwnSelector as In, isAriaSubstituted as ne } from "@readium/guided-navigation";
|
|
8
|
+
import { DomRange as Pn, DomRangePoint as tt } from "@readium/shared/html";
|
|
9
|
+
const k = (n) => {
|
|
10
10
|
if (!n) return ["", void 0];
|
|
11
11
|
const e = n.replace(/_/g, "-");
|
|
12
12
|
try {
|
|
@@ -22,7 +22,14 @@ const E = (n) => {
|
|
|
22
22
|
t[1]?.toUpperCase()
|
|
23
23
|
];
|
|
24
24
|
}
|
|
25
|
-
},
|
|
25
|
+
}, ve = (n, e) => {
|
|
26
|
+
const t = e.toLowerCase().replace(/_/g, "-"), [s] = k(e);
|
|
27
|
+
let i;
|
|
28
|
+
for (const a of [s, t])
|
|
29
|
+
for (const [r, o] of Object.entries(n))
|
|
30
|
+
r.toLowerCase().replace(/_/g, "-") === a && (i ??= /* @__PURE__ */ new Set(), o.forEach((l) => i.add(l)));
|
|
31
|
+
return i && [...i];
|
|
32
|
+
}, V = {
|
|
26
33
|
ar: {
|
|
27
34
|
defaultRegion: "SA",
|
|
28
35
|
availableRegions: [
|
|
@@ -409,16 +416,16 @@ const E = (n) => {
|
|
|
409
416
|
],
|
|
410
417
|
testUtterance: "你好,我叫 {name},係越中文聲。"
|
|
411
418
|
}
|
|
412
|
-
},
|
|
419
|
+
}, Re = /* @__PURE__ */ new Map(), An = /* @__PURE__ */ Object.assign({ "../../json/ar.json": () => import("./ar-BGKtJRyt.js"), "../../json/bg.json": () => import("./bg-D9Q1JriY.js"), "../../json/bho.json": () => import("./bho-CpuLBMN3.js"), "../../json/bn.json": () => import("./bn-Bpn_lzoe.js"), "../../json/ca.json": () => import("./ca-5hzouNcE.js"), "../../json/cmn.json": () => import("./cmn-DlnYMCd8.js"), "../../json/cs.json": () => import("./cs-CDpMkMNO.js"), "../../json/da.json": () => import("./da-XWCfWAwB.js"), "../../json/de.json": () => import("./de-DU0USiOh.js"), "../../json/el.json": () => import("./el-ClBwbIAW.js"), "../../json/en.json": () => import("./en-l3wcpTw3.js"), "../../json/es.json": () => import("./es-DwOFJY07.js"), "../../json/eu.json": () => import("./eu-DxWirHU-.js"), "../../json/fa.json": () => import("./fa-Ml9KtIw1.js"), "../../json/fi.json": () => import("./fi-Dk-5Fhhl.js"), "../../json/fr.json": () => import("./fr-MfhjukJ4.js"), "../../json/gl.json": () => import("./gl-DwtzWds9.js"), "../../json/he.json": () => import("./he-CfajFNE_.js"), "../../json/hi.json": () => import("./hi-pv2ttBoh.js"), "../../json/hr.json": () => import("./hr-MRApcEKR.js"), "../../json/hu.json": () => import("./hu-DGRDZdHH.js"), "../../json/id.json": () => import("./id-DZUuUiTG.js"), "../../json/it.json": () => import("./it-DJUYnjyj.js"), "../../json/ja.json": () => import("./ja-BpFcZRMu.js"), "../../json/kk.json": () => import("./kk-C480t1iH.js"), "../../json/kn.json": () => import("./kn-BVqs26qv.js"), "../../json/ko.json": () => import("./ko-TNoPZd6N.js"), "../../json/mr.json": () => import("./mr-DstAHTvT.js"), "../../json/ms.json": () => import("./ms-BceBSD-j.js"), "../../json/nb.json": () => import("./nb-CwPbwG-i.js"), "../../json/nl.json": () => import("./nl-BmW-Dmw5.js"), "../../json/pl.json": () => import("./pl-CH8qoDu8.js"), "../../json/pt.json": () => import("./pt-CjCENn24.js"), "../../json/ro.json": () => import("./ro-BlJN7qkA.js"), "../../json/ru.json": () => import("./ru-udzq1D5e.js"), "../../json/sk.json": () => import("./sk-VAEHsTWJ.js"), "../../json/sl.json": () => import("./sl-DaZQ1gp0.js"), "../../json/sv.json": () => import("./sv-CicHwXe4.js"), "../../json/ta.json": () => import("./ta-CvpRY89g.js"), "../../json/te.json": () => import("./te-D5TcdW9V.js"), "../../json/th.json": () => import("./th-CYakoFVa.js"), "../../json/tr.json": () => import("./tr-BfYrcAz7.js"), "../../json/uk.json": () => import("./uk-BVs6lQbX.js"), "../../json/vi.json": () => import("./vi-DP1xN9KL.js"), "../../json/wuu.json": () => import("./wuu-C6uQvT6g.js"), "../../json/yue.json": () => import("./yue-C8kEWdfv.js") });
|
|
413
420
|
async function xn(n) {
|
|
414
421
|
try {
|
|
415
|
-
const e = n.split("-")[0], t =
|
|
422
|
+
const e = n.split("-")[0], t = An[`../../json/${e}.json`];
|
|
416
423
|
if (!t)
|
|
417
424
|
throw new Error(`No voice data found for language: ${n}`);
|
|
418
425
|
const i = (await t()).default;
|
|
419
426
|
return {
|
|
420
427
|
...i,
|
|
421
|
-
voices: i.voices.map(
|
|
428
|
+
voices: i.voices.map(Un)
|
|
422
429
|
};
|
|
423
430
|
} catch (e) {
|
|
424
431
|
return console.warn(`Failed to load voice data for ${n}:`, e), {
|
|
@@ -429,13 +436,13 @@ async function xn(n) {
|
|
|
429
436
|
};
|
|
430
437
|
}
|
|
431
438
|
}
|
|
432
|
-
function
|
|
433
|
-
return
|
|
439
|
+
function nt(n) {
|
|
440
|
+
return Re.has(n) || Re.set(n, xn(n)), Re.get(n);
|
|
434
441
|
}
|
|
435
|
-
const
|
|
442
|
+
const Ln = ["veryLow", "low", "normal", "high", "veryHigh"], On = ["android", "apple"], Un = (n) => ({
|
|
436
443
|
...n,
|
|
437
|
-
quality: n.quality?.filter((e) =>
|
|
438
|
-
localizedName: n.localizedName &&
|
|
444
|
+
quality: n.quality?.filter((e) => Ln.includes(e)),
|
|
445
|
+
localizedName: n.localizedName && On.includes(n.localizedName) ? n.localizedName : void 0
|
|
439
446
|
}), Q = {
|
|
440
447
|
cmn: "cmn",
|
|
441
448
|
"cmn-CN": "cmn-CN",
|
|
@@ -456,21 +463,21 @@ const An = ["veryLow", "low", "normal", "high", "veryHigh"], Ln = ["android", "a
|
|
|
456
463
|
e = `${t.toLowerCase()}-${s.toUpperCase()}`;
|
|
457
464
|
}
|
|
458
465
|
return Q[e] || e;
|
|
459
|
-
},
|
|
466
|
+
}, Ae = async (n) => {
|
|
460
467
|
if (!n) return [];
|
|
461
468
|
try {
|
|
462
469
|
const e = L(n);
|
|
463
470
|
try {
|
|
464
|
-
const s = await
|
|
471
|
+
const s = await nt(e);
|
|
465
472
|
if (s?.voices?.length)
|
|
466
473
|
return s.voices;
|
|
467
474
|
} catch (s) {
|
|
468
475
|
console.warn(`Failed to load voices for ${e}:`, s);
|
|
469
476
|
}
|
|
470
|
-
const [t] =
|
|
477
|
+
const [t] = k(e);
|
|
471
478
|
if (t !== e)
|
|
472
479
|
try {
|
|
473
|
-
const s = await
|
|
480
|
+
const s = await nt(t);
|
|
474
481
|
if (s?.voices?.length)
|
|
475
482
|
return s.voices;
|
|
476
483
|
} catch (s) {
|
|
@@ -489,39 +496,39 @@ const An = ["veryLow", "low", "normal", "high", "veryHigh"], Ln = ["android", "a
|
|
|
489
496
|
} catch {
|
|
490
497
|
return n.toUpperCase();
|
|
491
498
|
}
|
|
492
|
-
},
|
|
499
|
+
}, st = (n) => {
|
|
493
500
|
if (!n) return "";
|
|
494
501
|
try {
|
|
495
|
-
const e = L(n), t =
|
|
502
|
+
const e = L(n), t = V[e];
|
|
496
503
|
if (t?.testUtterance)
|
|
497
504
|
return t.testUtterance;
|
|
498
505
|
if (e in Q) {
|
|
499
506
|
const i = Q[e];
|
|
500
|
-
if (i &&
|
|
501
|
-
return
|
|
507
|
+
if (i && V[i]?.testUtterance)
|
|
508
|
+
return V[i].testUtterance;
|
|
502
509
|
}
|
|
503
|
-
const [s] =
|
|
504
|
-
return s !== e &&
|
|
510
|
+
const [s] = k(e);
|
|
511
|
+
return s !== e && V[s]?.testUtterance ? V[s].testUtterance : "";
|
|
505
512
|
} catch (e) {
|
|
506
513
|
return console.error(`Error in getTestUtterance for ${n}:`, e), "";
|
|
507
514
|
}
|
|
508
|
-
},
|
|
515
|
+
}, ye = (n) => {
|
|
509
516
|
if (!n) return "";
|
|
510
517
|
try {
|
|
511
|
-
const e = L(n), t =
|
|
518
|
+
const e = L(n), t = V[e];
|
|
512
519
|
if (t?.defaultRegion)
|
|
513
520
|
return `${e}-${t.defaultRegion}`;
|
|
514
521
|
if (e in Q) {
|
|
515
522
|
const i = Q[e];
|
|
516
523
|
if (i) {
|
|
517
|
-
const a =
|
|
524
|
+
const a = V[i];
|
|
518
525
|
if (a?.defaultRegion)
|
|
519
526
|
return `${i}-${a.defaultRegion}`;
|
|
520
527
|
}
|
|
521
528
|
}
|
|
522
|
-
const [s] =
|
|
529
|
+
const [s] = k(e);
|
|
523
530
|
if (s !== e) {
|
|
524
|
-
const i =
|
|
531
|
+
const i = V[s];
|
|
525
532
|
if (i?.defaultRegion)
|
|
526
533
|
return `${s}-${i.defaultRegion}`;
|
|
527
534
|
}
|
|
@@ -529,26 +536,26 @@ const An = ["veryLow", "low", "normal", "high", "veryHigh"], Ln = ["android", "a
|
|
|
529
536
|
} catch (e) {
|
|
530
537
|
return console.error(`Failed to get default region for ${n}:`, e), "";
|
|
531
538
|
}
|
|
532
|
-
},
|
|
539
|
+
}, Se = (n) => {
|
|
533
540
|
if (!n?.length) return [];
|
|
534
541
|
const e = /* @__PURE__ */ new Set(), t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map();
|
|
535
542
|
for (const [i, a] of n.entries()) {
|
|
536
543
|
if (!a) continue;
|
|
537
|
-
const r = L(a), [o, l] =
|
|
544
|
+
const r = L(a), [o, l] = k(r);
|
|
538
545
|
l && (e.add(l), s.has(l) || s.set(l, i)), t.has(o) || t.set(o, /* @__PURE__ */ new Set()), l && t.get(o).add(l);
|
|
539
546
|
}
|
|
540
547
|
return Array.from(t.entries()).map(([i, a]) => {
|
|
541
548
|
const r = new Set(
|
|
542
|
-
|
|
549
|
+
V[i]?.availableRegions || []
|
|
543
550
|
), o = Array.from(a), l = Array.from(e).filter(
|
|
544
551
|
(u) => r.has(u) && !o.includes(u)
|
|
545
|
-
), c = Array.from(/* @__PURE__ */ new Set([...o, ...l])).sort((u,
|
|
546
|
-
const h = s.get(u) ?? Number.MAX_SAFE_INTEGER,
|
|
547
|
-
return h -
|
|
552
|
+
), c = Array.from(/* @__PURE__ */ new Set([...o, ...l])).sort((u, g) => {
|
|
553
|
+
const h = s.get(u) ?? Number.MAX_SAFE_INTEGER, d = s.get(g) ?? Number.MAX_SAFE_INTEGER;
|
|
554
|
+
return h - d;
|
|
548
555
|
});
|
|
549
556
|
if (c.length === 0) {
|
|
550
|
-
const u =
|
|
551
|
-
|
|
557
|
+
const u = ye(i), [, g] = k(u);
|
|
558
|
+
g && c.push(g);
|
|
552
559
|
}
|
|
553
560
|
return {
|
|
554
561
|
baseLang: i,
|
|
@@ -559,12 +566,12 @@ const An = ["veryLow", "low", "normal", "high", "veryHigh"], Ln = ["android", "a
|
|
|
559
566
|
const e = /* @__PURE__ */ new Map();
|
|
560
567
|
for (const s of n) {
|
|
561
568
|
if (s.source !== "json") continue;
|
|
562
|
-
const [i] =
|
|
569
|
+
const [i] = k(s.language);
|
|
563
570
|
e.has(i) || e.set(i, []), e.get(i).push(s);
|
|
564
571
|
}
|
|
565
572
|
const t = /* @__PURE__ */ new Map();
|
|
566
573
|
for (const [s, i] of e.entries()) {
|
|
567
|
-
const a = /* @__PURE__ */ new Map(), r = await
|
|
574
|
+
const a = /* @__PURE__ */ new Map(), r = await Ae(s), o = /* @__PURE__ */ new Map();
|
|
568
575
|
r.forEach((l, c) => {
|
|
569
576
|
o.set(l.name.toLowerCase(), c), l.altNames?.forEach((u) => {
|
|
570
577
|
o.set(u.toLowerCase(), c);
|
|
@@ -577,14 +584,14 @@ const An = ["veryLow", "low", "normal", "high", "veryHigh"], Ln = ["android", "a
|
|
|
577
584
|
a.size > 0 && t.set(s, a);
|
|
578
585
|
}
|
|
579
586
|
return t;
|
|
580
|
-
},
|
|
587
|
+
}, Vn = {
|
|
581
588
|
veryLow: 1,
|
|
582
589
|
low: 2,
|
|
583
590
|
normal: 3,
|
|
584
591
|
high: 4,
|
|
585
592
|
veryHigh: 5
|
|
586
|
-
},
|
|
587
|
-
const i =
|
|
593
|
+
}, ce = (n) => n ? Vn[n] ?? 0 : 0, j = (n, e, t, s) => {
|
|
594
|
+
const i = ce(n.quality), a = ce(e.quality);
|
|
588
595
|
if (t && s && n.source === "json" && e.source === "json") {
|
|
589
596
|
const r = t.get(s);
|
|
590
597
|
if (r) {
|
|
@@ -594,24 +601,24 @@ const An = ["veryLow", "low", "normal", "high", "veryHigh"], Ln = ["android", "a
|
|
|
594
601
|
}
|
|
595
602
|
}
|
|
596
603
|
return a !== i ? a - i : n.name.localeCompare(e.name);
|
|
597
|
-
},
|
|
604
|
+
}, be = (n, e) => {
|
|
598
605
|
const t = new Map(e.map((a) => [a.baseLang, a])), s = /* @__PURE__ */ new Map(), i = [];
|
|
599
606
|
for (const a of n) {
|
|
600
|
-
const [r] =
|
|
607
|
+
const [r] = k(a.language);
|
|
601
608
|
t.get(r) ? (s.has(r) || s.set(r, []), s.get(r).push(a)) : i.push(a);
|
|
602
609
|
}
|
|
603
610
|
return { voicesByLang: s, otherLangVoices: i };
|
|
604
|
-
},
|
|
605
|
-
const [, i] =
|
|
611
|
+
}, Nt = (n, e, t, s) => {
|
|
612
|
+
const [, i] = k(n.language), [, a] = k(e.language), r = i && t.regions.includes(i), o = a && t.regions.includes(a);
|
|
606
613
|
if (r && o) {
|
|
607
|
-
const h = t.regions.indexOf(i),
|
|
608
|
-
return h ===
|
|
614
|
+
const h = t.regions.indexOf(i), d = t.regions.indexOf(a);
|
|
615
|
+
return h === d ? j(n, e, s, t.baseLang) : h - d;
|
|
609
616
|
}
|
|
610
617
|
if (r) return -1;
|
|
611
618
|
if (o) return 1;
|
|
612
|
-
const l =
|
|
613
|
-
if (u && !
|
|
614
|
-
if (!u &&
|
|
619
|
+
const l = ye(t.baseLang), [, c] = k(l), u = !!c && i === c, g = !!c && a === c;
|
|
620
|
+
if (u && !g) return -1;
|
|
621
|
+
if (!u && g) return 1;
|
|
615
622
|
if (i && a) {
|
|
616
623
|
const h = i.localeCompare(a);
|
|
617
624
|
return h !== 0 ? h : j(n, e, s, t.baseLang);
|
|
@@ -619,60 +626,69 @@ const An = ["veryLow", "low", "normal", "high", "veryHigh"], Ln = ["android", "a
|
|
|
619
626
|
return i ? -1 : a ? 1 : j(n, e, s, t.baseLang);
|
|
620
627
|
}, Tn = async (n, e, t) => {
|
|
621
628
|
const s = t ?? await _(n);
|
|
622
|
-
n.sort((i, a) =>
|
|
623
|
-
},
|
|
624
|
-
const [s] =
|
|
629
|
+
n.sort((i, a) => Nt(i, a, e, s));
|
|
630
|
+
}, Bt = (n, e, t) => {
|
|
631
|
+
const [s] = k(n.language), [i] = k(e.language), a = xe(s).toLowerCase(), r = xe(i).toLowerCase(), o = a.localeCompare(r);
|
|
625
632
|
if (o !== 0)
|
|
626
633
|
return o;
|
|
627
634
|
if (s === i) {
|
|
628
|
-
const l =
|
|
629
|
-
if (
|
|
630
|
-
if (!
|
|
635
|
+
const l = ye(s), [, c] = k(n.language), [, u] = k(e.language), g = l && c === l.split("-")[1], h = l && u === l.split("-")[1];
|
|
636
|
+
if (g && !h) return -1;
|
|
637
|
+
if (!g && h) return 1;
|
|
631
638
|
if (c && u) {
|
|
632
|
-
const
|
|
633
|
-
if (
|
|
634
|
-
return
|
|
639
|
+
const d = c.localeCompare(u);
|
|
640
|
+
if (d !== 0)
|
|
641
|
+
return d;
|
|
635
642
|
}
|
|
636
643
|
return c && !u ? -1 : !c && u ? 1 : j(n, e, t, s);
|
|
637
644
|
}
|
|
638
645
|
return j(n, e, t, s);
|
|
639
|
-
},
|
|
646
|
+
}, Le = async (n, e) => {
|
|
640
647
|
const t = e ?? await _(n);
|
|
641
|
-
n.sort((s, i) =>
|
|
642
|
-
},
|
|
648
|
+
n.sort((s, i) => Bt(s, i, t));
|
|
649
|
+
}, zn = async (n, e) => {
|
|
643
650
|
if (!e?.length) return [];
|
|
644
|
-
const t =
|
|
651
|
+
const t = Se(n || []), { voicesByLang: s, otherLangVoices: i } = be(e, t), a = await _(e), r = [];
|
|
645
652
|
for (const o of t) {
|
|
646
653
|
const l = s.get(o.baseLang);
|
|
647
654
|
l && (await Tn(l, o, a), r.push(...l));
|
|
648
655
|
}
|
|
649
|
-
return await
|
|
650
|
-
},
|
|
656
|
+
return await Le(i, a), r.push(...i), r;
|
|
657
|
+
}, Nn = async (n, e) => {
|
|
651
658
|
if (!e.length) return null;
|
|
652
|
-
const [t] =
|
|
659
|
+
const [t] = Se([n]), { voicesByLang: s, otherLangVoices: i } = be(e, [t]), a = s.get(t.baseLang), r = a?.length ? a : i, o = await _(e), l = a?.length ? (c, u) => Nt(c, u, t, o) : (c, u) => Bt(c, u, o);
|
|
653
660
|
return r.reduce((c, u) => l(u, c) < 0 ? u : c);
|
|
654
|
-
},
|
|
661
|
+
}, Mt = (n, e) => {
|
|
655
662
|
const t = n.filter((s) => s.controls?.boundary !== !1 === e);
|
|
656
663
|
return t.length > 0 ? t : n;
|
|
657
|
-
},
|
|
658
|
-
voices:
|
|
659
|
-
},
|
|
660
|
-
voices:
|
|
661
|
-
},
|
|
664
|
+
}, Bn = [{ name: "Albert", nativeID: ["com.apple.speech.synthesis.voice.Albert"], note: "This novelty voice is part of a pack preloaded by Apple.", os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Bad News", nativeID: ["com.apple.speech.synthesis.voice.BadNews"], note: "This novelty voice is part of a pack preloaded by Apple.", altNames: ["Mauvaises nouvelles", "Malas noticias", "Brutte notizie"], os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Bahh", nativeID: ["com.apple.speech.synthesis.voice.Bahh"], note: "This novelty voice is part of a pack preloaded by Apple.", os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Bells", nativeID: ["com.apple.speech.synthesis.voice.Bells"], note: "This novelty voice is part of a pack preloaded by Apple.", altNames: ["Cloches", "Campanas", "Campane"], os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Boing", nativeID: ["com.apple.speech.synthesis.voice.Boing"], note: "This novelty voice is part of a pack preloaded by Apple.", os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Bubbles", nativeID: ["com.apple.speech.synthesis.voice.Bubbles"], note: "This novelty voice is part of a pack preloaded by Apple.", altNames: ["Bulles", "Burbujas", "Bollicine"], os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Cellos", nativeID: ["com.apple.speech.synthesis.voice.Cellos"], note: "This novelty voice is part of a pack preloaded by Apple.", altNames: ["Violoncelles", "Violonchelos", "Violoncelli"], os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Good News", nativeID: ["com.apple.speech.synthesis.voice.GoodNews"], note: "This novelty voice is part of a pack preloaded by Apple.", altNames: ["Bonnes nouvelles", "Buenas noticias", "Buone notizie"], os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Jester", nativeID: ["com.apple.speech.synthesis.voice.Hysterical"], note: "This novelty voice is part of a pack preloaded by Apple.", altNames: ["Bouffon", "Bufón", "Giullare"], os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Organ", nativeID: ["com.apple.speech.synthesis.voice.Organ"], note: "This novelty voice is part of a pack preloaded by Apple.", altNames: ["Orgue", "Órgano", "Organo"], os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Superstar", nativeID: ["com.apple.speech.synthesis.voice.Princess"], note: "This novelty voice is part of a pack preloaded by Apple.", altNames: ["Superestrella"], os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Trinoids", nativeID: ["com.apple.speech.synthesis.voice.Trinoids"], note: "This novelty voice is part of a pack preloaded by Apple.", altNames: ["Trinoïdes"], os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Whisper", nativeID: ["com.apple.speech.synthesis.voice.Whisper"], note: "This novelty voice is part of a pack preloaded by Apple.", altNames: ["Murmure", "Susurro", "Sussurro"], os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Wobble", nativeID: ["com.apple.speech.synthesis.voice.Deranged"], note: "This novelty voice is part of a pack preloaded by Apple.", os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Zarvox", nativeID: ["com.apple.speech.synthesis.voice.Zarvox"], note: "This novelty voice is part of a pack preloaded by Apple.", os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }], Mn = {
|
|
665
|
+
voices: Bn
|
|
666
|
+
}, Dn = [{ name: "Eddy", localizedName: "apple", note: "Eloquence voices are preloaded by default on Apple devices.", language: "en-US", otherLanguages: ["en-GB", "de-DE", "fr-FR", "fr-CA", "es-ES", "es-MX", "fi-FI", "it-IT", "ja-JP", "ko-KR", "pt-BR", "zh-CN", "zh-HK"], os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Flo", localizedName: "apple", note: "Eloquence voices are preloaded by default on Apple devices.", language: "en-US", otherLanguages: ["en-GB", "de-DE", "fr-FR", "fr-CA", "es-ES", "es-MX", "fi-FI", "it-IT", "ja-JP", "ko-KR", "pt-BR", "zh-CN", "zh-HK"], os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Grandma", localizedName: "apple", note: "Eloquence voices are preloaded by default on Apple devices.", language: "en-US", otherLanguages: ["en-GB", "de-DE", "fr-FR", "fr-CA", "es-ES", "es-MX", "fi-FI", "it-IT", "ja-JP", "ko-KR", "pt-BR", "zh-CN", "zh-HK"], os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Grandpa", localizedName: "apple", note: "Eloquence voices are preloaded by default on Apple devices.", language: "en-US", otherLanguages: ["en-GB", "de-DE", "fr-FR", "fr-CA", "es-ES", "es-MX", "fi-FI", "it-IT", "ja-JP", "ko-KR", "pt-BR", "zh-CN", "zh-HK"], os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Jacques", localizedName: "apple", note: "Eloquence voices are preloaded by default on Apple devices.", language: "en-US", otherLanguages: ["en-GB", "de-DE", "fr-FR", "fr-CA", "es-ES", "es-MX", "fi-FI", "it-IT", "ja-JP", "ko-KR", "pt-BR", "zh-CN", "zh-HK"], os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Reed", localizedName: "apple", note: "Eloquence voices are preloaded by default on Apple devices.", language: "en-US", otherLanguages: ["en-GB", "de-DE", "fr-FR", "fr-CA", "es-ES", "es-MX", "fi-FI", "it-IT", "ja-JP", "ko-KR", "pt-BR", "zh-CN", "zh-HK"], os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Rocko", localizedName: "apple", note: "Eloquence voices are preloaded by default on Apple devices.", language: "en-US", otherLanguages: ["en-GB", "de-DE", "fr-FR", "fr-CA", "es-ES", "es-MX", "fi-FI", "it-IT", "ja-JP", "ko-KR", "pt-BR", "zh-CN", "zh-HK"], os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Sandy", localizedName: "apple", note: "Eloquence voices are preloaded by default on Apple devices.", language: "en-US", otherLanguages: ["en-GB", "de-DE", "fr-FR", "fr-CA", "es-ES", "es-MX", "fi-FI", "it-IT", "ja-JP", "ko-KR", "pt-BR", "zh-CN", "zh-HK"], os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Shelley", localizedName: "apple", note: "Eloquence voices are preloaded by default on Apple devices.", language: "en-US", otherLanguages: ["en-GB", "de-DE", "fr-FR", "fr-CA", "es-ES", "es-MX", "fi-FI", "it-IT", "ja-JP", "ko-KR", "pt-BR", "zh-CN", "zh-HK"], os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Fred", language: "en-US", os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Junior", language: "en-US", os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Kathy", language: "en-US", os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "Ralph", language: "en-US", os: ["macOS", "iOS", "iPadOS"], preloaded: !0 }, { name: "eSpeak Arabic", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "ar", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Bulgarian", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "bg", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Bengali", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "bn", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Catalan", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "ca", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Chinese (Mandarin, latin as English)", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "cmn", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Czech", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "cs", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Danish", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "da", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak German", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "de", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Greek", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "el", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Spanish (Spain)", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "es", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Estonian", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "et", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Finnish", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "fi", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Gujarati", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "gu", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Croatian", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "hr", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Hungarian", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "hu", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Indonesian", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "id", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Italian", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "it", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Kannada", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "kn", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Korean", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "ko", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Lithuanian", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "lt", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Latvian", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "lv", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Malayalm", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "ml", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Marathi", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "mr", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Malay", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "ms", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Norwegian Bokmål", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "nb", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Polish", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "pl", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Portuguese (Brazil)", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "pt-br", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Romanian", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "ro", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Russian", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "ru", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Slovak", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "sk", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Slovenian", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "sl", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Serbian", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "sv", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Swedish", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "sv", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Swahili", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "sw", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Tamil", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "ta", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Telugu", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "te", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Turkish", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "tr", os: ["ChromeOS"], preloaded: !0 }, { name: "eSpeak Vietnamese (Northern)", note: "eSpeak voices are preloaded by default on Chrome OS.", language: "vi", os: ["ChromeOS"], preloaded: !0 }], jn = {
|
|
667
|
+
voices: Dn
|
|
668
|
+
}, Fn = Mn, _n = jn, Oe = (n, e) => Fn.voices.some(
|
|
662
669
|
(t) => n.includes(t.name) || e && t.nativeID?.some((s) => e.includes(s)) || t.altNames?.some((s) => n.includes(s))
|
|
663
|
-
),
|
|
670
|
+
), Ue = (n, e) => _n.voices.some(
|
|
664
671
|
(t) => n.includes(t.name)
|
|
665
|
-
) || e === "veryLow",
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
672
|
+
) || e === "veryLow", it = (n) => n?.length ? n.filter((e) => !(e.isNovelty || Oe(e.name, e.voiceURI))) : [], at = (n) => n?.length ? n.filter((e) => !Ue(e.name, e.quality)) : [], Hn = (n, e) => {
|
|
673
|
+
const t = Array.isArray(e) ? e : [e];
|
|
674
|
+
return n.filter((s) => t.some((i) => {
|
|
675
|
+
const a = i.toLowerCase(), r = s.language?.toLowerCase(), o = s.altLanguage?.toLowerCase();
|
|
676
|
+
if (r === a || o === a)
|
|
677
|
+
return !0;
|
|
678
|
+
const [l] = a.split("-");
|
|
679
|
+
return r && r.startsWith(l) || o && o.startsWith(l);
|
|
680
|
+
}));
|
|
681
|
+
}, qn = { ar: { normal: "محسن", high: "استثنائي" }, ca: { normal: "millorada", high: "prèmium" }, "cmn-CN": { normal: "优化音质", high: "高音质" }, "cmn-TW": { normal: "增強音質", high: "高音質" }, cs: { normal: "vylepšená verze", high: "prémiový" }, da: { normal: "forbedret", high: "høj kvalitet" }, de: { normal: "erweitert", high: "premium" }, el: { normal: "βελτιωμένη", high: "υψηλής ποιότητας" }, en: { normal: "Enhanced", high: "Premium" }, es: { normal: "mejorada", high: "premium" }, fi: { normal: "parannettu", high: "korkealaatuinen" }, fr: { normal: "premium", high: "de qualité" }, he: { normal: "משופר", high: "פרימיום" }, hi: { normal: "बेहतर", high: "प्रीमियम" }, hr: { normal: "poboljšani", high: "vrhunski" }, hu: { normal: "továbbfejlesztett", high: "prémium" }, id: { normal: "Ditingkatkan", high: "Premium" }, it: { normal: "ottimizzata", high: "premium" }, ja: { normal: "拡張", high: "プレミアム" }, ko: { normal: "고품질", high: "프리미엄" }, ms: { normal: "Dipertingkat", high: "Premium" }, nb: { normal: "forbedret", high: "premium" }, nl: { normal: "verbeterd", high: "premium" }, pl: { normal: "rozszerzony", high: "premium" }, pt: { normal: "melhorada", high: "premium" }, ro: { normal: "îmbunătățită", high: "premium" }, ru: { normal: "улучшенный", high: "высшее качество" }, sk: { normal: "vylepšený", high: "prémiový" }, sl: { normal: "izboljšano", high: "prvovrsten" }, sv: { normal: "förbättrad", high: "premium" }, th: { normal: "คุณภาพสูง", high: "คุณภาพสูง" }, tr: { normal: "Geliştirilmiş", high: "Yüksek Kaliteli" }, uk: { normal: "вдосконалений", high: "високої якості" }, vi: { normal: "Nâng cao", high: "Cao cấp" } }, Gn = {
|
|
682
|
+
quality: qn
|
|
683
|
+
}, Ve = {
|
|
684
|
+
apple: Gn.quality
|
|
669
685
|
// android: androidQualities.quality
|
|
670
|
-
},
|
|
686
|
+
}, $n = (n, e, t) => {
|
|
671
687
|
if (!n) return;
|
|
672
688
|
const s = Array.isArray(t) ? t : t ? [t] : [];
|
|
673
689
|
for (const i of s)
|
|
674
|
-
if (i &&
|
|
675
|
-
const a =
|
|
690
|
+
if (i && Ve[i]) {
|
|
691
|
+
const a = Ve[i], r = k(e)[0], o = a[e] || a[r];
|
|
676
692
|
if (o) {
|
|
677
693
|
const l = n.toLowerCase(), { normal: c, high: u } = o;
|
|
678
694
|
if (u && l.includes(u.toLowerCase()))
|
|
@@ -681,15 +697,15 @@ const An = ["veryLow", "low", "normal", "high", "veryHigh"], Ln = ["android", "a
|
|
|
681
697
|
return "normal";
|
|
682
698
|
}
|
|
683
699
|
}
|
|
684
|
-
},
|
|
685
|
-
const t =
|
|
700
|
+
}, Kn = (n, e) => {
|
|
701
|
+
const t = Ve[e];
|
|
686
702
|
if (t)
|
|
687
703
|
for (const [s, { high: i, normal: a }] of Object.entries(t)) {
|
|
688
704
|
const r = i && n.some((l) => l.includes(i)), o = a && n.some((l) => l.includes(a));
|
|
689
705
|
if (r && o)
|
|
690
706
|
return s;
|
|
691
707
|
}
|
|
692
|
-
},
|
|
708
|
+
}, Wn = {
|
|
693
709
|
low: {
|
|
694
710
|
values: ["super-compact", "compact"],
|
|
695
711
|
quality: "low"
|
|
@@ -702,20 +718,20 @@ const An = ["veryLow", "low", "normal", "high", "veryHigh"], Ln = ["android", "a
|
|
|
702
718
|
values: ["premium"],
|
|
703
719
|
quality: "high"
|
|
704
720
|
}
|
|
705
|
-
},
|
|
721
|
+
}, rt = (n) => {
|
|
706
722
|
if (!n) return;
|
|
707
723
|
const t = n.toLowerCase().split(/[._-]/);
|
|
708
|
-
for (const s of Object.values(
|
|
724
|
+
for (const s of Object.values(Wn))
|
|
709
725
|
if (s.values.some((i) => t.includes(i)))
|
|
710
726
|
return s.quality;
|
|
711
727
|
};
|
|
712
|
-
function
|
|
728
|
+
function Qn(n, e) {
|
|
713
729
|
if (n.name === n.originalName) return n;
|
|
714
730
|
if (e.name === e.originalName) return e;
|
|
715
731
|
const t = [n.originalName, ...n.altNames || []], s = [e.originalName, ...e.altNames || []], i = t.findIndex((r) => s.includes(r)), a = s.findIndex((r) => t.includes(r));
|
|
716
732
|
return i === -1 && a === -1 || i !== -1 && (a === -1 || i <= a) ? n : e;
|
|
717
733
|
}
|
|
718
|
-
function
|
|
734
|
+
function Jn(n, e) {
|
|
719
735
|
if (!n.altNames && !e.altNames)
|
|
720
736
|
return !1;
|
|
721
737
|
const t = n.originalName, s = e.originalName, i = n.altNames || [], a = e.altNames || [];
|
|
@@ -815,7 +831,7 @@ class b {
|
|
|
815
831
|
* @returns A tuple of [language, region] where language is lowercase and region is UPPERCASE
|
|
816
832
|
*/
|
|
817
833
|
static extractLangRegionFromBCP47(e) {
|
|
818
|
-
return
|
|
834
|
+
return k(e);
|
|
819
835
|
}
|
|
820
836
|
/**
|
|
821
837
|
* Clean voice name by removing specific formatting
|
|
@@ -854,7 +870,7 @@ class b {
|
|
|
854
870
|
*/
|
|
855
871
|
updateSystemLocale(e) {
|
|
856
872
|
if (!e?.length) return;
|
|
857
|
-
const t = e.map((i) => i.name), s =
|
|
873
|
+
const t = e.map((i) => i.name), s = Kn(t, "apple");
|
|
858
874
|
s && (this.systemLocale = s);
|
|
859
875
|
}
|
|
860
876
|
/**
|
|
@@ -863,15 +879,15 @@ class b {
|
|
|
863
879
|
* @private
|
|
864
880
|
*/
|
|
865
881
|
inferVoiceQuality(e, t, s) {
|
|
866
|
-
const i = e.voiceURI ?
|
|
882
|
+
const i = e.voiceURI ? rt(e.voiceURI) : void 0;
|
|
867
883
|
if (i) return i;
|
|
868
884
|
if (t?.nativeID && Array.isArray(t.nativeID))
|
|
869
885
|
for (const a of t.nativeID) {
|
|
870
|
-
const r =
|
|
886
|
+
const r = rt(a);
|
|
871
887
|
if (r) return r;
|
|
872
888
|
}
|
|
873
889
|
if (t?.localizedName && e.voiceURI && e.lang) {
|
|
874
|
-
const a =
|
|
890
|
+
const a = $n(
|
|
875
891
|
e.voiceURI,
|
|
876
892
|
this.systemLocale,
|
|
877
893
|
t.localizedName
|
|
@@ -905,12 +921,12 @@ class b {
|
|
|
905
921
|
const i = `${s.language.toLowerCase()}_${this.normalizeVoiceName(s.name)}`, a = t.get(i);
|
|
906
922
|
if (!a)
|
|
907
923
|
t.set(i, s);
|
|
908
|
-
else if (
|
|
909
|
-
const r =
|
|
924
|
+
else if (Jn(s, a)) {
|
|
925
|
+
const r = Qn(s, a);
|
|
910
926
|
t.set(i, r);
|
|
911
927
|
} else {
|
|
912
|
-
const r =
|
|
913
|
-
|
|
928
|
+
const r = ce(a.quality);
|
|
929
|
+
ce(s.quality) >= r && t.set(i, s);
|
|
914
930
|
}
|
|
915
931
|
}
|
|
916
932
|
return Array.from(t.values());
|
|
@@ -922,11 +938,11 @@ class b {
|
|
|
922
938
|
*/
|
|
923
939
|
getTestUtterance(e) {
|
|
924
940
|
if (!e) return "";
|
|
925
|
-
const t =
|
|
941
|
+
const t = st(e);
|
|
926
942
|
if (t) return t;
|
|
927
943
|
const [s] = b.extractLangRegionFromBCP47(e);
|
|
928
944
|
if (s && s !== e) {
|
|
929
|
-
const i =
|
|
945
|
+
const i = st(s);
|
|
930
946
|
if (i) return i;
|
|
931
947
|
}
|
|
932
948
|
return "";
|
|
@@ -953,10 +969,10 @@ class b {
|
|
|
953
969
|
for (const l of a) {
|
|
954
970
|
const u = L(l.language).split("-")[0];
|
|
955
971
|
if (!o.has(u)) {
|
|
956
|
-
const
|
|
957
|
-
(
|
|
972
|
+
const g = xe(u, e), h = a.filter(
|
|
973
|
+
(d) => L(d.language).split("-")[0] === u
|
|
958
974
|
).length;
|
|
959
|
-
r.push({ code: u, label:
|
|
975
|
+
r.push({ code: u, label: g, count: h }), o.add(u);
|
|
960
976
|
}
|
|
961
977
|
}
|
|
962
978
|
return s ? r : r.sort((l, c) => l.label.localeCompare(c.label));
|
|
@@ -978,16 +994,16 @@ class b {
|
|
|
978
994
|
for (const c of a) {
|
|
979
995
|
const [, u] = b.extractLangRegionFromBCP47(c.language);
|
|
980
996
|
if (u && !o.has(u)) {
|
|
981
|
-
let
|
|
997
|
+
let g = c.language;
|
|
982
998
|
try {
|
|
983
999
|
const h = e || navigator.language;
|
|
984
|
-
|
|
1000
|
+
g = new Intl.DisplayNames([h], { type: "region" }).of(u) || c.language;
|
|
985
1001
|
} catch (h) {
|
|
986
1002
|
console.warn(`Failed to get display name for region ${u}`, h);
|
|
987
1003
|
}
|
|
988
1004
|
r.push({
|
|
989
1005
|
code: u,
|
|
990
|
-
label:
|
|
1006
|
+
label: g,
|
|
991
1007
|
count: l.get(u) || 0
|
|
992
1008
|
}), o.add(u);
|
|
993
1009
|
}
|
|
@@ -1019,8 +1035,8 @@ class b {
|
|
|
1019
1035
|
const u = () => {
|
|
1020
1036
|
if (o < 1) return a([]);
|
|
1021
1037
|
--o;
|
|
1022
|
-
const
|
|
1023
|
-
if (Array.isArray(
|
|
1038
|
+
const g = s();
|
|
1039
|
+
if (Array.isArray(g) && g.length) return a(g);
|
|
1024
1040
|
setTimeout(u, t);
|
|
1025
1041
|
};
|
|
1026
1042
|
setTimeout(u, t);
|
|
@@ -1040,21 +1056,21 @@ class b {
|
|
|
1040
1056
|
return await Promise.all(
|
|
1041
1057
|
e.filter((i) => i?.name && i?.lang).map(async (i) => {
|
|
1042
1058
|
const a = L(i.lang), [r] = b.extractLangRegionFromBCP47(a), o = this.normalizeVoiceName(i.name), l = `${i.lang.toLowerCase()}_${o}`, c = t.get(l) || 1;
|
|
1043
|
-
let u = await
|
|
1044
|
-
(!u || u.length === 0) && (u = await
|
|
1045
|
-
const
|
|
1046
|
-
return
|
|
1047
|
-
...
|
|
1048
|
-
label:
|
|
1059
|
+
let u = await Ae(a);
|
|
1060
|
+
(!u || u.length === 0) && (u = await Ae(r));
|
|
1061
|
+
const g = this.findMatchingJsonVoice(u, o), h = this.inferVoiceQuality(i, g, c);
|
|
1062
|
+
return g ? {
|
|
1063
|
+
...g,
|
|
1064
|
+
label: g.label ?? this.cleanVoiceName(i.name),
|
|
1049
1065
|
source: "json",
|
|
1050
1066
|
originalName: i.name,
|
|
1051
|
-
language:
|
|
1067
|
+
language: g.language ?? a,
|
|
1052
1068
|
voiceURI: i.voiceURI,
|
|
1053
1069
|
quality: h,
|
|
1054
1070
|
isDefault: i.default || !1,
|
|
1055
1071
|
offlineAvailability: i.localService || !1,
|
|
1056
|
-
isNovelty:
|
|
1057
|
-
isLowQuality:
|
|
1072
|
+
isNovelty: Oe(i.name, i.voiceURI),
|
|
1073
|
+
isLowQuality: Ue(i.name, h)
|
|
1058
1074
|
} : {
|
|
1059
1075
|
source: "browser",
|
|
1060
1076
|
label: this.cleanVoiceName(i.name),
|
|
@@ -1065,8 +1081,8 @@ class b {
|
|
|
1065
1081
|
quality: h,
|
|
1066
1082
|
isDefault: i.default || !1,
|
|
1067
1083
|
offlineAvailability: i.localService || !1,
|
|
1068
|
-
isNovelty:
|
|
1069
|
-
isLowQuality:
|
|
1084
|
+
isNovelty: Oe(i.name, i.voiceURI),
|
|
1085
|
+
isLowQuality: Ue(i.name, h)
|
|
1070
1086
|
};
|
|
1071
1087
|
})
|
|
1072
1088
|
);
|
|
@@ -1095,23 +1111,13 @@ class b {
|
|
|
1095
1111
|
...e
|
|
1096
1112
|
// Let explicit options override the defaults
|
|
1097
1113
|
};
|
|
1098
|
-
if (i.languages) {
|
|
1099
|
-
const a = Array.isArray(i.languages) ? i.languages : [i.languages];
|
|
1100
|
-
s = s.filter((r) => a.some((o) => {
|
|
1101
|
-
const l = o.toLowerCase(), c = r.language?.toLowerCase(), u = r.altLanguage?.toLowerCase();
|
|
1102
|
-
if (c === l || u === l)
|
|
1103
|
-
return !0;
|
|
1104
|
-
const [d] = l.split("-");
|
|
1105
|
-
return c && c.startsWith(d) || u && u.startsWith(d);
|
|
1106
|
-
}));
|
|
1107
|
-
}
|
|
1108
|
-
if (i.source && (s = s.filter((a) => a.source === i.source)), i.gender && (s = s.filter((a) => a.gender === i.gender)), i.quality) {
|
|
1114
|
+
if (i.languages && (s = Hn(s, i.languages)), i.source && (s = s.filter((a) => a.source === i.source)), i.gender && (s = s.filter((a) => a.gender === i.gender)), i.quality) {
|
|
1109
1115
|
const a = Array.isArray(i.quality) ? i.quality : [i.quality];
|
|
1110
1116
|
s = s.filter((r) => r.quality && a.includes(r.quality));
|
|
1111
1117
|
}
|
|
1112
1118
|
return i.offlineOnly && (s = s.filter((a) => a.offlineAvailability === !0)), i.provider && (s = s.filter(
|
|
1113
1119
|
(a) => a.provider?.toLowerCase() === i.provider?.toLowerCase()
|
|
1114
|
-
)), i.excludeNovelty && (s =
|
|
1120
|
+
)), i.excludeNovelty && (s = it(s)), i.excludeVeryLowQuality && (s = at(s)), i.removeDuplicates && (s = this.removeDuplicates(s)), s;
|
|
1115
1121
|
}
|
|
1116
1122
|
/**
|
|
1117
1123
|
* Filter out novelty voices
|
|
@@ -1120,7 +1126,7 @@ class b {
|
|
|
1120
1126
|
*/
|
|
1121
1127
|
filterOutNoveltyVoices(e) {
|
|
1122
1128
|
const t = e ?? this.voices;
|
|
1123
|
-
return
|
|
1129
|
+
return it(t);
|
|
1124
1130
|
}
|
|
1125
1131
|
/**
|
|
1126
1132
|
* Filter out very low quality voices
|
|
@@ -1129,7 +1135,7 @@ class b {
|
|
|
1129
1135
|
*/
|
|
1130
1136
|
filterOutVeryLowQualityVoices(e) {
|
|
1131
1137
|
const t = e ?? this.voices;
|
|
1132
|
-
return
|
|
1138
|
+
return at(t);
|
|
1133
1139
|
}
|
|
1134
1140
|
/**
|
|
1135
1141
|
* Sort voices by quality, respecting JSON name order, then alphabetically for undefined/null quality
|
|
@@ -1146,7 +1152,7 @@ class b {
|
|
|
1146
1152
|
* Sort regions by default then alphabetically, sort voices by quality
|
|
1147
1153
|
*/
|
|
1148
1154
|
static async sortByDefaultRegion(e, t) {
|
|
1149
|
-
const s = await _(e), i =
|
|
1155
|
+
const s = await _(e), i = ye(t);
|
|
1150
1156
|
e.sort((a, r) => {
|
|
1151
1157
|
const [, o] = b.extractLangRegionFromBCP47(a.language), [, l] = b.extractLangRegionFromBCP47(r.language), c = i && o === i.split("-")[1], u = i && l === i.split("-")[1];
|
|
1152
1158
|
return c && !u ? -1 : !c && u ? 1 : j(a, r, s, t);
|
|
@@ -1163,14 +1169,14 @@ class b {
|
|
|
1163
1169
|
if (!s?.length) return [];
|
|
1164
1170
|
if (!e?.length) {
|
|
1165
1171
|
const l = [...s];
|
|
1166
|
-
return await
|
|
1172
|
+
return await Le(l), l;
|
|
1167
1173
|
}
|
|
1168
|
-
const i =
|
|
1174
|
+
const i = Se(e), { voicesByLang: a, otherLangVoices: r } = be(s, i), o = [];
|
|
1169
1175
|
for (const l of i) {
|
|
1170
1176
|
const c = a.get(l.baseLang);
|
|
1171
1177
|
c && (await b.sortByDefaultRegion(c, l.baseLang), o.push(...c));
|
|
1172
1178
|
}
|
|
1173
|
-
return await
|
|
1179
|
+
return await Le(r), o.push(...r), o;
|
|
1174
1180
|
}
|
|
1175
1181
|
/**
|
|
1176
1182
|
* Sort voices by region preference, then alphabetically
|
|
@@ -1179,7 +1185,7 @@ class b {
|
|
|
1179
1185
|
* @returns Sorted array of voices
|
|
1180
1186
|
*/
|
|
1181
1187
|
async sortVoicesByRegions(e, t) {
|
|
1182
|
-
return
|
|
1188
|
+
return zn(e, t || this.voices);
|
|
1183
1189
|
}
|
|
1184
1190
|
/**
|
|
1185
1191
|
* Group voices by the specified criteria
|
|
@@ -1211,7 +1217,7 @@ class b {
|
|
|
1211
1217
|
return s;
|
|
1212
1218
|
}
|
|
1213
1219
|
}
|
|
1214
|
-
const
|
|
1220
|
+
const Zn = ["webKit", "moz", "ms", "o"], Yn = [
|
|
1215
1221
|
"boundary",
|
|
1216
1222
|
"end",
|
|
1217
1223
|
"error",
|
|
@@ -1219,10 +1225,10 @@ const Qn = ["webKit", "moz", "ms", "o"], Jn = [
|
|
|
1219
1225
|
"pause",
|
|
1220
1226
|
"resume",
|
|
1221
1227
|
"start"
|
|
1222
|
-
],
|
|
1223
|
-
const e =
|
|
1228
|
+
], Xn = (n) => `${n.charAt(0).toUpperCase()}${n.slice(1)}`, G = (n = {}, e) => Object.hasOwnProperty.call(n, e) || e in n || !!n[e], es = (n) => typeof window < "u" && n in window, ts = (n) => {
|
|
1229
|
+
const e = Xn(n), t = Zn.map((i) => `${i}${e}`), s = [n, e].concat(t).find(es);
|
|
1224
1230
|
return s && typeof window < "u" ? window[s] : void 0;
|
|
1225
|
-
},
|
|
1231
|
+
}, ns = () => {
|
|
1226
1232
|
const n = {};
|
|
1227
1233
|
[
|
|
1228
1234
|
"speechSynthesis",
|
|
@@ -1231,14 +1237,14 @@ const Qn = ["webKit", "moz", "ms", "o"], Jn = [
|
|
|
1231
1237
|
"speechSynthesisEvent",
|
|
1232
1238
|
"speechSynthesisErrorEvent"
|
|
1233
1239
|
].forEach((t) => {
|
|
1234
|
-
n[t] =
|
|
1235
|
-
}), n.onvoiceschanged =
|
|
1236
|
-
const e = n.speechSynthesisUtterance ?
|
|
1237
|
-
return
|
|
1240
|
+
n[t] = ts(t);
|
|
1241
|
+
}), n.onvoiceschanged = G(n.speechSynthesis, "onvoiceschanged"), n.speechSynthesisSpeaking = G(n.speechSynthesis, "speaking"), n.speechSynthesisPaused = G(n.speechSynthesis, "paused");
|
|
1242
|
+
const e = n.speechSynthesisUtterance ? G(n.speechSynthesisUtterance, "prototype") : !1;
|
|
1243
|
+
return Yn.forEach((t) => {
|
|
1238
1244
|
const s = `on${t}`;
|
|
1239
|
-
n[s] = e && n.speechSynthesisUtterance ?
|
|
1245
|
+
n[s] = e && n.speechSynthesisUtterance ? G(n.speechSynthesisUtterance.prototype, s) : !1;
|
|
1240
1246
|
}), n;
|
|
1241
|
-
},
|
|
1247
|
+
}, ss = () => {
|
|
1242
1248
|
const e = typeof window < "u" && (window.navigator || {}).userAgent || "", t = () => /android/i.test(e), s = () => /kaios/i.test(e), i = () => typeof window.InstallTrigger < "u" ? !0 : /firefox/i.test(e), a = () => typeof window.GestureEvent < "u" || /safari/i.test(e);
|
|
1243
1249
|
return {
|
|
1244
1250
|
isAndroid: t(),
|
|
@@ -1247,7 +1253,7 @@ const Qn = ["webKit", "moz", "ms", "o"], Jn = [
|
|
|
1247
1253
|
isKaiOS: s()
|
|
1248
1254
|
};
|
|
1249
1255
|
};
|
|
1250
|
-
class
|
|
1256
|
+
class we {
|
|
1251
1257
|
listeners = /* @__PURE__ */ new Map();
|
|
1252
1258
|
on(e, t) {
|
|
1253
1259
|
return this.listeners.has(e) || this.listeners.set(e, []), this.listeners.get(e).push(t), () => {
|
|
@@ -1272,46 +1278,46 @@ class be {
|
|
|
1272
1278
|
this.listeners.clear();
|
|
1273
1279
|
}
|
|
1274
1280
|
}
|
|
1275
|
-
const
|
|
1281
|
+
const le = (n, e) => Math.min(Math.max(n, 0), Math.max(e - 1, 0));
|
|
1276
1282
|
function F(n, e, t, s) {
|
|
1277
1283
|
return Number.isFinite(n) ? Math.max(e, Math.min(t, n)) : s;
|
|
1278
1284
|
}
|
|
1279
|
-
const Te = "\\p{Ps}\\p{Pi}¿¡",
|
|
1280
|
-
function
|
|
1281
|
-
return
|
|
1285
|
+
const Te = "\\p{Ps}\\p{Pi}¿¡", is = new RegExp(`^[${Te}]`, "u"), as = new RegExp("^\\p{P}$", "u");
|
|
1286
|
+
function rs(n) {
|
|
1287
|
+
return is.test(n);
|
|
1282
1288
|
}
|
|
1283
|
-
function
|
|
1284
|
-
return
|
|
1289
|
+
function os(n) {
|
|
1290
|
+
return as.test(n);
|
|
1285
1291
|
}
|
|
1286
|
-
function
|
|
1292
|
+
function Dt(n) {
|
|
1287
1293
|
return n.replace(/[<>]/g, "");
|
|
1288
1294
|
}
|
|
1289
|
-
function
|
|
1295
|
+
function ls(n) {
|
|
1290
1296
|
return n.replace(/"/g, '"').replace(/'/g, "'").replace(/ /g, " ").replace(/&#(\d+);/g, (e, t) => String.fromCodePoint(Number(t))).replace(/&#x([0-9a-fA-F]+);/g, (e, t) => String.fromCodePoint(parseInt(t, 16)));
|
|
1291
1297
|
}
|
|
1292
|
-
const
|
|
1293
|
-
function
|
|
1294
|
-
return n.replace(
|
|
1298
|
+
const cs = /\s*<readium:[a-zA-Z][\w-]*\s+id="[^"]*"\s*\/>\s*/g;
|
|
1299
|
+
function us(n) {
|
|
1300
|
+
return n.replace(cs, (t, s, i) => {
|
|
1295
1301
|
const a = i.slice(s + t.length);
|
|
1296
|
-
return a.length === 0 ||
|
|
1302
|
+
return a.length === 0 || te(a) ? "" : " ";
|
|
1297
1303
|
}).replace(/ {2,}/g, " ").trim();
|
|
1298
1304
|
}
|
|
1299
|
-
function
|
|
1305
|
+
function hs(n) {
|
|
1300
1306
|
return n.includes("<");
|
|
1301
1307
|
}
|
|
1302
|
-
function
|
|
1308
|
+
function Be(n) {
|
|
1303
1309
|
if (n === void 0) return;
|
|
1304
1310
|
const e = {};
|
|
1305
1311
|
if (n.language !== void 0 && (e.language = n.language), n.ssml) {
|
|
1306
|
-
const t =
|
|
1307
|
-
|
|
1312
|
+
const t = us(n.ssml);
|
|
1313
|
+
hs(t) && (e.ssml = t);
|
|
1308
1314
|
}
|
|
1309
1315
|
return n.plain && (e.plain = n.plain), e.plain || e.ssml ? e : void 0;
|
|
1310
1316
|
}
|
|
1311
1317
|
function z(n) {
|
|
1312
|
-
return
|
|
1318
|
+
return jt(n).plain;
|
|
1313
1319
|
}
|
|
1314
|
-
function
|
|
1320
|
+
function jt(n) {
|
|
1315
1321
|
let e = "";
|
|
1316
1322
|
const t = [];
|
|
1317
1323
|
let s = !1, i = 0;
|
|
@@ -1319,7 +1325,7 @@ function Dt(n) {
|
|
|
1319
1325
|
const o = n[i];
|
|
1320
1326
|
if (o === "<") {
|
|
1321
1327
|
const c = n.indexOf(">", i), u = c === -1 ? "" : n.slice(c + 1);
|
|
1322
|
-
i = c === -1 ? n.length : c + 1, !s && e.length > 0 && u.length > 0 && !
|
|
1328
|
+
i = c === -1 ? n.length : c + 1, !s && e.length > 0 && u.length > 0 && !te(u) && (e += " ", t.push(i), s = !0);
|
|
1323
1329
|
continue;
|
|
1324
1330
|
}
|
|
1325
1331
|
const l = n.startsWith("<", i) ? "<" : n.startsWith(">", i) ? ">" : n.startsWith("&", i) ? "&" : void 0;
|
|
@@ -1339,7 +1345,7 @@ function Dt(n) {
|
|
|
1339
1345
|
for (; r > a && /\s/.test(e[r - 1]); ) r--;
|
|
1340
1346
|
return { plain: e.slice(a, r), map: t.slice(a, r) };
|
|
1341
1347
|
}
|
|
1342
|
-
function
|
|
1348
|
+
function ot(n, e) {
|
|
1343
1349
|
let t = 0, s = n.length;
|
|
1344
1350
|
for (; t < s; ) {
|
|
1345
1351
|
const i = t + s >> 1;
|
|
@@ -1347,27 +1353,27 @@ function rt(n, e) {
|
|
|
1347
1353
|
}
|
|
1348
1354
|
return t;
|
|
1349
1355
|
}
|
|
1350
|
-
const
|
|
1351
|
-
function
|
|
1356
|
+
const lt = /* @__PURE__ */ new WeakMap();
|
|
1357
|
+
function ds(n) {
|
|
1352
1358
|
return n.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
1353
1359
|
}
|
|
1354
|
-
function
|
|
1355
|
-
const e =
|
|
1360
|
+
function gs(n) {
|
|
1361
|
+
const e = ds(n), t = /\w/.test(n[0]) ? "(?<!\\w)" : "", s = /\w/.test(n[n.length - 1]) ? "(?!\\w)" : "";
|
|
1356
1362
|
return `${t}${e}${s}`;
|
|
1357
1363
|
}
|
|
1358
|
-
function
|
|
1364
|
+
function fs(n, e) {
|
|
1359
1365
|
if (typeof e == "string")
|
|
1360
|
-
return { regex: new RegExp(
|
|
1366
|
+
return { regex: new RegExp(gs(n), "g"), replace: e };
|
|
1361
1367
|
const t = e.pattern.flags.includes("g") ? e.pattern.flags : `${e.pattern.flags}g`;
|
|
1362
1368
|
return { regex: new RegExp(e.pattern.source, t), replace: e.replace };
|
|
1363
1369
|
}
|
|
1364
|
-
function
|
|
1365
|
-
let e =
|
|
1366
|
-
return e || (e = Object.entries(n).map(([t, s]) =>
|
|
1370
|
+
function ps(n) {
|
|
1371
|
+
let e = lt.get(n);
|
|
1372
|
+
return e || (e = Object.entries(n).map(([t, s]) => fs(t, s)), lt.set(n, e)), e;
|
|
1367
1373
|
}
|
|
1368
|
-
function
|
|
1374
|
+
function Ft(n, e) {
|
|
1369
1375
|
const t = [];
|
|
1370
|
-
for (const a of
|
|
1376
|
+
for (const a of ps(e))
|
|
1371
1377
|
for (const r of n.matchAll(a.regex)) {
|
|
1372
1378
|
const o = r.index, l = typeof a.replace == "string" ? a.replace : a.replace(...r);
|
|
1373
1379
|
t.push({ start: o, end: o + r[0].length, replacement: l });
|
|
@@ -1379,11 +1385,11 @@ function jt(n, e) {
|
|
|
1379
1385
|
a.start < i || (s.push(a), i = a.end);
|
|
1380
1386
|
return s;
|
|
1381
1387
|
}
|
|
1382
|
-
function
|
|
1388
|
+
function ms(n, e) {
|
|
1383
1389
|
let t = "";
|
|
1384
1390
|
const s = [];
|
|
1385
1391
|
let i = 0;
|
|
1386
|
-
for (const a of
|
|
1392
|
+
for (const a of Ft(n, e)) {
|
|
1387
1393
|
for (; i < a.start; )
|
|
1388
1394
|
t += n[i], s.push(i), i++;
|
|
1389
1395
|
for (let r = 0; r < a.replacement.length; r++)
|
|
@@ -1394,69 +1400,69 @@ function fs(n, e) {
|
|
|
1394
1400
|
t += n[i], s.push(i), i++;
|
|
1395
1401
|
return { text: t, map: s };
|
|
1396
1402
|
}
|
|
1397
|
-
function
|
|
1403
|
+
function ct(n, e) {
|
|
1398
1404
|
return n.length ? e <= 0 ? n[0] : e >= n.length ? n[n.length - 1] + 1 : n[e] : e;
|
|
1399
1405
|
}
|
|
1400
|
-
const
|
|
1401
|
-
function
|
|
1406
|
+
const vs = /<([a-zA-Z][\w-]*)([^>]*)>([\s\S]*?)<\/\1>|<[a-zA-Z][\w-]*\b[^>]*\/>|[^<]+/g;
|
|
1407
|
+
function ut(n) {
|
|
1402
1408
|
return n.replace(/</g, "<").replace(/>/g, ">").replace(/&/g, "&");
|
|
1403
1409
|
}
|
|
1404
|
-
function
|
|
1410
|
+
function _t(n) {
|
|
1405
1411
|
const e = [];
|
|
1406
|
-
for (const t of n.matchAll(
|
|
1407
|
-
t[1] !== void 0 ? e.push({ kind: "paired", raw: t[0], tag: t[1], attrs: t[2], innerText:
|
|
1412
|
+
for (const t of n.matchAll(vs))
|
|
1413
|
+
t[1] !== void 0 ? e.push({ kind: "paired", raw: t[0], tag: t[1], attrs: t[2], innerText: ut(t[3]) }) : t[0][0] === "<" ? e.push({ kind: "selfClosing", raw: t[0] }) : e.push({ kind: "text", raw: t[0], text: ut(t[0]) });
|
|
1408
1414
|
return e;
|
|
1409
1415
|
}
|
|
1410
|
-
function
|
|
1411
|
-
const t =
|
|
1416
|
+
function ys(n, e) {
|
|
1417
|
+
const t = _t(n);
|
|
1412
1418
|
let s = "", i = !1;
|
|
1413
1419
|
const a = [], r = t.map(() => []);
|
|
1414
|
-
t.forEach((y,
|
|
1420
|
+
t.forEach((y, C) => {
|
|
1415
1421
|
if (y.kind === "selfClosing") return;
|
|
1416
1422
|
const R = y.kind === "paired" ? y.innerText : y.text;
|
|
1417
|
-
if (!i && s.length > 0 && R.length > 0 && !
|
|
1418
|
-
const
|
|
1419
|
-
s += " ", r[
|
|
1423
|
+
if (!i && s.length > 0 && R.length > 0 && !te(R) && !/^\s/.test(R)) {
|
|
1424
|
+
const E = s.length;
|
|
1425
|
+
s += " ", r[C].push(a.length), a.push({ start: E, end: E + 1, atomIndex: -1 }), i = !0;
|
|
1420
1426
|
}
|
|
1421
1427
|
const w = s.length;
|
|
1422
|
-
s += R, r[
|
|
1428
|
+
s += R, r[C].push(a.length), a.push({ start: w, end: s.length, atomIndex: C }), R.length > 0 && (i = /\s$/.test(R));
|
|
1423
1429
|
});
|
|
1424
|
-
const o =
|
|
1430
|
+
const o = Ft(s, e);
|
|
1425
1431
|
let l = "", c = "";
|
|
1426
1432
|
const u = [];
|
|
1427
|
-
let
|
|
1433
|
+
let g = -2, h = "", d = 0;
|
|
1428
1434
|
const f = () => {
|
|
1429
|
-
if (
|
|
1430
|
-
const y = t[
|
|
1435
|
+
if (g >= 0) {
|
|
1436
|
+
const y = t[g];
|
|
1431
1437
|
l += y.kind === "paired" ? `<${y.tag}${y.attrs}>${h}</${y.tag}>` : h;
|
|
1432
1438
|
}
|
|
1433
|
-
h = "",
|
|
1439
|
+
h = "", g = -2;
|
|
1434
1440
|
};
|
|
1435
1441
|
for (let y = 0; y < t.length; y++) {
|
|
1436
|
-
const
|
|
1437
|
-
if (
|
|
1438
|
-
f(), l +=
|
|
1442
|
+
const C = t[y];
|
|
1443
|
+
if (C.kind === "selfClosing") {
|
|
1444
|
+
f(), l += C.raw;
|
|
1439
1445
|
continue;
|
|
1440
1446
|
}
|
|
1441
1447
|
for (const R of r[y]) {
|
|
1442
1448
|
const w = a[R];
|
|
1443
|
-
let
|
|
1444
|
-
for (;
|
|
1445
|
-
const
|
|
1446
|
-
if (
|
|
1447
|
-
const q =
|
|
1449
|
+
let E = w.start;
|
|
1450
|
+
for (; E < w.end; ) {
|
|
1451
|
+
const A = d < o.length ? o[d] : void 0;
|
|
1452
|
+
if (A && A.start <= E && A.end > E) {
|
|
1453
|
+
const q = A.start === E, vn = A.end > w.end;
|
|
1448
1454
|
if (q) {
|
|
1449
|
-
c +=
|
|
1450
|
-
for (let
|
|
1451
|
-
w.atomIndex === -1 ||
|
|
1455
|
+
c += A.replacement;
|
|
1456
|
+
for (let Xe = 0; Xe < A.replacement.length; Xe++) u.push(A.start);
|
|
1457
|
+
w.atomIndex === -1 || vn ? (f(), l += B(A.replacement)) : (g !== w.atomIndex && (f(), g = w.atomIndex), h += B(A.replacement));
|
|
1452
1458
|
}
|
|
1453
|
-
|
|
1459
|
+
E = Math.min(A.end, w.end), A.end <= w.end && d++;
|
|
1454
1460
|
continue;
|
|
1455
1461
|
}
|
|
1456
|
-
const
|
|
1457
|
-
c +=
|
|
1458
|
-
for (let q = 0; q <
|
|
1459
|
-
w.atomIndex === -1 ? (f(), l += B(
|
|
1462
|
+
const Ye = A ? Math.min(A.start, w.end) : w.end, ie = s.slice(E, Ye);
|
|
1463
|
+
c += ie;
|
|
1464
|
+
for (let q = 0; q < ie.length; q++) u.push(E + q);
|
|
1465
|
+
w.atomIndex === -1 ? (f(), l += B(ie)) : (g !== w.atomIndex && (f(), g = w.atomIndex), h += B(ie)), E = Ye;
|
|
1460
1466
|
}
|
|
1461
1467
|
}
|
|
1462
1468
|
}
|
|
@@ -1472,24 +1478,24 @@ function ms(n, e) {
|
|
|
1472
1478
|
const I = s.slice(p, m), P = u.slice(S, v).map((y) => Math.min(Math.max(y - p, 0), Math.max(I.length - 1, 0)));
|
|
1473
1479
|
return { ssml: l, plain: I, map: P };
|
|
1474
1480
|
}
|
|
1475
|
-
const
|
|
1476
|
-
function
|
|
1477
|
-
return new RegExp(
|
|
1481
|
+
const Ht = /<lang xml:lang="([^"]*)">([\s\S]*?)<\/lang>/g;
|
|
1482
|
+
function qt(n) {
|
|
1483
|
+
return new RegExp(Ht).test(n);
|
|
1478
1484
|
}
|
|
1479
|
-
function
|
|
1485
|
+
function ht(n) {
|
|
1480
1486
|
return n.replace(/<[^>]+>/g, "").replace(/</g, "<").replace(/>/g, ">").replace(/&/g, "&").replace(/ {2,}/g, " ");
|
|
1481
1487
|
}
|
|
1482
|
-
const
|
|
1488
|
+
const Ss = new RegExp(
|
|
1483
1489
|
`\\s+|[${Te}]+|[${K}]+|[^\\s${Te}${K}]+`,
|
|
1484
1490
|
"gu"
|
|
1485
1491
|
);
|
|
1486
|
-
function
|
|
1492
|
+
function Ie(n) {
|
|
1487
1493
|
const e = [];
|
|
1488
|
-
for (const [t] of n.matchAll(
|
|
1489
|
-
/^\s/.test(t) ? e.push({ kind: "space" }) :
|
|
1494
|
+
for (const [t] of n.matchAll(Ss))
|
|
1495
|
+
/^\s/.test(t) ? e.push({ kind: "space" }) : rs(t) ? e.push({ kind: "open", text: t }) : te(t) ? e.push({ kind: "close", text: t }) : e.push({ kind: "word", text: t });
|
|
1490
1496
|
return e;
|
|
1491
1497
|
}
|
|
1492
|
-
function
|
|
1498
|
+
function bs(n) {
|
|
1493
1499
|
let e = "", t = !1;
|
|
1494
1500
|
for (const s of n) {
|
|
1495
1501
|
if (s.kind === "space") {
|
|
@@ -1500,45 +1506,45 @@ function ys(n) {
|
|
|
1500
1506
|
}
|
|
1501
1507
|
return e;
|
|
1502
1508
|
}
|
|
1503
|
-
function
|
|
1509
|
+
function ws(n) {
|
|
1504
1510
|
let e = n.length;
|
|
1505
1511
|
for (; e > 0 && (n[e - 1].kind === "space" || n[e - 1].kind === "open"); ) e--;
|
|
1506
1512
|
return n.slice(e).some((t) => t.kind === "open") ? n.splice(e) : [];
|
|
1507
1513
|
}
|
|
1508
|
-
function
|
|
1514
|
+
function ks(n) {
|
|
1509
1515
|
let e = 0;
|
|
1510
1516
|
for (; e < n.length && (n[e].kind === "space" || n[e].kind === "close"); ) e++;
|
|
1511
1517
|
return n.slice(0, e).some((t) => t.kind === "close") ? n.splice(0, e) : [];
|
|
1512
1518
|
}
|
|
1513
|
-
function
|
|
1519
|
+
function Gt(n, e) {
|
|
1514
1520
|
const t = [];
|
|
1515
1521
|
let s = 0;
|
|
1516
|
-
for (const r of n.matchAll(
|
|
1522
|
+
for (const r of n.matchAll(Ht))
|
|
1517
1523
|
t.push({
|
|
1518
|
-
tokens:
|
|
1524
|
+
tokens: Ie(ht(n.slice(s, r.index))),
|
|
1519
1525
|
language: e,
|
|
1520
1526
|
tagged: !1
|
|
1521
|
-
}), t.push({ tokens:
|
|
1527
|
+
}), t.push({ tokens: Ie(z(r[2])), language: r[1], tagged: !0 }), s = r.index + r[0].length;
|
|
1522
1528
|
t.push({
|
|
1523
|
-
tokens:
|
|
1529
|
+
tokens: Ie(ht(n.slice(s))),
|
|
1524
1530
|
language: e,
|
|
1525
1531
|
tagged: !1
|
|
1526
1532
|
});
|
|
1527
1533
|
for (let r = 0; r < t.length - 1; r++)
|
|
1528
|
-
!t[r].tagged && t[r + 1].tagged ? t[r + 1].tokens.unshift(...
|
|
1534
|
+
!t[r].tagged && t[r + 1].tagged ? t[r + 1].tokens.unshift(...ws(t[r].tokens)) : t[r].tagged && !t[r + 1].tagged && t[r].tokens.push(...ks(t[r + 1].tokens));
|
|
1529
1535
|
const i = [];
|
|
1530
1536
|
let a = 0;
|
|
1531
1537
|
for (const r of t) {
|
|
1532
|
-
const o =
|
|
1538
|
+
const o = bs(r.tokens);
|
|
1533
1539
|
o && (i.push({ plain: o, language: r.language, start: a, end: a + o.length }), a += o.length);
|
|
1534
1540
|
}
|
|
1535
1541
|
return i;
|
|
1536
1542
|
}
|
|
1537
1543
|
const $t = /<readium:[a-zA-Z][\w-]*\s+id="([^"]*)"\s*\/>/g;
|
|
1538
|
-
function
|
|
1544
|
+
function Cs(n) {
|
|
1539
1545
|
return new RegExp($t).test(n);
|
|
1540
1546
|
}
|
|
1541
|
-
function
|
|
1547
|
+
function Es(n) {
|
|
1542
1548
|
const e = [];
|
|
1543
1549
|
let t = 0;
|
|
1544
1550
|
for (const i of n.matchAll($t)) {
|
|
@@ -1548,14 +1554,14 @@ function ks(n) {
|
|
|
1548
1554
|
const s = n.slice(t).trim();
|
|
1549
1555
|
return s && e.push({ ssml: s }), e;
|
|
1550
1556
|
}
|
|
1551
|
-
class
|
|
1557
|
+
class dt {
|
|
1552
1558
|
speechSynthesis;
|
|
1553
1559
|
speechSynthesisUtterance;
|
|
1554
1560
|
currentVoice = null;
|
|
1555
1561
|
currentUtterances = [];
|
|
1556
1562
|
currentUtteranceIndex = 0;
|
|
1557
1563
|
playbackState = "idle";
|
|
1558
|
-
events = new
|
|
1564
|
+
events = new we();
|
|
1559
1565
|
voiceManager = null;
|
|
1560
1566
|
voices = [];
|
|
1561
1567
|
defaultVoice = null;
|
|
@@ -1578,6 +1584,8 @@ class ht {
|
|
|
1578
1584
|
maxLengthExceeded = "warn";
|
|
1579
1585
|
utterancesBeingCancelled = !1;
|
|
1580
1586
|
// Flag to track if utterances are being cancelled
|
|
1587
|
+
lacksNativePauseEvents = !1;
|
|
1588
|
+
// Google online voices in desktop Chrome never fire onpause/onresume
|
|
1581
1589
|
// Playback parameters
|
|
1582
1590
|
rate = 1;
|
|
1583
1591
|
pitch = 1;
|
|
@@ -1585,7 +1593,7 @@ class ht {
|
|
|
1585
1593
|
features;
|
|
1586
1594
|
patches;
|
|
1587
1595
|
constructor() {
|
|
1588
|
-
if (this.features =
|
|
1596
|
+
if (this.features = ns(), this.patches = ss(), !this.features.speechSynthesis || !this.features.speechSynthesisUtterance)
|
|
1589
1597
|
throw new Error("Web Speech API is not available in this environment");
|
|
1590
1598
|
this.speechSynthesis = this.features.speechSynthesis, this.speechSynthesisUtterance = this.features.speechSynthesisUtterance;
|
|
1591
1599
|
}
|
|
@@ -1636,7 +1644,7 @@ class ht {
|
|
|
1636
1644
|
}
|
|
1637
1645
|
// No cross-region fallback: fr-FR content must not match an fr-CA voice.
|
|
1638
1646
|
voiceMatchesLanguage(e, t) {
|
|
1639
|
-
const [s, i] =
|
|
1647
|
+
const [s, i] = k(t), [a, r] = k(e.language);
|
|
1640
1648
|
return a === s && (!i || r === i);
|
|
1641
1649
|
}
|
|
1642
1650
|
languageCacheKey(e, t) {
|
|
@@ -1671,8 +1679,8 @@ class ht {
|
|
|
1671
1679
|
), i = [...s].filter((o) => this.warmingLanguages.has(this.languageCacheKey(o, t))), r = [...s].filter((o) => !this.warmingLanguages.has(this.languageCacheKey(o, t))).map((o) => {
|
|
1672
1680
|
const l = this.languageCacheKey(o, t), c = (async () => {
|
|
1673
1681
|
await b.initialize({ languages: [o] }), this.voices = this.voiceManager.getVoices();
|
|
1674
|
-
const u = this.voices.filter((f) => this.voiceMatchesLanguage(f, o)),
|
|
1675
|
-
this.languageVoiceCache.set(l,
|
|
1682
|
+
const u = this.voices.filter((f) => this.voiceMatchesLanguage(f, o)), g = Mt(u, t), d = (await this.voiceManager.sortVoicesByQuality(g))[0] ?? null;
|
|
1683
|
+
this.languageVoiceCache.set(l, d), d || this.emitEvent({ type: "languagefallback", detail: { language: o, reason: "no-matching-voice" } });
|
|
1676
1684
|
})();
|
|
1677
1685
|
return this.warmingLanguages.set(l, c.finally(() => this.warmingLanguages.delete(l))), this.warmingLanguages.get(l);
|
|
1678
1686
|
});
|
|
@@ -1685,7 +1693,7 @@ class ht {
|
|
|
1685
1693
|
return this.currentVoice;
|
|
1686
1694
|
}
|
|
1687
1695
|
setSpeakInContentLanguage(e) {
|
|
1688
|
-
this.speakInContentLanguage = e, e && this.warmLanguageVoiceCache(this.currentUtterances);
|
|
1696
|
+
e !== this.speakInContentLanguage && (this.speakInContentLanguage = e, e && this.warmLanguageVoiceCache(this.currentUtterances), this.scheduleRestartIfSpeaking());
|
|
1689
1697
|
}
|
|
1690
1698
|
getSpeakInContentLanguage() {
|
|
1691
1699
|
return this.speakInContentLanguage;
|
|
@@ -1696,22 +1704,22 @@ class ht {
|
|
|
1696
1704
|
toPlainText(e) {
|
|
1697
1705
|
return e.map((t) => ({
|
|
1698
1706
|
...t,
|
|
1699
|
-
plain: t.plain ?? (t.ssml ? z(
|
|
1707
|
+
plain: t.plain ?? (t.ssml ? z(ls(t.ssml)) : "")
|
|
1700
1708
|
}));
|
|
1701
1709
|
}
|
|
1702
1710
|
// Queue Management
|
|
1703
1711
|
loadUtterances(e, t) {
|
|
1704
|
-
this.currentUtterances = this.toPlainText(e), this.currentUtteranceIndex =
|
|
1712
|
+
this.currentUtterances = this.toPlainText(e), this.currentUtteranceIndex = le(t ?? 0, e.length), this.warmLanguageVoiceCache(this.currentUtterances), this.playbackState = "ready", this.emitEvent({ type: "ready" });
|
|
1705
1713
|
}
|
|
1706
1714
|
// Voice Configuration
|
|
1707
1715
|
async setVoice(e) {
|
|
1708
1716
|
const t = this.currentVoice;
|
|
1709
1717
|
if (typeof e == "string") {
|
|
1710
1718
|
const s = this.voices.find((i) => i.name === e || i.language === e);
|
|
1711
|
-
s ?
|
|
1719
|
+
s ? this.currentVoice = s : console.warn(`Voice "${e}" not found`);
|
|
1712
1720
|
} else
|
|
1713
|
-
this.currentVoice = e
|
|
1714
|
-
this.voiceManager && this.defaultVoice && this.currentVoice && this.currentVoice.language !== this.defaultVoice.language && (this.defaultVoice = await this.voiceManager.getDefaultVoice([this.currentVoice.language], this.voices));
|
|
1721
|
+
this.currentVoice = e;
|
|
1722
|
+
this.currentVoice?.name !== t?.name && this.scheduleRestartIfSpeaking(), this.voiceManager && this.defaultVoice && this.currentVoice && this.currentVoice.language !== this.defaultVoice.language && (this.defaultVoice = await this.voiceManager.getDefaultVoice([this.currentVoice.language], this.voices));
|
|
1715
1723
|
}
|
|
1716
1724
|
async getAvailableVoices() {
|
|
1717
1725
|
if (this.voices.length > 0)
|
|
@@ -1749,22 +1757,23 @@ class ht {
|
|
|
1749
1757
|
}
|
|
1750
1758
|
const t = this.currentUtterances[this.currentUtteranceIndex], s = t.plain ?? "";
|
|
1751
1759
|
this.validateText(s);
|
|
1752
|
-
const i = this.createUtterance(
|
|
1760
|
+
const i = this.createUtterance(Dt(s)), a = await this.voiceForUtterance(t);
|
|
1753
1761
|
if (e === this.speakGeneration) {
|
|
1754
|
-
if (a && this.voiceManager) {
|
|
1762
|
+
if (this.lacksNativePauseEvents = !1, a && this.voiceManager) {
|
|
1755
1763
|
const r = this.voiceManager.convertToSpeechSynthesisVoice(a);
|
|
1756
|
-
r && (i.voice = r, i.lang = r.lang);
|
|
1764
|
+
r && (i.voice = r, i.lang = r.lang, this.lacksNativePauseEvents = !r.localService && r.name.startsWith("Google"));
|
|
1757
1765
|
}
|
|
1758
1766
|
t.language && (i.lang = t.language), i.rate = this.rate, i.pitch = this.pitch, i.volume = this.volume, i.onstart = () => {
|
|
1767
|
+
if (e !== this.speakGeneration) return;
|
|
1759
1768
|
this.isSpeakingInternal = !0, this.isPausedInternal = !1, this.setState("playing"), this.emitEvent({ type: "start" }), this.patches.isAndroid && this.isAndroidPaused && (this.isAndroidPaused = !1), this.shouldUseResumeInfinity() && this.startResumeInfinity(i);
|
|
1760
1769
|
}, i.onend = () => {
|
|
1761
1770
|
if (this.utterancesBeingCancelled) {
|
|
1762
1771
|
this.utterancesBeingCancelled = !1;
|
|
1763
1772
|
return;
|
|
1764
1773
|
}
|
|
1765
|
-
this.playbackState !== "idle" && (this.isSpeakingInternal = !1, this.isPausedInternal = !1, this.stopResumeInfinity(), this.currentUtteranceIndex >= this.currentUtterances.length - 1 && this.setState("idle"), this.emitEvent({ type: "end" }));
|
|
1774
|
+
e === this.speakGeneration && this.playbackState !== "idle" && (this.isSpeakingInternal = !1, this.isPausedInternal = !1, this.stopResumeInfinity(), this.currentUtteranceIndex >= this.currentUtterances.length - 1 && this.setState("idle"), this.emitEvent({ type: "end" }));
|
|
1766
1775
|
}, i.onerror = (r) => {
|
|
1767
|
-
if (r.error === "interrupted" && this.patches.isAndroid && this.isAndroidPaused)
|
|
1776
|
+
if (e !== this.speakGeneration || r.error === "interrupted" && this.patches.isAndroid && this.isAndroidPaused)
|
|
1768
1777
|
return;
|
|
1769
1778
|
this.isSpeakingInternal = !1, this.isPausedInternal = !1, this.stopResumeInfinity(), this.setState("idle"), ["synthesis-unavailable", "audio-hardware", "voice-unavailable"].includes(r.error) && (console.log("[ENGINE] fatal error detected, resetting index to 0"), this.currentUtteranceIndex = 0), r.error === "interrupted" || r.error === "canceled" ? this.emitEvent({ type: "stop" }) : this.emitEvent({
|
|
1770
1779
|
type: "error",
|
|
@@ -1775,9 +1784,9 @@ class ht {
|
|
|
1775
1784
|
}
|
|
1776
1785
|
});
|
|
1777
1786
|
}, i.onpause = () => {
|
|
1778
|
-
this.isPausedInternal = !0, this.isSpeakingInternal = !1, this.emitEvent({ type: "pause" });
|
|
1787
|
+
e === this.speakGeneration && (this.isPausedInternal = !0, this.isSpeakingInternal = !1, this.emitEvent({ type: "pause" }));
|
|
1779
1788
|
}, i.onresume = () => {
|
|
1780
|
-
this.isPausedInternal = !1, this.isSpeakingInternal = !0, this.emitEvent({ type: "resume" });
|
|
1789
|
+
e === this.speakGeneration && (this.isPausedInternal = !1, this.isSpeakingInternal = !0, this.emitEvent({ type: "resume" }));
|
|
1781
1790
|
}, i.onboundary = (r) => {
|
|
1782
1791
|
e === this.speakGeneration && this.emitEvent({
|
|
1783
1792
|
type: "boundary",
|
|
@@ -1789,7 +1798,7 @@ class ht {
|
|
|
1789
1798
|
}
|
|
1790
1799
|
});
|
|
1791
1800
|
}, i.onmark = (r) => {
|
|
1792
|
-
this.emitEvent({
|
|
1801
|
+
e === this.speakGeneration && this.emitEvent({
|
|
1793
1802
|
type: "mark",
|
|
1794
1803
|
detail: {
|
|
1795
1804
|
name: r.name
|
|
@@ -1811,10 +1820,10 @@ class ht {
|
|
|
1811
1820
|
this.resumeInfinityTimer && (clearTimeout(this.resumeInfinityTimer), this.resumeInfinityTimer = void 0);
|
|
1812
1821
|
}
|
|
1813
1822
|
pause() {
|
|
1814
|
-
this.playbackState === "playing" && (this.pausedAtUtteranceIndex = this.currentUtteranceIndex, this.isPausedInternal = !0, this.isSpeakingInternal = !1, this.setState("paused"), this.patches.isAndroid ? (this.isAndroidPaused = !0, this.speechSynthesis.cancel(), this.emitEvent({ type: "pause" })) : this.speechSynthesis.pause());
|
|
1823
|
+
this.playbackState === "playing" && (this.pausedAtUtteranceIndex = this.currentUtteranceIndex, this.isPausedInternal = !0, this.isSpeakingInternal = !1, this.setState("paused"), this.patches.isAndroid ? (this.isAndroidPaused = !0, this.speechSynthesis.cancel(), this.emitEvent({ type: "pause" })) : (this.speechSynthesis.pause(), this.lacksNativePauseEvents && this.emitEvent({ type: "pause" })));
|
|
1815
1824
|
}
|
|
1816
1825
|
resume() {
|
|
1817
|
-
this.playbackState === "paused" && this.currentUtteranceIndex < this.currentUtterances.length && (this.isPausedInternal = !1, this.isSpeakingInternal = !0, this.setState("playing"), this.patches.isAndroid || this.pausedAtUtteranceIndex !== this.currentUtteranceIndex ? (this.emitEvent({ type: "resume" }), this.speak(this.currentUtteranceIndex)) : this.speechSynthesis.resume(), this.pausedAtUtteranceIndex = null);
|
|
1826
|
+
this.playbackState === "paused" && this.currentUtteranceIndex < this.currentUtterances.length && (this.isPausedInternal = !1, this.isSpeakingInternal = !0, this.setState("playing"), this.patches.isAndroid || this.pausedAtUtteranceIndex !== this.currentUtteranceIndex ? (this.emitEvent({ type: "resume" }), this.speak(this.currentUtteranceIndex)) : (this.speechSynthesis.resume(), this.lacksNativePauseEvents && this.emitEvent({ type: "resume" })), this.pausedAtUtteranceIndex = null);
|
|
1818
1827
|
}
|
|
1819
1828
|
stop() {
|
|
1820
1829
|
this.cancelCurrentSpeech(), this.speakGeneration++, this.currentUtteranceIndex = 0, this.patches.isAndroid && (this.isAndroidPaused = !1), this.setState("idle"), this.emitEvent({ type: "stop" });
|
|
@@ -1841,12 +1850,15 @@ class ht {
|
|
|
1841
1850
|
getVolume() {
|
|
1842
1851
|
return this.volume;
|
|
1843
1852
|
}
|
|
1844
|
-
// rate
|
|
1845
|
-
// restart
|
|
1846
|
-
// Coalesces multiple same-tick changes (e.g. rate+pitch together) into a single restart.
|
|
1853
|
+
// Voice, language, rate, pitch and volume are baked into the SpeechSynthesisUtterance at speak()-time:
|
|
1854
|
+
// restart it so a change applies now (or on resume when paused). Same-tick changes coalesce.
|
|
1847
1855
|
scheduleRestartIfSpeaking() {
|
|
1856
|
+
if (this.playbackState === "paused") {
|
|
1857
|
+
this.pausedAtUtteranceIndex = null;
|
|
1858
|
+
return;
|
|
1859
|
+
}
|
|
1848
1860
|
!this.isSpeakingInternal || this.restartPending || (this.restartPending = !0, queueMicrotask(() => {
|
|
1849
|
-
this.restartPending && (this.restartPending = !1, this.isSpeakingInternal && this.speak(this.currentUtteranceIndex));
|
|
1861
|
+
this.restartPending && (this.restartPending = !1, this.playbackState === "paused" ? this.pausedAtUtteranceIndex = null : this.isSpeakingInternal && this.speak(this.currentUtteranceIndex));
|
|
1850
1862
|
}));
|
|
1851
1863
|
}
|
|
1852
1864
|
// State
|
|
@@ -1861,7 +1873,11 @@ class ht {
|
|
|
1861
1873
|
t?.(!1);
|
|
1862
1874
|
return;
|
|
1863
1875
|
}
|
|
1864
|
-
e
|
|
1876
|
+
if (e === this.currentUtteranceIndex) {
|
|
1877
|
+
t?.(!0);
|
|
1878
|
+
return;
|
|
1879
|
+
}
|
|
1880
|
+
!this.isPausedInternal && this.isSpeakingInternal && this.cancelCurrentSpeech(), this.currentUtteranceIndex = e, t?.(!0);
|
|
1865
1881
|
}
|
|
1866
1882
|
getUtteranceCount() {
|
|
1867
1883
|
return this.currentUtterances.length;
|
|
@@ -1893,27 +1909,27 @@ class ht {
|
|
|
1893
1909
|
this.stop(), this.stopResumeInfinity(), this.events.clear(), this.currentUtterances = [], this.currentVoice = null, this.voices = [], this.defaultVoice = null, this.languageVoiceCache.clear(), this.warmingLanguages.clear(), this.initialized = !1;
|
|
1894
1910
|
}
|
|
1895
1911
|
}
|
|
1896
|
-
class
|
|
1912
|
+
class ia {
|
|
1897
1913
|
id = "webspeech";
|
|
1898
1914
|
name = "Web Speech API";
|
|
1899
1915
|
voiceEngine = null;
|
|
1900
1916
|
// No cache to bypass here — local API, no network cost to re-checking.
|
|
1901
1917
|
async getVoices() {
|
|
1902
|
-
return this.voiceEngine || (this.voiceEngine = new
|
|
1918
|
+
return this.voiceEngine || (this.voiceEngine = new dt(), await this.voiceEngine.initialize()), this.voiceEngine.getAvailableVoices();
|
|
1903
1919
|
}
|
|
1904
1920
|
async createEngine(e) {
|
|
1905
|
-
const t = new
|
|
1921
|
+
const t = new dt();
|
|
1906
1922
|
return await t.initialize(), e && await t.setVoice(e), t;
|
|
1907
1923
|
}
|
|
1908
1924
|
async destroy() {
|
|
1909
1925
|
this.voiceEngine && (await this.voiceEngine.destroy(), this.voiceEngine = null);
|
|
1910
1926
|
}
|
|
1911
1927
|
}
|
|
1912
|
-
function
|
|
1928
|
+
function Kt(n, e) {
|
|
1913
1929
|
const t = [];
|
|
1914
1930
|
let s = -1, i = -1;
|
|
1915
1931
|
const a = () => {
|
|
1916
|
-
s !== -1 && (t.push({ text:
|
|
1932
|
+
s !== -1 && (t.push({ text: Rs(n, s, i), offset: n[s].offset }), s = -1, i = -1);
|
|
1917
1933
|
};
|
|
1918
1934
|
for (let r = 0; r < n.length; r++) {
|
|
1919
1935
|
const o = n[r];
|
|
@@ -1926,49 +1942,49 @@ function Gt(n, e) {
|
|
|
1926
1942
|
}
|
|
1927
1943
|
return a(), t;
|
|
1928
1944
|
}
|
|
1929
|
-
function
|
|
1945
|
+
function Rs(n, e, t) {
|
|
1930
1946
|
const s = n[e], i = n[t];
|
|
1931
1947
|
return s === i ? s.text : n.slice(e, t + 1).map((a) => a.text).join("");
|
|
1932
1948
|
}
|
|
1933
|
-
const
|
|
1949
|
+
const Wt = new RegExp(
|
|
1934
1950
|
`[^${K}]*[${K}]+\\s*|[^${K}]+$`,
|
|
1935
1951
|
"gu"
|
|
1936
|
-
),
|
|
1937
|
-
function
|
|
1952
|
+
), Is = /\S+\s*|\s+/g;
|
|
1953
|
+
function Me(n, e, t) {
|
|
1938
1954
|
const s = [];
|
|
1939
1955
|
for (const i of n.matchAll(t))
|
|
1940
1956
|
i[0].length !== 0 && s.push({ text: i[0], offset: e + i.index, atomic: !1 });
|
|
1941
1957
|
return s;
|
|
1942
1958
|
}
|
|
1943
|
-
function
|
|
1959
|
+
function De(n, e) {
|
|
1944
1960
|
if (n.text.length <= e || n.atomic)
|
|
1945
1961
|
return [n];
|
|
1946
|
-
const t =
|
|
1962
|
+
const t = Me(n.text, n.offset, Is);
|
|
1947
1963
|
if (t.length > 1)
|
|
1948
|
-
return t.flatMap((r) =>
|
|
1964
|
+
return t.flatMap((r) => De(r, e));
|
|
1949
1965
|
const s = [];
|
|
1950
1966
|
let i = n.offset, a = "";
|
|
1951
1967
|
for (const r of n.text)
|
|
1952
1968
|
a.length > 0 && a.length + r.length > e && (s.push({ text: a, offset: i, atomic: !1 }), i += a.length, a = ""), a += r;
|
|
1953
1969
|
return a.length > 0 && s.push({ text: a, offset: i, atomic: !1 }), s;
|
|
1954
1970
|
}
|
|
1955
|
-
function
|
|
1971
|
+
function Ps(n, e) {
|
|
1956
1972
|
if (n.length <= e)
|
|
1957
1973
|
return [{ text: n, offset: 0 }];
|
|
1958
|
-
const s =
|
|
1959
|
-
return
|
|
1974
|
+
const s = Me(n, 0, Wt).flatMap((i) => De(i, e));
|
|
1975
|
+
return Kt(s, e);
|
|
1960
1976
|
}
|
|
1961
|
-
const
|
|
1962
|
-
function
|
|
1977
|
+
const As = /<([a-zA-Z][\w-]*)\b[^>]*>[\s\S]*?<\/\1>|<[a-zA-Z][\w-]*\b[^>]*\/>|[^<]+/g;
|
|
1978
|
+
function xs(n, e) {
|
|
1963
1979
|
if (n.length <= e)
|
|
1964
1980
|
return [{ text: n, offset: 0 }];
|
|
1965
1981
|
const t = [];
|
|
1966
|
-
for (const i of n.matchAll(
|
|
1967
|
-
i[0][0] === "<" ? t.push({ text: i[0], offset: i.index, atomic: !0 }) : t.push(...
|
|
1968
|
-
const s = t.flatMap((i) =>
|
|
1969
|
-
return
|
|
1982
|
+
for (const i of n.matchAll(As))
|
|
1983
|
+
i[0][0] === "<" ? t.push({ text: i[0], offset: i.index, atomic: !0 }) : t.push(...Me(i[0], i.index, Wt));
|
|
1984
|
+
const s = t.flatMap((i) => De(i, e));
|
|
1985
|
+
return Kt(s, e);
|
|
1970
1986
|
}
|
|
1971
|
-
const
|
|
1987
|
+
const Ls = {
|
|
1972
1988
|
wav: "audio/wav",
|
|
1973
1989
|
mp3: "audio/mpeg",
|
|
1974
1990
|
opus: "audio/ogg",
|
|
@@ -1978,31 +1994,31 @@ const xs = {
|
|
|
1978
1994
|
webm: "audio/webm",
|
|
1979
1995
|
m4a: "audio/mp4"
|
|
1980
1996
|
};
|
|
1981
|
-
function
|
|
1982
|
-
return
|
|
1997
|
+
function Os(n) {
|
|
1998
|
+
return Ls[n] ?? `audio/${n}`;
|
|
1983
1999
|
}
|
|
1984
|
-
const
|
|
1985
|
-
function
|
|
1986
|
-
const s = (o) => t(
|
|
2000
|
+
const Us = ["flac", "wav", "opus", "aac", "ogg", "webm", "mp3"], Vs = ["opus", "aac", "webm", "ogg", "mp3", "wav", "flac"];
|
|
2001
|
+
function Ts(n, e, t) {
|
|
2002
|
+
const s = (o) => t(Os(o)) !== "", i = n.formats.filter(s);
|
|
1987
2003
|
if (e.preferredFormat && i.includes(e.preferredFormat))
|
|
1988
2004
|
return e.preferredFormat;
|
|
1989
|
-
const a = e.strategy === "bandwidth" ?
|
|
2005
|
+
const a = e.strategy === "bandwidth" ? Vs : Us, r = [...a, ...i.filter((o) => !a.includes(o))];
|
|
1990
2006
|
for (const o of r)
|
|
1991
2007
|
if (i.includes(o))
|
|
1992
2008
|
return o;
|
|
1993
2009
|
return n.default;
|
|
1994
2010
|
}
|
|
1995
|
-
const
|
|
2011
|
+
const zs = /* @__PURE__ */ new Set(["wav", "flac"]), Ns = {
|
|
1996
2012
|
mp3: 48e3,
|
|
1997
2013
|
opus: 24e3,
|
|
1998
2014
|
aac: 48e3,
|
|
1999
2015
|
ogg: 48e3,
|
|
2000
2016
|
webm: 32e3
|
|
2001
2017
|
};
|
|
2002
|
-
function
|
|
2003
|
-
return
|
|
2018
|
+
function Bs(n, e, t) {
|
|
2019
|
+
return zs.has(n) || !e || !t ? void 0 : t.saveData === !0 || /2g/.test(t.effectiveType ?? "") ? Ns[n] : void 0;
|
|
2004
2020
|
}
|
|
2005
|
-
function
|
|
2021
|
+
function Qt(n, e) {
|
|
2006
2022
|
return {
|
|
2007
2023
|
source: "server",
|
|
2008
2024
|
label: n.name,
|
|
@@ -2026,17 +2042,17 @@ class J extends Error {
|
|
|
2026
2042
|
super(e), this.name = "SpeechServerError", this.status = t.status, this.type = t.type, this.title = t.title, this.instance = t.instance;
|
|
2027
2043
|
}
|
|
2028
2044
|
}
|
|
2029
|
-
class
|
|
2045
|
+
class Jt extends J {
|
|
2030
2046
|
constructor(e) {
|
|
2031
2047
|
super(e, { status: 408, type: "https://readium.org/speech-server/error#stall", title: "Synthesis Stalled" }), this.name = "SpeechServerStallError";
|
|
2032
2048
|
}
|
|
2033
2049
|
}
|
|
2034
|
-
class
|
|
2050
|
+
class Zt extends Error {
|
|
2035
2051
|
constructor(e) {
|
|
2036
2052
|
super(e), this.name = "SpeechServerAudioDecodeError";
|
|
2037
2053
|
}
|
|
2038
2054
|
}
|
|
2039
|
-
class
|
|
2055
|
+
class Yt extends Error {
|
|
2040
2056
|
constructor(e) {
|
|
2041
2057
|
super(e), this.name = "SpeechServerNetworkError";
|
|
2042
2058
|
}
|
|
@@ -2055,23 +2071,23 @@ async function W(n) {
|
|
|
2055
2071
|
}
|
|
2056
2072
|
return new J(`Request failed with status ${n.status}`, { status: n.status });
|
|
2057
2073
|
}
|
|
2058
|
-
const
|
|
2059
|
-
function
|
|
2074
|
+
const Ms = 3, Ds = 400;
|
|
2075
|
+
function js(n) {
|
|
2060
2076
|
const e = atob(n), t = new Uint8Array(e.length);
|
|
2061
2077
|
for (let s = 0; s < e.length; s++)
|
|
2062
2078
|
t[s] = e.charCodeAt(s);
|
|
2063
2079
|
return t.buffer;
|
|
2064
2080
|
}
|
|
2065
|
-
function
|
|
2081
|
+
function Fs(n) {
|
|
2066
2082
|
return F(n, 0.25, 4, 1);
|
|
2067
2083
|
}
|
|
2068
|
-
function
|
|
2084
|
+
function ae(n) {
|
|
2069
2085
|
return n?.plain ?? n?.ssml ?? void 0;
|
|
2070
2086
|
}
|
|
2071
|
-
function
|
|
2072
|
-
return n instanceof
|
|
2087
|
+
function gt(n) {
|
|
2088
|
+
return n instanceof Jt ? { message: n.message, status: n.status, type: n.type, title: n.title, instance: n.instance, recoverable: !0 } : n instanceof J ? { message: n.message, status: n.status, type: n.type, title: n.title, instance: n.instance, recoverable: !1 } : n instanceof Zt ? { message: n.message, recoverable: !1 } : n instanceof Yt ? { message: n.message, recoverable: !0 } : n instanceof Error ? { message: n.message, recoverable: !1 } : { message: String(n), recoverable: !1 };
|
|
2073
2089
|
}
|
|
2074
|
-
class
|
|
2090
|
+
class _s {
|
|
2075
2091
|
endpoints;
|
|
2076
2092
|
fetchImpl;
|
|
2077
2093
|
currentVoice = null;
|
|
@@ -2081,7 +2097,7 @@ class js {
|
|
|
2081
2097
|
currentUtterances = [];
|
|
2082
2098
|
currentUtteranceIndex = 0;
|
|
2083
2099
|
playbackState = "idle";
|
|
2084
|
-
events = new
|
|
2100
|
+
events = new we();
|
|
2085
2101
|
speakInContentLanguage = !1;
|
|
2086
2102
|
speakGeneration = 0;
|
|
2087
2103
|
loadGeneration = 0;
|
|
@@ -2102,6 +2118,7 @@ class js {
|
|
|
2102
2118
|
liveControllers = /* @__PURE__ */ new Set();
|
|
2103
2119
|
isSpeakingInternal = !1;
|
|
2104
2120
|
restartPending = !1;
|
|
2121
|
+
restartOnResume = !1;
|
|
2105
2122
|
audioContext = null;
|
|
2106
2123
|
masterGain = null;
|
|
2107
2124
|
scheduledChunks = [];
|
|
@@ -2110,7 +2127,7 @@ class js {
|
|
|
2110
2127
|
pitch = 1;
|
|
2111
2128
|
volume = 1;
|
|
2112
2129
|
constructor(e) {
|
|
2113
|
-
this.endpoints = e.endpoints, this.fetchImpl = e.fetch ?? fetch.bind(globalThis), this.prefetchWindow = e.prefetchWindow ??
|
|
2130
|
+
this.endpoints = e.endpoints, this.fetchImpl = e.fetch ?? fetch.bind(globalThis), this.prefetchWindow = e.prefetchWindow ?? Ms, this.readyBufferChars = e.readyBufferChars ?? Ds, this.overLengthText = e.overLengthText ?? "split", this.timeoutMs = e.timeoutMs, this.formatOptions = e.format ?? {}, this.canPlayType = typeof Audio < "u" ? (t) => new Audio().canPlayType(t) : () => "";
|
|
2114
2131
|
}
|
|
2115
2132
|
// Lets a provider that already fetched /voices seed this engine without a second request.
|
|
2116
2133
|
setAvailableVoices(e) {
|
|
@@ -2122,17 +2139,17 @@ class js {
|
|
|
2122
2139
|
try {
|
|
2123
2140
|
return await this.fetchImpl(e, t);
|
|
2124
2141
|
} catch (s) {
|
|
2125
|
-
throw s instanceof TypeError ? new
|
|
2142
|
+
throw s instanceof TypeError ? new Yt(s.message) : s;
|
|
2126
2143
|
}
|
|
2127
2144
|
}
|
|
2128
2145
|
loadUtterances(e, t) {
|
|
2129
|
-
this.abortLiveControllers(), this.clearPrefetchCache(), this.currentUtterances = e, this.currentUtteranceIndex =
|
|
2146
|
+
this.abortLiveControllers(), this.clearPrefetchCache(), this.currentUtterances = e, this.currentUtteranceIndex = le(t ?? 0, e.length), this.setState("loading"), this.bufferUntilReady(++this.loadGeneration);
|
|
2130
2147
|
}
|
|
2131
2148
|
// Buffers enough utterances ahead of currentUtteranceIndex to cover readyBufferChars before
|
|
2132
2149
|
// declaring "ready", so playback doesn't catch up to an empty prefetch cache right away —
|
|
2133
2150
|
// starting from wherever playback will actually resume, not always utterance 0.
|
|
2134
2151
|
async bufferUntilReady(e) {
|
|
2135
|
-
const t =
|
|
2152
|
+
const t = le(this.currentUtteranceIndex, this.currentUtterances.length), s = Math.min(this.indexCoveringChars(this.readyBufferChars, t), t + this.prefetchWindow), i = [];
|
|
2136
2153
|
for (let a = t; a <= s; a++) {
|
|
2137
2154
|
this.queuePrefetch(a);
|
|
2138
2155
|
const r = this.prefetchCache.get(a);
|
|
@@ -2147,33 +2164,34 @@ class js {
|
|
|
2147
2164
|
indexCoveringChars(e, t) {
|
|
2148
2165
|
if (this.currentUtterances.length === 0)
|
|
2149
2166
|
return -1;
|
|
2150
|
-
const s =
|
|
2167
|
+
const s = le(t, this.currentUtterances.length);
|
|
2151
2168
|
let i = 0;
|
|
2152
2169
|
for (let a = s; a < this.currentUtterances.length; a++)
|
|
2153
|
-
if (i += (
|
|
2170
|
+
if (i += (ae(this.currentUtterances[a]) ?? "").length, i >= e)
|
|
2154
2171
|
return a;
|
|
2155
2172
|
return this.currentUtterances.length - 1;
|
|
2156
2173
|
}
|
|
2157
2174
|
setVoice(e) {
|
|
2175
|
+
const t = this.currentVoice?.identifier ?? this.currentVoice?.name;
|
|
2158
2176
|
if (typeof e == "string") {
|
|
2159
|
-
const
|
|
2160
|
-
|
|
2177
|
+
const s = this.voices.find((i) => i.identifier === e || i.name === e);
|
|
2178
|
+
s ? this.currentVoice = s : (this.currentVoice = {
|
|
2161
2179
|
source: "server",
|
|
2162
2180
|
label: e,
|
|
2163
2181
|
name: e,
|
|
2164
2182
|
originalName: e,
|
|
2165
2183
|
language: "",
|
|
2166
2184
|
identifier: e
|
|
2167
|
-
}, this.getAvailableVoices().then((
|
|
2185
|
+
}, this.getAvailableVoices().then((i) => {
|
|
2168
2186
|
if (this.currentVoice?.identifier !== e)
|
|
2169
2187
|
return;
|
|
2170
|
-
const
|
|
2171
|
-
|
|
2188
|
+
const a = i.find((r) => r.identifier === e || r.name === e);
|
|
2189
|
+
a && (this.currentVoice = a, (a.identifier !== e || a.controls?.speed === !0) && (this.clearPrefetchCache(), this.scheduleRestartIfSpeaking()));
|
|
2172
2190
|
}).catch(() => {
|
|
2173
2191
|
}));
|
|
2174
2192
|
} else
|
|
2175
2193
|
this.currentVoice = e;
|
|
2176
|
-
this.
|
|
2194
|
+
(this.currentVoice?.identifier ?? this.currentVoice?.name) !== t && (this.clearPrefetchCache(), this.scheduleRestartIfSpeaking());
|
|
2177
2195
|
}
|
|
2178
2196
|
getCurrentVoice() {
|
|
2179
2197
|
return this.currentVoice;
|
|
@@ -2185,7 +2203,7 @@ class js {
|
|
|
2185
2203
|
if (!e.ok)
|
|
2186
2204
|
throw await W(e);
|
|
2187
2205
|
const s = await e.json(), i = new Map(t.providers.map((a) => [a.id, a.controls]));
|
|
2188
|
-
return this.voices = s.map((a) =>
|
|
2206
|
+
return this.voices = s.map((a) => Qt(a, i.get(a.provider))), this.voices;
|
|
2189
2207
|
}
|
|
2190
2208
|
// Cached after the first successful fetch; a failed fetch isn't cached, so the next
|
|
2191
2209
|
// synthesize() call retries rather than being stuck on a transient network error.
|
|
@@ -2201,7 +2219,7 @@ class js {
|
|
|
2201
2219
|
return e.json();
|
|
2202
2220
|
}
|
|
2203
2221
|
setSpeakInContentLanguage(e) {
|
|
2204
|
-
this.speakInContentLanguage = e, this.
|
|
2222
|
+
e !== this.speakInContentLanguage && (this.speakInContentLanguage = e, this.clearPrefetchCache(), this.scheduleRestartIfSpeaking());
|
|
2205
2223
|
}
|
|
2206
2224
|
getSpeakInContentLanguage() {
|
|
2207
2225
|
return this.speakInContentLanguage;
|
|
@@ -2212,7 +2230,7 @@ class js {
|
|
|
2212
2230
|
throw new Error("Invalid utterance index");
|
|
2213
2231
|
this.currentUtteranceIndex = e;
|
|
2214
2232
|
}
|
|
2215
|
-
if (this.restartPending = !1, this.currentUtterances.length === 0) {
|
|
2233
|
+
if (this.restartPending = !1, this.restartOnResume = !1, this.currentUtterances.length === 0) {
|
|
2216
2234
|
console.warn("No utterances loaded");
|
|
2217
2235
|
return;
|
|
2218
2236
|
}
|
|
@@ -2232,7 +2250,7 @@ class js {
|
|
|
2232
2250
|
return;
|
|
2233
2251
|
this.isSpeakingInternal = !1, this.setState("idle"), this.emitEvent({
|
|
2234
2252
|
type: "error",
|
|
2235
|
-
detail:
|
|
2253
|
+
detail: gt(s)
|
|
2236
2254
|
});
|
|
2237
2255
|
}
|
|
2238
2256
|
}
|
|
@@ -2279,11 +2297,11 @@ class js {
|
|
|
2279
2297
|
this.liveControllers.forEach((e) => e.abort()), this.liveControllers.clear();
|
|
2280
2298
|
}
|
|
2281
2299
|
async synthesizeStream(e, t) {
|
|
2282
|
-
const s = this.currentUtterances[e], i = !s.plain && !!s.ssml, a = this.speakInContentLanguage ? s.language : void 0, r =
|
|
2300
|
+
const s = this.currentUtterances[e], i = !s.plain && !!s.ssml, a = this.speakInContentLanguage ? s.language : void 0, r = ae(s) ?? "", o = i ? jt(r).map : void 0, l = ae(this.currentUtterances[e - 1]), c = ae(this.currentUtterances[e + 1]), u = await this.getServiceInfo(), g = Ts(u.output, this.formatOptions, this.canPlayType), h = navigator.connection, d = Bs(g, this.formatOptions.adaptBitrateToNetwork ?? !1, h);
|
|
2283
2301
|
if (r.length <= u.limits.maxTextLength) {
|
|
2284
2302
|
const v = new AbortController();
|
|
2285
2303
|
return (t ? this.activeControllers : this.liveControllers).add(v), [{
|
|
2286
|
-
promise: this.synthesizeChunk({ content: s, text: r, textOffset: 0, useSSML: i, ssmlMap: o, language: a, prevText: l, nextText: c, format:
|
|
2304
|
+
promise: this.synthesizeChunk({ content: s, text: r, textOffset: 0, useSSML: i, ssmlMap: o, language: a, prevText: l, nextText: c, format: g, bitrate: d, controller: v }),
|
|
2287
2305
|
controller: v
|
|
2288
2306
|
}];
|
|
2289
2307
|
}
|
|
@@ -2296,45 +2314,45 @@ class js {
|
|
|
2296
2314
|
title: "Payload Too Large"
|
|
2297
2315
|
}
|
|
2298
2316
|
);
|
|
2299
|
-
const f = Math.min(u.limits.maxTextLength, this.readyBufferChars), p = i ?
|
|
2317
|
+
const f = Math.min(u.limits.maxTextLength, this.readyBufferChars), p = i ? xs(r, f) : Ps(r, f), m = [];
|
|
2300
2318
|
let S = Promise.resolve();
|
|
2301
2319
|
for (let v = 0; v < p.length; v++) {
|
|
2302
|
-
const I = v === 0 ? l : p[v - 1].text, P = v === p.length - 1 ? c : p[v + 1].text, y = p[v],
|
|
2303
|
-
(t ? this.activeControllers : this.liveControllers).add(
|
|
2320
|
+
const I = v === 0 ? l : p[v - 1].text, P = v === p.length - 1 ? c : p[v + 1].text, y = p[v], C = new AbortController();
|
|
2321
|
+
(t ? this.activeControllers : this.liveControllers).add(C);
|
|
2304
2322
|
const R = S.then(
|
|
2305
|
-
() => this.synthesizeChunk({ content: s, text: y.text, textOffset: y.offset, useSSML: i, ssmlMap: o, language: a, prevText: I, nextText: P, format:
|
|
2323
|
+
() => this.synthesizeChunk({ content: s, text: y.text, textOffset: y.offset, useSSML: i, ssmlMap: o, language: a, prevText: I, nextText: P, format: g, bitrate: d, controller: C })
|
|
2306
2324
|
);
|
|
2307
|
-
m.push({ promise: R, controller:
|
|
2325
|
+
m.push({ promise: R, controller: C }), S = R;
|
|
2308
2326
|
}
|
|
2309
2327
|
return m;
|
|
2310
2328
|
}
|
|
2311
2329
|
async synthesizeChunk(e) {
|
|
2312
|
-
const { content: t, text: s, textOffset: i, useSSML: a, ssmlMap: r, language: o, prevText: l, nextText: c, format: u, bitrate:
|
|
2330
|
+
const { content: t, text: s, textOffset: i, useSSML: a, ssmlMap: r, language: o, prevText: l, nextText: c, format: u, bitrate: g, controller: h } = e;
|
|
2313
2331
|
try {
|
|
2314
|
-
const
|
|
2332
|
+
const d = await this.fetchNetwork(this.endpoints.synthesize, {
|
|
2315
2333
|
method: "POST",
|
|
2316
2334
|
headers: { "Content-Type": "application/json" },
|
|
2317
2335
|
body: JSON.stringify({
|
|
2318
2336
|
id: t.id,
|
|
2319
|
-
text: a ? s :
|
|
2337
|
+
text: a ? s : Dt(s),
|
|
2320
2338
|
ssml: a,
|
|
2321
2339
|
language: o,
|
|
2322
2340
|
voice: this.currentVoice?.identifier ?? this.currentVoice?.name,
|
|
2323
2341
|
prev_utterance: l,
|
|
2324
2342
|
next_utterance: c,
|
|
2325
2343
|
boundary: !0,
|
|
2326
|
-
output: { format: u, bitrate:
|
|
2344
|
+
output: { format: u, bitrate: g, speed: this.rate, pitch: this.pitch }
|
|
2327
2345
|
}),
|
|
2328
2346
|
signal: h.signal
|
|
2329
2347
|
});
|
|
2330
|
-
if (!
|
|
2331
|
-
throw await W(
|
|
2332
|
-
const f = await
|
|
2348
|
+
if (!d.ok)
|
|
2349
|
+
throw await W(d);
|
|
2350
|
+
const f = await d.json(), p = js(f.audio);
|
|
2333
2351
|
let m;
|
|
2334
2352
|
try {
|
|
2335
2353
|
m = await this.ensureAudioContext().decodeAudioData(p);
|
|
2336
2354
|
} catch {
|
|
2337
|
-
throw new
|
|
2355
|
+
throw new Zt("Audio playback failed");
|
|
2338
2356
|
}
|
|
2339
2357
|
return { audioBuffer: m, format: f.format, boundaries: f.boundaries, textOffset: i, ssmlMap: r };
|
|
2340
2358
|
} finally {
|
|
@@ -2355,7 +2373,7 @@ class js {
|
|
|
2355
2373
|
const i = s + this.timeoutMs;
|
|
2356
2374
|
return new Promise((a, r) => {
|
|
2357
2375
|
const o = setTimeout(() => {
|
|
2358
|
-
t.abort(), r(new
|
|
2376
|
+
t.abort(), r(new Jt(`No audio chunk arrived within ${i.toFixed(0)}ms of the playback buffer running dry`));
|
|
2359
2377
|
}, i);
|
|
2360
2378
|
e.then(
|
|
2361
2379
|
(l) => {
|
|
@@ -2372,21 +2390,21 @@ class js {
|
|
|
2372
2390
|
const s = await this.awaitWithStallDeadline(e[0].promise, e[0].controller, 0);
|
|
2373
2391
|
if (t !== this.speakGeneration)
|
|
2374
2392
|
return;
|
|
2375
|
-
const i = this.ensureAudioContext(), a = this.masterGain, o = this.currentVoice?.controls?.speed === !0 ? 1 :
|
|
2393
|
+
const i = this.ensureAudioContext(), a = this.masterGain, o = this.currentVoice?.controls?.speed === !0 ? 1 : Fs(this.rate);
|
|
2376
2394
|
this.scheduledChunks = [], this.setState("playing"), this.emitEvent({ type: "start" });
|
|
2377
2395
|
let l = i.currentTime, c = null;
|
|
2378
|
-
const u = (
|
|
2396
|
+
const u = (g) => {
|
|
2379
2397
|
const h = i.createBufferSource();
|
|
2380
|
-
h.buffer =
|
|
2398
|
+
h.buffer = g.audioBuffer, h.playbackRate.value = o, h.connect(a), h.start(l), c && (c.onended = null), h.onended = () => this.handleUtteranceEnded(t), c = h, this.scheduledChunks.push({ chunk: g, startTime: l, node: h, nextBoundaryIndex: 0, rate: o }), l += g.audioBuffer.duration / o;
|
|
2381
2399
|
};
|
|
2382
2400
|
u(s), this.startBoundaryPolling(t);
|
|
2383
|
-
for (let
|
|
2401
|
+
for (let g = 1; g < e.length; g++) {
|
|
2384
2402
|
let h;
|
|
2385
2403
|
try {
|
|
2386
|
-
const
|
|
2387
|
-
h = await this.awaitWithStallDeadline(e[
|
|
2388
|
-
} catch (
|
|
2389
|
-
t === this.speakGeneration && this.emitEvent({ type: "error", detail:
|
|
2404
|
+
const d = Math.max(0, (l - i.currentTime) * 1e3);
|
|
2405
|
+
h = await this.awaitWithStallDeadline(e[g].promise, e[g].controller, d);
|
|
2406
|
+
} catch (d) {
|
|
2407
|
+
t === this.speakGeneration && this.emitEvent({ type: "error", detail: gt(d) });
|
|
2390
2408
|
return;
|
|
2391
2409
|
}
|
|
2392
2410
|
if (t !== this.speakGeneration)
|
|
@@ -2417,7 +2435,7 @@ class js {
|
|
|
2417
2435
|
let r = a, o = i.charLength;
|
|
2418
2436
|
if (t.chunk.ssmlMap) {
|
|
2419
2437
|
const l = t.chunk.ssmlMap;
|
|
2420
|
-
r =
|
|
2438
|
+
r = ot(l, a), o = Math.max(0, ot(l, a + i.charLength) - r);
|
|
2421
2439
|
}
|
|
2422
2440
|
this.emitEvent({
|
|
2423
2441
|
type: "boundary",
|
|
@@ -2448,11 +2466,17 @@ class js {
|
|
|
2448
2466
|
}), this.stopBoundaryPolling(), this.isSpeakingInternal = !1, this.setState("paused"), this.emitEvent({ type: "pause" }));
|
|
2449
2467
|
}
|
|
2450
2468
|
resume() {
|
|
2451
|
-
this.playbackState === "paused" && this.audioContext
|
|
2452
|
-
|
|
2469
|
+
if (this.playbackState === "paused" && this.audioContext) {
|
|
2470
|
+
if (this.restartOnResume) {
|
|
2471
|
+
this.emitEvent({ type: "resume" }), this.speak(this.currentUtteranceIndex);
|
|
2472
|
+
return;
|
|
2473
|
+
}
|
|
2474
|
+
this.audioContext.resume().catch(() => {
|
|
2475
|
+
}), this.startBoundaryPolling(this.speakGeneration), this.isSpeakingInternal = !0, this.setState("playing"), this.emitEvent({ type: "resume" });
|
|
2476
|
+
}
|
|
2453
2477
|
}
|
|
2454
2478
|
stop() {
|
|
2455
|
-
this.speakGeneration++, this.loadGeneration++, this.stopAudio(), this.abortLiveControllers(), this.clearPrefetchCache(), this.isSpeakingInternal = !1, this.currentUtteranceIndex = 0, this.setState("idle"), this.emitEvent({ type: "stop" });
|
|
2479
|
+
this.speakGeneration++, this.loadGeneration++, this.stopAudio(), this.abortLiveControllers(), this.clearPrefetchCache(), this.isSpeakingInternal = !1, this.restartOnResume = !1, this.currentUtteranceIndex = 0, this.setState("idle"), this.emitEvent({ type: "stop" });
|
|
2456
2480
|
}
|
|
2457
2481
|
setRate(e) {
|
|
2458
2482
|
const t = F(e, 0.1, 10, this.rate);
|
|
@@ -2475,11 +2499,15 @@ class js {
|
|
|
2475
2499
|
getVolume() {
|
|
2476
2500
|
return this.volume;
|
|
2477
2501
|
}
|
|
2478
|
-
// rate
|
|
2479
|
-
//
|
|
2502
|
+
// Voice, language, rate and pitch are baked into each chunk's synthesis request at fetch-time:
|
|
2503
|
+
// restart the utterance so a change applies now (or on resume when paused). Same-tick changes coalesce.
|
|
2480
2504
|
scheduleRestartIfSpeaking() {
|
|
2505
|
+
if (this.playbackState === "paused") {
|
|
2506
|
+
this.restartOnResume = !0;
|
|
2507
|
+
return;
|
|
2508
|
+
}
|
|
2481
2509
|
!this.isSpeakingInternal || this.restartPending || (this.restartPending = !0, queueMicrotask(() => {
|
|
2482
|
-
this.restartPending && (this.restartPending = !1, this.isSpeakingInternal && this.speak(this.currentUtteranceIndex));
|
|
2510
|
+
this.restartPending && (this.restartPending = !1, this.playbackState === "paused" ? this.restartOnResume = !0 : this.isSpeakingInternal && this.speak(this.currentUtteranceIndex));
|
|
2483
2511
|
}));
|
|
2484
2512
|
}
|
|
2485
2513
|
getState() {
|
|
@@ -2527,7 +2555,7 @@ class js {
|
|
|
2527
2555
|
this.stop(), await this.audioContext?.close(), this.audioContext = null, this.masterGain = null, this.events.clear(), this.currentUtterances = [], this.currentVoice = null, this.voices = [];
|
|
2528
2556
|
}
|
|
2529
2557
|
}
|
|
2530
|
-
class
|
|
2558
|
+
class aa {
|
|
2531
2559
|
id = "speech-server";
|
|
2532
2560
|
name = "Readium Speech Server";
|
|
2533
2561
|
options;
|
|
@@ -2548,20 +2576,20 @@ class ta {
|
|
|
2548
2576
|
if (!s.ok)
|
|
2549
2577
|
throw await W(s);
|
|
2550
2578
|
const i = await t.json(), a = await s.json(), r = new Map(a.providers.map((o) => [o.id, o.controls]));
|
|
2551
|
-
return this.voices = i.map((o) =>
|
|
2579
|
+
return this.voices = i.map((o) => Qt(o, r.get(o.provider))), this.voices;
|
|
2552
2580
|
}
|
|
2553
2581
|
async createEngine(e) {
|
|
2554
|
-
const t = new
|
|
2582
|
+
const t = new _s(this.options);
|
|
2555
2583
|
return this.voices.length > 0 && t.setAvailableVoices(this.voices), e && t.setVoice(e), t;
|
|
2556
2584
|
}
|
|
2557
2585
|
async destroy() {
|
|
2558
2586
|
this.voices = [];
|
|
2559
2587
|
}
|
|
2560
2588
|
}
|
|
2561
|
-
function
|
|
2589
|
+
function Hs(n) {
|
|
2562
2590
|
return n.detail?.recoverable === !0;
|
|
2563
2591
|
}
|
|
2564
|
-
const
|
|
2592
|
+
const qs = 3e4, Gs = [
|
|
2565
2593
|
"start",
|
|
2566
2594
|
"pause",
|
|
2567
2595
|
"resume",
|
|
@@ -2576,7 +2604,7 @@ const _s = 3e4, Hs = [
|
|
|
2576
2604
|
"voiceschanged",
|
|
2577
2605
|
"languagefallback"
|
|
2578
2606
|
];
|
|
2579
|
-
class
|
|
2607
|
+
class $s {
|
|
2580
2608
|
activeEngine;
|
|
2581
2609
|
primaryProvider;
|
|
2582
2610
|
fallbackProvider;
|
|
@@ -2608,10 +2636,10 @@ class qs {
|
|
|
2608
2636
|
teardownEpoch = 0;
|
|
2609
2637
|
// Bumped by every loadUtterances() call, so startEngineWhenReady() can tell its queue is stale.
|
|
2610
2638
|
loadToken = 0;
|
|
2611
|
-
events = new
|
|
2639
|
+
events = new we();
|
|
2612
2640
|
unbindActiveEngine = null;
|
|
2613
2641
|
constructor(e) {
|
|
2614
|
-
this.activeEngine = e.primaryEngine, this.primaryProvider = e.primaryProvider, this.fallbackProvider = e.fallbackProvider, this.onFailure = e.onFailure ?? "fallback", this.healthCheckIntervalMs = e.healthCheckIntervalMs ??
|
|
2642
|
+
this.activeEngine = e.primaryEngine, this.primaryProvider = e.primaryProvider, this.fallbackProvider = e.fallbackProvider, this.onFailure = e.onFailure ?? "fallback", this.healthCheckIntervalMs = e.healthCheckIntervalMs ?? qs, this.lastVoiceRequest = e.primaryEngine.getCurrentVoice() ?? void 0, this.bindActiveEngine();
|
|
2615
2643
|
}
|
|
2616
2644
|
async initialize() {
|
|
2617
2645
|
return this.activeEngine.initialize?.();
|
|
@@ -2711,13 +2739,13 @@ class qs {
|
|
|
2711
2739
|
this.events.emit(e.type, e);
|
|
2712
2740
|
}
|
|
2713
2741
|
bindActiveEngine() {
|
|
2714
|
-
const e = this.activeEngine, t =
|
|
2742
|
+
const e = this.activeEngine, t = Gs.map((s) => e.on(s, (i) => {
|
|
2715
2743
|
this.emitEvent(i), this.maybeRecoverNow();
|
|
2716
2744
|
}));
|
|
2717
2745
|
t.push(e.on("error", (s) => this.handleError(s))), this.unbindActiveEngine = () => t.forEach((s) => s());
|
|
2718
2746
|
}
|
|
2719
2747
|
handleError(e) {
|
|
2720
|
-
if (this.hasFallenBack || this.swapInFlight || this.onFailure === "error" || !
|
|
2748
|
+
if (this.hasFallenBack || this.swapInFlight || this.onFailure === "error" || !Hs(e)) {
|
|
2721
2749
|
this.emitEvent(e);
|
|
2722
2750
|
return;
|
|
2723
2751
|
}
|
|
@@ -2809,14 +2837,14 @@ class qs {
|
|
|
2809
2837
|
async pickBestFallbackVoice(e, t, s) {
|
|
2810
2838
|
const i = await this.fallbackProvider.getVoices(), r = typeof navigator < "u" && navigator.onLine === !0 ? i : i.filter((f) => f.offlineAvailability === !0);
|
|
2811
2839
|
if (r.length === 0) return null;
|
|
2812
|
-
const [o] =
|
|
2813
|
-
return
|
|
2840
|
+
const [o] = Se([e]), { voicesByLang: l } = be(r, [o]), c = l.get(o.baseLang) ?? [], u = c.length > 0 ? c : r, g = t ? u.filter((f) => f.gender === t) : [], h = g.length > 0 ? g : u, d = Mt(h, s);
|
|
2841
|
+
return Nn(e, d);
|
|
2814
2842
|
}
|
|
2815
2843
|
async destroy() {
|
|
2816
2844
|
this.teardownEpoch++, this.healthCheckTimer !== null && (clearTimeout(this.healthCheckTimer), this.healthCheckTimer = null), this.unbindActiveEngine?.(), this.events.clear(), await this.activeEngine.destroy();
|
|
2817
2845
|
}
|
|
2818
2846
|
}
|
|
2819
|
-
class
|
|
2847
|
+
class ra {
|
|
2820
2848
|
id = "fallback";
|
|
2821
2849
|
name = "Fallback";
|
|
2822
2850
|
primary;
|
|
@@ -2844,7 +2872,7 @@ class na {
|
|
|
2844
2872
|
throw s;
|
|
2845
2873
|
return this.fallback.createEngine(e);
|
|
2846
2874
|
}
|
|
2847
|
-
return new
|
|
2875
|
+
return new $s({
|
|
2848
2876
|
primaryEngine: t,
|
|
2849
2877
|
primaryProvider: this.primary,
|
|
2850
2878
|
fallbackProvider: this.fallback,
|
|
@@ -2856,27 +2884,27 @@ class na {
|
|
|
2856
2884
|
await Promise.all([this.primary.destroy(), this.fallback.destroy()]);
|
|
2857
2885
|
}
|
|
2858
2886
|
}
|
|
2859
|
-
function
|
|
2860
|
-
return new
|
|
2861
|
-
start: new
|
|
2862
|
-
end: n.end ? new
|
|
2887
|
+
function Ks(n) {
|
|
2888
|
+
return new Pn({
|
|
2889
|
+
start: new tt(n.start),
|
|
2890
|
+
end: n.end ? new tt(n.end) : void 0
|
|
2863
2891
|
});
|
|
2864
2892
|
}
|
|
2865
|
-
function
|
|
2866
|
-
const { href: t, text: s, cssSelector: i, domRange: a, fragment: r } = n, o = s ? new
|
|
2867
|
-
l && (i && l.set("cssSelector", i), a && l.set("domRange",
|
|
2868
|
-
const u = l !== void 0 || r !== void 0 ? new
|
|
2893
|
+
function Ws(n, e = window) {
|
|
2894
|
+
const { href: t, text: s, cssSelector: i, domRange: a, fragment: r } = n, o = s ? new wn(s) : void 0, l = i || a ? /* @__PURE__ */ new Map() : void 0;
|
|
2895
|
+
l && (i && l.set("cssSelector", i), a && l.set("domRange", Ks(a).serialize()));
|
|
2896
|
+
const u = l !== void 0 || r !== void 0 ? new kn({
|
|
2869
2897
|
fragments: r ? [r] : void 0,
|
|
2870
2898
|
otherLocations: l
|
|
2871
2899
|
}) : void 0;
|
|
2872
|
-
return new
|
|
2900
|
+
return new Cn({
|
|
2873
2901
|
href: t ?? e.location.href,
|
|
2874
2902
|
type: "text/html",
|
|
2875
2903
|
text: o,
|
|
2876
2904
|
locations: u
|
|
2877
2905
|
});
|
|
2878
2906
|
}
|
|
2879
|
-
class
|
|
2907
|
+
class Qs extends yn {
|
|
2880
2908
|
constructor(e, t, s, i = {}) {
|
|
2881
2909
|
super(e.host, i), this.channel = e, this.wnd = t, this.decorator = s;
|
|
2882
2910
|
}
|
|
@@ -2892,7 +2920,7 @@ class Ks extends vn {
|
|
|
2892
2920
|
e.map(({ id: s, style: i, ...a }) => ({
|
|
2893
2921
|
id: s,
|
|
2894
2922
|
style: i,
|
|
2895
|
-
locator:
|
|
2923
|
+
locator: Ws(a, this.wnd)
|
|
2896
2924
|
})),
|
|
2897
2925
|
t
|
|
2898
2926
|
);
|
|
@@ -2901,11 +2929,11 @@ class Ks extends vn {
|
|
|
2901
2929
|
super.destroy(), this.decorator.unmount(this.wnd, this.channel.frame), this.channel.frame.destroy();
|
|
2902
2930
|
}
|
|
2903
2931
|
}
|
|
2904
|
-
function
|
|
2905
|
-
const t = new
|
|
2906
|
-
return s.mount(n, t.frame), new
|
|
2932
|
+
function oa(n = window, e = {}) {
|
|
2933
|
+
const t = new Sn(), s = new bn();
|
|
2934
|
+
return s.mount(n, t.frame), new Qs(t, n, s, e);
|
|
2907
2935
|
}
|
|
2908
|
-
class
|
|
2936
|
+
class la {
|
|
2909
2937
|
providers = /* @__PURE__ */ new Map();
|
|
2910
2938
|
register(e) {
|
|
2911
2939
|
if (this.providers.has(e.id))
|
|
@@ -2945,7 +2973,7 @@ class ia {
|
|
|
2945
2973
|
return t;
|
|
2946
2974
|
}
|
|
2947
2975
|
}
|
|
2948
|
-
const
|
|
2976
|
+
const ke = (n, e, t) => Object.freeze({ range: Object.freeze([n, e]), step: t }), ue = ke(0, 5e3, 100), he = ke(0.1, 10, 0.1), de = ke(0, 2, 0.1), ge = ke(0, 1, 0.05), je = Object.freeze(["none", "few", "some", "most", "custom"]), Fe = Object.freeze(["none", "block-level", "always"]), _e = Object.freeze(["plain", "ssml"]), He = Object.freeze(["none", "utterance", "block"]), qe = Object.freeze(["structure", "sentence"]), ft = Object.freeze([
|
|
2949
2977
|
"format",
|
|
2950
2978
|
"inlineContextualization",
|
|
2951
2979
|
"verbosity",
|
|
@@ -2954,13 +2982,13 @@ const we = (n, e, t) => Object.freeze({ range: Object.freeze([n, e]), step: t })
|
|
|
2954
2982
|
"language",
|
|
2955
2983
|
"segmentation"
|
|
2956
2984
|
]);
|
|
2957
|
-
function
|
|
2985
|
+
function Ge(n) {
|
|
2958
2986
|
return n == null || typeof n == "boolean" ? n : void 0;
|
|
2959
2987
|
}
|
|
2960
2988
|
function O(n, e) {
|
|
2961
2989
|
return n == null || e.includes(n) ? n : void 0;
|
|
2962
2990
|
}
|
|
2963
|
-
function
|
|
2991
|
+
function T(n, e) {
|
|
2964
2992
|
if (n == null) return n;
|
|
2965
2993
|
if (typeof n != "number" || Number.isNaN(n)) return;
|
|
2966
2994
|
const t = Math.min(...e), s = Math.max(...e);
|
|
@@ -2969,7 +2997,7 @@ function V(n, e) {
|
|
|
2969
2997
|
function Z(n) {
|
|
2970
2998
|
return n == null || Array.isArray(n) && n.every((e) => typeof e == "string") ? n : void 0;
|
|
2971
2999
|
}
|
|
2972
|
-
class
|
|
3000
|
+
class Js {
|
|
2973
3001
|
format;
|
|
2974
3002
|
inlineContextualization;
|
|
2975
3003
|
verbosity;
|
|
@@ -2983,7 +3011,7 @@ class Ws {
|
|
|
2983
3011
|
pitch;
|
|
2984
3012
|
volume;
|
|
2985
3013
|
constructor(e = {}) {
|
|
2986
|
-
this.format = O(e.format,
|
|
3014
|
+
this.format = O(e.format, _e) ?? "plain", this.inlineContextualization = Ge(e.inlineContextualization) ?? !1, this.verbosity = O(e.verbosity, je) ?? "few", this.skip = Z(e.skip) ?? [], this.contextualize = Z(e.contextualize) ?? [], this.language = O(e.language, Fe) ?? "block-level", this.segmentation = O(e.segmentation, qe) ?? "structure", this.pauseDuration = T(e.pauseDuration, ue.range) ?? 300, this.autoPause = O(e.autoPause, He) ?? "none", this.rate = T(e.rate, he.range) ?? 1, this.pitch = T(e.pitch, de.range) ?? 1, this.volume = T(e.volume, ge.range) ?? 1;
|
|
2987
3015
|
}
|
|
2988
3016
|
}
|
|
2989
3017
|
class Y {
|
|
@@ -3000,7 +3028,7 @@ class Y {
|
|
|
3000
3028
|
pitch;
|
|
3001
3029
|
volume;
|
|
3002
3030
|
constructor(e = {}) {
|
|
3003
|
-
this.format = O(e.format,
|
|
3031
|
+
this.format = O(e.format, _e), this.inlineContextualization = Ge(e.inlineContextualization), this.verbosity = O(e.verbosity, je), this.skip = Z(e.skip), this.contextualize = Z(e.contextualize), this.language = O(e.language, Fe), this.segmentation = O(e.segmentation, qe), this.pauseDuration = T(e.pauseDuration, ue.range), this.autoPause = O(e.autoPause, He), this.rate = T(e.rate, he.range), this.pitch = T(e.pitch, de.range), this.volume = T(e.volume, ge.range);
|
|
3004
3032
|
}
|
|
3005
3033
|
merging(e) {
|
|
3006
3034
|
const t = { ...this };
|
|
@@ -3009,7 +3037,7 @@ class Y {
|
|
|
3009
3037
|
return new Y(t);
|
|
3010
3038
|
}
|
|
3011
3039
|
}
|
|
3012
|
-
class
|
|
3040
|
+
class Ce {
|
|
3013
3041
|
_value;
|
|
3014
3042
|
_effectiveValue;
|
|
3015
3043
|
_isEffective;
|
|
@@ -3038,7 +3066,7 @@ class ke {
|
|
|
3038
3066
|
this._value = null, this._onChange(this._value);
|
|
3039
3067
|
}
|
|
3040
3068
|
}
|
|
3041
|
-
class
|
|
3069
|
+
class $ extends Ce {
|
|
3042
3070
|
_supportedValues;
|
|
3043
3071
|
constructor({
|
|
3044
3072
|
initialValue: e = null,
|
|
@@ -3061,9 +3089,9 @@ class G extends ke {
|
|
|
3061
3089
|
return this._supportedValues;
|
|
3062
3090
|
}
|
|
3063
3091
|
}
|
|
3064
|
-
class
|
|
3092
|
+
class Zs extends Ce {
|
|
3065
3093
|
set value(e) {
|
|
3066
|
-
if (e != null &&
|
|
3094
|
+
if (e != null && Ge(e) === void 0)
|
|
3067
3095
|
throw new Error(`Value '${String(e)}' is not a boolean.`);
|
|
3068
3096
|
this._value = e, this._onChange(this._value);
|
|
3069
3097
|
}
|
|
@@ -3071,7 +3099,7 @@ class Qs extends ke {
|
|
|
3071
3099
|
return this._value;
|
|
3072
3100
|
}
|
|
3073
3101
|
}
|
|
3074
|
-
class
|
|
3102
|
+
class pt extends Ce {
|
|
3075
3103
|
set value(e) {
|
|
3076
3104
|
if (e != null && Z(e) === void 0)
|
|
3077
3105
|
throw new Error(`Value '${String(e)}' is not an array of strings.`);
|
|
@@ -3081,7 +3109,7 @@ class ft extends ke {
|
|
|
3081
3109
|
return this._value;
|
|
3082
3110
|
}
|
|
3083
3111
|
}
|
|
3084
|
-
class
|
|
3112
|
+
class re extends Ce {
|
|
3085
3113
|
_supportedRange;
|
|
3086
3114
|
_step;
|
|
3087
3115
|
_decimals;
|
|
@@ -3096,7 +3124,7 @@ class ae extends ke {
|
|
|
3096
3124
|
super({ initialValue: e, effectiveValue: t, isEffective: s, onChange: i }), this._supportedRange = a, this._step = r, this._decimals = this._step.toString().includes(".") ? this._step.toString().split(".")[1].length : 0;
|
|
3097
3125
|
}
|
|
3098
3126
|
set value(e) {
|
|
3099
|
-
if (e != null &&
|
|
3127
|
+
if (e != null && T(e, this._supportedRange) === void 0)
|
|
3100
3128
|
throw new Error(`Value '${String(e)}' is out of the supported range for this preference.`);
|
|
3101
3129
|
this._value = e, this._onChange(this._value);
|
|
3102
3130
|
}
|
|
@@ -3125,7 +3153,7 @@ class ae extends ke {
|
|
|
3125
3153
|
return e.toString();
|
|
3126
3154
|
}
|
|
3127
3155
|
}
|
|
3128
|
-
class
|
|
3156
|
+
class mt {
|
|
3129
3157
|
preferences;
|
|
3130
3158
|
settings;
|
|
3131
3159
|
// Cloned rather than aliased: edits made through this editor's setters
|
|
@@ -3157,16 +3185,16 @@ class pt {
|
|
|
3157
3185
|
this.preferences[e] = t;
|
|
3158
3186
|
}
|
|
3159
3187
|
get format() {
|
|
3160
|
-
return new
|
|
3188
|
+
return new $({
|
|
3161
3189
|
initialValue: this.preferences.format,
|
|
3162
3190
|
effectiveValue: this.settings.format,
|
|
3163
3191
|
isEffective: this.preferences.format != null,
|
|
3164
3192
|
onChange: (e) => this.updatePreference("format", e ?? null),
|
|
3165
|
-
supportedValues:
|
|
3193
|
+
supportedValues: _e
|
|
3166
3194
|
});
|
|
3167
3195
|
}
|
|
3168
3196
|
get inlineContextualization() {
|
|
3169
|
-
return new
|
|
3197
|
+
return new Zs({
|
|
3170
3198
|
initialValue: this.preferences.inlineContextualization,
|
|
3171
3199
|
effectiveValue: this.settings.inlineContextualization,
|
|
3172
3200
|
isEffective: this.preferences.inlineContextualization != null,
|
|
@@ -3174,16 +3202,16 @@ class pt {
|
|
|
3174
3202
|
});
|
|
3175
3203
|
}
|
|
3176
3204
|
get verbosity() {
|
|
3177
|
-
return new
|
|
3205
|
+
return new $({
|
|
3178
3206
|
initialValue: this.preferences.verbosity,
|
|
3179
3207
|
effectiveValue: this.settings.verbosity,
|
|
3180
3208
|
isEffective: this.preferences.verbosity != null,
|
|
3181
3209
|
onChange: (e) => this.updatePreference("verbosity", e ?? null),
|
|
3182
|
-
supportedValues:
|
|
3210
|
+
supportedValues: je
|
|
3183
3211
|
});
|
|
3184
3212
|
}
|
|
3185
3213
|
get skip() {
|
|
3186
|
-
return new
|
|
3214
|
+
return new pt({
|
|
3187
3215
|
initialValue: this.preferences.skip,
|
|
3188
3216
|
effectiveValue: this.settings.skip,
|
|
3189
3217
|
isEffective: this.preferences.skip != null,
|
|
@@ -3191,7 +3219,7 @@ class pt {
|
|
|
3191
3219
|
});
|
|
3192
3220
|
}
|
|
3193
3221
|
get contextualize() {
|
|
3194
|
-
return new
|
|
3222
|
+
return new pt({
|
|
3195
3223
|
initialValue: this.preferences.contextualize,
|
|
3196
3224
|
effectiveValue: this.settings.contextualize,
|
|
3197
3225
|
isEffective: this.preferences.contextualize != null,
|
|
@@ -3199,75 +3227,75 @@ class pt {
|
|
|
3199
3227
|
});
|
|
3200
3228
|
}
|
|
3201
3229
|
get language() {
|
|
3202
|
-
return new
|
|
3230
|
+
return new $({
|
|
3203
3231
|
initialValue: this.preferences.language,
|
|
3204
3232
|
effectiveValue: this.settings.language,
|
|
3205
3233
|
isEffective: this.preferences.language != null,
|
|
3206
3234
|
onChange: (e) => this.updatePreference("language", e ?? null),
|
|
3207
|
-
supportedValues:
|
|
3235
|
+
supportedValues: Fe
|
|
3208
3236
|
});
|
|
3209
3237
|
}
|
|
3210
3238
|
get segmentation() {
|
|
3211
|
-
return new
|
|
3239
|
+
return new $({
|
|
3212
3240
|
initialValue: this.preferences.segmentation,
|
|
3213
3241
|
effectiveValue: this.settings.segmentation,
|
|
3214
3242
|
isEffective: this.preferences.segmentation != null,
|
|
3215
3243
|
onChange: (e) => this.updatePreference("segmentation", e ?? null),
|
|
3216
|
-
supportedValues:
|
|
3244
|
+
supportedValues: qe
|
|
3217
3245
|
});
|
|
3218
3246
|
}
|
|
3219
3247
|
get pauseDuration() {
|
|
3220
|
-
return new
|
|
3248
|
+
return new re({
|
|
3221
3249
|
initialValue: this.preferences.pauseDuration,
|
|
3222
3250
|
effectiveValue: this.settings.pauseDuration,
|
|
3223
3251
|
isEffective: this.preferences.pauseDuration != null,
|
|
3224
3252
|
onChange: (e) => this.updatePreference("pauseDuration", e ?? null),
|
|
3225
|
-
supportedRange:
|
|
3226
|
-
step:
|
|
3253
|
+
supportedRange: ue.range,
|
|
3254
|
+
step: ue.step
|
|
3227
3255
|
});
|
|
3228
3256
|
}
|
|
3229
3257
|
get autoPause() {
|
|
3230
|
-
return new
|
|
3258
|
+
return new $({
|
|
3231
3259
|
initialValue: this.preferences.autoPause,
|
|
3232
3260
|
effectiveValue: this.settings.autoPause,
|
|
3233
3261
|
isEffective: this.preferences.autoPause != null,
|
|
3234
3262
|
onChange: (e) => this.updatePreference("autoPause", e ?? null),
|
|
3235
|
-
supportedValues:
|
|
3263
|
+
supportedValues: He
|
|
3236
3264
|
});
|
|
3237
3265
|
}
|
|
3238
3266
|
get rate() {
|
|
3239
|
-
return new
|
|
3267
|
+
return new re({
|
|
3240
3268
|
initialValue: this.preferences.rate,
|
|
3241
3269
|
effectiveValue: this.settings.rate,
|
|
3242
3270
|
isEffective: this.preferences.rate != null,
|
|
3243
3271
|
onChange: (e) => this.updatePreference("rate", e ?? null),
|
|
3244
|
-
supportedRange:
|
|
3245
|
-
step:
|
|
3272
|
+
supportedRange: he.range,
|
|
3273
|
+
step: he.step
|
|
3246
3274
|
});
|
|
3247
3275
|
}
|
|
3248
3276
|
get pitch() {
|
|
3249
|
-
return new
|
|
3277
|
+
return new re({
|
|
3250
3278
|
initialValue: this.preferences.pitch,
|
|
3251
3279
|
effectiveValue: this.settings.pitch,
|
|
3252
3280
|
isEffective: this.preferences.pitch != null,
|
|
3253
3281
|
onChange: (e) => this.updatePreference("pitch", e ?? null),
|
|
3254
|
-
supportedRange:
|
|
3255
|
-
step:
|
|
3282
|
+
supportedRange: de.range,
|
|
3283
|
+
step: de.step
|
|
3256
3284
|
});
|
|
3257
3285
|
}
|
|
3258
3286
|
get volume() {
|
|
3259
|
-
return new
|
|
3287
|
+
return new re({
|
|
3260
3288
|
initialValue: this.preferences.volume,
|
|
3261
3289
|
effectiveValue: this.settings.volume,
|
|
3262
3290
|
isEffective: this.preferences.volume != null,
|
|
3263
3291
|
onChange: (e) => this.updatePreference("volume", e ?? null),
|
|
3264
|
-
supportedRange:
|
|
3265
|
-
step:
|
|
3292
|
+
supportedRange: ge.range,
|
|
3293
|
+
step: ge.step
|
|
3266
3294
|
});
|
|
3267
3295
|
}
|
|
3268
3296
|
}
|
|
3269
|
-
const
|
|
3270
|
-
...
|
|
3297
|
+
const Xt = ["audio", "figure", "image", "math", "table", "video"], en = [
|
|
3298
|
+
...Xt,
|
|
3271
3299
|
"blockquote",
|
|
3272
3300
|
"chapter",
|
|
3273
3301
|
"cover",
|
|
@@ -3280,8 +3308,8 @@ const Yt = ["audio", "figure", "image", "math", "table", "video"], Xt = [
|
|
|
3280
3308
|
"rowheader",
|
|
3281
3309
|
"subtitle",
|
|
3282
3310
|
"tip"
|
|
3283
|
-
],
|
|
3284
|
-
...
|
|
3311
|
+
], Ys = [
|
|
3312
|
+
...en,
|
|
3285
3313
|
"abstract",
|
|
3286
3314
|
"acknowledgments",
|
|
3287
3315
|
"afterword",
|
|
@@ -3325,7 +3353,7 @@ const Yt = ["audio", "figure", "image", "math", "table", "video"], Xt = [
|
|
|
3325
3353
|
"separator",
|
|
3326
3354
|
"summary",
|
|
3327
3355
|
"term"
|
|
3328
|
-
],
|
|
3356
|
+
], Xs = {
|
|
3329
3357
|
none: /* @__PURE__ */ new Set([
|
|
3330
3358
|
"aside",
|
|
3331
3359
|
"audio",
|
|
@@ -3393,28 +3421,28 @@ const Yt = ["audio", "figure", "image", "math", "table", "video"], Xt = [
|
|
|
3393
3421
|
"toc"
|
|
3394
3422
|
]),
|
|
3395
3423
|
most: /* @__PURE__ */ new Set(["landmarks", "loa", "loi", "lot", "lov", "toc"])
|
|
3396
|
-
},
|
|
3424
|
+
}, ei = {
|
|
3397
3425
|
none: /* @__PURE__ */ new Set(),
|
|
3398
|
-
few: new Set(
|
|
3399
|
-
some: new Set(
|
|
3400
|
-
most: new Set(
|
|
3401
|
-
},
|
|
3426
|
+
few: new Set(Xt),
|
|
3427
|
+
some: new Set(en),
|
|
3428
|
+
most: new Set(Ys)
|
|
3429
|
+
}, ze = {
|
|
3402
3430
|
table: { few: "inline", some: "block", most: "block" }
|
|
3403
3431
|
};
|
|
3404
|
-
function
|
|
3432
|
+
function oe(n) {
|
|
3405
3433
|
const e = {};
|
|
3406
|
-
for (const t of Object.keys(
|
|
3407
|
-
e[t] =
|
|
3434
|
+
for (const t of Object.keys(ze))
|
|
3435
|
+
e[t] = ze[t]?.[n] ?? "inline";
|
|
3408
3436
|
return e;
|
|
3409
3437
|
}
|
|
3410
|
-
const
|
|
3411
|
-
none:
|
|
3412
|
-
few:
|
|
3413
|
-
some:
|
|
3414
|
-
most:
|
|
3415
|
-
},
|
|
3416
|
-
function
|
|
3417
|
-
const t = n === "custom" ? {} :
|
|
3438
|
+
const ti = {
|
|
3439
|
+
none: oe("none"),
|
|
3440
|
+
few: oe("few"),
|
|
3441
|
+
some: oe("some"),
|
|
3442
|
+
most: oe("most")
|
|
3443
|
+
}, ca = Object.keys(ze);
|
|
3444
|
+
function ni(n, e) {
|
|
3445
|
+
const t = n === "custom" ? {} : ti[n];
|
|
3418
3446
|
if (!e) return t;
|
|
3419
3447
|
const s = { ...t };
|
|
3420
3448
|
for (const i of Object.keys(e)) {
|
|
@@ -3423,7 +3451,7 @@ function ei(n, e) {
|
|
|
3423
3451
|
}
|
|
3424
3452
|
return s;
|
|
3425
3453
|
}
|
|
3426
|
-
class
|
|
3454
|
+
class vt {
|
|
3427
3455
|
format;
|
|
3428
3456
|
inlineContextualization;
|
|
3429
3457
|
verbosity;
|
|
@@ -3437,57 +3465,57 @@ class mt {
|
|
|
3437
3465
|
pitch;
|
|
3438
3466
|
volume;
|
|
3439
3467
|
constructor(e, t) {
|
|
3440
|
-
this.format = e.format ?? t.format, this.inlineContextualization = e.inlineContextualization ?? t.inlineContextualization, this.verbosity = e.verbosity ?? t.verbosity, this.verbosity === "custom" ? (this.skip = e.skip ?? t.skip, this.contextualize = e.contextualize ?? t.contextualize) : (this.skip = [...
|
|
3468
|
+
this.format = e.format ?? t.format, this.inlineContextualization = e.inlineContextualization ?? t.inlineContextualization, this.verbosity = e.verbosity ?? t.verbosity, this.verbosity === "custom" ? (this.skip = e.skip ?? t.skip, this.contextualize = e.contextualize ?? t.contextualize) : (this.skip = [...Xs[this.verbosity]], this.contextualize = [...ei[this.verbosity]]), this.language = e.language ?? t.language, this.segmentation = e.segmentation ?? t.segmentation, this.pauseDuration = e.pauseDuration ?? t.pauseDuration, this.autoPause = e.autoPause ?? t.autoPause, this.rate = e.rate ?? t.rate, this.pitch = e.pitch ?? t.pitch, this.volume = e.volume ?? t.volume;
|
|
3441
3469
|
}
|
|
3442
3470
|
}
|
|
3443
|
-
const
|
|
3444
|
-
function
|
|
3445
|
-
|
|
3471
|
+
const yt = /* @__PURE__ */ new WeakMap(), tn = /* @__PURE__ */ new WeakMap();
|
|
3472
|
+
function St(n, e) {
|
|
3473
|
+
tn.set(n, e);
|
|
3446
3474
|
}
|
|
3447
|
-
const
|
|
3448
|
-
function
|
|
3449
|
-
return
|
|
3475
|
+
const nn = /* @__PURE__ */ new WeakSet();
|
|
3476
|
+
function bt(n) {
|
|
3477
|
+
return nn.add(n), n;
|
|
3450
3478
|
}
|
|
3451
|
-
function
|
|
3452
|
-
const s =
|
|
3479
|
+
function si(n, e, t) {
|
|
3480
|
+
const s = tn.get(n);
|
|
3453
3481
|
if (s) {
|
|
3454
|
-
const u =
|
|
3455
|
-
e = u, t = Math.max(0,
|
|
3482
|
+
const u = ct(s.map, e), g = ct(s.map, e + t);
|
|
3483
|
+
e = u, t = Math.max(0, g - u);
|
|
3456
3484
|
}
|
|
3457
3485
|
const i = n.offsets, a = !n.plain && !!n.ssml, r = s?.plain ?? n.plain ?? (n.ssml ? z(n.ssml) : "");
|
|
3458
3486
|
if (!i?.length || !r) return;
|
|
3459
|
-
const o =
|
|
3487
|
+
const o = yt.get(n), l = o !== void 0 && e >= o.cursor;
|
|
3460
3488
|
let c = l ? o.cursor : 0;
|
|
3461
3489
|
for (let u = l ? o.pieceIndex : 0; u < i.length; u++) {
|
|
3462
|
-
const
|
|
3463
|
-
if (!
|
|
3464
|
-
const f = r.indexOf(
|
|
3490
|
+
const g = i[u], h = g.locate.text?.highlight, d = h ? a ? z(h) : h : r.slice(c);
|
|
3491
|
+
if (!d) continue;
|
|
3492
|
+
const f = r.indexOf(d, c);
|
|
3465
3493
|
if (f === -1) continue;
|
|
3466
|
-
const p = f +
|
|
3494
|
+
const p = f + d.length;
|
|
3467
3495
|
if (e >= f && e < p) {
|
|
3468
|
-
if (
|
|
3469
|
-
|
|
3470
|
-
const m = e - f, S =
|
|
3496
|
+
if (nn.has(g.locate)) return;
|
|
3497
|
+
yt.set(n, { pieceIndex: u, cursor: c });
|
|
3498
|
+
const m = e - f, S = d.substring(m, Math.min(m + t, d.length));
|
|
3471
3499
|
return { locate: {
|
|
3472
|
-
...
|
|
3500
|
+
...g.locate,
|
|
3473
3501
|
domRange: void 0,
|
|
3474
3502
|
text: {
|
|
3475
3503
|
highlight: S,
|
|
3476
|
-
before:
|
|
3477
|
-
after:
|
|
3504
|
+
before: d.substring(0, m),
|
|
3505
|
+
after: d.substring(m + S.length)
|
|
3478
3506
|
}
|
|
3479
3507
|
}, word: S };
|
|
3480
3508
|
}
|
|
3481
3509
|
c = p;
|
|
3482
3510
|
}
|
|
3483
3511
|
}
|
|
3484
|
-
function
|
|
3512
|
+
function ii(n, e) {
|
|
3485
3513
|
return e === "sentence" && n.offsets?.length ? n.offsets.map((t) => t.locate) : n.locate ? [n.locate] : [];
|
|
3486
3514
|
}
|
|
3487
3515
|
function U(n) {
|
|
3488
3516
|
return { pattern: new RegExp(`(\\d+)\\s?u${n}\\b`, "g"), replace: (e, t) => `${t}µ${n}` };
|
|
3489
3517
|
}
|
|
3490
|
-
const
|
|
3518
|
+
const ai = {
|
|
3491
3519
|
"1/4": "¼",
|
|
3492
3520
|
"1/2": "½",
|
|
3493
3521
|
"3/4": "¾",
|
|
@@ -3507,8 +3535,8 @@ const si = {
|
|
|
3507
3535
|
"5/8": "⅝",
|
|
3508
3536
|
"7/8": "⅞",
|
|
3509
3537
|
"0/3": "↉"
|
|
3510
|
-
},
|
|
3511
|
-
...
|
|
3538
|
+
}, ri = {
|
|
3539
|
+
...ai,
|
|
3512
3540
|
// Rejects "(c)" directly preceded by "(a)"/"(b)" (a lettered list, not a copyright notice).
|
|
3513
3541
|
"(c)": { pattern: new RegExp("(?<!\\([ab]\\)\\s{0,3})\\(c\\)", "g"), replace: "©" },
|
|
3514
3542
|
"(C)": { pattern: new RegExp("(?<!\\([AB]\\)\\s{0,3})\\(C\\)", "g"), replace: "©" },
|
|
@@ -3534,18 +3562,18 @@ const si = {
|
|
|
3534
3562
|
// convention for pronunciation, but drop the real prime marks silently.
|
|
3535
3563
|
"′": "'",
|
|
3536
3564
|
"″": '"'
|
|
3537
|
-
},
|
|
3538
|
-
speech:
|
|
3539
|
-
},
|
|
3540
|
-
async function
|
|
3541
|
-
const e =
|
|
3565
|
+
}, oi = { contextualizations: { abstract: { block: { start: "Start of the abstract.", end: "End of the abstract." } }, acknowledgments: { block: { start: "Start of the acknowledgments.", end: "End of the acknowledgments." } }, afterword: { block: { start: "Start of the afterword.", end: "End of the afterword." } }, appendix: { block: { start: "Start of the appendix.", end: "End of the appendix." } }, aside: { block: { start: "Start of the aside.", end: "End of the aside." } }, audio: { inline: { labelled: "Audio with a label: {{ description }}", unlabelled: "Audio with no label." } }, bibliography: { block: { start: "Start of the bibliography.", end: "End of the bibliography." } }, blockquote: { inline: "Blockquote." }, cell: { inline: { withHeader: "{{ header }}: {{ value }}", withoutHeader: "{{ value }}" } }, chapter: { block: { start: "Start of the chapter.", end: "End of the chapter." } }, colophon: { inline: "Colophon." }, complementary: { block: { start: "Start of the complementary content.", end: "End of the complementary content." } }, conclusion: { block: { start: "Start of the conclusion.", end: "End of the conclusion." } }, cover: { inline: { labelled: "Cover with a label: {{ description }}", unlabelled: "Cover with no label." } }, credit: { inline: "Credit." }, credits: { block: { start: "Start of the credits.", end: "End of the credits." } }, dedication: { inline: "Dedication." }, definition: { inline: "Definition." }, details: { block: { start: "Start of the disclosure.", end: "End of the disclosure." } }, endnotes: { block: { start: "Start of the endnotes.", end: "End of the endnotes." } }, epigraph: { inline: "Epigraph." }, epilogue: { block: { start: "Start of the epilogue.", end: "End of the epilogue." } }, errata: { block: { start: "Start of the errata.", end: "End of the errata." } }, example: { block: { start: "Start of the example.", end: "End of the example." } }, figure: { inline: "Figure: {{ description }}" }, footnote: { block: { start: "Start of the footnote.", end: "End of the footnote." } }, foreword: { block: { start: "Start of the foreword.", end: "End of the foreword." } }, glossary: { block: { start: "Start of the glossary.", end: "End of the glossary." } }, heading1: { inline: "Heading level 1." }, heading2: { inline: "Heading level 2." }, heading3: { inline: "Heading level 3." }, heading4: { inline: "Heading level 4." }, heading5: { inline: "Heading level 5." }, heading6: { inline: "Heading level 6." }, image: { inline: { labelled: "Image with a label: {{ description }}", unlabelled: "Image with no label." } }, index: { block: { start: "Start of the index.", end: "End of the index." } }, introduction: { block: { start: "Start of the introduction.", end: "End of the introduction." } }, list: { block: { start: "Start of the list.", end: "End of the list." } }, listItem: { inline: "List item." }, math: { inline: { labelled: "{{ description }}", unlabelled: "Math formula with no label." } }, notice: { inline: "Notice." }, pagebreak: { inline: "Pagebreak." }, pagelist: { block: { start: "Start of the page list.", end: "End of the page list." } }, part: { inline: "Part." }, preface: { block: { start: "Start of the preface.", end: "End of the preface." } }, prologue: { block: { start: "Start of the prologue.", end: "End of the prologue." } }, pullquote: { inline: "Pullquote." }, qna: { block: { start: "Start of the questions and answers.", end: "End of the questions and answers." } }, row: { inline: "Row: {{ count }}" }, rowheader: { inline: { withHeader: "{{ header }}: {{ value }}", withoutHeader: "{{ value }}" } }, separator: { inline: "Separator." }, subtitle: { inline: "Subtitle." }, summary: { inline: "Summary." }, table: { block: { end: "End of the table.", start: { labelled: "Table: {{ description }}. {{ lines }}. {{ columns }}.", unlabelled: "Table. {{ lines }}. {{ columns }}." } }, inline: { labelled: "Table: {{ description }}. {{ lines }}. {{ columns }}.", unlabelled: "Table. {{ lines }}. {{ columns }}." }, parts: { columns_one: "1 column", columns_other: "{{ count }} columns", lines_one: "1 line", lines_other: "{{ count }} lines" } }, term: { inline: "Term." }, tip: { inline: "Tip." }, video: { inline: { labelled: "Video with a label: {{ description }}", unlabelled: "Video with no label." } } } }, li = {
|
|
3566
|
+
speech: oi
|
|
3567
|
+
}, sn = li.speech.contextualizations, wt = { en: sn }, ci = {};
|
|
3568
|
+
async function ui(n) {
|
|
3569
|
+
const e = wt[n];
|
|
3542
3570
|
if (e) return e;
|
|
3543
|
-
const t =
|
|
3544
|
-
if (!t) return
|
|
3571
|
+
const t = ci[n];
|
|
3572
|
+
if (!t) return sn;
|
|
3545
3573
|
const s = (await t()).speech.contextualizations;
|
|
3546
|
-
return
|
|
3574
|
+
return wt[n] = s, s;
|
|
3547
3575
|
}
|
|
3548
|
-
const
|
|
3576
|
+
const hi = {
|
|
3549
3577
|
de: ["A.", "A.M.", "Abs.", "Abt.", "Abw.", "Adj.", "Adr.", "Akt.", "Allg.", "Alt.", "App.", "Apr.", "Art.", "Aug.", "Ausg.", "Ausschl.", "B.", "Bed.", "Ben.", "Ber.", "Best.", "Bibl.", "C.", "Ca.", "Chin.", "Chr.", "Co.", "D.", "D. h.", "Dat.", "Dez.", "Di.", "Dim.", "Dipl.-Ing.", "Dipl.-Kfm.", "Dir.", "Do.", "Dr.", "Dtzd.", "Einh.", "Erf.", "Evtl.", "F.", "F.f.", "Fa.", "Fam.", "Feb.", "Fn.", "Folg.", "Forts. f.", "Fr.", "Frl.", "G.", "Gebr.", "Gem.", "Geograph.", "Ges.", "Gesch.", "Ggf.", "Hbf.", "Hptst.", "Hr.", "Hrn.", "Hrsg.", "I.", "Inc.", "Ing.", "Inh.", "Int.", "J.", "J.D.", "Jahrh.", "Jan.", "Jr.", "Kap.", "Kfm.", "Kl.", "Konv.", "Kop.", "L.", "Ltd.", "M.", "Max.", "Mi.", "Min.", "Mind.", "Mio.", "Mo.", "Mod.", "Mrd.", "Msp.", "N.", "Nov.", "Nr.", "O.", "Obj.", "Okt.", "Op.", "P.", "P.M.", "PIN.", "Pfd.", "Phys.", "Port.", "Prot.", "Proz.", "Qu.", "R.", "Rd.", "Reg.", "Reg.-Bez.", "Rel.", "Rep.", "S.A.", "Sa.", "Schr.", "Sek.", "Sep.", "Sept.", "So.", "Spezif.", "St.", "StR.", "Std.", "Str.", "T.", "Tel.", "Temp.", "Test.", "Trans.", "Tägl.", "U.", "U. U.", "U.S.", "U.S.A.", "U.U.", "Urspr.", "Ursprüngl.", "Verf.", "Vgl.", "W.", "Wg.", "Y.", "Z.", "Z. B.", "Z. Zt.", "Ztr.", "a.D.", "a.M.", "a.Rh.", "a.a.O.", "a.a.S.", "am.", "amtl.", "b.", "beil.", "d.J.", "d.Ä.", "e.V.", "e.Wz.", "e.h.", "ehem.", "eigtl.", "einschl.", "entspr.", "erw.", "ev.", "evtl.", "exkl.", "frz.", "geb.", "gedr.", "gek.", "gesch.", "gest.", "ggf.", "ggfs.", "hpts.", "i.A.", "i.B.", "i.H.", "i.J.", "i.R.", "i.V.", "inkl.", "jew.", "jhrl.", "k. u. k.", "k.u.k.", "kath.", "kfm.", "kgl.", "led.", "m.E.", "m.W.", "mtl.", "möbl.", "n. Chr.", "n.u.Z.", "näml.", "o.A.", "o.B.", "o.g.", "od.", "p.Adr.", "r.", "röm.", "röm.-kath.", "s.", "s.a.", "schles.", "schweiz.", "schwäb.", "sog.", "südd.", "tägl.", "u.", "u. Z.", "u.A.w.g.", "u.U.", "u.a.", "u.v.a.", "u.Ä.", "u.ä.", "v. Chr.", "v. H.", "v. u. Z.", "v.Chr.", "v.H.", "v.R.w.", "v.T.", "v.u.Z.", "verh.", "verw.", "vgl.", "z.", "z.B.", "z.Hd.", "z.Z.", "zzgl.", "österr."],
|
|
3550
3578
|
en: ["A.D.", "A.I.", "A.M.", "A.S.", "AA.", "AB.", "Abs.", "Adj.", "Adv.", "Alt.", "Approx.", "Aug.", "B.V.", "C.F.", "C.O.D.", "Capt.", "Col.", "Comm.", "Conn.", "Cont.", "D.A.", "D.C.", "DC.", "DR.", "Dec.", "Def.", "Dept.", "Diff.", "Dr.", "E.G.", "E.g.", "Ed.", "Est.", "Etc.", "Ex.", "Exec.", "Feb.", "Fn.", "Fri.", "Hon.B.A.", "I.", "I.D.", "I.T.", "I.e.", "J.B.", "J.D.", "J.K.", "Jan.", "Jun.", "K.R.", "L.A.", "L.P.", "Lev.", "Lib.", "Lt.", "Lt.Cdr.", "M.", "M.I.T.", "M.R.", "M.T.", "MR.", "Maj.", "Mar.", "Mart.", "Mb.", "Md.", "Mgr.", "Min.", "Misc.", "Mr.", "Mrs.", "Ms.", "Mt.", "N.V.", "N.Y.", "Nov.", "Nr.", "Num.", "Op.", "Org.", "P.M.", "P.O.", "P.V.", "PP.", "Ph.D.", "Phys.", "Prof.", "Pvt.", "R.L.", "R.T.", "Rep.", "Rev.", "S.A.", "S.A.R.", "S.E.", "S.p.A.", "Sep.", "Sept.", "Sgt.", "Sq.", "St.", "U.S.", "U.S.A.", "U.S.C.", "VS.", "Yr.", "a.m.", "d.", "dr.", "exec.", "pp.", "vs."],
|
|
3551
3579
|
es: ["A.C.", "AA.", "All.", "Ant.", "Av.", "Avda.", "Bien.", "C.", "C.P.", "C.S.", "C.V.", "CA.", "Col.", "Comm.", "Corp.", "Cía.", "D.", "DC.", "Da.", "Desc.", "Desv.", "Dr.", "Dra.", "Drs.", "Dto.", "Dª.", "Dña.", "Em.", "Emm.", "Exc.", "Excma.", "Excmas.", "Excmo.", "Excmos.", "Exma.", "Exmas.", "Exmo.", "Exmos.", "FF.CC.", "Fabric.", "Fr.", "H.P.", "Id.", "Ilma.", "Ilmas.", "Ilmo.", "Ilmos.", "Inc.", "JJ.OO.", "K.", "Kit.", "Korn.", "L.", "Lcda.", "Lcdo.", "Lda.", "Ldo.", "Lic.", "Ltd.", "Ltda.", "Ltdo.", "M.", "MM.", "Mons.", "Mr.", "Mrs.", "O.M.", "PP.", "R.D.", "R.U.", "RAM.", "RR.HH.", "Rdo.", "Rdos.", "Reg.", "Rev.", "Rol.", "Rvdmo.", "Rvdmos.", "Rvdo.", "Rvdos.", "SA.", "SS.AA.", "SS.MM.", "Sdad.", "Seg.", "Sol.", "Sr.", "Sra.", "Sras.", "Sres.", "Srta.", "Srtas.", "Sta.", "Sto.", "Trab.", "U.S.", "U.S.A.", "Var.", "Vda.", "a. C.", "a. e. c.", "abr.", "afma.", "afmas.", "afmo.", "afmos.", "ago.", "bco.", "bol.", "c/c.", "cap.", "cf.", "cfr.", "col.", "d. C.", "depto.", "deptos.", "dic.", "doc.", "dom.", "dpto.", "dptos.", "dtor.", "e. c.", "e.g.", "ed.", "ej.", "ene.", "feb.", "fig.", "figs.", "fund.", "hnos.", "jue.", "jul.", "jun.", "licda.", "licdo.", "lun.", "mar.", "may.", "mié.", "ms.", "mss.", "mtro.", "nov.", "ntra.", "ntro.", "oct.", "p.ej.", "prof.", "prov.", "sept.", "sras.", "sres.", "srs.", "ss.", "sáb.", "trad.", "v.gr.", "vid.", "vie.", "vs."],
|
|
@@ -3555,39 +3583,39 @@ const wt = {
|
|
|
3555
3583
|
ru: ["авг.", "апр.", "дек.", "до н. э.", "кв.", "н. э.", "н.э.", "нояб.", "окт.", "отд.", "проф.", "руб.", "сент.", "тел.", "тыс.", "ул.", "февр.", "янв."],
|
|
3556
3584
|
th: ["ค.ศ."]
|
|
3557
3585
|
};
|
|
3558
|
-
function
|
|
3586
|
+
function Pe(n, e, t) {
|
|
3559
3587
|
let s = t;
|
|
3560
3588
|
for (; s > e && /\s/.test(n[s - 1]); ) s--;
|
|
3561
3589
|
return s;
|
|
3562
3590
|
}
|
|
3563
|
-
const
|
|
3564
|
-
function
|
|
3591
|
+
const di = /[\s([{"'“‘]/;
|
|
3592
|
+
function gi(n, e) {
|
|
3565
3593
|
for (const t of e) {
|
|
3566
3594
|
if (n.length < t.length || !n.endsWith(t)) continue;
|
|
3567
3595
|
const s = n.length - t.length - 1;
|
|
3568
|
-
if (s < 0 ||
|
|
3596
|
+
if (s < 0 || di.test(n[s])) return !0;
|
|
3569
3597
|
}
|
|
3570
3598
|
return !1;
|
|
3571
3599
|
}
|
|
3572
|
-
function
|
|
3600
|
+
function fi(n) {
|
|
3573
3601
|
let e = 0;
|
|
3574
3602
|
for (const t of n)
|
|
3575
3603
|
if (new RegExp("\\p{L}", "u").test(t) && e++, e >= 2) return !0;
|
|
3576
3604
|
return !1;
|
|
3577
3605
|
}
|
|
3578
|
-
function
|
|
3606
|
+
function pi(n) {
|
|
3579
3607
|
return /\.{3,}$/.test(n);
|
|
3580
3608
|
}
|
|
3581
|
-
function
|
|
3609
|
+
function mi(n, e, t, s) {
|
|
3582
3610
|
if (s === "“") return !0;
|
|
3583
3611
|
if (s !== '"') return !1;
|
|
3584
3612
|
let i = 0;
|
|
3585
3613
|
for (let a = e; a < t; a++) n[a] === '"' && i++;
|
|
3586
3614
|
return i % 2 === 1;
|
|
3587
3615
|
}
|
|
3588
|
-
const
|
|
3589
|
-
function
|
|
3590
|
-
const t = [...n.matchAll(
|
|
3616
|
+
const vi = new RegExp(`[.!?][”"'’)\\]]*\\s+—\\s+(?=\\p{Lu})`, "gu");
|
|
3617
|
+
function yi(n, e) {
|
|
3618
|
+
const t = [...n.matchAll(vi)].map((i) => i.index + i[0].length);
|
|
3591
3619
|
if (t.length === 0) return e;
|
|
3592
3620
|
const s = [];
|
|
3593
3621
|
for (const i of e) {
|
|
@@ -3598,40 +3626,40 @@ function pi(n, e) {
|
|
|
3598
3626
|
}
|
|
3599
3627
|
return s;
|
|
3600
3628
|
}
|
|
3601
|
-
function
|
|
3602
|
-
const s =
|
|
3629
|
+
function Si(n, e, t) {
|
|
3630
|
+
const s = yi(n, e).map((a) => ({ ...a }));
|
|
3603
3631
|
for (let a = 0; a < s.length - 1; a++) {
|
|
3604
|
-
const r =
|
|
3632
|
+
const r = Pe(n, s[a].start, s[a].end);
|
|
3605
3633
|
if (r !== s[a].end || r <= s[a].start) continue;
|
|
3606
3634
|
const o = n[r - 1];
|
|
3607
|
-
|
|
3635
|
+
mi(n, s[a].start, r, o) && (s[a].end -= 1, s[a + 1].start -= 1);
|
|
3608
3636
|
}
|
|
3609
3637
|
const i = [];
|
|
3610
3638
|
for (const a of s) {
|
|
3611
3639
|
let r = a;
|
|
3612
3640
|
for (; i.length > 0; ) {
|
|
3613
|
-
const o = i[i.length - 1], l =
|
|
3614
|
-
if (!
|
|
3641
|
+
const o = i[i.length - 1], l = Pe(n, o.start, o.end), c = n.slice(o.start, l);
|
|
3642
|
+
if (!gi(c, t) && fi(c) && !pi(c)) break;
|
|
3615
3643
|
i.pop(), r = { start: o.start, end: r.end };
|
|
3616
3644
|
}
|
|
3617
3645
|
i.push(r);
|
|
3618
3646
|
}
|
|
3619
3647
|
return i.map((a) => {
|
|
3620
|
-
const r =
|
|
3648
|
+
const r = Pe(n, a.start, a.end);
|
|
3621
3649
|
return { text: n.slice(a.start, r), start: a.start, end: a.end, contentEnd: r };
|
|
3622
3650
|
});
|
|
3623
3651
|
}
|
|
3624
3652
|
const kt = /* @__PURE__ */ new Map();
|
|
3625
|
-
function
|
|
3653
|
+
function bi(n) {
|
|
3626
3654
|
let e = kt.get(n);
|
|
3627
3655
|
return e || (e = new Intl.Segmenter(n, { granularity: "sentence" }), kt.set(n, e)), e;
|
|
3628
3656
|
}
|
|
3629
|
-
async function
|
|
3657
|
+
async function wi(n, e, t) {
|
|
3630
3658
|
if (e === "") return [];
|
|
3631
|
-
const i = [...
|
|
3632
|
-
return
|
|
3659
|
+
const i = [...bi(n).segment(e)].map((o) => ({ start: o.index, end: o.index + o.segment.length })), a = ve(hi, n) ?? [], r = t ? [...a, ...t] : a;
|
|
3660
|
+
return Si(e, i, r);
|
|
3633
3661
|
}
|
|
3634
|
-
const
|
|
3662
|
+
const ua = [
|
|
3635
3663
|
"aside",
|
|
3636
3664
|
"audio",
|
|
3637
3665
|
"bibliography",
|
|
@@ -3657,7 +3685,7 @@ const ra = [
|
|
|
3657
3685
|
"table",
|
|
3658
3686
|
"toc",
|
|
3659
3687
|
"video"
|
|
3660
|
-
],
|
|
3688
|
+
], ki = [
|
|
3661
3689
|
// Headings
|
|
3662
3690
|
"heading1",
|
|
3663
3691
|
"heading2",
|
|
@@ -3715,49 +3743,49 @@ const ra = [
|
|
|
3715
3743
|
"section",
|
|
3716
3744
|
"summary",
|
|
3717
3745
|
"tip"
|
|
3718
|
-
],
|
|
3746
|
+
], Ci = {
|
|
3719
3747
|
footnote: { drops: ["aside"], unconditional: !0 },
|
|
3720
3748
|
cover: { drops: ["image"] },
|
|
3721
3749
|
pullquote: { drops: ["blockquote", "aside"] },
|
|
3722
3750
|
epigraph: { drops: ["blockquote"] }
|
|
3723
|
-
},
|
|
3724
|
-
function
|
|
3725
|
-
const t =
|
|
3751
|
+
}, Ei = ["noteref", "pagebreak"], Ri = ["audio", "video", "image", "figure", "math", "table", "cover"], Ii = ["cell", "rowheader"], Pi = ["separator"], Ct = new Set(ki), Ai = new Set(Ei), xi = new Set(Ri), an = new Set(Ii), Li = new Set(Pi);
|
|
3752
|
+
function Oi(n, e) {
|
|
3753
|
+
const t = En.createInstance();
|
|
3726
3754
|
return t.init({
|
|
3727
3755
|
lng: n,
|
|
3728
3756
|
resources: { [n]: { translation: e } },
|
|
3729
3757
|
interpolation: { escapeValue: !1 }
|
|
3730
3758
|
}), t;
|
|
3731
3759
|
}
|
|
3732
|
-
function
|
|
3760
|
+
function Ui(n, e, t) {
|
|
3733
3761
|
if (!e) return n;
|
|
3734
3762
|
const s = { ...n };
|
|
3735
3763
|
for (const i of Object.keys(e))
|
|
3736
3764
|
s[i] = t(n[i], e[i]);
|
|
3737
3765
|
return s;
|
|
3738
3766
|
}
|
|
3739
|
-
function
|
|
3767
|
+
function rn(n, e) {
|
|
3740
3768
|
if (typeof e == "string" || typeof n != "object") return e;
|
|
3741
3769
|
const t = { ...n };
|
|
3742
3770
|
for (const s of Object.keys(e))
|
|
3743
|
-
t[s] =
|
|
3771
|
+
t[s] = rn(n[s], e[s]);
|
|
3744
3772
|
return t;
|
|
3745
3773
|
}
|
|
3746
|
-
function
|
|
3747
|
-
return
|
|
3774
|
+
function Vi(n, e) {
|
|
3775
|
+
return Ui(n, e, rn);
|
|
3748
3776
|
}
|
|
3749
|
-
function
|
|
3777
|
+
function on(n, e = [], t = /* @__PURE__ */ new Map()) {
|
|
3750
3778
|
for (const s of n)
|
|
3751
|
-
t.set(s, e), s.children &&
|
|
3779
|
+
t.set(s, e), s.children && on(s.children, [s, ...e], t);
|
|
3752
3780
|
return t;
|
|
3753
3781
|
}
|
|
3754
|
-
async function
|
|
3755
|
-
const t = e.contextualizationLocale ?? "en", s =
|
|
3756
|
-
await
|
|
3782
|
+
async function ln(n, e) {
|
|
3783
|
+
const t = e.contextualizationLocale ?? "en", s = Vi(
|
|
3784
|
+
await ui(t),
|
|
3757
3785
|
e.contextualization?.contextualizations
|
|
3758
3786
|
);
|
|
3759
3787
|
return {
|
|
3760
|
-
i18n:
|
|
3788
|
+
i18n: Oi(t, s),
|
|
3761
3789
|
skip: new Set(e.skip ?? []),
|
|
3762
3790
|
contextualize: new Set(e.contextualize ?? []),
|
|
3763
3791
|
contextualizationShapes: e.contextualization?.shapes ?? {},
|
|
@@ -3770,26 +3798,26 @@ async function on(n, e) {
|
|
|
3770
3798
|
// (Intl.Segmenter has no built-in equivalent of its own) — this is only
|
|
3771
3799
|
// the caller's own additive extras, per `SegmentationOptions.suppressions`.
|
|
3772
3800
|
segmentationSuppressions: e.segmentation?.suppressions ?? {},
|
|
3773
|
-
segmenter: e.segmentation?.segmenter ??
|
|
3801
|
+
segmenter: e.segmentation?.segmenter ?? wi,
|
|
3774
3802
|
// Per-key override, not an additive union — each key holds one whole rule.
|
|
3775
|
-
substitutions: { ...
|
|
3803
|
+
substitutions: { ...ri, ...e.substitutions },
|
|
3776
3804
|
blockStarts: /* @__PURE__ */ new Set(),
|
|
3777
3805
|
tableRowNumbers: /* @__PURE__ */ new Map(),
|
|
3778
3806
|
tableCellHeaders: /* @__PURE__ */ new Map(),
|
|
3779
3807
|
synthetic: /* @__PURE__ */ new Set(),
|
|
3780
|
-
ancestorChains:
|
|
3808
|
+
ancestorChains: on(n),
|
|
3781
3809
|
pendingRange: /* @__PURE__ */ new Map(),
|
|
3782
3810
|
edgeSubstitutedLocate: /* @__PURE__ */ new WeakMap()
|
|
3783
3811
|
};
|
|
3784
3812
|
}
|
|
3785
|
-
const
|
|
3786
|
-
function
|
|
3787
|
-
return n.replace(
|
|
3813
|
+
const Ti = /<lang xml:lang="[^"]*">([\s\S]*?)<\/lang>/g;
|
|
3814
|
+
function cn(n) {
|
|
3815
|
+
return n.replace(Ti, "$1");
|
|
3788
3816
|
}
|
|
3789
|
-
function
|
|
3817
|
+
function X(n) {
|
|
3790
3818
|
return n.role ? [...n.role] : [];
|
|
3791
3819
|
}
|
|
3792
|
-
function
|
|
3820
|
+
function Ne(n) {
|
|
3793
3821
|
return n.role?.has("math") ? void 0 : n.text;
|
|
3794
3822
|
}
|
|
3795
3823
|
function $e(n) {
|
|
@@ -3803,22 +3831,22 @@ function H(n, e) {
|
|
|
3803
3831
|
const s = { cssSelector: t, text: { highlight: e } };
|
|
3804
3832
|
return n.href !== void 0 && (s.href = n.href), s;
|
|
3805
3833
|
}
|
|
3806
|
-
function
|
|
3807
|
-
const t =
|
|
3834
|
+
function x(n, e) {
|
|
3835
|
+
const t = et(n);
|
|
3808
3836
|
if (t) return { own: !0, ref: t };
|
|
3809
3837
|
for (const s of e.get(n) ?? []) {
|
|
3810
|
-
const i =
|
|
3838
|
+
const i = et(s);
|
|
3811
3839
|
if (i) return { own: !1, ref: i };
|
|
3812
3840
|
}
|
|
3813
3841
|
}
|
|
3814
|
-
function
|
|
3842
|
+
function Ke(n, e) {
|
|
3815
3843
|
if (n)
|
|
3816
3844
|
return n.own ? n.ref : H(n.ref, e);
|
|
3817
3845
|
}
|
|
3818
|
-
function
|
|
3819
|
-
return (n && e ?
|
|
3846
|
+
function We(n, e, t) {
|
|
3847
|
+
return (n && e ? Rn(n.ref, e.ref) : void 0) ?? t;
|
|
3820
3848
|
}
|
|
3821
|
-
function
|
|
3849
|
+
function un(n, e, t) {
|
|
3822
3850
|
const { ancestorChains: s } = t, i = /* @__PURE__ */ new Map();
|
|
3823
3851
|
for (const a of e)
|
|
3824
3852
|
a && !Array.isArray(a) && i.set(a, (i.get(a) ?? 0) + 1);
|
|
@@ -3826,31 +3854,31 @@ function cn(n, e, t) {
|
|
|
3826
3854
|
if (a.offsets) return a;
|
|
3827
3855
|
const o = e[r], l = a.plain ?? a.ssml ?? "";
|
|
3828
3856
|
if (Array.isArray(o)) {
|
|
3829
|
-
const [h,
|
|
3857
|
+
const [h, d] = o, f = x(h, s), p = x(d, s), m = We(f, p, Ke(f, l));
|
|
3830
3858
|
return m ? { ...a, locate: m } : a;
|
|
3831
3859
|
}
|
|
3832
|
-
const c = o, u = c ?
|
|
3860
|
+
const c = o, u = c ? x(c, s) : void 0;
|
|
3833
3861
|
if (!u) return a;
|
|
3834
|
-
const
|
|
3862
|
+
const g = { ...a, locate: u.ref };
|
|
3835
3863
|
if (!t.synthetic.has(a)) {
|
|
3836
|
-
const h = t.pendingRange.get(a),
|
|
3837
|
-
|
|
3864
|
+
const h = t.pendingRange.get(a), d = h !== void 0 || c && (i.get(c) ?? 0) > 1;
|
|
3865
|
+
g.locate = u.own && !d ? u.ref : H(u.ref, l), g.offsets = [{ start: h?.start ?? 0, end: h?.end ?? l.length, locate: g.locate }];
|
|
3838
3866
|
}
|
|
3839
|
-
return
|
|
3867
|
+
return g;
|
|
3840
3868
|
});
|
|
3841
3869
|
}
|
|
3842
|
-
function
|
|
3843
|
-
const e = Ne(
|
|
3870
|
+
function Qe(n) {
|
|
3871
|
+
const e = Be(Ne(n));
|
|
3844
3872
|
return e ? e.plain ?? (e.ssml ? z(e.ssml) : "") : "";
|
|
3845
3873
|
}
|
|
3846
|
-
function
|
|
3874
|
+
function zi(n) {
|
|
3847
3875
|
const e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Map();
|
|
3848
3876
|
let s = 0, i;
|
|
3849
3877
|
return n.forEach((a, r) => {
|
|
3850
3878
|
e.set(a, r + 1);
|
|
3851
3879
|
const o = a.children ?? [];
|
|
3852
3880
|
if (s = Math.max(s, o.length), o.some((l) => l.role?.has("columnheader"))) {
|
|
3853
|
-
i = o.map(
|
|
3881
|
+
i = o.map(Qe);
|
|
3854
3882
|
return;
|
|
3855
3883
|
}
|
|
3856
3884
|
i && o.forEach((l, c) => {
|
|
@@ -3868,34 +3896,34 @@ function D(n, e, t, s) {
|
|
|
3868
3896
|
n.push(...s);
|
|
3869
3897
|
for (let i = 0; i < s.length; i++) e.push(t);
|
|
3870
3898
|
}
|
|
3871
|
-
function
|
|
3899
|
+
function hn(n, e, t, s, i, a, r) {
|
|
3872
3900
|
r ? (i.some((o) => t.blockStarts.has(o)) && t.blockStarts.add(r), D(n, e, a[0] ?? s, [r])) : (n.push(...i), e.push(...a));
|
|
3873
3901
|
}
|
|
3874
|
-
function
|
|
3902
|
+
function ee(n, e, t, s) {
|
|
3875
3903
|
const i = t ? `${e}.${t}` : void 0;
|
|
3876
3904
|
if (i && n.i18n.exists(i)) return n.i18n.t(i, s);
|
|
3877
3905
|
if (n.i18n.exists(e)) return n.i18n.t(e, s);
|
|
3878
3906
|
}
|
|
3879
|
-
function
|
|
3880
|
-
return
|
|
3907
|
+
function Je(n, e) {
|
|
3908
|
+
return an.has(n) ? !0 : e.contextualize.has(n);
|
|
3881
3909
|
}
|
|
3882
|
-
function
|
|
3910
|
+
function Ni(n, e, t) {
|
|
3883
3911
|
return e.some((s) => {
|
|
3884
|
-
const i =
|
|
3885
|
-
return i?.drops.includes(n) ? i.unconditional ||
|
|
3912
|
+
const i = Ci[s];
|
|
3913
|
+
return i?.drops.includes(n) ? i.unconditional || Je(s, t) : !1;
|
|
3886
3914
|
});
|
|
3887
3915
|
}
|
|
3888
3916
|
function fe(n, e, t, s, i) {
|
|
3889
3917
|
const a = e.lastIndexOf(t);
|
|
3890
3918
|
if (a === -1) return;
|
|
3891
|
-
const r =
|
|
3919
|
+
const r = x(s, i.ancestorChains);
|
|
3892
3920
|
if (!r) return;
|
|
3893
3921
|
const o = H(r.ref, t);
|
|
3894
3922
|
n.offsets = [{ start: a, end: a + t.length, locate: o }], n.locate = r.own ? r.ref : o;
|
|
3895
3923
|
}
|
|
3896
3924
|
function Et(n, e, t, s, i, a) {
|
|
3897
3925
|
const r = a?.value;
|
|
3898
|
-
if (r !== void 0 && r ===
|
|
3926
|
+
if (r !== void 0 && r === Qe(t)) {
|
|
3899
3927
|
if (s.language !== "none") {
|
|
3900
3928
|
const l = t.text?.language;
|
|
3901
3929
|
l && (n.language = l);
|
|
@@ -3907,17 +3935,17 @@ function Et(n, e, t, s, i, a) {
|
|
|
3907
3935
|
o !== void 0 && o === $e(t) && (i === "figure" || i === "table") && fe(n, e, o, t, s);
|
|
3908
3936
|
}
|
|
3909
3937
|
function Rt(n, e, t, s, i, a, r, o) {
|
|
3910
|
-
if (!
|
|
3938
|
+
if (!Je(i, s)) return;
|
|
3911
3939
|
if ((s.i18n.exists(`${i}.block.start`) || s.i18n.exists(`${i}.block.end`)) && s.contextualizationShapes[i] !== "inline") {
|
|
3912
|
-
const c = a === "before" ? `${i}.block.start` : `${i}.block.end`, u =
|
|
3940
|
+
const c = a === "before" ? `${i}.block.start` : `${i}.block.end`, u = ee(s, c, r, o);
|
|
3913
3941
|
if (u) {
|
|
3914
|
-
const
|
|
3915
|
-
Et(
|
|
3942
|
+
const g = M(u, s);
|
|
3943
|
+
Et(g, u, t, s, i, o), D(n, e, t, [g]);
|
|
3916
3944
|
}
|
|
3917
3945
|
return;
|
|
3918
3946
|
}
|
|
3919
3947
|
if (a === "before") {
|
|
3920
|
-
const c =
|
|
3948
|
+
const c = ee(s, `${i}.inline`, r, o);
|
|
3921
3949
|
if (c) {
|
|
3922
3950
|
const u = M(c, s);
|
|
3923
3951
|
Et(u, c, t, s, i, o), D(n, e, t, [u]);
|
|
@@ -3928,7 +3956,7 @@ function It(n, e, t, s) {
|
|
|
3928
3956
|
const i = `${e}.parts.${t}`;
|
|
3929
3957
|
return n.i18n.exists(i, { count: s }) ? n.i18n.t(i, { count: s }) : String(s);
|
|
3930
3958
|
}
|
|
3931
|
-
function
|
|
3959
|
+
function Bi(n) {
|
|
3932
3960
|
const e = $e(n);
|
|
3933
3961
|
return e === void 0 ? { variantKey: "unlabelled" } : { variantKey: "labelled", params: { description: e } };
|
|
3934
3962
|
}
|
|
@@ -3936,12 +3964,12 @@ function Pt(n, e) {
|
|
|
3936
3964
|
const t = e.tableCellHeaders.get(n);
|
|
3937
3965
|
return {
|
|
3938
3966
|
variantKey: t !== void 0 ? "withHeader" : "withoutHeader",
|
|
3939
|
-
params: { header: t ?? "", value:
|
|
3967
|
+
params: { header: t ?? "", value: Qe(n) }
|
|
3940
3968
|
};
|
|
3941
3969
|
}
|
|
3942
|
-
const
|
|
3970
|
+
const Mi = {
|
|
3943
3971
|
table: (n, e) => {
|
|
3944
|
-
const t = (n.children ?? []).filter((i) => i.role?.has("row")), s =
|
|
3972
|
+
const t = (n.children ?? []).filter((i) => i.role?.has("row")), s = zi(t);
|
|
3945
3973
|
for (const [i, a] of s.rowNumbers) e.tableRowNumbers.set(i, a);
|
|
3946
3974
|
for (const [i, a] of s.cellHeaders) e.tableCellHeaders.set(i, a);
|
|
3947
3975
|
return {
|
|
@@ -3955,10 +3983,10 @@ const zi = {
|
|
|
3955
3983
|
cell: Pt,
|
|
3956
3984
|
rowheader: Pt
|
|
3957
3985
|
};
|
|
3958
|
-
function
|
|
3959
|
-
const s =
|
|
3986
|
+
function At(n, e, t) {
|
|
3987
|
+
const s = Bi(e);
|
|
3960
3988
|
let i = s.variantKey, a = s.params;
|
|
3961
|
-
const r =
|
|
3989
|
+
const r = Mi[n]?.(e, t);
|
|
3962
3990
|
r && (r.variantKey && (i = r.variantKey), a = { ...a, ...r.params });
|
|
3963
3991
|
const o = t.contextualizationParams?.(n, e);
|
|
3964
3992
|
return o && (a = { ...a, ...o }), { variantKey: i, params: a };
|
|
@@ -3967,25 +3995,25 @@ function pe(n) {
|
|
|
3967
3995
|
let e = "";
|
|
3968
3996
|
const t = [];
|
|
3969
3997
|
for (const s of n) {
|
|
3970
|
-
if (s.length === 1 &&
|
|
3998
|
+
if (s.length === 1 && os(s) && e.endsWith(s)) {
|
|
3971
3999
|
t.push({ start: e.length, end: e.length });
|
|
3972
4000
|
continue;
|
|
3973
4001
|
}
|
|
3974
|
-
e && !
|
|
4002
|
+
e && !te(s) && !/\s$/.test(e) && !/^\s/.test(s) && (e += " ");
|
|
3975
4003
|
const i = e.length;
|
|
3976
4004
|
e += s, t.push({ start: i, end: e.length });
|
|
3977
4005
|
}
|
|
3978
4006
|
return { joined: e, ranges: t };
|
|
3979
4007
|
}
|
|
3980
|
-
function
|
|
3981
|
-
const t =
|
|
4008
|
+
function Ee(n, e) {
|
|
4009
|
+
const t = In(n), s = x(n, e.ancestorChains)?.ref;
|
|
3982
4010
|
if (t) {
|
|
3983
4011
|
const i = { cssSelector: t };
|
|
3984
|
-
return s?.href !== void 0 && (i.href = s.href),
|
|
4012
|
+
return s?.href !== void 0 && (i.href = s.href), bt(i);
|
|
3985
4013
|
}
|
|
3986
|
-
return s &&
|
|
4014
|
+
return s && bt(s);
|
|
3987
4015
|
}
|
|
3988
|
-
function
|
|
4016
|
+
function Di(n, e, t) {
|
|
3989
4017
|
const s = [];
|
|
3990
4018
|
return n.forEach((i, a) => {
|
|
3991
4019
|
if (i.offsets) {
|
|
@@ -3995,29 +4023,29 @@ function Ni(n, e, t) {
|
|
|
3995
4023
|
if (t.synthetic.has(i)) return;
|
|
3996
4024
|
const r = e[a];
|
|
3997
4025
|
if (!r || Array.isArray(r)) return;
|
|
3998
|
-
const o =
|
|
4026
|
+
const o = x(r, t.ancestorChains);
|
|
3999
4027
|
if (!o) return;
|
|
4000
4028
|
const l = t.format === "ssml" ? i.ssml : i.plain;
|
|
4001
4029
|
if (!l) return;
|
|
4002
|
-
const c = t.pendingRange.get(i), u =
|
|
4030
|
+
const c = t.pendingRange.get(i), u = ne(r) ? Ee(r, t) ?? o.ref : H(o.ref, l);
|
|
4003
4031
|
s.push({ start: c?.start ?? 0, end: c?.end ?? l.length, locate: u });
|
|
4004
4032
|
}), s;
|
|
4005
4033
|
}
|
|
4006
|
-
function
|
|
4034
|
+
function xt(n, e, t, s) {
|
|
4007
4035
|
const i = s.edgeSubstitutedLocate.get(n);
|
|
4008
4036
|
if (i) return i[t];
|
|
4009
|
-
if (!(!e || Array.isArray(e) || !
|
|
4010
|
-
return
|
|
4037
|
+
if (!(!e || Array.isArray(e) || !ne(e)))
|
|
4038
|
+
return Ee(e, s);
|
|
4011
4039
|
}
|
|
4012
|
-
function
|
|
4040
|
+
function ji(n, e, t) {
|
|
4013
4041
|
const s = n.map((l, c) => {
|
|
4014
4042
|
if (l.locate) return l.locate;
|
|
4015
4043
|
if (t.synthetic.has(l)) return;
|
|
4016
4044
|
const u = e[c];
|
|
4017
4045
|
if (!u || Array.isArray(u)) return;
|
|
4018
|
-
const
|
|
4019
|
-
if (
|
|
4020
|
-
return
|
|
4046
|
+
const g = t.format === "ssml" ? l.ssml : l.plain;
|
|
4047
|
+
if (g)
|
|
4048
|
+
return ne(u) ? x(u, t.ancestorChains) && Ee(u, t) : Ke(x(u, t.ancestorChains), g);
|
|
4021
4049
|
}), i = s.findIndex((l) => l !== void 0);
|
|
4022
4050
|
if (i === -1) return;
|
|
4023
4051
|
let a = s.length - 1;
|
|
@@ -4025,12 +4053,12 @@ function Bi(n, e, t) {
|
|
|
4025
4053
|
if (i === a) return s[i];
|
|
4026
4054
|
const r = e[i], o = e[a];
|
|
4027
4055
|
if (r && o && !Array.isArray(r) && !Array.isArray(o)) {
|
|
4028
|
-
const l =
|
|
4029
|
-
return
|
|
4056
|
+
const l = x(r, t.ancestorChains), c = x(o, t.ancestorChains);
|
|
4057
|
+
return We(l, c, s[i]);
|
|
4030
4058
|
}
|
|
4031
4059
|
return s[i];
|
|
4032
4060
|
}
|
|
4033
|
-
function
|
|
4061
|
+
function Ze(n, e, t) {
|
|
4034
4062
|
let s, i = !1;
|
|
4035
4063
|
const a = [], r = [], o = [];
|
|
4036
4064
|
for (let f = 0; f < n.length; f++) {
|
|
@@ -4043,133 +4071,133 @@ function Je(n, e, t) {
|
|
|
4043
4071
|
if (a.length === 0) return;
|
|
4044
4072
|
const { joined: l } = pe(a), c = t.format === "ssml" ? { ssml: l } : { plain: l };
|
|
4045
4073
|
s && (c.language = s), n.some((f) => t.synthetic.has(f)) && t.synthetic.add(c);
|
|
4046
|
-
const u =
|
|
4074
|
+
const u = Di(r, o, t);
|
|
4047
4075
|
u.length > 0 && (c.offsets = u);
|
|
4048
|
-
const
|
|
4049
|
-
|
|
4050
|
-
const h =
|
|
4051
|
-
return (h ||
|
|
4052
|
-
}
|
|
4053
|
-
function
|
|
4054
|
-
if (e === "plain" && t !== "block-level" && t !== "none" && n.ssml &&
|
|
4055
|
-
return
|
|
4076
|
+
const g = ji(r, o, t);
|
|
4077
|
+
g && (c.locate = g);
|
|
4078
|
+
const h = xt(r[0], o[0], "leading", t), d = xt(r[r.length - 1], o[r.length - 1], "trailing", t);
|
|
4079
|
+
return (h || d) && t.edgeSubstitutedLocate.set(c, { leading: h, trailing: d }), c;
|
|
4080
|
+
}
|
|
4081
|
+
function dn(n, e, t, s) {
|
|
4082
|
+
if (e === "plain" && t !== "block-level" && t !== "none" && n.ssml && qt(n.ssml))
|
|
4083
|
+
return Gt(n.ssml, n.language).map((a) => {
|
|
4056
4084
|
const r = { plain: a.plain };
|
|
4057
4085
|
return a.language && (r.language = a.language), s.pendingRange.set(r, { start: a.start, end: a.end }), r;
|
|
4058
4086
|
});
|
|
4059
4087
|
const i = {};
|
|
4060
|
-
return n.language && (i.language = n.language), e === "ssml" ? i.ssml = n.ssml ?? B(n.plain ?? "") : i.plain = n.plain ?? z(n.ssml ?? ""), (t === "block-level" || t === "none") && (i.ssml && (i.ssml =
|
|
4088
|
+
return n.language && (i.language = n.language), e === "ssml" ? i.ssml = n.ssml ?? B(n.plain ?? "") : i.plain = n.plain ?? z(n.ssml ?? ""), (t === "block-level" || t === "none") && (i.ssml && (i.ssml = cn(i.ssml)), t === "none" && delete i.language), [i];
|
|
4061
4089
|
}
|
|
4062
|
-
function
|
|
4090
|
+
function se(n, e) {
|
|
4063
4091
|
return e !== "ssml" ? n : n.replace(/<[^>]+>/g, "").replace(/</g, "<").replace(/>/g, ">").replace(/&/g, "&");
|
|
4064
4092
|
}
|
|
4065
4093
|
function Lt(n, e) {
|
|
4066
4094
|
return e.size > 0 && n.some((t) => e.has(t));
|
|
4067
4095
|
}
|
|
4068
|
-
function
|
|
4069
|
-
const t =
|
|
4096
|
+
function Fi(n, e) {
|
|
4097
|
+
const t = Be(n.text), s = t ? dn(t, e.format, e.language, e) : [];
|
|
4070
4098
|
if (!e.contextualize.has("pagebreak")) return s;
|
|
4071
|
-
const i = e.i18n.exists("pagebreak.block.start") ? "pagebreak.block.start" : "pagebreak.inline", a =
|
|
4099
|
+
const i = e.i18n.exists("pagebreak.block.start") ? "pagebreak.block.start" : "pagebreak.inline", a = ee(e, i);
|
|
4072
4100
|
if (a === void 0) return s;
|
|
4073
4101
|
const r = M(a, e);
|
|
4074
4102
|
if (s.length === 0) return [r];
|
|
4075
|
-
const o =
|
|
4103
|
+
const o = Ze([r, ...s], [void 0, ...s.map(() => n)], e);
|
|
4076
4104
|
return o ? (o.plain !== void 0 && (o.plain += "."), o.ssml !== void 0 && (o.ssml += "."), [o]) : [r, ...s];
|
|
4077
4105
|
}
|
|
4078
|
-
function
|
|
4079
|
-
return
|
|
4106
|
+
function _i(n) {
|
|
4107
|
+
return X(n).some((e) => Ai.has(e));
|
|
4080
4108
|
}
|
|
4081
|
-
function
|
|
4109
|
+
function Hi(n, e, t, s, i, a) {
|
|
4082
4110
|
const r = n.text?.language, o = new Map((n.children ?? []).map((h) => [h.id, h])), l = [], c = [], u = [];
|
|
4083
|
-
for (const h of
|
|
4111
|
+
for (const h of Es(e)) {
|
|
4084
4112
|
if (h.placeholderId !== void 0) {
|
|
4085
4113
|
const f = o.get(h.placeholderId);
|
|
4086
4114
|
if (!f) continue;
|
|
4087
|
-
i.inlineContextualization || !
|
|
4115
|
+
i.inlineContextualization || !_i(f) ? gn(f, l, c, i, a) : u.push(f);
|
|
4088
4116
|
continue;
|
|
4089
4117
|
}
|
|
4090
4118
|
if (!h.ssml) continue;
|
|
4091
|
-
if (i.format === "plain" && i.language !== "block-level" && i.language !== "none" &&
|
|
4092
|
-
for (const f of
|
|
4119
|
+
if (i.format === "plain" && i.language !== "block-level" && i.language !== "none" && qt(h.ssml)) {
|
|
4120
|
+
for (const f of Gt(h.ssml, r)) {
|
|
4093
4121
|
const p = { plain: f.plain };
|
|
4094
4122
|
f.language && (p.language = f.language), l.push(p), c.push(n);
|
|
4095
4123
|
}
|
|
4096
4124
|
continue;
|
|
4097
4125
|
}
|
|
4098
|
-
const
|
|
4099
|
-
r && (
|
|
4126
|
+
const d = {};
|
|
4127
|
+
r && (d.language = r), i.format === "ssml" ? d.ssml = h.ssml : d.plain = z(h.ssml), (i.language === "block-level" || i.language === "none") && (d.ssml && (d.ssml = cn(d.ssml)), i.language === "none" && delete d.language), l.push(d), c.push(n);
|
|
4100
4128
|
}
|
|
4101
|
-
const
|
|
4102
|
-
return
|
|
4129
|
+
const g = l.length > 1 ? Ze(l, c, i) : void 0;
|
|
4130
|
+
return hn(t, s, i, n, l, c, g), u;
|
|
4103
4131
|
}
|
|
4104
|
-
function
|
|
4105
|
-
const a =
|
|
4132
|
+
function gn(n, e, t, s, i) {
|
|
4133
|
+
const a = X(n), r = $e(n);
|
|
4106
4134
|
if (Lt(a, s.skip)) return;
|
|
4107
|
-
const o = a.some((
|
|
4108
|
-
(
|
|
4109
|
-
),
|
|
4135
|
+
const o = a.some((d) => Ct.has(d)), l = o && !i, c = e.length, u = a.filter(
|
|
4136
|
+
(d) => d !== "footnote" && d !== "pagebreak" && !Ni(d, a, s)
|
|
4137
|
+
), g = a.some((d) => xi.has(d) && s.contextualize.has(d)), h = a.includes("table") && r !== void 0 && !g;
|
|
4110
4138
|
if (h) {
|
|
4111
|
-
const
|
|
4112
|
-
fe(
|
|
4139
|
+
const d = M(r, s);
|
|
4140
|
+
fe(d, r, r, n, s), D(e, t, n, [d]);
|
|
4113
4141
|
}
|
|
4114
|
-
for (const
|
|
4115
|
-
if (
|
|
4116
|
-
const { variantKey: f, params: p } =
|
|
4117
|
-
Rt(e, t, n, s,
|
|
4142
|
+
for (const d of u) {
|
|
4143
|
+
if (d === "figure" && r === void 0) continue;
|
|
4144
|
+
const { variantKey: f, params: p } = At(d, n, s);
|
|
4145
|
+
Rt(e, t, n, s, d, "before", f, p);
|
|
4118
4146
|
}
|
|
4119
4147
|
if (a.includes("noteref"))
|
|
4120
|
-
for (const
|
|
4121
|
-
const f =
|
|
4148
|
+
for (const d of n.children ?? []) {
|
|
4149
|
+
const f = X(d);
|
|
4122
4150
|
if (!Lt(f, s.skip))
|
|
4123
4151
|
if (f.includes("footnote")) {
|
|
4124
|
-
const p = s.contextualize.has("footnote"), m = s.i18n.exists("footnote.block.start") || s.i18n.exists("footnote.block.end"), S = f.some((
|
|
4125
|
-
v !== void 0 && (P.push(M(v, s)), y.push(
|
|
4126
|
-
const
|
|
4127
|
-
if (N([
|
|
4128
|
-
const
|
|
4129
|
-
|
|
4152
|
+
const p = s.contextualize.has("footnote"), m = s.i18n.exists("footnote.block.start") || s.i18n.exists("footnote.block.end"), S = f.some((E) => Ct.has(E)) && !i && !s.inlineContextualization, v = p ? ee(s, m ? "footnote.block.start" : "footnote.inline") : void 0, I = p && (v !== void 0 || m), P = [], y = [];
|
|
4153
|
+
v !== void 0 && (P.push(M(v, s)), y.push(d));
|
|
4154
|
+
const C = [], R = [];
|
|
4155
|
+
if (N([d], C, R, s, i || S), S && C.length > 0 && s.blockStarts.add(C[0]), P.push(...C), y.push(...R), I && m) {
|
|
4156
|
+
const E = ee(s, "footnote.block.end");
|
|
4157
|
+
E !== void 0 && (P.push(M(E, s)), y.push(d));
|
|
4130
4158
|
}
|
|
4131
|
-
const w = I && P.length > 1 ?
|
|
4132
|
-
|
|
4159
|
+
const w = I && P.length > 1 ? Ze(P, y, s) : void 0;
|
|
4160
|
+
hn(e, t, s, d, P, y, w);
|
|
4133
4161
|
} else
|
|
4134
|
-
N([
|
|
4162
|
+
N([d], e, t, s, i);
|
|
4135
4163
|
}
|
|
4136
|
-
else if (!a.some((
|
|
4137
|
-
const
|
|
4138
|
-
if (
|
|
4139
|
-
const f =
|
|
4164
|
+
else if (!a.some((d) => Li.has(d))) {
|
|
4165
|
+
const d = Ne(n)?.ssml;
|
|
4166
|
+
if (d && Cs(d)) {
|
|
4167
|
+
const f = Hi(n, d, e, t, s, i);
|
|
4140
4168
|
if (f.length > 0) {
|
|
4141
4169
|
const p = i || o && e.length > c;
|
|
4142
4170
|
N(f, e, t, s, p);
|
|
4143
4171
|
}
|
|
4144
4172
|
} else if (a.includes("pagebreak")) {
|
|
4145
|
-
if (D(e, t, n,
|
|
4173
|
+
if (D(e, t, n, Fi(n, s)), n.children) {
|
|
4146
4174
|
const f = i || o && e.length > c;
|
|
4147
4175
|
N(n.children, e, t, s, f);
|
|
4148
4176
|
}
|
|
4149
4177
|
} else {
|
|
4150
|
-
const p = a.some((m) =>
|
|
4151
|
-
if (p && D(e, t, n,
|
|
4178
|
+
const p = a.some((m) => an.has(m) && Je(m, s)) ? void 0 : Be(Ne(n));
|
|
4179
|
+
if (p && D(e, t, n, dn(p, s.format, s.language, s)), n.children) {
|
|
4152
4180
|
const m = i || o && e.length > c;
|
|
4153
4181
|
N(n.children, e, t, s, m);
|
|
4154
4182
|
}
|
|
4155
4183
|
}
|
|
4156
4184
|
}
|
|
4157
|
-
if (l && e.length > c && s.blockStarts.add(e[c]), r !== void 0 && !
|
|
4158
|
-
const
|
|
4159
|
-
a.includes("figure") && fe(
|
|
4185
|
+
if (l && e.length > c && s.blockStarts.add(e[c]), r !== void 0 && !g && !h) {
|
|
4186
|
+
const d = M(r, s);
|
|
4187
|
+
a.includes("figure") && fe(d, r, r, n, s), D(e, t, n, [d]);
|
|
4160
4188
|
}
|
|
4161
|
-
for (const
|
|
4162
|
-
if (
|
|
4163
|
-
const { variantKey: f, params: p } =
|
|
4164
|
-
Rt(e, t, n, s,
|
|
4189
|
+
for (const d of u) {
|
|
4190
|
+
if (d === "figure" && r === void 0) continue;
|
|
4191
|
+
const { variantKey: f, params: p } = At(d, n, s);
|
|
4192
|
+
Rt(e, t, n, s, d, "after", f, p);
|
|
4165
4193
|
}
|
|
4166
4194
|
}
|
|
4167
4195
|
function N(n, e, t, s, i) {
|
|
4168
|
-
n.forEach((a, r) =>
|
|
4196
|
+
n.forEach((a, r) => gn(a, e, t, s, r === 0 ? i : !1));
|
|
4169
4197
|
}
|
|
4170
|
-
const
|
|
4171
|
-
async function
|
|
4172
|
-
const i =
|
|
4198
|
+
const qi = _t;
|
|
4199
|
+
async function fn(n, e, t, s) {
|
|
4200
|
+
const i = qi(n);
|
|
4173
4201
|
let a = "";
|
|
4174
4202
|
const r = [];
|
|
4175
4203
|
for (const h of i)
|
|
@@ -4179,35 +4207,35 @@ async function gn(n, e, t, s) {
|
|
|
4179
4207
|
if (o.length <= 1) return;
|
|
4180
4208
|
const l = [];
|
|
4181
4209
|
let c = "", u = 0;
|
|
4182
|
-
function
|
|
4183
|
-
let p =
|
|
4184
|
-
const m =
|
|
4210
|
+
function g(h, d, f) {
|
|
4211
|
+
let p = d;
|
|
4212
|
+
const m = d + h.length;
|
|
4185
4213
|
for (; p < m; ) {
|
|
4186
4214
|
const S = o[u], v = Math.min(m, S.end), I = v >= S.end && u < o.length - 1;
|
|
4187
|
-
let P = h.slice(p -
|
|
4215
|
+
let P = h.slice(p - d, v - d);
|
|
4188
4216
|
I && (P = P.replace(/[ \t\r\n]+$/, ""));
|
|
4189
4217
|
const y = B(P);
|
|
4190
4218
|
c += f ? f(y) : y, p = v, I && (l.push(c), c = "", u++);
|
|
4191
4219
|
}
|
|
4192
4220
|
}
|
|
4193
|
-
return i.forEach((h,
|
|
4221
|
+
return i.forEach((h, d) => {
|
|
4194
4222
|
if (h.kind === "selfClosing")
|
|
4195
4223
|
c += h.raw;
|
|
4196
4224
|
else if (h.kind === "text")
|
|
4197
|
-
|
|
4225
|
+
g(h.text, r[d]);
|
|
4198
4226
|
else {
|
|
4199
4227
|
const f = `<${h.tag}${h.attrs}>`, p = `</${h.tag}>`;
|
|
4200
|
-
h.innerText ?
|
|
4228
|
+
h.innerText ? g(h.innerText, r[d], (m) => `${f}${m}${p}`) : c += f + p;
|
|
4201
4229
|
}
|
|
4202
4230
|
}), c && l.push(c.replace(/[ \t\r\n]+$/, "")), l;
|
|
4203
4231
|
}
|
|
4204
|
-
async function
|
|
4205
|
-
const t = n.language ?? "en", s = e.segmentationSuppressions
|
|
4232
|
+
async function Gi(n, e) {
|
|
4233
|
+
const t = n.language ?? "en", s = ve(e.segmentationSuppressions, t), i = e.format === "ssml" ? n.ssml : n.plain;
|
|
4206
4234
|
if (!i) return;
|
|
4207
|
-
const a = await e.segmenter(t,
|
|
4235
|
+
const a = await e.segmenter(t, se(i, e.format), s);
|
|
4208
4236
|
if (a.length <= 1) return;
|
|
4209
4237
|
if (e.format !== "ssml") return a.map((o) => ({ text: o.text, start: o.start, end: o.contentEnd }));
|
|
4210
|
-
const r = await
|
|
4238
|
+
const r = await fn(i, t, e.segmenter, s);
|
|
4211
4239
|
if (r)
|
|
4212
4240
|
return a.map((o, l) => ({ text: r[l], start: o.start, end: o.contentEnd }));
|
|
4213
4241
|
}
|
|
@@ -4227,32 +4255,39 @@ const Ot = /* @__PURE__ */ new Set([
|
|
|
4227
4255
|
"heading6"
|
|
4228
4256
|
]);
|
|
4229
4257
|
function Ut(n) {
|
|
4230
|
-
return n ?
|
|
4258
|
+
return n ? X(Array.isArray(n) ? n[1] : n) : [];
|
|
4259
|
+
}
|
|
4260
|
+
function Vt(n, e, t) {
|
|
4261
|
+
const s = Array.isArray(n) ? n[e === "leading" ? 0 : 1] : n;
|
|
4262
|
+
return (t.ancestorChains.get(s) ?? []).filter((i) => X(i).some((a) => a !== "presentation"));
|
|
4263
|
+
}
|
|
4264
|
+
function $i(n, e) {
|
|
4265
|
+
return n.length === e.length && n.every((t, s) => t === e[s]);
|
|
4231
4266
|
}
|
|
4232
4267
|
function Tt(n, e, t, s) {
|
|
4233
|
-
return s.edgeSubstitutedLocate.get(e)?.[t] ? !0 : !!n && !Array.isArray(n) &&
|
|
4268
|
+
return s.edgeSubstitutedLocate.get(e)?.[t] ? !0 : !!n && !Array.isArray(n) && ne(n);
|
|
4234
4269
|
}
|
|
4235
|
-
function
|
|
4270
|
+
function Ki(n, e, t, s, i) {
|
|
4236
4271
|
if (i.synthetic.has(n) || i.synthetic.has(t) || !e || !s) return !1;
|
|
4237
4272
|
const a = i.format === "ssml" ? n.ssml : n.plain, r = i.format === "ssml" ? t.ssml : t.plain;
|
|
4238
|
-
return !(!a || !r || (n.language ?? "en") !== (t.language ?? "en") || Ut(e).some((o) => Ot.has(o)) || Ut(s).some((o) => Ot.has(o)) || Tt(e, n, "trailing", i) || Tt(s, t, "leading", i));
|
|
4273
|
+
return !(!a || !r || (n.language ?? "en") !== (t.language ?? "en") || Ut(e).some((o) => Ot.has(o)) || Ut(s).some((o) => Ot.has(o)) || !$i(Vt(e, "trailing", i), Vt(s, "leading", i)) || Tt(e, n, "trailing", i) || Tt(s, t, "leading", i));
|
|
4239
4274
|
}
|
|
4240
|
-
async function
|
|
4241
|
-
const a = t.synthetic.has(n) ? void 0 : await
|
|
4275
|
+
async function zt(n, e, t, s, i) {
|
|
4276
|
+
const a = t.synthetic.has(n) ? void 0 : await Gi(n, t);
|
|
4242
4277
|
if (!a) {
|
|
4243
4278
|
s.push(n), i.push(e);
|
|
4244
4279
|
return;
|
|
4245
4280
|
}
|
|
4246
4281
|
const r = t.blockStarts.has(n);
|
|
4247
4282
|
r && t.blockStarts.delete(n);
|
|
4248
|
-
const o = Array.isArray(e) ? void 0 : e, l = o ?
|
|
4249
|
-
a.forEach(({ text:
|
|
4250
|
-
const p = { ...n, [t.format]:
|
|
4283
|
+
const o = Array.isArray(e) ? void 0 : e, l = o ? x(o, t.ancestorChains) : void 0, c = o && ne(o) ? Ee(o, t) : void 0, u = t.edgeSubstitutedLocate.get(n);
|
|
4284
|
+
a.forEach(({ text: g, start: h, end: d }, f) => {
|
|
4285
|
+
const p = { ...n, [t.format]: g }, m = (f === 0 ? u?.leading : void 0) ?? (f === a.length - 1 ? u?.trailing : void 0) ?? c;
|
|
4251
4286
|
if (m && l)
|
|
4252
|
-
p.locate = m, p.offsets = [{ start: h, end:
|
|
4287
|
+
p.locate = m, p.offsets = [{ start: h, end: d, locate: m }];
|
|
4253
4288
|
else if (l) {
|
|
4254
|
-
const S = t.format === "ssml" ?
|
|
4255
|
-
p.locate = v, p.offsets = [{ start: h, end:
|
|
4289
|
+
const S = t.format === "ssml" ? se(g, t.format) : g, v = H(l.ref, S);
|
|
4290
|
+
p.locate = v, p.offsets = [{ start: h, end: d, locate: v }];
|
|
4256
4291
|
}
|
|
4257
4292
|
r && f === 0 && t.blockStarts.add(p), s.push(p), i.push(e);
|
|
4258
4293
|
});
|
|
@@ -4262,89 +4297,89 @@ function me(n, e) {
|
|
|
4262
4297
|
for (; t < n.length - 1 && n[t + 1].start <= e; ) t++;
|
|
4263
4298
|
return t;
|
|
4264
4299
|
}
|
|
4265
|
-
async function
|
|
4266
|
-
const i = n.map((c) =>
|
|
4300
|
+
async function Wi(n, e, t, s) {
|
|
4301
|
+
const i = n.map((c) => se(e.format === "ssml" ? c.ssml : c.plain, e.format)), { joined: a, ranges: r } = pe(i), o = await e.segmenter(t, a, s), l = new Array(n.length - 1).fill(!1);
|
|
4267
4302
|
for (const c of o) {
|
|
4268
|
-
const u = me(r, c.start),
|
|
4269
|
-
for (let h = u; h <
|
|
4303
|
+
const u = me(r, c.start), g = c.end > c.start ? me(r, c.end - 1) : u;
|
|
4304
|
+
for (let h = u; h < g; h++) l[h] = !0;
|
|
4270
4305
|
}
|
|
4271
4306
|
return l;
|
|
4272
4307
|
}
|
|
4273
|
-
function
|
|
4308
|
+
function Qi(n, e, t, s, i, a, r) {
|
|
4274
4309
|
const o = [];
|
|
4275
4310
|
for (let l = i; l <= a; l++) {
|
|
4276
|
-
const c =
|
|
4311
|
+
const c = x(e[l], r.ancestorChains);
|
|
4277
4312
|
if (!c) continue;
|
|
4278
|
-
const u = t[l],
|
|
4279
|
-
if (h <=
|
|
4280
|
-
const
|
|
4281
|
-
o.push({ start:
|
|
4313
|
+
const u = t[l], g = Math.max(u.start, s.start), h = Math.min(u.end, l === a ? s.contentEnd : s.end);
|
|
4314
|
+
if (h <= g) continue;
|
|
4315
|
+
const d = g - u.start, f = h - u.start, p = se(r.format === "ssml" ? n[l].ssml : n[l].plain, r.format), m = H(c.ref, p.slice(d, f));
|
|
4316
|
+
o.push({ start: d, end: f, locate: m });
|
|
4282
4317
|
}
|
|
4283
4318
|
return o;
|
|
4284
4319
|
}
|
|
4285
|
-
async function
|
|
4286
|
-
const a = n[0].language ?? "en", r = t.segmentationSuppressions
|
|
4287
|
-
let
|
|
4288
|
-
t.format === "ssml" && (h = pe(n.map((f) => f.ssml)).joined,
|
|
4289
|
-
const m = me(c, f.start), S = f.end > f.start ? me(c, f.end - 1) : m, v = t.format === "ssml" ?
|
|
4290
|
-
a && (I.language = a), n.slice(m, S + 1).some((
|
|
4291
|
-
const y =
|
|
4320
|
+
async function Ji(n, e, t, s, i) {
|
|
4321
|
+
const a = n[0].language ?? "en", r = ve(t.segmentationSuppressions, a), o = n.map((f) => se(t.format === "ssml" ? f.ssml : f.plain, t.format)), { joined: l, ranges: c } = pe(o), u = await t.segmenter(a, l, r);
|
|
4322
|
+
let g, h;
|
|
4323
|
+
t.format === "ssml" && (h = pe(n.map((f) => f.ssml)).joined, g = u.length > 1 ? await fn(h, a, t.segmenter, r) : void 0), (u.length > 0 ? u : [{ text: l, start: 0, end: l.length, contentEnd: l.length }]).forEach((f, p) => {
|
|
4324
|
+
const m = me(c, f.start), S = f.end > f.start ? me(c, f.end - 1) : m, v = t.format === "ssml" ? g ? g[p] : h : f.text, I = { [t.format]: v };
|
|
4325
|
+
a && (I.language = a), n.slice(m, S + 1).some((E) => t.blockStarts.has(E)) && t.blockStarts.add(I);
|
|
4326
|
+
const y = Qi(n, e, c, f, m, S, t);
|
|
4292
4327
|
y.length > 0 && (I.offsets = y);
|
|
4293
|
-
const
|
|
4328
|
+
const C = x(e[m], t.ancestorChains), R = Ke(C, v), w = m !== S ? We(C, x(e[S], t.ancestorChains), R) : R;
|
|
4294
4329
|
w && (I.locate = w), s.push(I), i.push(m === S ? e[m] : [e[m], e[S]]);
|
|
4295
4330
|
});
|
|
4296
4331
|
}
|
|
4297
|
-
async function
|
|
4332
|
+
async function pn(n, e, t) {
|
|
4298
4333
|
if (t.segmentation !== "sentence") return { out: n, sources: e };
|
|
4299
4334
|
const s = [], i = [];
|
|
4300
4335
|
let a = 0;
|
|
4301
4336
|
for (; a < n.length; ) {
|
|
4302
4337
|
let r = a;
|
|
4303
|
-
for (; r + 1 < n.length &&
|
|
4338
|
+
for (; r + 1 < n.length && Ki(n[r], e[r], n[r + 1], e[r + 1], t); ) r++;
|
|
4304
4339
|
if (r === a) {
|
|
4305
|
-
await
|
|
4340
|
+
await zt(n[a], e[a], t, s, i), a = r + 1;
|
|
4306
4341
|
continue;
|
|
4307
4342
|
}
|
|
4308
|
-
const o = n.slice(a, r + 1), l = e.slice(a, r + 1), c = o[0].language ?? "en", u = await
|
|
4309
|
-
let
|
|
4343
|
+
const o = n.slice(a, r + 1), l = e.slice(a, r + 1), c = o[0].language ?? "en", u = await Wi(o, t, c, ve(t.segmentationSuppressions, c));
|
|
4344
|
+
let g = 0;
|
|
4310
4345
|
for (let h = 0; h < o.length; h++)
|
|
4311
|
-
h < o.length - 1 && u[h] || (
|
|
4346
|
+
h < o.length - 1 && u[h] || (g === h ? await zt(o[g], l[g], t, s, i) : await Ji(o.slice(g, h + 1), l.slice(g, h + 1), t, s, i), g = h + 1);
|
|
4312
4347
|
a = r + 1;
|
|
4313
4348
|
}
|
|
4314
4349
|
return { out: s, sources: i };
|
|
4315
4350
|
}
|
|
4316
|
-
function
|
|
4351
|
+
function mn(n, e) {
|
|
4317
4352
|
return Object.keys(e.substitutions).length === 0 ? n : n.map((t) => {
|
|
4318
4353
|
if (t.ssml) {
|
|
4319
|
-
const { ssml: o, plain: l, map: c } =
|
|
4354
|
+
const { ssml: o, plain: l, map: c } = ys(t.ssml, e.substitutions);
|
|
4320
4355
|
if (o === t.ssml) return t;
|
|
4321
4356
|
const u = { ...t, ssml: o };
|
|
4322
|
-
return
|
|
4357
|
+
return St(u, { plain: l, map: c }), u;
|
|
4323
4358
|
}
|
|
4324
4359
|
const s = t.plain;
|
|
4325
4360
|
if (!s) return t;
|
|
4326
|
-
const { text: i, map: a } =
|
|
4361
|
+
const { text: i, map: a } = ms(s, e.substitutions);
|
|
4327
4362
|
if (i === s) return t;
|
|
4328
4363
|
const r = { ...t, plain: i };
|
|
4329
|
-
return
|
|
4364
|
+
return St(r, { plain: s, map: a }), r;
|
|
4330
4365
|
});
|
|
4331
4366
|
}
|
|
4332
|
-
async function
|
|
4333
|
-
const t = [], s = [], i = await
|
|
4367
|
+
async function ha(n, e = {}) {
|
|
4368
|
+
const t = [], s = [], i = await ln(n, e);
|
|
4334
4369
|
N(n, t, s, i, !1);
|
|
4335
|
-
const a = await
|
|
4336
|
-
return
|
|
4370
|
+
const a = await pn(t, s, i);
|
|
4371
|
+
return mn(un(a.out, a.sources, i), i);
|
|
4337
4372
|
}
|
|
4338
|
-
async function
|
|
4339
|
-
const t = [], s = [], i = await
|
|
4373
|
+
async function Zi(n, e = {}) {
|
|
4374
|
+
const t = [], s = [], i = await ln(n, e);
|
|
4340
4375
|
N(n, t, s, i, !1);
|
|
4341
|
-
const a = await
|
|
4342
|
-
return { utterances:
|
|
4376
|
+
const a = await pn(t, s, i), r = a.out.map((l) => i.blockStarts.has(l)), o = un(a.out, a.sources, i);
|
|
4377
|
+
return { utterances: mn(o, i), sources: a.sources, blockStarts: r };
|
|
4343
4378
|
}
|
|
4344
|
-
class
|
|
4379
|
+
class da {
|
|
4345
4380
|
engine;
|
|
4346
4381
|
contentQueue = [];
|
|
4347
|
-
events = new
|
|
4382
|
+
events = new we();
|
|
4348
4383
|
// Navigator owns the state, not the engine
|
|
4349
4384
|
navigatorState = "idle";
|
|
4350
4385
|
// Scheduled by the "end" handler's pauseDuration delay — cleared on
|
|
@@ -4377,7 +4412,7 @@ class la {
|
|
|
4377
4412
|
// Index to speak() on the next play() when autoPause has stopped playback between utterances.
|
|
4378
4413
|
pendingAutoPauseIndex = null;
|
|
4379
4414
|
constructor(e, t = {}) {
|
|
4380
|
-
this.engine = e, this._defaults = new
|
|
4415
|
+
this.engine = e, this._defaults = new Js(t.defaults), this._preferences = new Y(t.preferences), this._settings = new vt(this._preferences, this._defaults), this.contextualizationOverrides = t.contextualizationOverrides, this.segmentationOverrides = t.segmentationOverrides, this.setupEngineListeners(), this.applyEngineParameters(), this.initializeEngine();
|
|
4381
4416
|
}
|
|
4382
4417
|
// Unlike pauseDuration/autoPause (read live off settings), the engine owns rate/pitch/volume and must be pushed.
|
|
4383
4418
|
applyEngineParameters() {
|
|
@@ -4423,13 +4458,13 @@ class la {
|
|
|
4423
4458
|
}
|
|
4424
4459
|
if (t === "paused") {
|
|
4425
4460
|
const s = e ?? 0;
|
|
4426
|
-
s > 0 ? this.engine.setCurrentUtteranceIndex(s, () => this.setNavigatorState("paused")) : this.setNavigatorState("paused");
|
|
4461
|
+
this.pendingAutoPauseIndex = s, s > 0 ? this.engine.setCurrentUtteranceIndex(s, () => this.setNavigatorState("paused")) : this.setNavigatorState("paused");
|
|
4427
4462
|
return;
|
|
4428
4463
|
}
|
|
4429
4464
|
this.setNavigatorState("ready"), this.emitEvent({ type: "ready" });
|
|
4430
4465
|
}
|
|
4431
4466
|
}), this.engine.on("boundary", (e) => {
|
|
4432
|
-
const { charIndex: t, charLength: s } = e.detail ?? {}, i = this.getCurrentContent(), a = i && typeof t == "number" && typeof s == "number" ?
|
|
4467
|
+
const { charIndex: t, charLength: s } = e.detail ?? {}, i = this.getCurrentContent(), a = i && typeof t == "number" && typeof s == "number" ? si(i, t, s) : void 0;
|
|
4433
4468
|
this.emitEvent(a ? { ...e, detail: { ...e.detail, ...a } } : e);
|
|
4434
4469
|
}), this.engine.on("mark", (e) => {
|
|
4435
4470
|
this.emitEvent(e);
|
|
@@ -4479,14 +4514,14 @@ class la {
|
|
|
4479
4514
|
// Re-runs extraction from `this.source`, resuming near the old position if playback was underway.
|
|
4480
4515
|
async reextract() {
|
|
4481
4516
|
if (!this.source) return;
|
|
4482
|
-
const e = this.navigatorState === "playing" || this.navigatorState === "paused" ? this.navigatorState : null, t = this.contentSources, s = this.getCurrentUtteranceIndex(), { utterances: i, sources: a, blockStarts: r } = await
|
|
4517
|
+
const e = this.navigatorState === "playing" || this.navigatorState === "paused" ? this.navigatorState : null, t = this.contentSources, s = this.getCurrentUtteranceIndex(), { utterances: i, sources: a, blockStarts: r } = await Zi(this.source, {
|
|
4483
4518
|
format: this._settings.format,
|
|
4484
4519
|
inlineContextualization: this._settings.inlineContextualization,
|
|
4485
4520
|
skip: this._settings.skip,
|
|
4486
4521
|
contextualize: this._settings.contextualize,
|
|
4487
4522
|
contextualization: {
|
|
4488
4523
|
contextualizations: this.contextualizationOverrides?.contextualizations,
|
|
4489
|
-
shapes:
|
|
4524
|
+
shapes: ni(this._settings.verbosity, this.contextualizationOverrides?.shapes),
|
|
4490
4525
|
params: this.contextualizationOverrides?.params
|
|
4491
4526
|
},
|
|
4492
4527
|
language: this._settings.language,
|
|
@@ -4537,7 +4572,13 @@ class la {
|
|
|
4537
4572
|
return;
|
|
4538
4573
|
}
|
|
4539
4574
|
pause() {
|
|
4540
|
-
this.navigatorState === "playing"
|
|
4575
|
+
if (this.navigatorState === "playing") {
|
|
4576
|
+
if (this.pendingAdvanceTimeout !== null) {
|
|
4577
|
+
this.clearPendingAdvance(), this.pendingAutoPauseIndex = this.getCurrentUtteranceIndex() + 1, this.setNavigatorState("paused"), this.emitEvent({ type: "pause" });
|
|
4578
|
+
return;
|
|
4579
|
+
}
|
|
4580
|
+
this.pendingAutoPauseIndex = null, this.setNavigatorState("paused"), this.engine.pause();
|
|
4581
|
+
}
|
|
4541
4582
|
}
|
|
4542
4583
|
stop() {
|
|
4543
4584
|
this.clearPendingAdvance(), this.pendingAutoPauseIndex = null, this.setNavigatorState("idle"), this.engine.stop(), this.emitEvent({ type: "stop" });
|
|
@@ -4588,7 +4629,7 @@ class la {
|
|
|
4588
4629
|
// LocatorOptions there — and the same "resolve, then skip if there's nothing
|
|
4589
4630
|
// to show" shape, since there's no raw engine event to fall back to unenriched.
|
|
4590
4631
|
emitUtteranceBoundary(e) {
|
|
4591
|
-
const t = this._settings.segmentation, s =
|
|
4632
|
+
const t = this._settings.segmentation, s = ii(e, t);
|
|
4592
4633
|
if (!s.length) return;
|
|
4593
4634
|
const i = t === "sentence" ? "sentence" : "structure";
|
|
4594
4635
|
this.emitEvent({
|
|
@@ -4604,16 +4645,16 @@ class la {
|
|
|
4604
4645
|
return this._settings;
|
|
4605
4646
|
}
|
|
4606
4647
|
get preferencesEditor() {
|
|
4607
|
-
return this._preferencesEditor === null && (this._preferencesEditor = new
|
|
4648
|
+
return this._preferencesEditor === null && (this._preferencesEditor = new mt(this._preferences, this.settings)), this._preferencesEditor;
|
|
4608
4649
|
}
|
|
4609
4650
|
async submitPreferences(e) {
|
|
4610
|
-
!this.source &&
|
|
4651
|
+
!this.source && this.contentQueue.length > 0 && ft.some((t) => e[t] !== void 0) && console.warn(
|
|
4611
4652
|
"submitPreferences(): extraction-affecting preferences (format, inlineContextualization, verbosity, skip, contextualize, language, segmentation) have no effect on content loaded via loadContent() — use loadGndContent() to re-extract on submission."
|
|
4612
4653
|
), this._preferences = this._preferences.merging(e), await this.applyPreferences();
|
|
4613
4654
|
}
|
|
4614
4655
|
async applyPreferences() {
|
|
4615
4656
|
const e = this._settings;
|
|
4616
|
-
this._settings = new
|
|
4657
|
+
this._settings = new vt(this._preferences, this._defaults), this.applyEngineParameters(), this._preferencesEditor !== null && (this._preferencesEditor = new mt(this._preferences, this._settings)), ft.some((t) => !this.sameSettingValue(e[t], this._settings[t])) && await this.reextract();
|
|
4617
4658
|
}
|
|
4618
4659
|
// Arrays (skip/contextualize) compare as sets, not by reference.
|
|
4619
4660
|
sameSettingValue(e, t) {
|
|
@@ -4624,61 +4665,77 @@ class la {
|
|
|
4624
4665
|
}
|
|
4625
4666
|
}
|
|
4626
4667
|
export {
|
|
4627
|
-
|
|
4628
|
-
|
|
4629
|
-
|
|
4630
|
-
|
|
4631
|
-
|
|
4632
|
-
|
|
4633
|
-
|
|
4634
|
-
|
|
4635
|
-
|
|
4636
|
-
|
|
4637
|
-
|
|
4638
|
-
|
|
4639
|
-
|
|
4668
|
+
Zs as BooleanPreference,
|
|
4669
|
+
$ as EnumPreference,
|
|
4670
|
+
ra as FallbackEngineProvider,
|
|
4671
|
+
$s as FallbackSpeechEngine,
|
|
4672
|
+
ma as Locator,
|
|
4673
|
+
va as LocatorLocations,
|
|
4674
|
+
ya as LocatorText,
|
|
4675
|
+
Ce as Preference,
|
|
4676
|
+
re as RangePreference,
|
|
4677
|
+
Qs as ReadiumSpeechDecorationController,
|
|
4678
|
+
da as ReadiumSpeechNavigator,
|
|
4679
|
+
la as ReadiumSpeechProviderRegistry,
|
|
4680
|
+
Js as SpeechDefaults,
|
|
4640
4681
|
Y as SpeechPreferences,
|
|
4641
|
-
|
|
4642
|
-
|
|
4643
|
-
|
|
4644
|
-
|
|
4682
|
+
mt as SpeechPreferencesEditor,
|
|
4683
|
+
Zt as SpeechServerAudioDecodeError,
|
|
4684
|
+
_s as SpeechServerEngine,
|
|
4685
|
+
aa as SpeechServerEngineProvider,
|
|
4645
4686
|
J as SpeechServerError,
|
|
4646
|
-
|
|
4647
|
-
|
|
4648
|
-
|
|
4649
|
-
|
|
4650
|
-
|
|
4651
|
-
|
|
4687
|
+
Yt as SpeechServerNetworkError,
|
|
4688
|
+
Jt as SpeechServerStallError,
|
|
4689
|
+
vt as SpeechSettings,
|
|
4690
|
+
pt as StringArrayPreference,
|
|
4691
|
+
dt as WebSpeechEngine,
|
|
4692
|
+
ia as WebSpeechEngineProvider,
|
|
4652
4693
|
b as WebSpeechVoiceManager,
|
|
4653
|
-
|
|
4654
|
-
|
|
4694
|
+
He as autoPauseScopes,
|
|
4695
|
+
ki as blockLevelRoles,
|
|
4655
4696
|
Q as chineseVariantMap,
|
|
4656
|
-
|
|
4657
|
-
|
|
4658
|
-
|
|
4659
|
-
|
|
4660
|
-
|
|
4661
|
-
|
|
4662
|
-
|
|
4663
|
-
|
|
4664
|
-
|
|
4665
|
-
|
|
4666
|
-
|
|
4667
|
-
|
|
4668
|
-
|
|
4669
|
-
|
|
4670
|
-
|
|
4671
|
-
|
|
4672
|
-
|
|
4673
|
-
|
|
4674
|
-
|
|
4675
|
-
|
|
4676
|
-
|
|
4677
|
-
|
|
4678
|
-
|
|
4679
|
-
|
|
4680
|
-
|
|
4697
|
+
Ps as chunkPlainText,
|
|
4698
|
+
xs as chunkSsmlText,
|
|
4699
|
+
Bt as compareAlphabetically,
|
|
4700
|
+
Nt as compareByPreferredRegion,
|
|
4701
|
+
ti as contextualizationShapesAtVerbosity,
|
|
4702
|
+
ei as contextualizedAtVerbosity,
|
|
4703
|
+
_ as createJsonOrderMap,
|
|
4704
|
+
Ws as createLocator,
|
|
4705
|
+
sn as defaultContextualizations,
|
|
4706
|
+
ha as extractUtterances,
|
|
4707
|
+
_e as extractionFormats,
|
|
4708
|
+
ft as extractionPreferenceKeys,
|
|
4709
|
+
Mt as filterByBoundarySupport,
|
|
4710
|
+
Hn as filterByLanguages,
|
|
4711
|
+
it as filterOutNoveltyVoices,
|
|
4712
|
+
at as filterOutVeryLowQualityVoices,
|
|
4713
|
+
ce as getQualityValue,
|
|
4714
|
+
be as groupVoicesByLanguage,
|
|
4715
|
+
Oe as isNoveltyVoice,
|
|
4716
|
+
Hs as isRecoverableFailure,
|
|
4717
|
+
Ue as isVeryLowQualityVoice,
|
|
4718
|
+
Fe as languageModes,
|
|
4719
|
+
Qt as mapServerVoice,
|
|
4720
|
+
Os as mimeTypeForFormat,
|
|
4721
|
+
ue as pauseDurationRangeConfig,
|
|
4722
|
+
Nn as pickBestVoiceByRegion,
|
|
4723
|
+
de as pitchRangeConfig,
|
|
4724
|
+
he as rateRangeConfig,
|
|
4725
|
+
si as resolveBoundaryLocate,
|
|
4726
|
+
ii as resolveUtteranceLocate,
|
|
4727
|
+
qe as segmentationModes,
|
|
4728
|
+
Bs as selectBitrate,
|
|
4729
|
+
Ts as selectFormat,
|
|
4730
|
+
oa as setupDecorations,
|
|
4731
|
+
ca as shapeableRoles,
|
|
4732
|
+
ua as skippableRoles,
|
|
4733
|
+
Xs as skippedAtVerbosity,
|
|
4734
|
+
Le as sortAlphabetically,
|
|
4735
|
+
Tn as sortByPreferredRegion,
|
|
4736
|
+
j as sortByQuality,
|
|
4737
|
+
zn as sortVoicesByRegions,
|
|
4681
4738
|
W as toSpeechServerError,
|
|
4682
|
-
|
|
4683
|
-
|
|
4739
|
+
je as verbosityPresets,
|
|
4740
|
+
ge as volumeRangeConfig
|
|
4684
4741
|
};
|