@pie-players/pie-section-player 0.3.17 → 0.3.20
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/README.md +76 -2
- package/dist/components/shared/player-action.d.ts +0 -2
- package/dist/components/shared/player-action.d.ts.map +1 -1
- package/dist/components/shared/player-preload.d.ts.map +1 -1
- package/dist/components/shared/section-player-runtime.d.ts +38 -7
- package/dist/components/shared/section-player-runtime.d.ts.map +1 -1
- package/dist/components/shared/section-player-view-state.d.ts.map +1 -1
- package/dist/contracts/layout-contract.d.ts +1 -1
- package/dist/contracts/layout-contract.d.ts.map +1 -1
- package/dist/contracts/layout-parity-metadata.d.ts.map +1 -1
- package/dist/controllers/SectionController.d.ts.map +1 -1
- package/dist/defineProperty-CyepwRr5-eHUSgEtz.js +33 -0
- package/dist/defineProperty-CyepwRr5.js +33 -0
- package/dist/dist-BCuSaTvi.js +393 -0
- package/dist/dist-BIgX-aC4-C5B4fLQK.js +389 -0
- package/dist/dist-DwP27yIs-gkxodgFn.js +201 -0
- package/dist/dist-S3IAfazl.js +201 -0
- package/dist/{index-BZq66Ke6-D8dZwpj4.js → module-COIydQYl-2o-TlgiW.js} +38152 -30086
- package/dist/pie-section-player.js +7438 -8680
- package/dist/player-preload-C_CjM5hv.js +6317 -0
- package/dist/tool-annotation-toolbar-BS_MjvXd.js +3974 -0
- package/dist/utils/player-preload.js +5 -5
- package/package.json +14 -14
- package/dist/index-CGqExkh0-DYpgzOOU.js +0 -338
- package/dist/index-CGqExkh0.js +0 -354
- package/dist/index-DF-Dk87f-lxErM8bo.js +0 -178
- package/dist/index-DF-Dk87f.js +0 -192
- package/dist/player-preload-Dxvgw3gW.js +0 -7023
- package/dist/tool-annotation-toolbar-BOoJpOXj.js +0 -4845
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a, i as r, o as t, r as l, t as o } from "../player-preload-C_CjM5hv.js";
|
|
2
2
|
export {
|
|
3
|
-
|
|
3
|
+
o as buildPreloadSignature,
|
|
4
4
|
l as getLoaderView,
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
r as getRenderablesSignature,
|
|
6
|
+
a as orchestratePlayerElementPreload,
|
|
7
|
+
t as preloadPlayerElements
|
|
8
8
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-players/pie-section-player",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.20",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Web component for rendering QTI 3.0 assessment sections with passages and items",
|
|
6
6
|
"license": "MIT",
|
|
@@ -89,7 +89,7 @@
|
|
|
89
89
|
"lint": "biome check ."
|
|
90
90
|
},
|
|
91
91
|
"peerDependencies": {
|
|
92
|
-
"@pie-players/pie-tool-annotation-toolbar": "0.3.
|
|
92
|
+
"@pie-players/pie-tool-annotation-toolbar": "0.3.20"
|
|
93
93
|
},
|
|
94
94
|
"peerDependenciesMeta": {
|
|
95
95
|
"@pie-players/pie-tool-annotation-toolbar": {
|
|
@@ -97,25 +97,25 @@
|
|
|
97
97
|
}
|
|
98
98
|
},
|
|
99
99
|
"dependencies": {
|
|
100
|
-
"@pie-players/pie-assessment-toolkit": "0.3.
|
|
101
|
-
"@pie-players/pie-item-player": "0.3.
|
|
102
|
-
"@pie-players/pie-context": "0.3.
|
|
103
|
-
"@pie-players/pie-players-shared": "0.3.
|
|
104
|
-
"@pie-players/pie-tool-calculator-desmos": "0.3.
|
|
105
|
-
"@pie-players/pie-tool-text-to-speech": "0.3.
|
|
106
|
-
"@pie-players/pie-tool-tts-inline": "0.3.
|
|
107
|
-
"@pie-players/pie-toolbars": "0.3.
|
|
100
|
+
"@pie-players/pie-assessment-toolkit": "0.3.20",
|
|
101
|
+
"@pie-players/pie-item-player": "0.3.20",
|
|
102
|
+
"@pie-players/pie-context": "0.3.20",
|
|
103
|
+
"@pie-players/pie-players-shared": "0.3.20",
|
|
104
|
+
"@pie-players/pie-tool-calculator-desmos": "0.3.20",
|
|
105
|
+
"@pie-players/pie-tool-text-to-speech": "0.3.20",
|
|
106
|
+
"@pie-players/pie-tool-tts-inline": "0.3.20",
|
|
107
|
+
"@pie-players/pie-toolbars": "0.3.20"
|
|
108
108
|
},
|
|
109
109
|
"devDependencies": {
|
|
110
110
|
"@axe-core/playwright": "^4.11.1",
|
|
111
111
|
"@biomejs/biome": "^2.3.13",
|
|
112
112
|
"@playwright/test": "^1.58.2",
|
|
113
|
-
"@sveltejs/vite-plugin-svelte": "^
|
|
113
|
+
"@sveltejs/vite-plugin-svelte": "^7.0.0",
|
|
114
114
|
"@types/node": "^25.1.0",
|
|
115
|
-
"svelte": "^5.
|
|
116
|
-
"svelte-check": "^4.4.
|
|
115
|
+
"svelte": "^5.54.0",
|
|
116
|
+
"svelte-check": "^4.4.5",
|
|
117
117
|
"typescript": "^5.9.3",
|
|
118
|
-
"vite": "^
|
|
118
|
+
"vite": "^8.0.1",
|
|
119
119
|
"vite-plugin-dts": "^4.5.4"
|
|
120
120
|
},
|
|
121
121
|
"homepage": "https://github.com/pie-framework/pie-players/tree/master/packages/section-player#readme",
|
|
@@ -1,338 +0,0 @@
|
|
|
1
|
-
var v = Object.defineProperty, w = (i, t, e) => t in i ? v(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e, u = (i, t, e) => w(i, typeof t != "symbol" ? t + "" : t, e);
|
|
2
|
-
const T = {
|
|
3
|
-
pie: 3e3,
|
|
4
|
-
custom: 3e3
|
|
5
|
-
}, m = (i) => i.replace(/\/+$/, ""), f = (i) => i.transportMode === "custom" ? "custom" : i.transportMode === "pie" ? "pie" : i.provider === "custom" ? "custom" : "pie", y = (i, t) => i.endpointMode ? i.endpointMode : t === "custom" ? "rootPost" : "synthesizePath", S = (i, t) => i.endpointValidationMode ? i.endpointValidationMode : t === "custom" ? "none" : "voices", b = (i) => {
|
|
6
|
-
const t = i.providerOptions || {};
|
|
7
|
-
if (typeof t.speedRate == "string")
|
|
8
|
-
return t.speedRate;
|
|
9
|
-
const e = Number(i.rate ?? 1);
|
|
10
|
-
return !Number.isFinite(e) || e <= 0.95 ? "slow" : e >= 1.5 ? "fast" : "medium";
|
|
11
|
-
}, A = (i) => {
|
|
12
|
-
const t = [];
|
|
13
|
-
let e = 0;
|
|
14
|
-
const s = i.split(`
|
|
15
|
-
`).map((r) => r.trim()).filter(Boolean);
|
|
16
|
-
for (const r of s)
|
|
17
|
-
try {
|
|
18
|
-
const n = JSON.parse(r), h = typeof n.type == "string" ? n.type : "word", o = typeof n.time == "number" && Number.isFinite(n.time) ? n.time : 0, a = typeof n.value == "string" ? n.value : "", d = typeof n.start == "number" && Number.isFinite(n.start) ? n.start : null, p = typeof n.end == "number" && Number.isFinite(n.end) ? n.end : null, g = d ?? e, l = p ?? g + Math.max(1, a.length || String(n.value || "").length);
|
|
19
|
-
e = Math.max(l + 1, e), t.push({
|
|
20
|
-
time: o,
|
|
21
|
-
type: h,
|
|
22
|
-
start: g,
|
|
23
|
-
end: l,
|
|
24
|
-
value: a
|
|
25
|
-
});
|
|
26
|
-
} catch {
|
|
27
|
-
}
|
|
28
|
-
return t;
|
|
29
|
-
}, k = {
|
|
30
|
-
id: "pie",
|
|
31
|
-
resolveSynthesisUrl: (i) => {
|
|
32
|
-
const t = y(i, "pie"), e = m(i.apiEndpoint);
|
|
33
|
-
return t === "rootPost" ? e : `${e}/synthesize`;
|
|
34
|
-
},
|
|
35
|
-
buildRequestBody: (i, t) => {
|
|
36
|
-
const e = t.providerOptions || {}, s = typeof t.engine == "string" ? t.engine : typeof e.engine == "string" ? e.engine : void 0, r = typeof e.sampleRate == "number" && Number.isFinite(e.sampleRate) ? e.sampleRate : void 0, n = e.format === "mp3" || e.format === "ogg" || e.format === "pcm" ? e.format : void 0, h = Array.isArray(e.speechMarkTypes) ? e.speechMarkTypes.filter((o) => o === "word" || o === "sentence" || o === "ssml") : void 0;
|
|
37
|
-
return {
|
|
38
|
-
text: i,
|
|
39
|
-
provider: t.provider || "polly",
|
|
40
|
-
voice: t.voice,
|
|
41
|
-
language: t.language,
|
|
42
|
-
rate: t.rate,
|
|
43
|
-
engine: s,
|
|
44
|
-
sampleRate: r,
|
|
45
|
-
format: n,
|
|
46
|
-
speechMarkTypes: h,
|
|
47
|
-
includeSpeechMarks: !0
|
|
48
|
-
};
|
|
49
|
-
},
|
|
50
|
-
parseResponse: async (i) => {
|
|
51
|
-
const t = await i.json();
|
|
52
|
-
return {
|
|
53
|
-
audio: {
|
|
54
|
-
kind: "base64",
|
|
55
|
-
data: t.audio,
|
|
56
|
-
contentType: t.contentType
|
|
57
|
-
},
|
|
58
|
-
speechMarks: Array.isArray(t.speechMarks) ? t.speechMarks : []
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
}, R = {
|
|
62
|
-
id: "custom",
|
|
63
|
-
resolveSynthesisUrl: (i) => {
|
|
64
|
-
const t = y(i, "custom"), e = m(i.apiEndpoint);
|
|
65
|
-
return t === "synthesizePath" ? `${e}/synthesize` : e;
|
|
66
|
-
},
|
|
67
|
-
buildRequestBody: (i, t) => {
|
|
68
|
-
const e = t.providerOptions || {}, s = typeof e.lang_id == "string" ? e.lang_id : t.language || "en-US", r = typeof e.cache == "boolean" ? e.cache : !0;
|
|
69
|
-
return {
|
|
70
|
-
text: i,
|
|
71
|
-
speedRate: b(t),
|
|
72
|
-
lang_id: s,
|
|
73
|
-
cache: r
|
|
74
|
-
};
|
|
75
|
-
},
|
|
76
|
-
parseResponse: async (i, t, e, s) => {
|
|
77
|
-
const r = await i.json(), n = {};
|
|
78
|
-
if (t.includeAuthOnAssetFetch)
|
|
79
|
-
for (const [o, a] of Object.entries(e))
|
|
80
|
-
o.toLowerCase() === "authorization" && (n[o] = a);
|
|
81
|
-
let h = [];
|
|
82
|
-
if (typeof r.word == "string" && r.word.length > 0) {
|
|
83
|
-
const o = await fetch(r.word, {
|
|
84
|
-
headers: n,
|
|
85
|
-
signal: s
|
|
86
|
-
});
|
|
87
|
-
if (o.ok) {
|
|
88
|
-
const a = await o.text();
|
|
89
|
-
h = A(a);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
return {
|
|
93
|
-
audio: {
|
|
94
|
-
kind: "url",
|
|
95
|
-
url: r.audioContent
|
|
96
|
-
},
|
|
97
|
-
speechMarks: h
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
}, M = {
|
|
101
|
-
pie: k,
|
|
102
|
-
custom: R
|
|
103
|
-
};
|
|
104
|
-
class I {
|
|
105
|
-
constructor(t, e) {
|
|
106
|
-
u(this, "config"), u(this, "adapter"), u(this, "currentAudio", null), u(this, "pausedState", !1), u(this, "wordTimings", []), u(this, "highlightInterval", null), u(this, "intentionallyStopped", !1), u(this, "activeSynthesisController", null), u(this, "synthesisRunId", 0), u(this, "onWordBoundary"), this.config = t, this.adapter = e;
|
|
107
|
-
}
|
|
108
|
-
async speak(t) {
|
|
109
|
-
this.stop(), this.intentionallyStopped = !1;
|
|
110
|
-
const e = ++this.synthesisRunId, s = new AbortController();
|
|
111
|
-
this.activeSynthesisController = s;
|
|
112
|
-
const { audioUrl: r, wordTimings: n } = await this.synthesizeSpeech(t, s.signal, e);
|
|
113
|
-
if (e !== this.synthesisRunId) {
|
|
114
|
-
URL.revokeObjectURL(r);
|
|
115
|
-
return;
|
|
116
|
-
}
|
|
117
|
-
const h = this.config.rate || 1;
|
|
118
|
-
return this.wordTimings = n.map((o) => ({
|
|
119
|
-
...o,
|
|
120
|
-
time: o.time / h
|
|
121
|
-
})), new Promise((o, a) => {
|
|
122
|
-
const d = new Audio(r);
|
|
123
|
-
this.currentAudio = d, this.config.rate && (d.playbackRate = Math.max(0.25, Math.min(4, this.config.rate))), this.config.volume !== void 0 && (d.volume = Math.max(0, Math.min(1, this.config.volume))), d.onplay = () => {
|
|
124
|
-
this.pausedState = !1, this.onWordBoundary && this.wordTimings.length > 0 && this.startWordHighlighting();
|
|
125
|
-
}, d.onended = () => {
|
|
126
|
-
this.stopWordHighlighting(), URL.revokeObjectURL(r), this.currentAudio = null, this.wordTimings = [], o();
|
|
127
|
-
}, d.onerror = (p) => {
|
|
128
|
-
this.stopWordHighlighting(), URL.revokeObjectURL(r), this.currentAudio = null, this.wordTimings = [], this.intentionallyStopped ? o() : a(new Error("Failed to play audio from server"));
|
|
129
|
-
}, d.onpause = () => {
|
|
130
|
-
this.stopWordHighlighting(), this.pausedState = !0;
|
|
131
|
-
}, d.play().catch(a);
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* Call server API to synthesize speech
|
|
136
|
-
*/
|
|
137
|
-
async synthesizeSpeech(t, e, s) {
|
|
138
|
-
const r = {
|
|
139
|
-
"Content-Type": "application/json",
|
|
140
|
-
...this.config.headers
|
|
141
|
-
};
|
|
142
|
-
this.config.authToken && (r.Authorization = `Bearer ${this.config.authToken}`);
|
|
143
|
-
const n = this.adapter.resolveSynthesisUrl(this.config), h = this.adapter.buildRequestBody(t, this.config), o = await fetch(n, {
|
|
144
|
-
method: "POST",
|
|
145
|
-
headers: r,
|
|
146
|
-
body: JSON.stringify(h),
|
|
147
|
-
signal: e
|
|
148
|
-
});
|
|
149
|
-
if (!o.ok) {
|
|
150
|
-
const l = await o.json().catch(() => ({})), c = l.message || l.error?.message || `Server returned ${o.status}`;
|
|
151
|
-
throw new Error(c);
|
|
152
|
-
}
|
|
153
|
-
const a = await this.adapter.parseResponse(o, this.config, r, e);
|
|
154
|
-
if (s !== this.synthesisRunId || e.aborted)
|
|
155
|
-
throw new Error("Synthesis superseded by a newer request");
|
|
156
|
-
let d;
|
|
157
|
-
if (a.audio.kind === "base64")
|
|
158
|
-
d = this.base64ToBlob(a.audio.data, a.audio.contentType);
|
|
159
|
-
else {
|
|
160
|
-
const l = {};
|
|
161
|
-
this.config.includeAuthOnAssetFetch && this.config.authToken && (l.Authorization = `Bearer ${this.config.authToken}`);
|
|
162
|
-
const c = await fetch(a.audio.url, {
|
|
163
|
-
headers: l,
|
|
164
|
-
signal: e
|
|
165
|
-
});
|
|
166
|
-
if (!c.ok)
|
|
167
|
-
throw new Error(`Failed to download synthesized audio (${c.status})`);
|
|
168
|
-
d = await c.blob();
|
|
169
|
-
}
|
|
170
|
-
const p = URL.createObjectURL(d), g = this.parseSpeechMarks(a.speechMarks);
|
|
171
|
-
return { audioUrl: p, wordTimings: g };
|
|
172
|
-
}
|
|
173
|
-
/**
|
|
174
|
-
* Convert base64 to Blob
|
|
175
|
-
*/
|
|
176
|
-
base64ToBlob(t, e) {
|
|
177
|
-
const s = atob(t), r = new Array(s.length);
|
|
178
|
-
for (let h = 0; h < s.length; h++)
|
|
179
|
-
r[h] = s.charCodeAt(h);
|
|
180
|
-
const n = new Uint8Array(r);
|
|
181
|
-
return new Blob([n], { type: e });
|
|
182
|
-
}
|
|
183
|
-
/**
|
|
184
|
-
* Parse speech marks into word timings
|
|
185
|
-
*/
|
|
186
|
-
parseSpeechMarks(t) {
|
|
187
|
-
return t.filter((e) => e.type === "word").map((e, s) => ({
|
|
188
|
-
time: e.time,
|
|
189
|
-
wordIndex: s,
|
|
190
|
-
charIndex: e.start,
|
|
191
|
-
length: e.end - e.start
|
|
192
|
-
}));
|
|
193
|
-
}
|
|
194
|
-
/**
|
|
195
|
-
* Start word highlighting synchronized with audio playback
|
|
196
|
-
*/
|
|
197
|
-
startWordHighlighting() {
|
|
198
|
-
if (this.stopWordHighlighting(), !this.currentAudio || !this.onWordBoundary || this.wordTimings.length === 0) {
|
|
199
|
-
console.log("[ServerTTSProvider] Cannot start highlighting:", {
|
|
200
|
-
hasAudio: !!this.currentAudio,
|
|
201
|
-
hasCallback: !!this.onWordBoundary,
|
|
202
|
-
wordTimingsCount: this.wordTimings.length
|
|
203
|
-
});
|
|
204
|
-
return;
|
|
205
|
-
}
|
|
206
|
-
console.log("[ServerTTSProvider] Starting word highlighting with", this.wordTimings.length, "word timings"), console.log("[ServerTTSProvider] Playback rate:", this.currentAudio.playbackRate), console.log("[ServerTTSProvider] First 3 timings:", this.wordTimings.slice(0, 3));
|
|
207
|
-
let t = -1;
|
|
208
|
-
this.highlightInterval = window.setInterval(() => {
|
|
209
|
-
if (!this.currentAudio) {
|
|
210
|
-
this.stopWordHighlighting();
|
|
211
|
-
return;
|
|
212
|
-
}
|
|
213
|
-
const e = this.currentAudio.currentTime * 1e3;
|
|
214
|
-
for (let s = 0; s < this.wordTimings.length; s++) {
|
|
215
|
-
const r = this.wordTimings[s];
|
|
216
|
-
if (e >= r.time && s > t) {
|
|
217
|
-
this.onWordBoundary && (console.log("[ServerTTSProvider] Highlighting word at charIndex:", r.charIndex, "length:", r.length, "time:", r.time, "currentTime:", e), this.onWordBoundary("", r.charIndex, r.length)), t = s;
|
|
218
|
-
break;
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
}, 50);
|
|
222
|
-
}
|
|
223
|
-
/**
|
|
224
|
-
* Stop word highlighting
|
|
225
|
-
*/
|
|
226
|
-
stopWordHighlighting() {
|
|
227
|
-
this.highlightInterval !== null && (clearInterval(this.highlightInterval), this.highlightInterval = null);
|
|
228
|
-
}
|
|
229
|
-
pause() {
|
|
230
|
-
this.currentAudio && !this.pausedState && (this.currentAudio.pause(), this.stopWordHighlighting(), this.pausedState = !0);
|
|
231
|
-
}
|
|
232
|
-
resume() {
|
|
233
|
-
this.currentAudio && this.pausedState && (this.currentAudio.play(), this.pausedState = !1, this.onWordBoundary && this.wordTimings.length > 0 && this.startWordHighlighting());
|
|
234
|
-
}
|
|
235
|
-
stop() {
|
|
236
|
-
this.synthesisRunId += 1, this.activeSynthesisController && (this.activeSynthesisController.abort(), this.activeSynthesisController = null), this.stopWordHighlighting(), this.currentAudio && (this.intentionallyStopped = !0, this.currentAudio.pause(), this.currentAudio.src && URL.revokeObjectURL(this.currentAudio.src), this.currentAudio.src = "", this.currentAudio = null), this.pausedState = !1, this.wordTimings = [];
|
|
237
|
-
}
|
|
238
|
-
isPlaying() {
|
|
239
|
-
return this.currentAudio !== null && !this.pausedState;
|
|
240
|
-
}
|
|
241
|
-
isPaused() {
|
|
242
|
-
return this.pausedState;
|
|
243
|
-
}
|
|
244
|
-
/**
|
|
245
|
-
* Update settings dynamically (rate, pitch, voice)
|
|
246
|
-
* Note: Voice changes require resynthesis, so voice updates are stored but
|
|
247
|
-
* take effect on the next speak() call. Rate can be applied to current playback.
|
|
248
|
-
*/
|
|
249
|
-
updateSettings(t) {
|
|
250
|
-
t.rate !== void 0 && (this.config.rate = t.rate, this.currentAudio && (this.currentAudio.playbackRate = Math.max(0.25, Math.min(4, t.rate)))), t.pitch !== void 0 && (this.config.pitch = t.pitch), t.voice !== void 0 && (this.config.voice = t.voice);
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
class P {
|
|
254
|
-
constructor() {
|
|
255
|
-
u(this, "providerId", "server-tts"), u(this, "providerName", "Server TTS"), u(this, "version", "1.0.0"), u(this, "config", null), u(this, "adapter", null);
|
|
256
|
-
}
|
|
257
|
-
/**
|
|
258
|
-
* Initialize the server TTS provider.
|
|
259
|
-
*
|
|
260
|
-
* This is designed to be fast by default (no API calls).
|
|
261
|
-
* Set validateEndpoint: true in config to test API availability during initialization.
|
|
262
|
-
*
|
|
263
|
-
* @performance Default: <10ms, With validation: 100-500ms
|
|
264
|
-
*/
|
|
265
|
-
async initialize(t) {
|
|
266
|
-
const e = t;
|
|
267
|
-
if (!e.apiEndpoint)
|
|
268
|
-
throw new Error("apiEndpoint is required for ServerTTSProvider");
|
|
269
|
-
this.config = e;
|
|
270
|
-
const s = f(e);
|
|
271
|
-
if (this.adapter = M[s], e.validateEndpoint && !await this.testAPIAvailability())
|
|
272
|
-
throw new Error(`Server TTS API not available at ${e.apiEndpoint}`);
|
|
273
|
-
return new I(e, this.adapter);
|
|
274
|
-
}
|
|
275
|
-
/**
|
|
276
|
-
* Test if API endpoint is available (with timeout).
|
|
277
|
-
*
|
|
278
|
-
* @performance 100-500ms depending on network
|
|
279
|
-
*/
|
|
280
|
-
async testAPIAvailability() {
|
|
281
|
-
if (!this.config || !this.adapter)
|
|
282
|
-
return !1;
|
|
283
|
-
try {
|
|
284
|
-
const t = { ...this.config.headers };
|
|
285
|
-
this.config.authToken && (t.Authorization = `Bearer ${this.config.authToken}`);
|
|
286
|
-
const e = new AbortController(), s = setTimeout(() => e.abort(), 5e3), r = S(this.config, this.adapter.id);
|
|
287
|
-
if (r === "none")
|
|
288
|
-
return clearTimeout(s), !0;
|
|
289
|
-
const n = m(this.config.apiEndpoint), h = r === "voices" ? `${n}/voices` : this.adapter.resolveSynthesisUrl(this.config), o = r === "voices" ? "GET" : "OPTIONS";
|
|
290
|
-
try {
|
|
291
|
-
const a = await fetch(h, {
|
|
292
|
-
method: o,
|
|
293
|
-
headers: t,
|
|
294
|
-
signal: e.signal
|
|
295
|
-
});
|
|
296
|
-
return clearTimeout(s), a.ok || a.status === 405;
|
|
297
|
-
} catch {
|
|
298
|
-
return clearTimeout(s), !1;
|
|
299
|
-
}
|
|
300
|
-
} catch {
|
|
301
|
-
return !1;
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
supportsFeature(t) {
|
|
305
|
-
switch (t) {
|
|
306
|
-
case "pause":
|
|
307
|
-
case "resume":
|
|
308
|
-
case "wordBoundary":
|
|
309
|
-
case "voiceSelection":
|
|
310
|
-
case "rateControl":
|
|
311
|
-
return !0;
|
|
312
|
-
case "pitchControl":
|
|
313
|
-
return !1;
|
|
314
|
-
default:
|
|
315
|
-
return !1;
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
getCapabilities() {
|
|
319
|
-
const t = this.config ? f(this.config) : "pie";
|
|
320
|
-
return {
|
|
321
|
-
supportsPause: !0,
|
|
322
|
-
supportsResume: !0,
|
|
323
|
-
supportsWordBoundary: !0,
|
|
324
|
-
// ✅ Via speech marks from server
|
|
325
|
-
supportsVoiceSelection: !0,
|
|
326
|
-
supportsRateControl: !0,
|
|
327
|
-
supportsPitchControl: !1,
|
|
328
|
-
// Depends on server provider
|
|
329
|
-
maxTextLength: T[t]
|
|
330
|
-
};
|
|
331
|
-
}
|
|
332
|
-
destroy() {
|
|
333
|
-
this.config = null, this.adapter = null;
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
export {
|
|
337
|
-
P as ServerTTSProvider
|
|
338
|
-
};
|