@readium/speech 0.16.0 → 0.16.1
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/WebSpeech/webSpeechEngine.d.ts +1 -1
- package/build/index.js +239 -232
- package/package.json +1 -1
package/build/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DecorationController as ci, DirectCommsChannel as ui, Decorator as hi } from "@readium/decorator";
|
|
2
2
|
export * from "@readium/decorator";
|
|
3
3
|
import { LocatorText as di, LocatorLocations as gi, Locator as fi } from "@readium/shared";
|
|
4
|
-
import { Locator as
|
|
4
|
+
import { Locator as fr, LocatorLocations as pr, LocatorText as mr } from "@readium/shared";
|
|
5
5
|
import { startsWithBindingPunct as he, ssmlTextEscape as T, BINDING_PUNCT_CLASS as se, ssmlAttrEscape as ln } from "@readium/helpers";
|
|
6
6
|
import pi from "i18next";
|
|
7
7
|
import { decodeTextref as Et, combineDomRangeTextrefs as mi, substitutedOwnSelector as vi, isAriaSubstituted as de } from "@readium/guided-navigation";
|
|
@@ -469,7 +469,7 @@ const wi = ["veryLow", "low", "normal", "high", "veryHigh"], ki = ["android", "a
|
|
|
469
469
|
e = `${t.toLowerCase()}-${i.toUpperCase()}`;
|
|
470
470
|
}
|
|
471
471
|
return re[e] || e;
|
|
472
|
-
},
|
|
472
|
+
}, De = async (n) => {
|
|
473
473
|
if (!n) return [];
|
|
474
474
|
try {
|
|
475
475
|
const e = V(n);
|
|
@@ -493,7 +493,7 @@ const wi = ["veryLow", "low", "normal", "high", "veryHigh"], ki = ["android", "a
|
|
|
493
493
|
} catch (e) {
|
|
494
494
|
return console.error(`Error in getVoices for ${n}:`, e), [];
|
|
495
495
|
}
|
|
496
|
-
},
|
|
496
|
+
}, je = (n, e) => {
|
|
497
497
|
try {
|
|
498
498
|
return new Intl.DisplayNames(
|
|
499
499
|
e ? [e] : [],
|
|
@@ -577,7 +577,7 @@ const wi = ["veryLow", "low", "normal", "high", "veryHigh"], ki = ["android", "a
|
|
|
577
577
|
}
|
|
578
578
|
const t = /* @__PURE__ */ new Map();
|
|
579
579
|
for (const [i, s] of e.entries()) {
|
|
580
|
-
const a = /* @__PURE__ */ new Map(), r = await
|
|
580
|
+
const a = /* @__PURE__ */ new Map(), r = await De(i), o = /* @__PURE__ */ new Map();
|
|
581
581
|
r.forEach((l, c) => {
|
|
582
582
|
o.set(l.name.toLowerCase(), c), l.altNames?.forEach((u) => {
|
|
583
583
|
o.set(u.toLowerCase(), c);
|
|
@@ -634,7 +634,7 @@ const wi = ["veryLow", "low", "normal", "high", "veryHigh"], ki = ["android", "a
|
|
|
634
634
|
const i = t ?? await H(n);
|
|
635
635
|
n.sort((s, a) => un(s, a, e, i));
|
|
636
636
|
}, hn = (n, e, t) => {
|
|
637
|
-
const [i] = k(n.language), [s] = k(e.language), a =
|
|
637
|
+
const [i] = k(n.language), [s] = k(e.language), a = je(i).toLowerCase(), r = je(s).toLowerCase(), o = a.localeCompare(r);
|
|
638
638
|
if (o !== 0)
|
|
639
639
|
return o;
|
|
640
640
|
if (i === s) {
|
|
@@ -737,7 +737,7 @@ function Bi(n, e) {
|
|
|
737
737
|
const t = [n.originalName, ...n.altNames || []], i = [e.originalName, ...e.altNames || []], s = t.findIndex((r) => i.includes(r)), a = i.findIndex((r) => t.includes(r));
|
|
738
738
|
return s === -1 && a === -1 || s !== -1 && (a === -1 || s <= a) ? n : e;
|
|
739
739
|
}
|
|
740
|
-
function
|
|
740
|
+
function Di(n, e) {
|
|
741
741
|
if (!n.altNames && !e.altNames)
|
|
742
742
|
return !1;
|
|
743
743
|
const t = n.originalName, i = e.originalName, s = n.altNames || [], a = e.altNames || [];
|
|
@@ -937,7 +937,7 @@ class C {
|
|
|
937
937
|
const s = `${i.language.toLowerCase()}_${this.normalizeVoiceName(i.name)}`, a = t.get(s);
|
|
938
938
|
if (!a)
|
|
939
939
|
t.set(s, i);
|
|
940
|
-
else if (
|
|
940
|
+
else if (Di(i, a)) {
|
|
941
941
|
const r = Bi(i, a);
|
|
942
942
|
t.set(s, r);
|
|
943
943
|
} else {
|
|
@@ -1002,7 +1002,7 @@ class C {
|
|
|
1002
1002
|
const a = V(s).split("-")[0];
|
|
1003
1003
|
i.set(a, (i.get(a) ?? 0) + 1);
|
|
1004
1004
|
}
|
|
1005
|
-
return [...i].map(([s, a]) => ({ code: s, label:
|
|
1005
|
+
return [...i].map(([s, a]) => ({ code: s, label: je(s, t), count: a }));
|
|
1006
1006
|
}
|
|
1007
1007
|
/**
|
|
1008
1008
|
* Get available regions with voice counts
|
|
@@ -1083,8 +1083,8 @@ class C {
|
|
|
1083
1083
|
return await Promise.all(
|
|
1084
1084
|
e.filter((s) => s?.name && s?.lang).map(async (s) => {
|
|
1085
1085
|
const a = V(s.lang), [r] = C.extractLangRegionFromBCP47(a), o = this.normalizeVoiceName(s.name), l = `${s.lang.toLowerCase()}_${o}`, c = t.get(l) || 1;
|
|
1086
|
-
let u = await
|
|
1087
|
-
(!u || u.length === 0) && (u = await
|
|
1086
|
+
let u = await De(a);
|
|
1087
|
+
(!u || u.length === 0) && (u = await De(r));
|
|
1088
1088
|
const g = this.findMatchingJsonVoice(u, o), d = this.inferVoiceQuality(s, g, c), h = this.isAndroid ? { ...g?.controls, boundary: !1 } : g?.controls;
|
|
1089
1089
|
return g ? {
|
|
1090
1090
|
...g,
|
|
@@ -1247,7 +1247,7 @@ class C {
|
|
|
1247
1247
|
const pn = (n, e) => {
|
|
1248
1248
|
const [t, i] = k(e), [s, a] = k(n.language);
|
|
1249
1249
|
return s === t && (!i || a === i);
|
|
1250
|
-
}, Ge = (n, e) => !!n && k(n.language)[0] === k(e)[0],
|
|
1250
|
+
}, Ge = (n, e) => !!n && k(n.language)[0] === k(e)[0], ji = ["webKit", "moz", "ms", "o"], Fi = [
|
|
1251
1251
|
"boundary",
|
|
1252
1252
|
"end",
|
|
1253
1253
|
"error",
|
|
@@ -1256,7 +1256,7 @@ const pn = (n, e) => {
|
|
|
1256
1256
|
"resume",
|
|
1257
1257
|
"start"
|
|
1258
1258
|
], _i = (n) => `${n.charAt(0).toUpperCase()}${n.slice(1)}`, ne = (n = {}, e) => Object.hasOwnProperty.call(n, e) || e in n || !!n[e], $i = (n) => typeof window < "u" && n in window, qi = (n) => {
|
|
1259
|
-
const e = _i(n), t =
|
|
1259
|
+
const e = _i(n), t = ji.map((s) => `${s}${e}`), i = [n, e].concat(t).find($i);
|
|
1260
1260
|
return i && typeof window < "u" ? window[i] : void 0;
|
|
1261
1261
|
}, Gi = () => {
|
|
1262
1262
|
const n = {};
|
|
@@ -1475,7 +1475,7 @@ function rs(n, e) {
|
|
|
1475
1475
|
const B = R.start === I, ee = R.end > E.end;
|
|
1476
1476
|
if (B) {
|
|
1477
1477
|
c += R.replacement;
|
|
1478
|
-
for (let
|
|
1478
|
+
for (let D = 0; D < R.replacement.length; D++) u.push(R.start);
|
|
1479
1479
|
E.atomIndex === -1 || ee ? (f(), l += T(R.replacement)) : (g !== E.atomIndex && (f(), g = E.atomIndex), d += T(R.replacement));
|
|
1480
1480
|
}
|
|
1481
1481
|
I = Math.min(R.end, E.end), R.end <= E.end && h++;
|
|
@@ -1576,6 +1576,7 @@ function ds(n) {
|
|
|
1576
1576
|
const i = n.slice(t).trim();
|
|
1577
1577
|
return i && e.push({ ssml: i }), e;
|
|
1578
1578
|
}
|
|
1579
|
+
const gs = 250;
|
|
1579
1580
|
class Nt {
|
|
1580
1581
|
speechSynthesis;
|
|
1581
1582
|
speechSynthesisUtterance;
|
|
@@ -1608,8 +1609,8 @@ class Nt {
|
|
|
1608
1609
|
maxLengthExceeded = "warn";
|
|
1609
1610
|
utterancesBeingCancelled = !1;
|
|
1610
1611
|
// Flag to track if utterances are being cancelled
|
|
1611
|
-
|
|
1612
|
-
// Safari: cancel() stopped speech
|
|
1612
|
+
lastCancelAt = -1 / 0;
|
|
1613
|
+
// Safari: when cancel() last stopped speech
|
|
1613
1614
|
lacksNativePauseEvents = !1;
|
|
1614
1615
|
// Google and Chrome OS voices never fire onpause/onresume
|
|
1615
1616
|
// Playback parameters
|
|
@@ -1789,8 +1790,10 @@ class Nt {
|
|
|
1789
1790
|
}
|
|
1790
1791
|
this.patches.isSafari && this.speakGeneration++, this.cancelCurrentSpeech();
|
|
1791
1792
|
const t = ++this.speakGeneration;
|
|
1792
|
-
|
|
1793
|
-
|
|
1793
|
+
this.isSpeakingInternal = !0, this.isPausedInternal = !1, this.setState("playing"), this.stopResumeInfinity(), this.currentUtteranceIndex >= this.currentUtterances.length && (this.currentUtteranceIndex = 0);
|
|
1794
|
+
const i = this.lastCancelAt + gs - Date.now();
|
|
1795
|
+
if (this.patches.isSafari && i > 0) {
|
|
1796
|
+
this.speakNextTask(t, 1, i);
|
|
1794
1797
|
return;
|
|
1795
1798
|
}
|
|
1796
1799
|
this.speakCurrentUtterance(t);
|
|
@@ -1798,15 +1801,19 @@ class Nt {
|
|
|
1798
1801
|
cancelCurrentSpeech() {
|
|
1799
1802
|
this.patches.isFirefox && this.speechSynthesis.speaking && (this.utterancesBeingCancelled = !0, setTimeout(() => {
|
|
1800
1803
|
this.utterancesBeingCancelled = !1;
|
|
1801
|
-
}, 100)), this.patches.isSafari && this.speechSynthesis.speaking && (this.
|
|
1802
|
-
this.hasCancelledInTask = !1;
|
|
1803
|
-
}, 0)), this.speechSynthesis.cancel();
|
|
1804
|
+
}, 100)), this.patches.isSafari && this.speechSynthesis.speaking && (this.lastCancelAt = Date.now()), this.speechSynthesis.cancel();
|
|
1804
1805
|
}
|
|
1805
1806
|
// Safari: `unstartedRetries` is how many more times to speak it if Safari ends it without starting it, as it can right after cancel()
|
|
1806
|
-
speakNextTask(e, t) {
|
|
1807
|
+
speakNextTask(e, t, i = 0) {
|
|
1807
1808
|
setTimeout(() => {
|
|
1808
|
-
e === this.speakGeneration
|
|
1809
|
-
|
|
1809
|
+
if (e === this.speakGeneration) {
|
|
1810
|
+
if (this.playbackState === "paused") {
|
|
1811
|
+
this.pausedAtUtteranceIndex = null;
|
|
1812
|
+
return;
|
|
1813
|
+
}
|
|
1814
|
+
this.playbackState === "playing" && this.speakCurrentUtterance(e, t);
|
|
1815
|
+
}
|
|
1816
|
+
}, i);
|
|
1810
1817
|
}
|
|
1811
1818
|
async speakCurrentUtterance(e, t) {
|
|
1812
1819
|
if (this.currentUtteranceIndex >= this.currentUtterances.length) {
|
|
@@ -1981,7 +1988,7 @@ class Nt {
|
|
|
1981
1988
|
this.stop(), this.stopResumeInfinity(), this.events.clear(), this.currentUtterances = [], this.currentVoice = null, this.speakingVoice = null, this.voiceManager = null, this.defaultVoice = null, this.languageVoiceCache.clear(), this.warmingLanguages.clear(), this.initialized = !1;
|
|
1982
1989
|
}
|
|
1983
1990
|
}
|
|
1984
|
-
class
|
|
1991
|
+
class tr {
|
|
1985
1992
|
id = "webspeech";
|
|
1986
1993
|
name = "Web Speech API";
|
|
1987
1994
|
voiceEngine = null;
|
|
@@ -2001,7 +2008,7 @@ function Cn(n, e) {
|
|
|
2001
2008
|
const t = [];
|
|
2002
2009
|
let i = -1, s = -1;
|
|
2003
2010
|
const a = () => {
|
|
2004
|
-
i !== -1 && (t.push({ text:
|
|
2011
|
+
i !== -1 && (t.push({ text: fs(n, i, s), offset: n[i].offset }), i = -1, s = -1);
|
|
2005
2012
|
};
|
|
2006
2013
|
for (let r = 0; r < n.length; r++) {
|
|
2007
2014
|
const o = n[r];
|
|
@@ -2014,14 +2021,14 @@ function Cn(n, e) {
|
|
|
2014
2021
|
}
|
|
2015
2022
|
return a(), t;
|
|
2016
2023
|
}
|
|
2017
|
-
function
|
|
2024
|
+
function fs(n, e, t) {
|
|
2018
2025
|
const i = n[e], s = n[t];
|
|
2019
2026
|
return i === s ? i.text : n.slice(e, t + 1).map((a) => a.text).join("");
|
|
2020
2027
|
}
|
|
2021
2028
|
const En = new RegExp(
|
|
2022
2029
|
`[^${se}]*[${se}]+\\s*|[^${se}]+$`,
|
|
2023
2030
|
"gu"
|
|
2024
|
-
),
|
|
2031
|
+
), ps = /\S+\s*|\s+/g;
|
|
2025
2032
|
function rt(n, e, t) {
|
|
2026
2033
|
const i = [];
|
|
2027
2034
|
for (const s of n.matchAll(t))
|
|
@@ -2031,7 +2038,7 @@ function rt(n, e, t) {
|
|
|
2031
2038
|
function ot(n, e) {
|
|
2032
2039
|
if (n.text.length <= e || n.atomic)
|
|
2033
2040
|
return [n];
|
|
2034
|
-
const t = rt(n.text, n.offset,
|
|
2041
|
+
const t = rt(n.text, n.offset, ps);
|
|
2035
2042
|
if (t.length > 1)
|
|
2036
2043
|
return t.flatMap((r) => ot(r, e));
|
|
2037
2044
|
const i = [];
|
|
@@ -2040,23 +2047,23 @@ function ot(n, e) {
|
|
|
2040
2047
|
a.length > 0 && a.length + r.length > e && (i.push({ text: a, offset: s, atomic: !1 }), s += a.length, a = ""), a += r;
|
|
2041
2048
|
return a.length > 0 && i.push({ text: a, offset: s, atomic: !1 }), i;
|
|
2042
2049
|
}
|
|
2043
|
-
function
|
|
2050
|
+
function ms(n, e) {
|
|
2044
2051
|
if (n.length <= e)
|
|
2045
2052
|
return [{ text: n, offset: 0 }];
|
|
2046
2053
|
const i = rt(n, 0, En).flatMap((s) => ot(s, e));
|
|
2047
2054
|
return Cn(i, e);
|
|
2048
2055
|
}
|
|
2049
|
-
const
|
|
2050
|
-
function
|
|
2056
|
+
const vs = /<([a-zA-Z][\w-]*)\b[^>]*>[\s\S]*?<\/\1>|<[a-zA-Z][\w-]*\b[^>]*\/>|[^<]+/g;
|
|
2057
|
+
function ys(n, e) {
|
|
2051
2058
|
if (n.length <= e)
|
|
2052
2059
|
return [{ text: n, offset: 0 }];
|
|
2053
2060
|
const t = [];
|
|
2054
|
-
for (const s of n.matchAll(
|
|
2061
|
+
for (const s of n.matchAll(vs))
|
|
2055
2062
|
s[0][0] === "<" ? t.push({ text: s[0], offset: s.index, atomic: !0 }) : t.push(...rt(s[0], s.index, En));
|
|
2056
2063
|
const i = t.flatMap((s) => ot(s, e));
|
|
2057
2064
|
return Cn(i, e);
|
|
2058
2065
|
}
|
|
2059
|
-
const
|
|
2066
|
+
const Ss = {
|
|
2060
2067
|
wav: "audio/wav",
|
|
2061
2068
|
mp3: "audio/mpeg",
|
|
2062
2069
|
opus: "audio/ogg",
|
|
@@ -2066,29 +2073,29 @@ const ys = {
|
|
|
2066
2073
|
webm: "audio/webm",
|
|
2067
2074
|
m4a: "audio/mp4"
|
|
2068
2075
|
};
|
|
2069
|
-
function
|
|
2070
|
-
return
|
|
2076
|
+
function bs(n) {
|
|
2077
|
+
return Ss[n] ?? `audio/${n}`;
|
|
2071
2078
|
}
|
|
2072
|
-
const
|
|
2073
|
-
function
|
|
2074
|
-
const i = (o) => t(
|
|
2079
|
+
const ws = ["flac", "wav", "opus", "aac", "ogg", "webm", "mp3"], ks = ["opus", "aac", "webm", "ogg", "mp3", "wav", "flac"];
|
|
2080
|
+
function Cs(n, e, t) {
|
|
2081
|
+
const i = (o) => t(bs(o)) !== "", s = n.formats.filter(i);
|
|
2075
2082
|
if (e.preferredFormat && s.includes(e.preferredFormat))
|
|
2076
2083
|
return e.preferredFormat;
|
|
2077
|
-
const a = e.strategy === "bandwidth" ?
|
|
2084
|
+
const a = e.strategy === "bandwidth" ? ks : ws, r = [...a, ...s.filter((o) => !a.includes(o))];
|
|
2078
2085
|
for (const o of r)
|
|
2079
2086
|
if (s.includes(o))
|
|
2080
2087
|
return o;
|
|
2081
2088
|
return n.default;
|
|
2082
2089
|
}
|
|
2083
|
-
const
|
|
2090
|
+
const Es = /* @__PURE__ */ new Set(["wav", "flac"]), Rs = {
|
|
2084
2091
|
mp3: 48e3,
|
|
2085
2092
|
opus: 24e3,
|
|
2086
2093
|
aac: 48e3,
|
|
2087
2094
|
ogg: 48e3,
|
|
2088
2095
|
webm: 32e3
|
|
2089
2096
|
};
|
|
2090
|
-
function
|
|
2091
|
-
return
|
|
2097
|
+
function Is(n, e, t) {
|
|
2098
|
+
return Es.has(n) || !e || !t ? void 0 : t.saveData === !0 || /2g/.test(t.effectiveType ?? "") ? Rs[n] : void 0;
|
|
2092
2099
|
}
|
|
2093
2100
|
function Rn(n, e) {
|
|
2094
2101
|
return {
|
|
@@ -2143,14 +2150,14 @@ async function ae(n) {
|
|
|
2143
2150
|
}
|
|
2144
2151
|
return new oe(`Request failed with status ${n.status}`, { status: n.status });
|
|
2145
2152
|
}
|
|
2146
|
-
const
|
|
2147
|
-
function
|
|
2153
|
+
const Ps = 3, As = 400;
|
|
2154
|
+
function Ls(n) {
|
|
2148
2155
|
const e = atob(n), t = new Uint8Array(e.length);
|
|
2149
2156
|
for (let i = 0; i < e.length; i++)
|
|
2150
2157
|
t[i] = e.charCodeAt(i);
|
|
2151
2158
|
return t.buffer;
|
|
2152
2159
|
}
|
|
2153
|
-
function
|
|
2160
|
+
function Os(n) {
|
|
2154
2161
|
return q(n, 0.25, 4, 1);
|
|
2155
2162
|
}
|
|
2156
2163
|
function pe(n) {
|
|
@@ -2159,7 +2166,7 @@ function pe(n) {
|
|
|
2159
2166
|
function Mt(n) {
|
|
2160
2167
|
return n instanceof In ? { message: n.message, status: n.status, type: n.type, title: n.title, instance: n.instance, recoverable: !0 } : n instanceof oe ? { message: n.message, status: n.status, type: n.type, title: n.title, instance: n.instance, recoverable: !1 } : n instanceof Pn ? { message: n.message, recoverable: !1 } : n instanceof An ? { message: n.message, recoverable: !0 } : n instanceof Error ? { message: n.message, recoverable: !1 } : { message: String(n), recoverable: !1 };
|
|
2161
2168
|
}
|
|
2162
|
-
class
|
|
2169
|
+
class Vs {
|
|
2163
2170
|
endpoints;
|
|
2164
2171
|
fetchImpl;
|
|
2165
2172
|
currentVoice = null;
|
|
@@ -2203,7 +2210,7 @@ class Os {
|
|
|
2203
2210
|
pitch = 1;
|
|
2204
2211
|
volume = 1;
|
|
2205
2212
|
constructor(e) {
|
|
2206
|
-
this.endpoints = e.endpoints, this.fetchImpl = e.fetch ?? fetch.bind(globalThis), this.prefetchWindow = e.prefetchWindow ??
|
|
2213
|
+
this.endpoints = e.endpoints, this.fetchImpl = e.fetch ?? fetch.bind(globalThis), this.prefetchWindow = e.prefetchWindow ?? Ps, this.readyBufferChars = e.readyBufferChars ?? As, this.overLengthText = e.overLengthText ?? "split", this.timeoutMs = e.timeoutMs, this.formatOptions = e.format ?? {}, this.canPlayType = typeof Audio < "u" ? (t) => new Audio().canPlayType(t) : () => "";
|
|
2207
2214
|
}
|
|
2208
2215
|
// Lets a provider that already fetched /voices seed this engine without a second request.
|
|
2209
2216
|
setAvailableVoices(e) {
|
|
@@ -2404,7 +2411,7 @@ class Os {
|
|
|
2404
2411
|
this.liveControllers.forEach((e) => e.abort()), this.liveControllers.clear();
|
|
2405
2412
|
}
|
|
2406
2413
|
async synthesizeStream(e, t) {
|
|
2407
|
-
const i = this.currentUtterances[e], s = !i.plain && !!i.ssml, a = i.language, r = pe(i) ?? "", o = s ? vn(r).map : void 0, l = pe(this.currentUtterances[e - 1]), c = pe(this.currentUtterances[e + 1]), u = await this.getServiceInfo(), g =
|
|
2414
|
+
const i = this.currentUtterances[e], s = !i.plain && !!i.ssml, a = i.language, r = pe(i) ?? "", o = s ? vn(r).map : void 0, l = pe(this.currentUtterances[e - 1]), c = pe(this.currentUtterances[e + 1]), u = await this.getServiceInfo(), g = Cs(u.output, this.formatOptions, this.canPlayType), d = navigator.connection, h = Is(g, this.formatOptions.adaptBitrateToNetwork ?? !1, d);
|
|
2408
2415
|
if (r.length <= u.limits.maxTextLength) {
|
|
2409
2416
|
const v = new AbortController();
|
|
2410
2417
|
return (t ? this.activeControllers : this.liveControllers).add(v), [{
|
|
@@ -2421,7 +2428,7 @@ class Os {
|
|
|
2421
2428
|
title: "Payload Too Large"
|
|
2422
2429
|
}
|
|
2423
2430
|
);
|
|
2424
|
-
const f = Math.min(u.limits.maxTextLength, this.readyBufferChars), p = s ?
|
|
2431
|
+
const f = Math.min(u.limits.maxTextLength, this.readyBufferChars), p = s ? ys(r, f) : ms(r, f), m = [];
|
|
2425
2432
|
let S = Promise.resolve();
|
|
2426
2433
|
for (let v = 0; v < p.length; v++) {
|
|
2427
2434
|
const w = v === 0 ? l : p[v - 1].text, y = v === p.length - 1 ? c : p[v + 1].text, b = p[v], P = new AbortController();
|
|
@@ -2454,7 +2461,7 @@ class Os {
|
|
|
2454
2461
|
});
|
|
2455
2462
|
if (!f.ok)
|
|
2456
2463
|
throw await ae(f);
|
|
2457
|
-
const p = await f.json(), m =
|
|
2464
|
+
const p = await f.json(), m = Ls(p.audio);
|
|
2458
2465
|
let S;
|
|
2459
2466
|
try {
|
|
2460
2467
|
S = await this.ensureAudioContext().decodeAudioData(m);
|
|
@@ -2497,7 +2504,7 @@ class Os {
|
|
|
2497
2504
|
const s = await this.awaitWithStallDeadline(e[0].promise, e[0].controller, 0);
|
|
2498
2505
|
if (t !== this.speakGeneration)
|
|
2499
2506
|
return;
|
|
2500
|
-
const a = this.ensureAudioContext(), r = this.masterGain, l = i?.controls?.speed === !0 ? 1 :
|
|
2507
|
+
const a = this.ensureAudioContext(), r = this.masterGain, l = i?.controls?.speed === !0 ? 1 : Os(this.rate);
|
|
2501
2508
|
this.scheduledChunks = [], this.setState("playing"), this.emitEvent({ type: "start", detail: { voice: i } });
|
|
2502
2509
|
let c = a.currentTime, u = null;
|
|
2503
2510
|
const g = (d) => {
|
|
@@ -2662,7 +2669,7 @@ class Os {
|
|
|
2662
2669
|
this.stop(), await this.audioContext?.close(), this.audioContext = null, this.masterGain = null, this.events.clear(), this.currentUtterances = [], this.currentVoice = null, this.defaultVoice = null, this.voices = [], this.voicesRequest = null, this.languageVoiceCache.clear();
|
|
2663
2670
|
}
|
|
2664
2671
|
}
|
|
2665
|
-
class
|
|
2672
|
+
class nr {
|
|
2666
2673
|
id = "speech-server";
|
|
2667
2674
|
name = "Readium Speech Server";
|
|
2668
2675
|
options;
|
|
@@ -2686,17 +2693,17 @@ class tr {
|
|
|
2686
2693
|
return this.voices = s.map((o) => Rn(o, r.get(o.provider))), this.voices;
|
|
2687
2694
|
}
|
|
2688
2695
|
async createEngine(e) {
|
|
2689
|
-
const t = new
|
|
2696
|
+
const t = new Vs(this.options);
|
|
2690
2697
|
return this.voices.length > 0 && t.setAvailableVoices(this.voices), e && t.setVoice(e), t;
|
|
2691
2698
|
}
|
|
2692
2699
|
async destroy() {
|
|
2693
2700
|
this.voices = [];
|
|
2694
2701
|
}
|
|
2695
2702
|
}
|
|
2696
|
-
function
|
|
2703
|
+
function xs(n) {
|
|
2697
2704
|
return n.detail?.recoverable === !0;
|
|
2698
2705
|
}
|
|
2699
|
-
const
|
|
2706
|
+
const Us = 3e4, Ts = [
|
|
2700
2707
|
"start",
|
|
2701
2708
|
"pause",
|
|
2702
2709
|
"resume",
|
|
@@ -2711,7 +2718,7 @@ const xs = 3e4, Us = [
|
|
|
2711
2718
|
"voiceschanged",
|
|
2712
2719
|
"languagefallback"
|
|
2713
2720
|
];
|
|
2714
|
-
class
|
|
2721
|
+
class zs {
|
|
2715
2722
|
activeEngine;
|
|
2716
2723
|
primaryProvider;
|
|
2717
2724
|
fallbackProvider;
|
|
@@ -2746,7 +2753,7 @@ class Ts {
|
|
|
2746
2753
|
events = new Ae();
|
|
2747
2754
|
unbindActiveEngine = null;
|
|
2748
2755
|
constructor(e) {
|
|
2749
|
-
this.activeEngine = e.primaryEngine, this.primaryProvider = e.primaryProvider, this.fallbackProvider = e.fallbackProvider, this.onFailure = e.onFailure ?? "fallback", this.healthCheckIntervalMs = e.healthCheckIntervalMs ??
|
|
2756
|
+
this.activeEngine = e.primaryEngine, this.primaryProvider = e.primaryProvider, this.fallbackProvider = e.fallbackProvider, this.onFailure = e.onFailure ?? "fallback", this.healthCheckIntervalMs = e.healthCheckIntervalMs ?? Us, this.lastVoiceRequest = e.primaryEngine.getCurrentVoice() ?? void 0, this.bindActiveEngine();
|
|
2750
2757
|
}
|
|
2751
2758
|
async initialize() {
|
|
2752
2759
|
return this.activeEngine.initialize?.();
|
|
@@ -2840,13 +2847,13 @@ class Ts {
|
|
|
2840
2847
|
this.events.emit(e.type, e);
|
|
2841
2848
|
}
|
|
2842
2849
|
bindActiveEngine() {
|
|
2843
|
-
const e = this.activeEngine, t =
|
|
2850
|
+
const e = this.activeEngine, t = Ts.map((i) => e.on(i, (s) => {
|
|
2844
2851
|
this.emitEvent(s), this.maybeRecoverNow();
|
|
2845
2852
|
}));
|
|
2846
2853
|
t.push(e.on("error", (i) => this.handleError(i))), this.unbindActiveEngine = () => t.forEach((i) => i());
|
|
2847
2854
|
}
|
|
2848
2855
|
handleError(e) {
|
|
2849
|
-
if (this.hasFallenBack || this.swapInFlight || this.onFailure === "error" || !
|
|
2856
|
+
if (this.hasFallenBack || this.swapInFlight || this.onFailure === "error" || !xs(e)) {
|
|
2850
2857
|
this.emitEvent(e);
|
|
2851
2858
|
return;
|
|
2852
2859
|
}
|
|
@@ -2945,7 +2952,7 @@ class Ts {
|
|
|
2945
2952
|
this.teardownEpoch++, this.healthCheckTimer !== null && (clearTimeout(this.healthCheckTimer), this.healthCheckTimer = null), this.unbindActiveEngine?.(), this.events.clear(), await this.activeEngine.destroy();
|
|
2946
2953
|
}
|
|
2947
2954
|
}
|
|
2948
|
-
class
|
|
2955
|
+
class ir {
|
|
2949
2956
|
id = "fallback";
|
|
2950
2957
|
name = "Fallback";
|
|
2951
2958
|
primary;
|
|
@@ -2973,7 +2980,7 @@ class nr {
|
|
|
2973
2980
|
throw i;
|
|
2974
2981
|
return this.fallback.createEngine(e);
|
|
2975
2982
|
}
|
|
2976
|
-
return new
|
|
2983
|
+
return new zs({
|
|
2977
2984
|
primaryEngine: t,
|
|
2978
2985
|
primaryProvider: this.primary,
|
|
2979
2986
|
fallbackProvider: this.fallback,
|
|
@@ -2985,15 +2992,15 @@ class nr {
|
|
|
2985
2992
|
await Promise.all([this.primary.destroy(), this.fallback.destroy()]);
|
|
2986
2993
|
}
|
|
2987
2994
|
}
|
|
2988
|
-
function
|
|
2995
|
+
function Ns(n) {
|
|
2989
2996
|
return new yi({
|
|
2990
2997
|
start: new Rt(n.start),
|
|
2991
2998
|
end: n.end ? new Rt(n.end) : void 0
|
|
2992
2999
|
});
|
|
2993
3000
|
}
|
|
2994
|
-
function
|
|
3001
|
+
function Ms(n, e = window) {
|
|
2995
3002
|
const { href: t, text: i, cssSelector: s, domRange: a, fragment: r } = n, o = i ? new di(i) : void 0, l = s || a ? /* @__PURE__ */ new Map() : void 0;
|
|
2996
|
-
l && (s && l.set("cssSelector", s), a && l.set("domRange",
|
|
3003
|
+
l && (s && l.set("cssSelector", s), a && l.set("domRange", Ns(a).serialize()));
|
|
2997
3004
|
const u = l !== void 0 || r !== void 0 ? new gi({
|
|
2998
3005
|
fragments: r ? [r] : void 0,
|
|
2999
3006
|
otherLocations: l
|
|
@@ -3005,7 +3012,7 @@ function Ns(n, e = window) {
|
|
|
3005
3012
|
locations: u
|
|
3006
3013
|
});
|
|
3007
3014
|
}
|
|
3008
|
-
class
|
|
3015
|
+
class Bs extends ci {
|
|
3009
3016
|
constructor(e, t, i, s = {}) {
|
|
3010
3017
|
super(e.host, s), this.channel = e, this.wnd = t, this.decorator = i;
|
|
3011
3018
|
}
|
|
@@ -3021,7 +3028,7 @@ class Ms extends ci {
|
|
|
3021
3028
|
e.map(({ id: i, style: s, ...a }) => ({
|
|
3022
3029
|
id: i,
|
|
3023
3030
|
style: s,
|
|
3024
|
-
locator:
|
|
3031
|
+
locator: Ms(a, this.wnd)
|
|
3025
3032
|
})),
|
|
3026
3033
|
t
|
|
3027
3034
|
);
|
|
@@ -3030,12 +3037,12 @@ class Ms extends ci {
|
|
|
3030
3037
|
super.destroy(), this.decorator.unmount(this.wnd, this.channel.frame), this.channel.frame.destroy();
|
|
3031
3038
|
}
|
|
3032
3039
|
}
|
|
3033
|
-
function
|
|
3040
|
+
function sr(n = window, e = {}) {
|
|
3034
3041
|
const t = new ui(), i = new hi();
|
|
3035
|
-
return i.mount(n, t.frame), new
|
|
3042
|
+
return i.mount(n, t.frame), new Bs(t, n, i, e);
|
|
3036
3043
|
}
|
|
3037
3044
|
const Ln = (n) => n.voiceURI ?? n.identifier ?? n.name;
|
|
3038
|
-
class
|
|
3045
|
+
class ar {
|
|
3039
3046
|
providers = /* @__PURE__ */ new Map();
|
|
3040
3047
|
register(e) {
|
|
3041
3048
|
if (this.providers.has(e.id))
|
|
@@ -3085,7 +3092,7 @@ const Le = (n, e, t) => Object.freeze({ range: Object.freeze([n, e]), step: t })
|
|
|
3085
3092
|
"languageOverrides",
|
|
3086
3093
|
"segmentation"
|
|
3087
3094
|
]);
|
|
3088
|
-
function
|
|
3095
|
+
function Ds(n) {
|
|
3089
3096
|
return n == null || typeof n == "boolean" ? n : void 0;
|
|
3090
3097
|
}
|
|
3091
3098
|
function O(n, e) {
|
|
@@ -3204,9 +3211,9 @@ class ie extends K {
|
|
|
3204
3211
|
return this._supportedValues;
|
|
3205
3212
|
}
|
|
3206
3213
|
}
|
|
3207
|
-
class
|
|
3214
|
+
class rr extends K {
|
|
3208
3215
|
set value(e) {
|
|
3209
|
-
if (e != null &&
|
|
3216
|
+
if (e != null && Ds(e) === void 0)
|
|
3210
3217
|
throw new Error(`Value '${String(e)}' is not a boolean.`);
|
|
3211
3218
|
this._value = e, this._onChange(this._value);
|
|
3212
3219
|
}
|
|
@@ -3268,7 +3275,7 @@ class me extends K {
|
|
|
3268
3275
|
return e.toString();
|
|
3269
3276
|
}
|
|
3270
3277
|
}
|
|
3271
|
-
class
|
|
3278
|
+
class Dt {
|
|
3272
3279
|
preferences;
|
|
3273
3280
|
settings;
|
|
3274
3281
|
// Cloned rather than aliased: edits made through this editor's setters
|
|
@@ -3441,7 +3448,7 @@ const Vn = ["audio", "figure", "image", "math", "table", "video"], xn = [
|
|
|
3441
3448
|
"rowheader",
|
|
3442
3449
|
"subtitle",
|
|
3443
3450
|
"tip"
|
|
3444
|
-
],
|
|
3451
|
+
], Fs = [
|
|
3445
3452
|
...xn,
|
|
3446
3453
|
"abstract",
|
|
3447
3454
|
"acknowledgments",
|
|
@@ -3486,7 +3493,7 @@ const Vn = ["audio", "figure", "image", "math", "table", "video"], xn = [
|
|
|
3486
3493
|
"separator",
|
|
3487
3494
|
"summary",
|
|
3488
3495
|
"term"
|
|
3489
|
-
],
|
|
3496
|
+
], _s = {
|
|
3490
3497
|
none: /* @__PURE__ */ new Set([
|
|
3491
3498
|
"aside",
|
|
3492
3499
|
"audio",
|
|
@@ -3554,11 +3561,11 @@ const Vn = ["audio", "figure", "image", "math", "table", "video"], xn = [
|
|
|
3554
3561
|
"toc"
|
|
3555
3562
|
]),
|
|
3556
3563
|
most: /* @__PURE__ */ new Set(["landmarks", "loa", "loi", "lot", "lov", "toc"])
|
|
3557
|
-
},
|
|
3564
|
+
}, $s = {
|
|
3558
3565
|
none: /* @__PURE__ */ new Set(),
|
|
3559
3566
|
few: new Set(Vn),
|
|
3560
3567
|
some: new Set(xn),
|
|
3561
|
-
most: new Set(
|
|
3568
|
+
most: new Set(Fs)
|
|
3562
3569
|
}, Ke = {
|
|
3563
3570
|
table: { few: "inline", some: "block", most: "block" }
|
|
3564
3571
|
};
|
|
@@ -3568,14 +3575,14 @@ function ve(n) {
|
|
|
3568
3575
|
e[t] = Ke[t]?.[n] ?? "inline";
|
|
3569
3576
|
return e;
|
|
3570
3577
|
}
|
|
3571
|
-
const
|
|
3578
|
+
const qs = {
|
|
3572
3579
|
none: ve("none"),
|
|
3573
3580
|
few: ve("few"),
|
|
3574
3581
|
some: ve("some"),
|
|
3575
3582
|
most: ve("most")
|
|
3576
|
-
},
|
|
3577
|
-
function
|
|
3578
|
-
const t = n === "custom" ? {} :
|
|
3583
|
+
}, or = Object.keys(Ke);
|
|
3584
|
+
function Gs(n, e) {
|
|
3585
|
+
const t = n === "custom" ? {} : qs[n];
|
|
3579
3586
|
if (!e) return t;
|
|
3580
3587
|
const i = { ...t };
|
|
3581
3588
|
for (const s of Object.keys(e)) {
|
|
@@ -3584,7 +3591,7 @@ function qs(n, e) {
|
|
|
3584
3591
|
}
|
|
3585
3592
|
return i;
|
|
3586
3593
|
}
|
|
3587
|
-
const
|
|
3594
|
+
const Hs = (n, e) => {
|
|
3588
3595
|
if (!e || typeof n == "string") return n;
|
|
3589
3596
|
const [t] = k(e.language);
|
|
3590
3597
|
return !t || n && nt(n, t) !== void 0 ? n : { ...n, [t]: Ln(e) };
|
|
@@ -3608,10 +3615,10 @@ class ze {
|
|
|
3608
3615
|
* @param engineVoice The engine's voice, which `voice` falls back to: when unset, or for its language in a record without it.
|
|
3609
3616
|
*/
|
|
3610
3617
|
constructor(e, t, i) {
|
|
3611
|
-
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 = [...
|
|
3618
|
+
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 = [..._s[this.verbosity]], this.contextualize = [...$s[this.verbosity]]), this.language = e.language ?? t.language, this.languageOverrides = e.languageOverrides ?? t.languageOverrides, this.segmentation = e.segmentation ?? t.segmentation, this.voice = Hs(e.voice ?? t.voice, i), 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;
|
|
3612
3619
|
}
|
|
3613
3620
|
}
|
|
3614
|
-
const
|
|
3621
|
+
const jt = /* @__PURE__ */ new WeakMap(), Un = /* @__PURE__ */ new WeakMap();
|
|
3615
3622
|
function Ft(n, e) {
|
|
3616
3623
|
Un.set(n, e);
|
|
3617
3624
|
}
|
|
@@ -3619,7 +3626,7 @@ const Tn = /* @__PURE__ */ new WeakSet();
|
|
|
3619
3626
|
function _t(n) {
|
|
3620
3627
|
return Tn.add(n), n;
|
|
3621
3628
|
}
|
|
3622
|
-
function
|
|
3629
|
+
function Ks(n, e, t) {
|
|
3623
3630
|
const i = Un.get(n);
|
|
3624
3631
|
if (i) {
|
|
3625
3632
|
const u = Ut(i.map, e), g = Ut(i.map, e + t);
|
|
@@ -3627,7 +3634,7 @@ function Hs(n, e, t) {
|
|
|
3627
3634
|
}
|
|
3628
3635
|
const s = n.offsets, a = !n.plain && !!n.ssml, r = i?.plain ?? n.plain ?? (n.ssml ? N(n.ssml) : "");
|
|
3629
3636
|
if (!s?.length || !r) return;
|
|
3630
|
-
const o =
|
|
3637
|
+
const o = jt.get(n), l = o !== void 0 && e >= o.cursor;
|
|
3631
3638
|
let c = l ? o.cursor : 0;
|
|
3632
3639
|
for (let u = l ? o.pieceIndex : 0; u < s.length; u++) {
|
|
3633
3640
|
const g = s[u], d = g.locate.text?.highlight, h = d ? a ? N(d) : d : r.slice(c);
|
|
@@ -3637,7 +3644,7 @@ function Hs(n, e, t) {
|
|
|
3637
3644
|
const p = f + h.length;
|
|
3638
3645
|
if (e >= f && e < p) {
|
|
3639
3646
|
if (Tn.has(g.locate)) return;
|
|
3640
|
-
|
|
3647
|
+
jt.set(n, { pieceIndex: u, cursor: c });
|
|
3641
3648
|
const m = e - f, S = h.substring(m, Math.min(m + t, h.length));
|
|
3642
3649
|
return { locate: {
|
|
3643
3650
|
...g.locate,
|
|
@@ -3652,13 +3659,13 @@ function Hs(n, e, t) {
|
|
|
3652
3659
|
c = p;
|
|
3653
3660
|
}
|
|
3654
3661
|
}
|
|
3655
|
-
function
|
|
3662
|
+
function Ws(n, e) {
|
|
3656
3663
|
return e === "sentence" && n.offsets?.length ? n.offsets.map((t) => t.locate) : n.locate ? [n.locate] : [];
|
|
3657
3664
|
}
|
|
3658
3665
|
function x(n) {
|
|
3659
3666
|
return { pattern: new RegExp(`(\\d+)\\s?u${n}\\b`, "g"), replace: (e, t) => `${t}µ${n}` };
|
|
3660
3667
|
}
|
|
3661
|
-
const
|
|
3668
|
+
const Qs = {
|
|
3662
3669
|
"1/4": "¼",
|
|
3663
3670
|
"1/2": "½",
|
|
3664
3671
|
"3/4": "¾",
|
|
@@ -3678,8 +3685,8 @@ const Ws = {
|
|
|
3678
3685
|
"5/8": "⅝",
|
|
3679
3686
|
"7/8": "⅞",
|
|
3680
3687
|
"0/3": "↉"
|
|
3681
|
-
},
|
|
3682
|
-
...
|
|
3688
|
+
}, Js = {
|
|
3689
|
+
...Qs,
|
|
3683
3690
|
// Rejects "(c)" directly preceded by "(a)"/"(b)" (a lettered list, not a copyright notice).
|
|
3684
3691
|
"(c)": { pattern: new RegExp("(?<!\\([ab]\\)\\s{0,3})\\(c\\)", "g"), replace: "©" },
|
|
3685
3692
|
"(C)": { pattern: new RegExp("(?<!\\([AB]\\)\\s{0,3})\\(C\\)", "g"), replace: "©" },
|
|
@@ -3705,13 +3712,13 @@ const Ws = {
|
|
|
3705
3712
|
// convention for pronunciation, but drop the real prime marks silently.
|
|
3706
3713
|
"′": "'",
|
|
3707
3714
|
"″": '"'
|
|
3708
|
-
},
|
|
3709
|
-
speech:
|
|
3710
|
-
}, zn =
|
|
3711
|
-
function
|
|
3715
|
+
}, Zs = { 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.", number: "Page {{ number }}" }, 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." } } } }, Xs = {
|
|
3716
|
+
speech: Zs
|
|
3717
|
+
}, zn = Xs.speech.contextualizations, We = { en: zn }, Nn = {};
|
|
3718
|
+
function Ys(n) {
|
|
3712
3719
|
return We[n] || Nn[n] ? n : "en";
|
|
3713
3720
|
}
|
|
3714
|
-
async function
|
|
3721
|
+
async function ea(n) {
|
|
3715
3722
|
const e = We[n];
|
|
3716
3723
|
if (e) return e;
|
|
3717
3724
|
const t = Nn[n];
|
|
@@ -3719,7 +3726,7 @@ async function Ys(n) {
|
|
|
3719
3726
|
const i = (await t()).speech.contextualizations;
|
|
3720
3727
|
return We[n] = i, i;
|
|
3721
3728
|
}
|
|
3722
|
-
const
|
|
3729
|
+
const ta = {
|
|
3723
3730
|
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."],
|
|
3724
3731
|
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."],
|
|
3725
3732
|
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."],
|
|
@@ -3734,34 +3741,34 @@ function Ne(n, e, t) {
|
|
|
3734
3741
|
for (; i > e && /\s/.test(n[i - 1]); ) i--;
|
|
3735
3742
|
return i;
|
|
3736
3743
|
}
|
|
3737
|
-
const
|
|
3738
|
-
function
|
|
3744
|
+
const na = /[\s([{"'“‘]/;
|
|
3745
|
+
function ia(n, e) {
|
|
3739
3746
|
for (const t of e) {
|
|
3740
3747
|
if (n.length < t.length || !n.endsWith(t)) continue;
|
|
3741
3748
|
const i = n.length - t.length - 1;
|
|
3742
|
-
if (i < 0 ||
|
|
3749
|
+
if (i < 0 || na.test(n[i])) return !0;
|
|
3743
3750
|
}
|
|
3744
3751
|
return !1;
|
|
3745
3752
|
}
|
|
3746
|
-
function
|
|
3753
|
+
function sa(n) {
|
|
3747
3754
|
let e = 0;
|
|
3748
3755
|
for (const t of n)
|
|
3749
3756
|
if (new RegExp("\\p{L}", "u").test(t) && e++, e >= 2) return !0;
|
|
3750
3757
|
return !1;
|
|
3751
3758
|
}
|
|
3752
|
-
function
|
|
3759
|
+
function aa(n) {
|
|
3753
3760
|
return /\.{3,}$/.test(n);
|
|
3754
3761
|
}
|
|
3755
|
-
function
|
|
3762
|
+
function ra(n, e, t, i) {
|
|
3756
3763
|
if (i === "“") return !0;
|
|
3757
3764
|
if (i !== '"') return !1;
|
|
3758
3765
|
let s = 0;
|
|
3759
3766
|
for (let a = e; a < t; a++) n[a] === '"' && s++;
|
|
3760
3767
|
return s % 2 === 1;
|
|
3761
3768
|
}
|
|
3762
|
-
const
|
|
3763
|
-
function
|
|
3764
|
-
const t = [...n.matchAll(
|
|
3769
|
+
const oa = new RegExp(`[.!?][”"'’)\\]]*\\s+—\\s+(?=\\p{Lu})`, "gu");
|
|
3770
|
+
function la(n, e) {
|
|
3771
|
+
const t = [...n.matchAll(oa)].map((s) => s.index + s[0].length);
|
|
3765
3772
|
if (t.length === 0) return e;
|
|
3766
3773
|
const i = [];
|
|
3767
3774
|
for (const s of e) {
|
|
@@ -3772,8 +3779,8 @@ function oa(n, e) {
|
|
|
3772
3779
|
}
|
|
3773
3780
|
return i;
|
|
3774
3781
|
}
|
|
3775
|
-
const
|
|
3776
|
-
function
|
|
3782
|
+
const ca = { "»": "«", "«": "»", "›": "‹", "‹": "›" };
|
|
3783
|
+
function ua(n, e) {
|
|
3777
3784
|
const t = [], i = /* @__PURE__ */ new Map();
|
|
3778
3785
|
let s = 0;
|
|
3779
3786
|
const a = (r, o) => {
|
|
@@ -3785,7 +3792,7 @@ function ca(n, e) {
|
|
|
3785
3792
|
let c = o.start;
|
|
3786
3793
|
for (; l && c < o.end; ) {
|
|
3787
3794
|
for (; c < o.end && /\s/.test(n[c]); ) c++;
|
|
3788
|
-
const u =
|
|
3795
|
+
const u = ca[n[c]];
|
|
3789
3796
|
if (u === void 0 || a(l.end, u) <= a(l.end, n[c])) break;
|
|
3790
3797
|
for (c++; c < o.end && /\s/.test(n[c]); ) c++;
|
|
3791
3798
|
l.end = o.start = c;
|
|
@@ -3794,20 +3801,20 @@ function ca(n, e) {
|
|
|
3794
3801
|
}
|
|
3795
3802
|
return t;
|
|
3796
3803
|
}
|
|
3797
|
-
function
|
|
3798
|
-
const i =
|
|
3804
|
+
function ha(n, e, t) {
|
|
3805
|
+
const i = ua(n, la(n, e));
|
|
3799
3806
|
for (let a = 0; a < i.length - 1; a++) {
|
|
3800
3807
|
const r = Ne(n, i[a].start, i[a].end);
|
|
3801
3808
|
if (r !== i[a].end || r <= i[a].start) continue;
|
|
3802
3809
|
const o = n[r - 1];
|
|
3803
|
-
|
|
3810
|
+
ra(n, i[a].start, r, o) && (i[a].end -= 1, i[a + 1].start -= 1);
|
|
3804
3811
|
}
|
|
3805
3812
|
const s = [];
|
|
3806
3813
|
for (const a of i) {
|
|
3807
3814
|
let r = a;
|
|
3808
3815
|
for (; s.length > 0; ) {
|
|
3809
3816
|
const o = s[s.length - 1], l = Ne(n, o.start, o.end), c = n.slice(o.start, l);
|
|
3810
|
-
if (!
|
|
3817
|
+
if (!ia(c, t) && sa(c) && !aa(c)) break;
|
|
3811
3818
|
s.pop(), r = { start: o.start, end: r.end };
|
|
3812
3819
|
}
|
|
3813
3820
|
s.push(r);
|
|
@@ -3831,15 +3838,15 @@ function Mn(n) {
|
|
|
3831
3838
|
}
|
|
3832
3839
|
return e;
|
|
3833
3840
|
}
|
|
3834
|
-
function
|
|
3841
|
+
function da(n) {
|
|
3835
3842
|
return Mn(n).language;
|
|
3836
3843
|
}
|
|
3837
3844
|
async function Bn(n, e, t) {
|
|
3838
3845
|
if (e === "") return [];
|
|
3839
|
-
const { segmenter: i, language: s } = Mn(n), r = [...i.segment(e)].map((c) => ({ start: c.index, end: c.index + c.segment.length })), o = cn(
|
|
3840
|
-
return
|
|
3846
|
+
const { segmenter: i, language: s } = Mn(n), r = [...i.segment(e)].map((c) => ({ start: c.index, end: c.index + c.segment.length })), o = cn(ta, s) ?? [], l = t ? [...o, ...t] : o;
|
|
3847
|
+
return ha(e, r, l);
|
|
3841
3848
|
}
|
|
3842
|
-
const
|
|
3849
|
+
const lr = [
|
|
3843
3850
|
"aside",
|
|
3844
3851
|
"audio",
|
|
3845
3852
|
"bibliography",
|
|
@@ -3865,7 +3872,7 @@ const or = [
|
|
|
3865
3872
|
"table",
|
|
3866
3873
|
"toc",
|
|
3867
3874
|
"video"
|
|
3868
|
-
],
|
|
3875
|
+
], ga = [
|
|
3869
3876
|
// Headings
|
|
3870
3877
|
"heading1",
|
|
3871
3878
|
"heading2",
|
|
@@ -3923,13 +3930,13 @@ const or = [
|
|
|
3923
3930
|
"section",
|
|
3924
3931
|
"summary",
|
|
3925
3932
|
"tip"
|
|
3926
|
-
],
|
|
3933
|
+
], fa = {
|
|
3927
3934
|
footnote: { drops: ["aside"], unconditional: !0 },
|
|
3928
3935
|
cover: { drops: ["image"] },
|
|
3929
3936
|
pullquote: { drops: ["blockquote", "aside"] },
|
|
3930
3937
|
epigraph: { drops: ["blockquote"] }
|
|
3931
|
-
},
|
|
3932
|
-
function
|
|
3938
|
+
}, pa = ["noteref", "pagebreak"], ma = ["audio", "video", "image", "figure", "math", "table", "cover"], va = ["cell", "rowheader"], ya = ["separator"], qt = new Set(ga), Dn = new Set(pa), Sa = new Set(ma), jn = new Set(va), ba = new Set(ya);
|
|
3939
|
+
function wa(n, e) {
|
|
3933
3940
|
const t = pi.createInstance();
|
|
3934
3941
|
return t.init({
|
|
3935
3942
|
lng: n,
|
|
@@ -3937,7 +3944,7 @@ function ba(n, e) {
|
|
|
3937
3944
|
interpolation: { escapeValue: !1 }
|
|
3938
3945
|
}), t;
|
|
3939
3946
|
}
|
|
3940
|
-
function
|
|
3947
|
+
function ka(n, e, t) {
|
|
3941
3948
|
if (!e) return n;
|
|
3942
3949
|
const i = { ...n };
|
|
3943
3950
|
for (const s of Object.keys(e))
|
|
@@ -3951,8 +3958,8 @@ function Fn(n, e) {
|
|
|
3951
3958
|
t[i] = Fn(n[i], e[i]);
|
|
3952
3959
|
return t;
|
|
3953
3960
|
}
|
|
3954
|
-
function
|
|
3955
|
-
return
|
|
3961
|
+
function Ca(n, e) {
|
|
3962
|
+
return ka(n, e, Fn);
|
|
3956
3963
|
}
|
|
3957
3964
|
function _n(n, e = [], t = /* @__PURE__ */ new Map()) {
|
|
3958
3965
|
for (const i of n)
|
|
@@ -3960,13 +3967,13 @@ function _n(n, e = [], t = /* @__PURE__ */ new Map()) {
|
|
|
3960
3967
|
return t;
|
|
3961
3968
|
}
|
|
3962
3969
|
async function $n(n, e) {
|
|
3963
|
-
const t = e.contextualizationLocale ?? "en", i =
|
|
3964
|
-
await
|
|
3970
|
+
const t = e.contextualizationLocale ?? "en", i = Ca(
|
|
3971
|
+
await ea(t),
|
|
3965
3972
|
e.contextualization?.contextualizations
|
|
3966
3973
|
);
|
|
3967
3974
|
return {
|
|
3968
|
-
i18n:
|
|
3969
|
-
contextualizationLanguage:
|
|
3975
|
+
i18n: wa(t, i),
|
|
3976
|
+
contextualizationLanguage: Ys(t),
|
|
3970
3977
|
skip: new Set(e.skip ?? []),
|
|
3971
3978
|
contextualize: new Set(e.contextualize ?? []),
|
|
3972
3979
|
contextualizationShapes: e.contextualization?.shapes ?? {},
|
|
@@ -3983,7 +3990,7 @@ async function $n(n, e) {
|
|
|
3983
3990
|
segmentationSuppressions: e.segmentation?.suppressions ?? {},
|
|
3984
3991
|
segmenter: e.segmentation?.segmenter ?? Bn,
|
|
3985
3992
|
// Per-key override, not an additive union — each key holds one whole rule.
|
|
3986
|
-
substitutions: { ...
|
|
3993
|
+
substitutions: { ...Js, ...e.substitutions },
|
|
3987
3994
|
blockStarts: /* @__PURE__ */ new Set(),
|
|
3988
3995
|
tableRowNumbers: /* @__PURE__ */ new Map(),
|
|
3989
3996
|
tableCellHeaders: /* @__PURE__ */ new Map(),
|
|
@@ -3994,9 +4001,9 @@ async function $n(n, e) {
|
|
|
3994
4001
|
placeholderPieces: /* @__PURE__ */ new Map()
|
|
3995
4002
|
};
|
|
3996
4003
|
}
|
|
3997
|
-
const
|
|
4004
|
+
const Ea = /<lang xml:lang="[^"]*">([\s\S]*?)<\/lang>/g;
|
|
3998
4005
|
function qn(n) {
|
|
3999
|
-
return n.replace(
|
|
4006
|
+
return n.replace(Ea, "$1");
|
|
4000
4007
|
}
|
|
4001
4008
|
function Gn(n, e) {
|
|
4002
4009
|
return n === void 0 ? void 0 : nt(e, n) ?? n;
|
|
@@ -4020,7 +4027,7 @@ function Hn(n, e, t) {
|
|
|
4020
4027
|
if (!Je(i, s, e, t)) return null;
|
|
4021
4028
|
return i.content ?? i.entry;
|
|
4022
4029
|
}
|
|
4023
|
-
function
|
|
4030
|
+
function Ra(n, e) {
|
|
4024
4031
|
return Hn(n, e, !1);
|
|
4025
4032
|
}
|
|
4026
4033
|
function Kn(n, e) {
|
|
@@ -4106,7 +4113,7 @@ function vt(n) {
|
|
|
4106
4113
|
const e = st(Ze(n));
|
|
4107
4114
|
return e ? e.plain ?? (e.ssml ? N(e.ssml) : "") : "";
|
|
4108
4115
|
}
|
|
4109
|
-
function
|
|
4116
|
+
function Ia(n) {
|
|
4110
4117
|
const e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Map();
|
|
4111
4118
|
let i = 0, s;
|
|
4112
4119
|
return n.forEach((a, r) => {
|
|
@@ -4127,7 +4134,7 @@ function ei(n, e) {
|
|
|
4127
4134
|
const t = e.format === "ssml" ? { ssml: T(n) } : { plain: n };
|
|
4128
4135
|
return e.synthetic.add(t), t;
|
|
4129
4136
|
}
|
|
4130
|
-
function
|
|
4137
|
+
function j(n, e) {
|
|
4131
4138
|
const t = ei(n, e), i = e.language === "none" ? M(void 0, e) : e.contextualizationLanguage;
|
|
4132
4139
|
return i && (t.language = i), t;
|
|
4133
4140
|
}
|
|
@@ -4148,11 +4155,11 @@ function Q(n, e, t, i) {
|
|
|
4148
4155
|
if (n.i18n.exists(e)) return n.i18n.t(e, i);
|
|
4149
4156
|
}
|
|
4150
4157
|
function yt(n, e) {
|
|
4151
|
-
return
|
|
4158
|
+
return jn.has(n) ? !0 : e.contextualize.has(n);
|
|
4152
4159
|
}
|
|
4153
4160
|
function ti(n, e, t) {
|
|
4154
4161
|
return e.some((i) => {
|
|
4155
|
-
const s =
|
|
4162
|
+
const s = fa[i];
|
|
4156
4163
|
return s?.drops.includes(n) ? s.unconditional || yt(i, t) : !1;
|
|
4157
4164
|
});
|
|
4158
4165
|
}
|
|
@@ -4189,20 +4196,20 @@ function Kt(n, e, t, i, s, a) {
|
|
|
4189
4196
|
if (!r) return [];
|
|
4190
4197
|
const o = t?.description, l = a.language !== "none" && o !== void 0 && o === Oe(i) ? M(Xn(i), a) : void 0, c = l ? Q(a, n, e, { ...t, description: Ht })?.split(Ht) : void 0;
|
|
4191
4198
|
if (!l || !c || c.length < 2) {
|
|
4192
|
-
const d =
|
|
4199
|
+
const d = j(r, a);
|
|
4193
4200
|
return Me(d, r, i, a, s, t), [d];
|
|
4194
4201
|
}
|
|
4195
4202
|
if (k(l)[0] === k(a.contextualizationLanguage)[0]) {
|
|
4196
|
-
const d =
|
|
4203
|
+
const d = j(r, a);
|
|
4197
4204
|
return d.language = l, Me(d, r, i, a, s, t), [d];
|
|
4198
4205
|
}
|
|
4199
4206
|
const u = `<lang xml:lang="${ln(l)}">${T(o)}</lang>`, g = c.map((d) => T(d)).join(u);
|
|
4200
4207
|
if (a.format === "ssml") {
|
|
4201
|
-
const d =
|
|
4208
|
+
const d = j(r, a);
|
|
4202
4209
|
return d.ssml = g, Me(d, r, i, a, s, t), [d];
|
|
4203
4210
|
}
|
|
4204
4211
|
return at(g, a.contextualizationLanguage).map((d) => {
|
|
4205
|
-
if (d.language !== l) return
|
|
4212
|
+
if (d.language !== l) return j(d.plain, a);
|
|
4206
4213
|
const h = Xe(d.plain, i, a);
|
|
4207
4214
|
return (s === "figure" || s === "table") && ce(h, d.plain, o, i, a), h;
|
|
4208
4215
|
});
|
|
@@ -4211,7 +4218,7 @@ function Wt(n, e, t, i) {
|
|
|
4211
4218
|
const s = `${e}.parts.${t}`;
|
|
4212
4219
|
return n.i18n.exists(s, { count: i }) ? n.i18n.t(s, { count: i }) : String(i);
|
|
4213
4220
|
}
|
|
4214
|
-
function
|
|
4221
|
+
function Pa(n) {
|
|
4215
4222
|
const e = Oe(n);
|
|
4216
4223
|
return e === void 0 ? { variantKey: "unlabelled" } : { variantKey: "labelled", params: { description: e } };
|
|
4217
4224
|
}
|
|
@@ -4222,9 +4229,9 @@ function Qt(n, e) {
|
|
|
4222
4229
|
params: { header: t ?? "", value: vt(n) }
|
|
4223
4230
|
};
|
|
4224
4231
|
}
|
|
4225
|
-
const
|
|
4232
|
+
const Aa = {
|
|
4226
4233
|
table: (n, e) => {
|
|
4227
|
-
const t = (n.children ?? []).filter((s) => s.role?.has("row")), i =
|
|
4234
|
+
const t = (n.children ?? []).filter((s) => s.role?.has("row")), i = Ia(t);
|
|
4228
4235
|
for (const [s, a] of i.rowNumbers) e.tableRowNumbers.set(s, a);
|
|
4229
4236
|
for (const [s, a] of i.cellHeaders) e.tableCellHeaders.set(s, a);
|
|
4230
4237
|
return {
|
|
@@ -4239,9 +4246,9 @@ const Pa = {
|
|
|
4239
4246
|
rowheader: Qt
|
|
4240
4247
|
};
|
|
4241
4248
|
function Jt(n, e, t) {
|
|
4242
|
-
const i =
|
|
4249
|
+
const i = Pa(e);
|
|
4243
4250
|
let s = i.variantKey, a = i.params;
|
|
4244
|
-
const r =
|
|
4251
|
+
const r = Aa[n]?.(e, t);
|
|
4245
4252
|
r && (r.variantKey && (s = r.variantKey), a = { ...a, ...r.params });
|
|
4246
4253
|
const o = t.contextualizationParams?.(n, e);
|
|
4247
4254
|
return o && (a = { ...a, ...o }), { variantKey: s, params: a };
|
|
@@ -4292,7 +4299,7 @@ function Zt(n, e, t, i) {
|
|
|
4292
4299
|
if (!(!e || Array.isArray(e) || !de(e)))
|
|
4293
4300
|
return Ve(e, i);
|
|
4294
4301
|
}
|
|
4295
|
-
function
|
|
4302
|
+
function La(n, e, t) {
|
|
4296
4303
|
const i = n.map((l, c) => {
|
|
4297
4304
|
if (l.locate) return l.locate;
|
|
4298
4305
|
if (t.synthetic.has(l)) return;
|
|
@@ -4326,7 +4333,7 @@ function St(n, e, t) {
|
|
|
4326
4333
|
r && (l.language = r), n.some((h) => t.synthetic.has(h)) && t.synthetic.add(l);
|
|
4327
4334
|
const c = ni(s, a, t);
|
|
4328
4335
|
c.length > 0 && (l.offsets = c);
|
|
4329
|
-
const u =
|
|
4336
|
+
const u = La(s, a, t);
|
|
4330
4337
|
u && (l.locate = u);
|
|
4331
4338
|
const g = Zt(s[0], a[0], "leading", t), d = Zt(s[s.length - 1], a[s.length - 1], "trailing", t);
|
|
4332
4339
|
return (g || d) && t.edgeSubstitutedLocate.set(l, { leading: g, trailing: d }), l;
|
|
@@ -4343,7 +4350,7 @@ function ii(n, e, t, i) {
|
|
|
4343
4350
|
function ge(n, e) {
|
|
4344
4351
|
return e !== "ssml" ? n : n.replace(/<[^>]+>/g, "").replace(/</g, "<").replace(/>/g, ">").replace(/&/g, "&");
|
|
4345
4352
|
}
|
|
4346
|
-
const Xt = "[\\u0391-\\u03A9\\u03B1-\\u03C9\\u03D8-\\u03E1]",
|
|
4353
|
+
const Xt = "[\\u0391-\\u03A9\\u03B1-\\u03C9\\u03D8-\\u03E1]", Oa = "[\\u0374\\u02B9\\u0384']", Be = "[\\u05D0-\\u05EA]", Yt = "[\\u0400-\\u0481\\u048A-\\u04FF]", Va = [
|
|
4347
4354
|
new RegExp("^\\p{Nd}+$", "u"),
|
|
4348
4355
|
new RegExp("^\\p{Nl}+$", "u"),
|
|
4349
4356
|
/^(?=[MDCLXVI])M{0,4}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})$/i,
|
|
@@ -4351,57 +4358,57 @@ const Xt = "[\\u0391-\\u03A9\\u03B1-\\u03C9\\u03D8-\\u03E1]", La = "[\\u0374\\u0
|
|
|
4351
4358
|
/^[፩-፼]+$/u,
|
|
4352
4359
|
new RegExp(`^${Be}[\\u05F3']$`, "u"),
|
|
4353
4360
|
new RegExp(`^${Be}+[\\u05F4"]${Be}$`, "u"),
|
|
4354
|
-
new RegExp(`^(?:\\u0375${Xt})*${Xt}+${
|
|
4361
|
+
new RegExp(`^(?:\\u0375${Xt})*${Xt}+${Oa}$`, "u"),
|
|
4355
4362
|
/^(?:[Ա-Ֆա-և]̅)+$/u,
|
|
4356
4363
|
new RegExp(`^\\u0482?${Yt}+\\u0483${Yt}*$`, "u")
|
|
4357
4364
|
];
|
|
4358
|
-
function
|
|
4365
|
+
function xa(n) {
|
|
4359
4366
|
const e = n.trim();
|
|
4360
|
-
return e.length > 0 &&
|
|
4367
|
+
return e.length > 0 && Va.some((t) => t.test(e));
|
|
4361
4368
|
}
|
|
4362
4369
|
function en(n, e) {
|
|
4363
4370
|
return e.skip.size > 0 && n.some((t) => e.skip.has(t) && !ti(t, n, e));
|
|
4364
4371
|
}
|
|
4365
|
-
function
|
|
4372
|
+
function Ua(n, e) {
|
|
4366
4373
|
const t = st(n.text);
|
|
4367
4374
|
if (!t) return [];
|
|
4368
4375
|
const i = t.plain ?? N(t.ssml ?? "");
|
|
4369
|
-
if (
|
|
4376
|
+
if (xa(i)) {
|
|
4370
4377
|
const s = Q(e, "pagebreak.number", void 0, { number: i.trim() });
|
|
4371
|
-
if (s !== void 0) return [
|
|
4378
|
+
if (s !== void 0) return [j(s, e)];
|
|
4372
4379
|
}
|
|
4373
4380
|
return ii(t, e.format, e.language, e);
|
|
4374
4381
|
}
|
|
4375
4382
|
function tn(n) {
|
|
4376
4383
|
n.plain !== void 0 && (n.plain += "."), n.ssml !== void 0 && (n.ssml += ".");
|
|
4377
4384
|
}
|
|
4378
|
-
function
|
|
4379
|
-
const t =
|
|
4385
|
+
function Ta(n, e) {
|
|
4386
|
+
const t = Ua(n, e);
|
|
4380
4387
|
if (!e.contextualize.has("pagebreak")) return t;
|
|
4381
4388
|
const i = e.i18n.exists("pagebreak.block.start") ? "pagebreak.block.start" : "pagebreak.inline", s = Q(e, i);
|
|
4382
4389
|
if (s === void 0) return t;
|
|
4383
|
-
const a =
|
|
4390
|
+
const a = j(s, e);
|
|
4384
4391
|
if (t.length === 0) return [a];
|
|
4385
4392
|
const r = St([a, ...t], [void 0, ...t.map(() => n)], e);
|
|
4386
4393
|
return r ? (tn(r), [r]) : (tn(t[t.length - 1]), [a, ...t]);
|
|
4387
4394
|
}
|
|
4388
|
-
function
|
|
4389
|
-
return W(n).some((t) =>
|
|
4395
|
+
function za(n, e) {
|
|
4396
|
+
return W(n).some((t) => Dn.has(t) && !e.inlineContextualization.has(t));
|
|
4390
4397
|
}
|
|
4391
|
-
function
|
|
4398
|
+
function Na(n, e, t, i, s, a, r) {
|
|
4392
4399
|
const o = n.text?.language, l = M(o, s), c = new Map((n.children ?? []).map((m) => [m.id, m])), u = [], g = [], d = [], h = /* @__PURE__ */ new Set(), f = /* @__PURE__ */ new Set(), p = s.segmentation === "sentence";
|
|
4393
4400
|
for (const m of ds(e)) {
|
|
4394
4401
|
if (m.placeholderId !== void 0) {
|
|
4395
4402
|
const v = c.get(m.placeholderId);
|
|
4396
4403
|
if (!v) continue;
|
|
4397
|
-
if (
|
|
4404
|
+
if (za(v, s)) {
|
|
4398
4405
|
if (d.push(v), p) {
|
|
4399
4406
|
const w = u.length;
|
|
4400
4407
|
et(v, u, g, s, d.length === 1 && (a || r)), u.slice(w).forEach((y) => f.add(y));
|
|
4401
4408
|
}
|
|
4402
4409
|
} else {
|
|
4403
4410
|
const w = u.length;
|
|
4404
|
-
et(v, u, g, s, a), W(v).some((y) =>
|
|
4411
|
+
et(v, u, g, s, a), W(v).some((y) => Dn.has(y)) && u.slice(w).forEach((y) => h.add(y));
|
|
4405
4412
|
}
|
|
4406
4413
|
continue;
|
|
4407
4414
|
}
|
|
@@ -4432,7 +4439,7 @@ function et(n, e, t, i, s) {
|
|
|
4432
4439
|
if (en(a, i)) return;
|
|
4433
4440
|
const o = a.some((h) => qt.has(h)), l = o && !s, c = e.length, u = a.filter(
|
|
4434
4441
|
(h) => h !== "footnote" && h !== "pagebreak" && !ti(h, a, i)
|
|
4435
|
-
), g = a.some((h) =>
|
|
4442
|
+
), g = a.some((h) => Sa.has(h) && i.contextualize.has(h)), d = a.includes("table") && r !== void 0 && !g;
|
|
4436
4443
|
if (d) {
|
|
4437
4444
|
const h = Xe(r, n, i);
|
|
4438
4445
|
ce(h, r, r, n, i), _(e, t, n, [h]);
|
|
@@ -4448,32 +4455,32 @@ function et(n, e, t, i, s) {
|
|
|
4448
4455
|
if (!en(f, i))
|
|
4449
4456
|
if (f.includes("footnote")) {
|
|
4450
4457
|
const p = i.contextualize.has("footnote"), m = i.i18n.exists("footnote.block.start") || i.i18n.exists("footnote.block.end"), S = f.some((I) => qt.has(I)) && !s && !i.inlineContextualization.has("noteref"), v = p ? Q(i, m ? "footnote.block.start" : "footnote.inline") : void 0, w = p && (v !== void 0 || m), y = [], b = [];
|
|
4451
|
-
v !== void 0 && (y.push(
|
|
4458
|
+
v !== void 0 && (y.push(j(v, i)), b.push(h));
|
|
4452
4459
|
const P = [], A = [];
|
|
4453
4460
|
if (F([h], P, A, i, s || S), S && P.length > 0 && i.blockStarts.add(P[0]), y.push(...P), b.push(...A), w && m) {
|
|
4454
4461
|
const I = Q(i, "footnote.block.end");
|
|
4455
|
-
I !== void 0 && (y.push(
|
|
4462
|
+
I !== void 0 && (y.push(j(I, i)), b.push(h));
|
|
4456
4463
|
}
|
|
4457
4464
|
const E = w && y.length > 1 ? St(y, b, i) : void 0;
|
|
4458
4465
|
Ye(e, t, i, h, y, b, E);
|
|
4459
4466
|
} else
|
|
4460
4467
|
F([h], e, t, i, s);
|
|
4461
4468
|
}
|
|
4462
|
-
else if (!a.some((h) =>
|
|
4469
|
+
else if (!a.some((h) => ba.has(h))) {
|
|
4463
4470
|
const h = Ze(n)?.ssml;
|
|
4464
4471
|
if (h && hs(h)) {
|
|
4465
|
-
const f =
|
|
4472
|
+
const f = Na(n, h, e, t, i, s, o);
|
|
4466
4473
|
if (f.length > 0) {
|
|
4467
4474
|
const p = s || o && e.length > c;
|
|
4468
4475
|
F(f, e, t, i, p);
|
|
4469
4476
|
}
|
|
4470
4477
|
} else if (a.includes("pagebreak")) {
|
|
4471
|
-
if (_(e, t, n,
|
|
4478
|
+
if (_(e, t, n, Ta(n, i)), n.children) {
|
|
4472
4479
|
const f = s || o && e.length > c;
|
|
4473
4480
|
F(n.children, e, t, i, f);
|
|
4474
4481
|
}
|
|
4475
4482
|
} else {
|
|
4476
|
-
const p = a.some((m) =>
|
|
4483
|
+
const p = a.some((m) => jn.has(m) && yt(m, i)) ? void 0 : st(Ze(n));
|
|
4477
4484
|
if (p && _(e, t, n, ii(p, i.format, i.language, i)), n.children) {
|
|
4478
4485
|
const m = s || o && e.length > c;
|
|
4479
4486
|
F(n.children, e, t, i, m);
|
|
@@ -4493,9 +4500,9 @@ function et(n, e, t, i, s) {
|
|
|
4493
4500
|
function F(n, e, t, i, s) {
|
|
4494
4501
|
n.forEach((a, r) => et(a, e, t, i, r === 0 ? s : !1));
|
|
4495
4502
|
}
|
|
4496
|
-
const
|
|
4503
|
+
const Ma = Sn;
|
|
4497
4504
|
async function si(n, e, t, i) {
|
|
4498
|
-
const s =
|
|
4505
|
+
const s = Ma(n);
|
|
4499
4506
|
let a = "";
|
|
4500
4507
|
const r = [];
|
|
4501
4508
|
for (const d of s)
|
|
@@ -4528,10 +4535,10 @@ async function si(n, e, t, i) {
|
|
|
4528
4535
|
}), c && l.push(c.replace(/[ \t\r\n]+$/, "")), l;
|
|
4529
4536
|
}
|
|
4530
4537
|
function bt(n, e) {
|
|
4531
|
-
const t = e.segmenter === Bn ?
|
|
4538
|
+
const t = e.segmenter === Bn ? da(n) : n;
|
|
4532
4539
|
return cn(e.segmentationSuppressions, t);
|
|
4533
4540
|
}
|
|
4534
|
-
async function
|
|
4541
|
+
async function Ba(n, e) {
|
|
4535
4542
|
const t = n.language ?? "en", i = bt(t, e), s = e.format === "ssml" ? n.ssml : n.plain;
|
|
4536
4543
|
if (!s) return;
|
|
4537
4544
|
const a = await e.segmenter(t, ge(s, e.format), i);
|
|
@@ -4563,7 +4570,7 @@ function an(n, e, t) {
|
|
|
4563
4570
|
const i = Array.isArray(n) ? n[e === "leading" ? 0 : 1] : n;
|
|
4564
4571
|
return (t.ancestorChains.get(i) ?? []).filter((s) => W(s).some((a) => a !== "presentation"));
|
|
4565
4572
|
}
|
|
4566
|
-
function
|
|
4573
|
+
function Da(n, e) {
|
|
4567
4574
|
return n.length === e.length && n.every((t, i) => t === e[i]);
|
|
4568
4575
|
}
|
|
4569
4576
|
function rn(n, e, t, i) {
|
|
@@ -4584,12 +4591,12 @@ function tt(n, e, t) {
|
|
|
4584
4591
|
const i = t.placeholderPieces.get(n)?.node;
|
|
4585
4592
|
return i !== void 0 && i === t.placeholderPieces.get(e)?.node;
|
|
4586
4593
|
}
|
|
4587
|
-
function
|
|
4594
|
+
function Fa(n, e, t, i, s) {
|
|
4588
4595
|
const a = s.format === "ssml" ? n.ssml : n.plain, r = s.format === "ssml" ? t.ssml : t.plain;
|
|
4589
|
-
return !a || !r ? !1 : tt(n, t, s) ? !0 : !(!ft(n.language ?? "en", t.language ?? "en") || s.synthetic.has(n) || s.synthetic.has(t) || !e || !i || sn(e).some((o) => nn.has(o)) || sn(i).some((o) => nn.has(o)) || !
|
|
4596
|
+
return !a || !r ? !1 : tt(n, t, s) ? !0 : !(!ft(n.language ?? "en", t.language ?? "en") || s.synthetic.has(n) || s.synthetic.has(t) || !e || !i || sn(e).some((o) => nn.has(o)) || sn(i).some((o) => nn.has(o)) || !Da(an(e, "trailing", s), an(i, "leading", s)) || rn(e, n, "trailing", s) || rn(i, t, "leading", s));
|
|
4590
4597
|
}
|
|
4591
4598
|
async function on(n, e, t, i, s) {
|
|
4592
|
-
const a = t.synthetic.has(n) ? void 0 : await
|
|
4599
|
+
const a = t.synthetic.has(n) ? void 0 : await Ba(n, t);
|
|
4593
4600
|
if (!a) {
|
|
4594
4601
|
i.push(n), s.push(e);
|
|
4595
4602
|
return;
|
|
@@ -4613,7 +4620,7 @@ function ue(n, e) {
|
|
|
4613
4620
|
for (; t < n.length - 1 && n[t + 1].start <= e; ) t++;
|
|
4614
4621
|
return t;
|
|
4615
4622
|
}
|
|
4616
|
-
async function
|
|
4623
|
+
async function _a(n, e, t, i) {
|
|
4617
4624
|
const s = n.map((c) => ge(e.format === "ssml" ? c.ssml : c.plain, e.format)), { joined: a, ranges: r } = Ee(s), o = await e.segmenter(t, a, i), l = new Array(n.length - 1).fill(!1);
|
|
4618
4625
|
for (const c of o) {
|
|
4619
4626
|
const u = ue(r, c.start), g = c.end > c.start ? ue(r, c.end - 1) : u;
|
|
@@ -4621,7 +4628,7 @@ async function Fa(n, e, t, i) {
|
|
|
4621
4628
|
}
|
|
4622
4629
|
return l;
|
|
4623
4630
|
}
|
|
4624
|
-
function
|
|
4631
|
+
function $a(n, e, t) {
|
|
4625
4632
|
const i = [...e];
|
|
4626
4633
|
return n.forEach((s, a) => {
|
|
4627
4634
|
if (!Z(s, t)) return;
|
|
@@ -4629,7 +4636,7 @@ function _a(n, e, t) {
|
|
|
4629
4636
|
r && !i[a - 1] ? i[a - 1] = !0 : o && (i[a] = !0);
|
|
4630
4637
|
}), i;
|
|
4631
4638
|
}
|
|
4632
|
-
function
|
|
4639
|
+
function qa(n, e, t, i, s) {
|
|
4633
4640
|
const a = (l) => Z(t[ue(i, l)], s), r = [];
|
|
4634
4641
|
let o;
|
|
4635
4642
|
return e.forEach((l, c) => {
|
|
@@ -4638,7 +4645,7 @@ function $a(n, e, t, i, s) {
|
|
|
4638
4645
|
u && (a(l.contentEnd - 1) || a(u.start)) || (r.push({ text: n.slice(o.start, l.contentEnd), start: o.start, end: l.end, contentEnd: l.contentEnd }), o = void 0);
|
|
4639
4646
|
}), r;
|
|
4640
4647
|
}
|
|
4641
|
-
function
|
|
4648
|
+
function Ga(n, e, t, i, s, a, r) {
|
|
4642
4649
|
const o = [];
|
|
4643
4650
|
for (let l = s; l <= a; l++) {
|
|
4644
4651
|
if (Z(n[l], r)) {
|
|
@@ -4655,18 +4662,18 @@ function qa(n, e, t, i, s, a, r) {
|
|
|
4655
4662
|
return o;
|
|
4656
4663
|
}
|
|
4657
4664
|
function ri(n, e) {
|
|
4658
|
-
const t =
|
|
4665
|
+
const t = Ra(n, e);
|
|
4659
4666
|
return t !== null ? t ?? "en" : n.find((i) => !Z(i, e))?.language ?? n[0].language ?? "en";
|
|
4660
4667
|
}
|
|
4661
|
-
function
|
|
4668
|
+
function Ha(n, e, t, i, s) {
|
|
4662
4669
|
const a = ue(t, n.start), r = n.end > n.start ? ue(t, n.end - 1) : a, o = Jn(e.slice(a, r + 1), s);
|
|
4663
4670
|
return o.map(([l, c], u) => {
|
|
4664
4671
|
const g = a + l, d = a + c - 1, h = u === o.length - 1, f = u === 0 ? n.start : t[g].start, p = h ? n.contentEnd : t[d].end, m = h ? n.end : t[d + 1].start, S = Wn(e.slice(g, d + 1), s) ?? void 0, v = { text: i.slice(f, p), start: f, end: m, contentEnd: p }, w = o.length > 1 && g === d && Z(e[g], s);
|
|
4665
4672
|
return { boundary: v, startIdx: g, endIdx: d, language: S, sentenceEnd: h ? n.end : void 0, isolated: w };
|
|
4666
4673
|
});
|
|
4667
4674
|
}
|
|
4668
|
-
async function
|
|
4669
|
-
const r = ri(n, t), o = bt(r, t), l = n.map((v) => ge(t.format === "ssml" ? v.ssml : v.plain, t.format)), { joined: c, ranges: u } = Ee(l), g =
|
|
4675
|
+
async function Ka(n, e, t, i, s, a) {
|
|
4676
|
+
const r = ri(n, t), o = bt(r, t), l = n.map((v) => ge(t.format === "ssml" ? v.ssml : v.plain, t.format)), { joined: c, ranges: u } = Ee(l), g = qa(c, await t.segmenter(r, c, o), n, u, t), h = (g.length > 0 ? g : [{ text: c, start: 0, end: c.length, contentEnd: c.length }]).flatMap((v) => Ha(v, n, u, c, t));
|
|
4670
4677
|
let f, p;
|
|
4671
4678
|
if (t.format === "ssml") {
|
|
4672
4679
|
const v = /* @__PURE__ */ new Map();
|
|
@@ -4687,10 +4694,10 @@ async function Ha(n, e, t, i, s, a) {
|
|
|
4687
4694
|
}
|
|
4688
4695
|
const I = t.format === "ssml" ? f ? f[E] : p : v.text, R = { [t.format]: I }, X = t.language === "none" ? M(void 0, t) : b ?? "en";
|
|
4689
4696
|
X && (R.language = X), n.slice(w, y + 1).filter((te) => m.delete(te)).length > 0 && t.blockStarts.add(R);
|
|
4690
|
-
const B =
|
|
4697
|
+
const B = Ga(n, e, u, v, w, y, t);
|
|
4691
4698
|
B.length > 0 && (R.offsets = B);
|
|
4692
|
-
const ee = [...Array(y - w + 1).keys()].map((te) => w + te).filter((te) => !Z(n[te], t)),
|
|
4693
|
-
Ct && (R.locate = Ct), i.push(R), s.push(
|
|
4699
|
+
const ee = [...Array(y - w + 1).keys()].map((te) => w + te).filter((te) => !Z(n[te], t)), D = ee[0] ?? w, fe = ee[ee.length - 1] ?? y, wt = L(e[D], t.ancestorChains), kt = pt(wt, I), Ct = D !== fe ? mt(wt, L(e[fe], t.ancestorChains), kt) : kt;
|
|
4700
|
+
Ct && (R.locate = Ct), i.push(R), s.push(D === fe ? e[D] : [e[D], e[fe]]), S(P, E);
|
|
4694
4701
|
});
|
|
4695
4702
|
}
|
|
4696
4703
|
async function oi(n, e, t) {
|
|
@@ -4699,7 +4706,7 @@ async function oi(n, e, t) {
|
|
|
4699
4706
|
let a = 0;
|
|
4700
4707
|
for (; a < n.length; ) {
|
|
4701
4708
|
let r = a;
|
|
4702
|
-
for (; r + 1 < n.length &&
|
|
4709
|
+
for (; r + 1 < n.length && Fa(n[r], e[r], n[r + 1], e[r + 1], t); ) r++;
|
|
4703
4710
|
if (r === a) {
|
|
4704
4711
|
await on(n[a], e[a], t, i, s), a = r + 1;
|
|
4705
4712
|
continue;
|
|
@@ -4718,7 +4725,7 @@ async function oi(n, e, t) {
|
|
|
4718
4725
|
a = r + 1;
|
|
4719
4726
|
continue;
|
|
4720
4727
|
}
|
|
4721
|
-
const u = ri(o, t), g = await
|
|
4728
|
+
const u = ri(o, t), g = await _a(o, t, u, bt(u, t)), d = $a(o, g, t);
|
|
4722
4729
|
let h = 0;
|
|
4723
4730
|
for (let f = 0; f < o.length; f++)
|
|
4724
4731
|
if (!(f < o.length - 1 && d[f])) {
|
|
@@ -4727,7 +4734,7 @@ async function oi(n, e, t) {
|
|
|
4727
4734
|
else {
|
|
4728
4735
|
const p = /* @__PURE__ */ new Map();
|
|
4729
4736
|
for (let m = h; m <= f; m++) c.has(m) && p.set(m - h, c.get(m));
|
|
4730
|
-
await
|
|
4737
|
+
await Ka(o.slice(h, f + 1), l.slice(h, f + 1), t, i, s, p);
|
|
4731
4738
|
}
|
|
4732
4739
|
h = f + 1;
|
|
4733
4740
|
}
|
|
@@ -4751,19 +4758,19 @@ function li(n, e) {
|
|
|
4751
4758
|
return Ft(r, { plain: i, map: a }), r;
|
|
4752
4759
|
});
|
|
4753
4760
|
}
|
|
4754
|
-
async function
|
|
4761
|
+
async function cr(n, e = {}) {
|
|
4755
4762
|
const t = [], i = [], s = await $n(n, e);
|
|
4756
4763
|
F(n, t, i, s, !1);
|
|
4757
4764
|
const a = await oi(t, i, s);
|
|
4758
4765
|
return li(Yn(a.out, a.sources, s), s);
|
|
4759
4766
|
}
|
|
4760
|
-
async function
|
|
4767
|
+
async function Wa(n, e = {}) {
|
|
4761
4768
|
const t = [], i = [], s = await $n(n, e);
|
|
4762
4769
|
F(n, t, i, s, !1);
|
|
4763
4770
|
const a = await oi(t, i, s), r = a.out.map((l) => s.blockStarts.has(l)), o = Yn(a.out, a.sources, s);
|
|
4764
4771
|
return { utterances: li(o, s), sources: a.sources, blockStarts: r };
|
|
4765
4772
|
}
|
|
4766
|
-
class
|
|
4773
|
+
class ur {
|
|
4767
4774
|
engine;
|
|
4768
4775
|
contentQueue = [];
|
|
4769
4776
|
// `contentQueue` as loaded, before `voice` stamped it — re-stamped when that changes.
|
|
@@ -4856,7 +4863,7 @@ class cr {
|
|
|
4856
4863
|
this.setNavigatorState("ready"), this.emitEvent({ type: "ready" });
|
|
4857
4864
|
}
|
|
4858
4865
|
}), this.engine.on("boundary", (e) => {
|
|
4859
|
-
const { charIndex: t, charLength: i } = e.detail ?? {}, s = this.loadedQueue[this.getCurrentUtteranceIndex()], a = s && typeof t == "number" && typeof i == "number" ?
|
|
4866
|
+
const { charIndex: t, charLength: i } = e.detail ?? {}, s = this.loadedQueue[this.getCurrentUtteranceIndex()], a = s && typeof t == "number" && typeof i == "number" ? Ks(s, t, i) : void 0;
|
|
4860
4867
|
this.emitEvent(a ? { ...e, detail: { ...e.detail, ...a } } : e);
|
|
4861
4868
|
}), this.engine.on("mark", (e) => {
|
|
4862
4869
|
this.emitEvent(e);
|
|
@@ -4905,14 +4912,14 @@ class cr {
|
|
|
4905
4912
|
// Re-runs extraction from `this.source`, resuming near the old position if playback was underway.
|
|
4906
4913
|
async reextract() {
|
|
4907
4914
|
if (!this.source) return;
|
|
4908
|
-
const { index: e, state: t } = this.resumeTarget(), i = this.contentSources, { utterances: s, sources: a, blockStarts: r } = await
|
|
4915
|
+
const { index: e, state: t } = this.resumeTarget(), i = this.contentSources, { utterances: s, sources: a, blockStarts: r } = await Wa(this.source, {
|
|
4909
4916
|
format: this._settings.format,
|
|
4910
4917
|
inlineContextualization: this._settings.inlineContextualization,
|
|
4911
4918
|
skip: this._settings.skip,
|
|
4912
4919
|
contextualize: this._settings.contextualize,
|
|
4913
4920
|
contextualization: {
|
|
4914
4921
|
contextualizations: this.contextualizationOverrides?.contextualizations,
|
|
4915
|
-
shapes:
|
|
4922
|
+
shapes: Gs(this._settings.verbosity, this.contextualizationOverrides?.shapes),
|
|
4916
4923
|
params: this.contextualizationOverrides?.params
|
|
4917
4924
|
},
|
|
4918
4925
|
language: this._settings.language,
|
|
@@ -5032,7 +5039,7 @@ class cr {
|
|
|
5032
5039
|
// LocatorOptions there — and the same "resolve, then skip if there's nothing
|
|
5033
5040
|
// to show" shape, since there's no raw engine event to fall back to unenriched.
|
|
5034
5041
|
emitUtteranceBoundary(e) {
|
|
5035
|
-
const t = this._settings.segmentation, i =
|
|
5042
|
+
const t = this._settings.segmentation, i = Ws(e, t);
|
|
5036
5043
|
if (!i.length) return;
|
|
5037
5044
|
const s = t === "sentence" ? "sentence" : "structure";
|
|
5038
5045
|
this.emitEvent({
|
|
@@ -5051,7 +5058,7 @@ class cr {
|
|
|
5051
5058
|
// Rebuilt, staged edits kept, once the engine's voice changes, e.g. when it picks its default after being read.
|
|
5052
5059
|
get preferencesEditor() {
|
|
5053
5060
|
const e = this.engine.getCurrentVoice(), t = e ? Ln(e) : null;
|
|
5054
|
-
return (this._preferencesEditor === null || t !== this.preferencesEditorEngineVoice) && (this._preferencesEditor = new
|
|
5061
|
+
return (this._preferencesEditor === null || t !== this.preferencesEditorEngineVoice) && (this._preferencesEditor = new Dt(this._preferencesEditor?.preferences ?? this._preferences, this.settings), this.preferencesEditorEngineVoice = t), this._preferencesEditor;
|
|
5055
5062
|
}
|
|
5056
5063
|
async submitPreferences(e) {
|
|
5057
5064
|
!this.source && this.contentQueue.length > 0 && Bt.some((t) => e[t] !== void 0) && console.warn(
|
|
@@ -5060,7 +5067,7 @@ class cr {
|
|
|
5060
5067
|
}
|
|
5061
5068
|
async applyPreferences() {
|
|
5062
5069
|
const e = this._settings;
|
|
5063
|
-
if (this._settings = new ze(this._preferences, this._defaults), this.applyEngineParameters(), this._preferencesEditor !== null && (this._preferencesEditor = new
|
|
5070
|
+
if (this._settings = new ze(this._preferences, this._defaults), this.applyEngineParameters(), this._preferencesEditor !== null && (this._preferencesEditor = new Dt(this._preferences, this.settings)), Bt.some((t) => !this.sameSettingValue(e[t], this._settings[t])))
|
|
5064
5071
|
await this.reextract();
|
|
5065
5072
|
else if (this.loadedQueue.length > 0 && !this.sameSettingValue(e.voice, this._settings.voice)) {
|
|
5066
5073
|
const { index: t, state: i } = this.resumeTarget();
|
|
@@ -5082,76 +5089,76 @@ class cr {
|
|
|
5082
5089
|
}
|
|
5083
5090
|
}
|
|
5084
5091
|
export {
|
|
5085
|
-
|
|
5092
|
+
rr as BooleanPreference,
|
|
5086
5093
|
ie as EnumPreference,
|
|
5087
|
-
|
|
5088
|
-
|
|
5089
|
-
|
|
5090
|
-
|
|
5091
|
-
|
|
5094
|
+
ir as FallbackEngineProvider,
|
|
5095
|
+
zs as FallbackSpeechEngine,
|
|
5096
|
+
fr as Locator,
|
|
5097
|
+
pr as LocatorLocations,
|
|
5098
|
+
mr as LocatorText,
|
|
5092
5099
|
K as Preference,
|
|
5093
5100
|
me as RangePreference,
|
|
5094
|
-
|
|
5095
|
-
|
|
5096
|
-
|
|
5101
|
+
Bs as ReadiumSpeechDecorationController,
|
|
5102
|
+
ur as ReadiumSpeechNavigator,
|
|
5103
|
+
ar as ReadiumSpeechProviderRegistry,
|
|
5097
5104
|
js as SpeechDefaults,
|
|
5098
5105
|
le as SpeechPreferences,
|
|
5099
|
-
|
|
5106
|
+
Dt as SpeechPreferencesEditor,
|
|
5100
5107
|
Pn as SpeechServerAudioDecodeError,
|
|
5101
|
-
|
|
5102
|
-
|
|
5108
|
+
Vs as SpeechServerEngine,
|
|
5109
|
+
nr as SpeechServerEngineProvider,
|
|
5103
5110
|
oe as SpeechServerError,
|
|
5104
5111
|
An as SpeechServerNetworkError,
|
|
5105
5112
|
In as SpeechServerStallError,
|
|
5106
5113
|
ze as SpeechSettings,
|
|
5107
5114
|
Te as StringArrayPreference,
|
|
5108
5115
|
Nt as WebSpeechEngine,
|
|
5109
|
-
|
|
5116
|
+
tr as WebSpeechEngineProvider,
|
|
5110
5117
|
C as WebSpeechVoiceManager,
|
|
5111
5118
|
ht as autoPauseScopes,
|
|
5112
|
-
|
|
5119
|
+
ga as blockLevelRoles,
|
|
5113
5120
|
re as chineseVariantMap,
|
|
5114
|
-
|
|
5115
|
-
|
|
5121
|
+
ms as chunkPlainText,
|
|
5122
|
+
ys as chunkSsmlText,
|
|
5116
5123
|
hn as compareAlphabetically,
|
|
5117
5124
|
un as compareByPreferredRegion,
|
|
5118
|
-
|
|
5119
|
-
|
|
5125
|
+
qs as contextualizationShapesAtVerbosity,
|
|
5126
|
+
$s as contextualizedAtVerbosity,
|
|
5120
5127
|
H as createJsonOrderMap,
|
|
5121
|
-
|
|
5128
|
+
Ms as createLocator,
|
|
5122
5129
|
zn as defaultContextualizations,
|
|
5123
5130
|
k as extractLangRegionFromBCP47,
|
|
5124
|
-
|
|
5131
|
+
cr as extractUtterances,
|
|
5125
5132
|
ut as extractionFormats,
|
|
5126
5133
|
Bt as extractionPreferenceKeys,
|
|
5127
5134
|
it as filterByBoundarySupport,
|
|
5128
5135
|
xi as filterByLanguages,
|
|
5129
5136
|
At as filterOutNoveltyVoices,
|
|
5130
5137
|
Lt as filterOutVeryLowQualityVoices,
|
|
5131
|
-
|
|
5138
|
+
je as getLanguageDisplayName,
|
|
5132
5139
|
Se as getQualityValue,
|
|
5133
5140
|
Ln as getVoiceId,
|
|
5134
5141
|
Pe as groupVoicesByLanguage,
|
|
5135
|
-
|
|
5142
|
+
pa as inlineContextualizationRoles,
|
|
5136
5143
|
_e as isNoveltyVoice,
|
|
5137
|
-
|
|
5144
|
+
xs as isRecoverableFailure,
|
|
5138
5145
|
$e as isVeryLowQualityVoice,
|
|
5139
5146
|
ct as languageModes,
|
|
5140
5147
|
Rn as mapServerVoice,
|
|
5141
|
-
|
|
5148
|
+
bs as mimeTypeForFormat,
|
|
5142
5149
|
be as pauseDurationRangeConfig,
|
|
5143
5150
|
gn as pickBestVoiceByRegion,
|
|
5144
5151
|
ke as pitchRangeConfig,
|
|
5145
5152
|
we as rateRangeConfig,
|
|
5146
|
-
|
|
5147
|
-
|
|
5153
|
+
Ks as resolveBoundaryLocate,
|
|
5154
|
+
Ws as resolveUtteranceLocate,
|
|
5148
5155
|
dt as segmentationModes,
|
|
5149
|
-
|
|
5150
|
-
|
|
5151
|
-
|
|
5152
|
-
|
|
5153
|
-
|
|
5154
|
-
|
|
5156
|
+
Is as selectBitrate,
|
|
5157
|
+
Cs as selectFormat,
|
|
5158
|
+
sr as setupDecorations,
|
|
5159
|
+
or as shapeableRoles,
|
|
5160
|
+
lr as skippableRoles,
|
|
5161
|
+
_s as skippedAtVerbosity,
|
|
5155
5162
|
Fe as sortAlphabetically,
|
|
5156
5163
|
Ri as sortByPreferredRegion,
|
|
5157
5164
|
$ as sortByQuality,
|