@beff/aula-cli 0.12.0 → 0.13.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/README.md +6 -1
- package/dist/src/aula-render.core.wasm +0 -0
- package/dist/src/{aula-voice-tts-YOS4IQXV.js → aula-voice-tts-FEFKNA2I.js} +1 -1
- package/dist/src/aula.js +2 -2
- package/dist/src/{chunk-DC7A435Z.js → chunk-2BEUK7M7.js} +1 -1
- package/dist/src/{chunk-2PAZTBSE.js → chunk-2VD3JPLV.js} +3 -5
- package/dist/src/chunk-4N5SDSCV.js +63 -0
- package/dist/src/{chunk-AXQBWV7J.js → chunk-F37DXY3P.js} +219 -115
- package/dist/src/{chunk-PZXFW6ZD.js → chunk-FGTN34N7.js} +3 -3
- package/dist/src/{chunk-RAGZAJKD.js → chunk-GQSFMINU.js} +3 -33
- package/dist/src/chunk-N3YZ7K5L.js +111 -0
- package/dist/src/{chunk-DN2LVJO3.js → chunk-T7S65ZHW.js} +4307 -1645
- package/dist/src/{chunk-TDAWUJ2L.js → chunk-V3GJ4XSW.js} +118 -66
- package/dist/src/{chunk-T6CAPT32.js → chunk-VJAXVLXZ.js} +3 -2
- package/dist/src/{chunk-HD6FTA3H.js → chunk-Z7VLJSDG.js} +211 -92
- package/dist/src/cli.js +44 -155
- package/dist/src/{commands-BSDNHYB3.js → commands-ZTGXXVOO.js} +12 -10
- package/dist/src/generated/aula.core5.wasm +0 -0
- package/dist/src/generated/aula.js +4076 -1341
- package/dist/src/generated/interfaces/aula-engine-engine.d.ts +39 -0
- package/dist/src/problems-BDPV4IRL.js +17 -0
- package/dist/src/project-XHL7FN7B.js +16 -0
- package/dist/src/run-LZVKYMKT.js +238 -0
- package/dist/src/{server-TJTMSDO2.js → server-H7XOUJNL.js} +24 -21
- package/dist/src/{site-RGPJOWSU.js → site-7MLO35NA.js} +16 -89
- package/dist/src/workspace-load-OQXB2ZOC.js +16 -0
- package/dist/web/app/assets/{bf5dd884 → 15e78332}/aula-method.js +1 -1
- package/dist/web/app/assets/{bf5dd884 → 15e78332}/aula.js +1 -1
- package/dist/web/app/assets/15e78332/build-worker.js +2 -0
- package/dist/web/app/assets/15e78332/index.js +51 -0
- package/dist/web/app/assets/__vite-browser-external-CCI-9X_7.js +1 -0
- package/dist/web/app/assets/aula-voice-worker-bYZ7BKji.js +1 -0
- package/dist/web/app/assets/{aula.core5-CQ2oHbtB.wasm → aula.core5-CtBp7wFf.wasm} +0 -0
- package/dist/web/app/assets/protocol-j759xoXL.js +15 -0
- package/dist/web/app/assets/src-BjcN7H3T.js +6 -0
- package/dist/web/{site/assets/tex-mathjax-DrZV_cwB.js → app/assets/tex-mathjax-Bbh2jsAv.js} +1 -1
- package/dist/web/app/index.html +4 -4
- package/dist/web/site/assets/{07fb5cf0 → 671a8ee2}/aula-method.js +1 -1
- package/dist/web/site/assets/{07fb5cf0 → 671a8ee2}/aula.js +1 -1
- package/dist/web/site/assets/671a8ee2/build-worker.js +2 -0
- package/dist/web/site/assets/671a8ee2/index.js +51 -0
- package/dist/web/site/assets/__vite-browser-external-CrZYh5ba.js +1 -0
- package/dist/web/site/assets/aula-voice-worker-Doyh20uI.js +1 -0
- package/dist/web/site/assets/{aula.core5-CQ2oHbtB.wasm → aula.core5-CtBp7wFf.wasm} +0 -0
- package/dist/web/site/assets/protocol-ByKVs3Yn.js +15 -0
- package/dist/web/site/assets/src-BwnY0kQu.js +6 -0
- package/dist/web/{app/assets/tex-mathjax-eWNptbJg.js → site/assets/tex-mathjax-DKtiwFu-.js} +1 -1
- package/dist/web/site/index.html +4 -4
- package/package.json +1 -1
- package/dist/src/chunk-4QGX7XXO.js +0 -104
- package/dist/src/problems-CGKCPETU.js +0 -18
- package/dist/src/project-EUFMRQXR.js +0 -16
- package/dist/src/run-ER27SVTA.js +0 -183
- package/dist/web/app/assets/__vite-browser-external-BHESVS8k.js +0 -1
- package/dist/web/app/assets/aula-voice-worker-CJpoa9h-.js +0 -1
- package/dist/web/app/assets/bf5dd884/build-worker.js +0 -2
- package/dist/web/app/assets/bf5dd884/index.js +0 -51
- package/dist/web/app/assets/protocol-Dc79M9p3.js +0 -15
- package/dist/web/app/assets/src-DWqZcp-P.js +0 -6
- package/dist/web/site/assets/07fb5cf0/build-worker.js +0 -2
- package/dist/web/site/assets/07fb5cf0/index.js +0 -51
- package/dist/web/site/assets/__vite-browser-external-DQubyTsZ.js +0 -1
- package/dist/web/site/assets/aula-voice-worker-BRrzyFz3.js +0 -1
- package/dist/web/site/assets/protocol-F-4tHoAW.js +0 -15
- package/dist/web/site/assets/src-DfPcHwz-.js +0 -6
package/README.md
CHANGED
|
@@ -4,7 +4,12 @@ The `aula` command of [aula](https://github.com/lucasavila00/aula): it runs chap
|
|
|
4
4
|
|
|
5
5
|
It needs Node 24. Narration (aula-voice) needs only Node. `aula export` needs ffmpeg. Refer to [CLI](https://github.com/lucasavila00/aula/blob/main/docs/agents/cli.md) for the commands and [Getting started](https://github.com/lucasavila00/aula/blob/main/docs/agents/getting-started.md) for the setup.
|
|
6
6
|
|
|
7
|
-
The package has no model file.
|
|
7
|
+
The package has no model file.
|
|
8
|
+
The first command that narrates or times a video downloads the narrator's model of aula-voice's release [v0.2.5](https://github.com/lucasavila00/aula-voice/releases/tag/v0.2.5) (about 21 MB).
|
|
9
|
+
Those commands are `check`, `script`, `timeline`, `preview`, `export` and `aula web`.
|
|
10
|
+
The CLI checks the SHA-256 of each file, makes the engine's weight file from them, and checks its SHA-256 too.
|
|
11
|
+
`aula web` narrates in the browser and serves that file to its page.
|
|
12
|
+
The [model card](https://github.com/lucasavila00/aula-voice/releases/download/v0.2.5/MODEL_CARD.md) has the license of the model, its sources and its training data, and their attribution.
|
|
8
13
|
|
|
9
14
|
## Licenses
|
|
10
15
|
|
|
Binary file
|
package/dist/src/aula.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
manim_exports
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-GQSFMINU.js";
|
|
4
4
|
import {
|
|
5
5
|
defineChapter,
|
|
6
6
|
defineProject,
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
pronounce,
|
|
11
11
|
say,
|
|
12
12
|
show
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-T7S65ZHW.js";
|
|
14
14
|
import "./chunk-VX7UVLQW.js";
|
|
15
15
|
import "./chunk-CZ7CSFO4.js";
|
|
16
16
|
export {
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
error,
|
|
5
5
|
projectName,
|
|
6
6
|
wrongArgument
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-VJAXVLXZ.js";
|
|
8
8
|
import {
|
|
9
9
|
definedAt,
|
|
10
10
|
importUserModule,
|
|
@@ -12,8 +12,9 @@ import {
|
|
|
12
12
|
isProjectDefinition,
|
|
13
13
|
loadEngine,
|
|
14
14
|
loadTex,
|
|
15
|
+
slugOf,
|
|
15
16
|
v8Frames
|
|
16
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-T7S65ZHW.js";
|
|
17
18
|
|
|
18
19
|
// ../aula-project/src/node.ts
|
|
19
20
|
import { existsSync } from "node:fs";
|
|
@@ -49,9 +50,6 @@ function host(capabilities, root, glue = []) {
|
|
|
49
50
|
function propertyOf(e, key) {
|
|
50
51
|
return typeof e === "object" && e !== null ? Reflect.get(e, key) : void 0;
|
|
51
52
|
}
|
|
52
|
-
function slugOf(text) {
|
|
53
|
-
return text.normalize("NFKD").replace(/[\u0300-\u036f]/g, "").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
|
|
54
|
-
}
|
|
55
53
|
function listedChapters(capabilities, folder, projectFile) {
|
|
56
54
|
const source = capabilities.fs.readFileSync(projectFile, "utf8");
|
|
57
55
|
const imports = /* @__PURE__ */ new Map();
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// ../../node_modules/.pnpm/@beff+diy@0.0.36/node_modules/@beff/diy/dist/esm/capabilities.js
|
|
2
|
+
function create(serviceMap) {
|
|
3
|
+
return serviceMap;
|
|
4
|
+
}
|
|
5
|
+
function extend(capabilities, extra) {
|
|
6
|
+
return Object.assign({}, capabilities, extra);
|
|
7
|
+
}
|
|
8
|
+
function override(capabilities, replacement) {
|
|
9
|
+
return { ...capabilities, ...replacement };
|
|
10
|
+
}
|
|
11
|
+
function merge(...capabilitiesList) {
|
|
12
|
+
return Object.assign({}, ...capabilitiesList);
|
|
13
|
+
}
|
|
14
|
+
var Capabilities = {
|
|
15
|
+
/**
|
|
16
|
+
* Build the app's concrete services.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* const capabilities = Capabilities.create<AppCapability>({
|
|
21
|
+
* clock: { now: () => new Date() },
|
|
22
|
+
* fs,
|
|
23
|
+
* });
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
create,
|
|
27
|
+
/**
|
|
28
|
+
* Add scoped services around an existing bag.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```ts
|
|
32
|
+
* const jobCapabilities = Capabilities.extend(
|
|
33
|
+
* capabilities,
|
|
34
|
+
* Capabilities.create<ProgressCapability>({ progress }),
|
|
35
|
+
* );
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
extend,
|
|
39
|
+
/**
|
|
40
|
+
* Combine capability bags built by separate modules.
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```ts
|
|
44
|
+
* const appCapabilities = Capabilities.merge(nodeCapabilities, databaseCapabilities);
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
merge,
|
|
48
|
+
/**
|
|
49
|
+
* Replace services without changing the capability type.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```ts
|
|
53
|
+
* const quietCapabilities = Capabilities.override(capabilities, {
|
|
54
|
+
* logger: { info: () => undefined },
|
|
55
|
+
* });
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
override
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export {
|
|
62
|
+
Capabilities
|
|
63
|
+
};
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
} from "./chunk-4QGX7XXO.js";
|
|
4
|
-
import {
|
|
2
|
+
chapterNarration,
|
|
5
3
|
check,
|
|
6
4
|
moveFrames,
|
|
7
5
|
narrationScript,
|
|
8
6
|
paragraphAt,
|
|
9
|
-
|
|
7
|
+
scriptBeats,
|
|
10
8
|
timeline,
|
|
11
9
|
unclearWords,
|
|
12
|
-
|
|
13
|
-
} from "./chunk-
|
|
10
|
+
unclearWordsFrom
|
|
11
|
+
} from "./chunk-V3GJ4XSW.js";
|
|
14
12
|
import {
|
|
15
13
|
LIST_MODULE,
|
|
16
14
|
Problems,
|
|
@@ -18,12 +16,13 @@ import {
|
|
|
18
16
|
isError,
|
|
19
17
|
linkBundle,
|
|
20
18
|
wrongArgument
|
|
21
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-VJAXVLXZ.js";
|
|
22
20
|
import {
|
|
23
21
|
manim_exports
|
|
24
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-GQSFMINU.js";
|
|
25
23
|
import {
|
|
26
24
|
FPS,
|
|
25
|
+
TITLE,
|
|
27
26
|
chapterNames,
|
|
28
27
|
checkChapter,
|
|
29
28
|
checkLexicon,
|
|
@@ -35,13 +34,156 @@ import {
|
|
|
35
34
|
loadEngine,
|
|
36
35
|
readChapter,
|
|
37
36
|
renderChapter
|
|
38
|
-
} from "./chunk-
|
|
37
|
+
} from "./chunk-T7S65ZHW.js";
|
|
38
|
+
|
|
39
|
+
// ../aula-narration/src/script.ts
|
|
40
|
+
var starts = (words) => Float64Array.from(words, (w) => w.start);
|
|
41
|
+
function joinChapter(cues, speeches) {
|
|
42
|
+
let rate = 0;
|
|
43
|
+
for (const [i, speech] of speeches.entries()) {
|
|
44
|
+
if (!speech.samples.length || speech.samples.some((s) => !Number.isFinite(s))) {
|
|
45
|
+
const text = cues[i]?.text.slice(0, 60) ?? "";
|
|
46
|
+
throw new Error(`the narrator returned empty or invalid audio for ${JSON.stringify(text)}`);
|
|
47
|
+
}
|
|
48
|
+
if (rate !== 0 && speech.sampleRate !== rate) throw new Error("the narrator changed its sample rate");
|
|
49
|
+
rate = speech.sampleRate;
|
|
50
|
+
}
|
|
51
|
+
const spoken = speeches.map((s) => ({ samples: s.samples.length, starts: starts(s.words) }));
|
|
52
|
+
const narration = chapterNarration(cues, spoken, rate);
|
|
53
|
+
const samples = new Float32Array(narration.endFrame);
|
|
54
|
+
for (const [i, speech] of speeches.entries()) samples.set(speech.samples, narration.cues[i]?.speechStartFrame ?? 0);
|
|
55
|
+
return { samples, narration };
|
|
56
|
+
}
|
|
57
|
+
function withWaits(samples, waits) {
|
|
58
|
+
if (waits.length === 0) return samples;
|
|
59
|
+
const out = new Float32Array(samples.length + waits.reduce((sum, w) => sum + w.samples, 0));
|
|
60
|
+
let from = 0;
|
|
61
|
+
let to = 0;
|
|
62
|
+
for (const wait of waits.toSorted((a, b) => a.sample - b.sample)) {
|
|
63
|
+
const at = Math.min(wait.sample, samples.length);
|
|
64
|
+
out.set(samples.subarray(from, at), to);
|
|
65
|
+
to += at - from + wait.samples;
|
|
66
|
+
from = at;
|
|
67
|
+
}
|
|
68
|
+
out.set(samples.subarray(from), to);
|
|
69
|
+
return out;
|
|
70
|
+
}
|
|
71
|
+
function timeChapter(cues, timings) {
|
|
72
|
+
const rate = timings[0]?.sampleRate ?? 0;
|
|
73
|
+
if (timings.some((t) => t.sampleRate !== rate)) throw new Error("the narrator changed its sample rate");
|
|
74
|
+
const spoken = timings.map(
|
|
75
|
+
(t) => t.words ? { samples: t.samples, starts: starts(t.words) } : { samples: t.samples }
|
|
76
|
+
);
|
|
77
|
+
return chapterNarration(cues, spoken, rate);
|
|
78
|
+
}
|
|
79
|
+
async function narrateScript(speak, chapters, speaking) {
|
|
80
|
+
const count = chapters.reduce((sum, c) => sum + c.length, 0);
|
|
81
|
+
let spoken = 0;
|
|
82
|
+
const narrated = [];
|
|
83
|
+
for (const cues of chapters) {
|
|
84
|
+
const speeches = [];
|
|
85
|
+
for (const cue of cues) {
|
|
86
|
+
spoken += 1;
|
|
87
|
+
speaking(spoken, count, cue);
|
|
88
|
+
speeches.push(await speak(cue.words));
|
|
89
|
+
}
|
|
90
|
+
narrated.push(joinChapter(cues, speeches));
|
|
91
|
+
}
|
|
92
|
+
if (!narrated.some((c) => c.narration.sampleRate > 0)) throw new Error("the script has no cues");
|
|
93
|
+
return narrated;
|
|
94
|
+
}
|
|
95
|
+
function scriptAudio(chapters, waits) {
|
|
96
|
+
const sounds = chapters.map((c, i) => withWaits(c.samples, waits[i] ?? []));
|
|
97
|
+
const samples = new Float32Array(sounds.reduce((sum, s) => sum + s.length, 0));
|
|
98
|
+
let at = 0;
|
|
99
|
+
for (const sound of sounds) {
|
|
100
|
+
samples.set(sound, at);
|
|
101
|
+
at += sound.length;
|
|
102
|
+
}
|
|
103
|
+
const sampleRate = chapters.find((c) => c.narration.sampleRate > 0)?.narration.sampleRate ?? 0;
|
|
104
|
+
return { samples, sampleRate };
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// ../aula-narration/src/wav.ts
|
|
108
|
+
function wav(samples, rate) {
|
|
109
|
+
const bytes = new Uint8Array(44 + samples.length * 2);
|
|
110
|
+
const view = new DataView(bytes.buffer);
|
|
111
|
+
const text = (at, value) => {
|
|
112
|
+
for (let i = 0; i < value.length; i++) view.setUint8(at + i, value.charCodeAt(i));
|
|
113
|
+
};
|
|
114
|
+
text(0, "RIFF");
|
|
115
|
+
view.setUint32(4, 36 + samples.length * 2, true);
|
|
116
|
+
text(8, "WAVE");
|
|
117
|
+
text(12, "fmt ");
|
|
118
|
+
view.setUint32(16, 16, true);
|
|
119
|
+
view.setUint16(20, 1, true);
|
|
120
|
+
view.setUint16(22, 1, true);
|
|
121
|
+
view.setUint32(24, rate, true);
|
|
122
|
+
view.setUint32(28, rate * 2, true);
|
|
123
|
+
view.setUint16(32, 2, true);
|
|
124
|
+
view.setUint16(34, 16, true);
|
|
125
|
+
text(36, "data");
|
|
126
|
+
view.setUint32(40, samples.length * 2, true);
|
|
127
|
+
samples.forEach((sample, i) => {
|
|
128
|
+
view.setInt16(44 + i * 2, Math.round(Math.min(1, Math.max(-1, sample)) * 32767), true);
|
|
129
|
+
});
|
|
130
|
+
return bytes;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// ../aula-project/src/notes.ts
|
|
134
|
+
function scriptUnclear(script, only) {
|
|
135
|
+
return script.map((cues, index) => {
|
|
136
|
+
if (only !== null && !only.includes(index)) return cues.map(() => []);
|
|
137
|
+
return cues.map((cue) => unclearWords(cue.words));
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
function wordNotes(script, only, unclear = null) {
|
|
141
|
+
const lists = unclear ?? scriptUnclear(script, only);
|
|
142
|
+
const notes = /* @__PURE__ */ new Map();
|
|
143
|
+
script.forEach((cues, index) => {
|
|
144
|
+
if (only !== null && !only.includes(index)) return;
|
|
145
|
+
cues.forEach((cue, cueIndex) => {
|
|
146
|
+
for (const { word, kind, reading } of lists[index]?.[cueIndex] ?? []) {
|
|
147
|
+
const lower = word.slice(0, 1).toLowerCase() + word.slice(1);
|
|
148
|
+
const key = `${kind} ${lower}`;
|
|
149
|
+
const note = notes.get(key);
|
|
150
|
+
if (note === void 0) notes.set(key, { word, kind, reading, uses: 1, place: cue.place ?? null });
|
|
151
|
+
else {
|
|
152
|
+
note.uses += 1;
|
|
153
|
+
if (word === lower) note.word = word;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
});
|
|
158
|
+
return [...notes.values()];
|
|
159
|
+
}
|
|
160
|
+
function noteLine(note) {
|
|
161
|
+
const why = note.kind === "ambiguous" ? `the context decides its reading, and the lexicon says "${note.reading}"` : `no dictionary has it, and eSpeak NG says /${note.reading}/`;
|
|
162
|
+
const place = note.place ?? "the title";
|
|
163
|
+
const uses = note.uses === 1 ? `1 use, at ${place}` : `${String(note.uses)} uses, the first at ${place}`;
|
|
164
|
+
return `note: ${JSON.stringify(note.word)}: ${why} (${uses})`;
|
|
165
|
+
}
|
|
166
|
+
function notesLine(notes) {
|
|
167
|
+
const count = notes.length === 1 ? "1 note" : `${String(notes.length)} notes`;
|
|
168
|
+
return `${count}: a note is not an error. Give each word its reading with pronounce or in the project lexicon`;
|
|
169
|
+
}
|
|
39
170
|
|
|
40
171
|
// ../aula-project/src/chapters.ts
|
|
172
|
+
function rejectTitleChapter(name) {
|
|
173
|
+
if (name !== TITLE) return;
|
|
174
|
+
throw wrongArgument(
|
|
175
|
+
"title is not a chapter: give a chapter id such as 01-double-the-side",
|
|
176
|
+
"omit <chapter> to check or preview the whole project, including the title card"
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
function chapterHintNames(names) {
|
|
180
|
+
return names.filter((name) => name !== TITLE).join(", ");
|
|
181
|
+
}
|
|
41
182
|
function chapterIndex(names, name) {
|
|
183
|
+
rejectTitleChapter(name);
|
|
42
184
|
const at = names.indexOf(name);
|
|
43
185
|
if (at >= 0) return at;
|
|
44
|
-
throw wrongArgument(`No chapter '${name}': use one of [${names
|
|
186
|
+
throw wrongArgument(`No chapter '${name}': use one of [${chapterHintNames(names)}]`);
|
|
45
187
|
}
|
|
46
188
|
function chapterText(project, host, index) {
|
|
47
189
|
const result = readChapter(project, index, { host });
|
|
@@ -51,8 +193,8 @@ function chapterText(project, host, index) {
|
|
|
51
193
|
function paragraphCue(text, name, line) {
|
|
52
194
|
const p = paragraphAt(text, line);
|
|
53
195
|
if (p !== void 0) return p + 1;
|
|
54
|
-
const
|
|
55
|
-
const list =
|
|
196
|
+
const starts2 = text.paragraphs.flatMap((q) => q.place ? [String(q.place.line)] : []);
|
|
197
|
+
const list = starts2.length > 1 ? `${starts2.slice(0, -1).join(", ")} and ${starts2.at(-1) ?? ""}` : starts2.join("");
|
|
56
198
|
throw wrongArgument(`line ${String(line)} of ${name} is in no paragraph; the paragraphs start at lines ${list}`);
|
|
57
199
|
}
|
|
58
200
|
function openMoves(text) {
|
|
@@ -63,37 +205,62 @@ function openCount(chapters, indexes) {
|
|
|
63
205
|
}
|
|
64
206
|
|
|
65
207
|
// ../aula-project/src/check.ts
|
|
66
|
-
var hasSpokenSound = (spoken) => Array.from(phonemize(spoken)).some((c) => new RegExp("\\p{L}", "u").test(c) && c !== "\u02C8" && c !== "\u02CC");
|
|
67
208
|
function cueLocation(place) {
|
|
68
209
|
if (place === void 0) return void 0;
|
|
69
210
|
const colon = place.lastIndexOf(":");
|
|
70
211
|
const line = Number(place.slice(colon + 1));
|
|
71
212
|
return colon > 0 && Number.isInteger(line) ? { file: place.slice(0, colon), line, col: 0 } : void 0;
|
|
72
213
|
}
|
|
214
|
+
function cueNoSpoken(cue, index, names) {
|
|
215
|
+
const chapter = names[index] ?? `chapter ${String(index)}`;
|
|
216
|
+
const location = cueLocation(cue.place);
|
|
217
|
+
return new Problems([
|
|
218
|
+
error(`cannot narrate ${cue.kind} in ${chapter}: ${JSON.stringify(cue.text)} has no spoken words`, {
|
|
219
|
+
code: "cue-no-spoken",
|
|
220
|
+
...location === void 0 ? {} : { location },
|
|
221
|
+
hint: `give the ${cue.kind} words that the narrator can say`
|
|
222
|
+
})
|
|
223
|
+
]);
|
|
224
|
+
}
|
|
73
225
|
async function clock(narrator, chapters, only = null, names = []) {
|
|
74
226
|
const narrations = /* @__PURE__ */ new Map();
|
|
75
227
|
for (const [index, cues] of chapters.entries()) {
|
|
76
228
|
if (only !== null && !only.includes(index)) continue;
|
|
77
229
|
const timings = [];
|
|
78
230
|
for (const cue of cues) {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
throw new Problems([
|
|
84
|
-
error(`cannot narrate ${cue.kind} in ${chapter}: ${JSON.stringify(cue.text)} has no spoken words`, {
|
|
85
|
-
code: "cue-no-spoken",
|
|
86
|
-
...location === void 0 ? {} : { location },
|
|
87
|
-
hint: `give the ${cue.kind} words that the narrator can say`
|
|
88
|
-
})
|
|
89
|
-
]);
|
|
90
|
-
}
|
|
91
|
-
timings.push(await narrator.time(cue.words));
|
|
231
|
+
if (!cue.words.length) throw cueNoSpoken(cue, index, names);
|
|
232
|
+
const timed = await narrator.tryTime(cue.words);
|
|
233
|
+
if (timed._tag === "Left") throw cueNoSpoken(cue, index, names);
|
|
234
|
+
timings.push(timed.right);
|
|
92
235
|
}
|
|
93
236
|
narrations.set(index, timeChapter(cues, timings));
|
|
94
237
|
}
|
|
95
238
|
return narrations;
|
|
96
239
|
}
|
|
240
|
+
function unclearFromTiming(words, timing) {
|
|
241
|
+
const cue = timing.cue;
|
|
242
|
+
if (cue === void 0) return unclearWords(words);
|
|
243
|
+
return unclearWordsFrom(words, cue.unknowns, cue.alonePhonemes);
|
|
244
|
+
}
|
|
245
|
+
async function clockWithUnclear(narrator, chapters, only = null, names = []) {
|
|
246
|
+
const narrations = /* @__PURE__ */ new Map();
|
|
247
|
+
const unclear = chapters.map((cues) => cues.map(() => []));
|
|
248
|
+
for (const [index, cues] of chapters.entries()) {
|
|
249
|
+
if (only !== null && !only.includes(index)) continue;
|
|
250
|
+
const timings = [];
|
|
251
|
+
const chapterUnclear = [];
|
|
252
|
+
for (const cue of cues) {
|
|
253
|
+
if (!cue.words.length) throw cueNoSpoken(cue, index, names);
|
|
254
|
+
const timed = await narrator.tryTime(cue.words);
|
|
255
|
+
if (timed._tag === "Left") throw cueNoSpoken(cue, index, names);
|
|
256
|
+
timings.push(timed.right);
|
|
257
|
+
chapterUnclear.push(unclearFromTiming(cue.words, timed.right));
|
|
258
|
+
}
|
|
259
|
+
narrations.set(index, timeChapter(cues, timings));
|
|
260
|
+
unclear[index] = chapterUnclear;
|
|
261
|
+
}
|
|
262
|
+
return { narrations, unclear };
|
|
263
|
+
}
|
|
97
264
|
function narrationAt(narrations, index) {
|
|
98
265
|
const narration = narrations.get(index);
|
|
99
266
|
if (narration === void 0) throw new Error(`no narration of chapter ${String(index)}`);
|
|
@@ -108,8 +275,13 @@ function checkProject(project, host, only) {
|
|
|
108
275
|
});
|
|
109
276
|
const all = reads.map((r) => r.value ?? EMPTY);
|
|
110
277
|
const own = /* @__PURE__ */ new Map();
|
|
278
|
+
const textRules = /* @__PURE__ */ new Map();
|
|
111
279
|
reads.forEach((r, i) => {
|
|
112
|
-
if (r.value !== void 0)
|
|
280
|
+
if (r.value !== void 0) {
|
|
281
|
+
const checked = check(r.value);
|
|
282
|
+
textRules.set(i + 1, checked);
|
|
283
|
+
own.set(i + 1, [...r.diagnostics, ...checked]);
|
|
284
|
+
}
|
|
113
285
|
});
|
|
114
286
|
const targets = (only ?? chapterNames(project).map((_, i) => i)).filter((i) => !unloaded.has(i));
|
|
115
287
|
const inScope = (index) => only === null || only.includes(index);
|
|
@@ -117,7 +289,7 @@ function checkProject(project, host, only) {
|
|
|
117
289
|
for (const index of targets) {
|
|
118
290
|
const run = checkChapter(project, index, { host });
|
|
119
291
|
const text = all[index - 1];
|
|
120
|
-
own.set(index, [...run.diagnostics, ...index === 0 || text === void 0 ? [] :
|
|
292
|
+
own.set(index, [...run.diagnostics, ...index === 0 || text === void 0 ? [] : textRules.get(index) ?? []]);
|
|
121
293
|
}
|
|
122
294
|
}
|
|
123
295
|
const byChapter = [...unloaded, ...[...own].toSorted(([a], [b]) => a - b)];
|
|
@@ -158,14 +330,14 @@ function exportCheck(project, host) {
|
|
|
158
330
|
return { ...checked, findings: [...checked.findings, ...open], errors: checked.errors + open.length };
|
|
159
331
|
}
|
|
160
332
|
function clipPlan(narrations, fps) {
|
|
161
|
-
const
|
|
162
|
-
for (const narration of narrations)
|
|
163
|
-
const firsts =
|
|
333
|
+
const starts2 = [0];
|
|
334
|
+
for (const narration of narrations) starts2.push((starts2.at(-1) ?? 0) + narration.endFrame / narration.sampleRate);
|
|
335
|
+
const firsts = starts2.map((seconds) => Math.round(seconds * fps));
|
|
164
336
|
const clips = narrations.map((_, index) => {
|
|
165
337
|
const first = firsts[index] ?? 0;
|
|
166
|
-
return { from: first / fps - (
|
|
338
|
+
return { from: first / fps - (starts2[index] ?? 0), frames: (firsts[index + 1] ?? first) - first };
|
|
167
339
|
});
|
|
168
|
-
return { clips, seconds:
|
|
340
|
+
return { clips, seconds: starts2.at(-1) ?? 0 };
|
|
169
341
|
}
|
|
170
342
|
function overlayPlan(narrations, embeds) {
|
|
171
343
|
let offset = 0;
|
|
@@ -185,37 +357,6 @@ function overlayPlan(narrations, embeds) {
|
|
|
185
357
|
return out;
|
|
186
358
|
}
|
|
187
359
|
|
|
188
|
-
// ../aula-project/src/notes.ts
|
|
189
|
-
function wordNotes(script, only) {
|
|
190
|
-
const notes = /* @__PURE__ */ new Map();
|
|
191
|
-
script.forEach((cues, index) => {
|
|
192
|
-
if (only !== null && !only.includes(index)) return;
|
|
193
|
-
for (const cue of cues) {
|
|
194
|
-
for (const { word, kind, reading } of unclearWords(cue.words)) {
|
|
195
|
-
const lower = word.slice(0, 1).toLowerCase() + word.slice(1);
|
|
196
|
-
const key = `${kind} ${lower}`;
|
|
197
|
-
const note = notes.get(key);
|
|
198
|
-
if (note === void 0) notes.set(key, { word, kind, reading, uses: 1, place: cue.place ?? null });
|
|
199
|
-
else {
|
|
200
|
-
note.uses += 1;
|
|
201
|
-
if (word === lower) note.word = word;
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
});
|
|
206
|
-
return [...notes.values()];
|
|
207
|
-
}
|
|
208
|
-
function noteLine(note) {
|
|
209
|
-
const why = note.kind === "ambiguous" ? `the context decides its reading, and the lexicon says "${note.reading}"` : `no dictionary has it, and eSpeak NG says /${note.reading}/`;
|
|
210
|
-
const place = note.place ?? "the title";
|
|
211
|
-
const uses = note.uses === 1 ? `1 use, at ${place}` : `${String(note.uses)} uses, the first at ${place}`;
|
|
212
|
-
return `note: ${JSON.stringify(note.word)}: ${why} (${uses})`;
|
|
213
|
-
}
|
|
214
|
-
function notesLine(notes) {
|
|
215
|
-
const count = notes.length === 1 ? "1 note" : `${String(notes.length)} notes`;
|
|
216
|
-
return `${count}: a note is not an error. Give each word its reading with pronounce or in the project lexicon`;
|
|
217
|
-
}
|
|
218
|
-
|
|
219
360
|
// ../aula-project/src/stills.ts
|
|
220
361
|
var clipLength = (frames) => `${(frames / FPS).toFixed(1)} s`;
|
|
221
362
|
function stillsOf(narration, text, frames, embeds = []) {
|
|
@@ -259,7 +400,6 @@ function previewTargets(project, given) {
|
|
|
259
400
|
return given.map((target) => {
|
|
260
401
|
const m = /^(.*):([0-9]+)$/.exec(target);
|
|
261
402
|
const index = chapterIndex(names, m?.[1] ?? target);
|
|
262
|
-
if (index === 0 && m !== null) throw wrongArgument("the title card has no lines: give a chapter name with :<line>");
|
|
263
403
|
return { index, name: names[index] ?? target, line: m?.[2] === void 0 ? null : Number(m[2]) };
|
|
264
404
|
});
|
|
265
405
|
}
|
|
@@ -306,50 +446,7 @@ function pictureGroups(window, stills) {
|
|
|
306
446
|
}
|
|
307
447
|
|
|
308
448
|
// ../aula-project/src/rows.ts
|
|
309
|
-
var EMBED_TAIL = 15;
|
|
310
449
|
var EMPTY2 = { heading: "", headingSpoken: "", metaphor: "", paragraphs: [] };
|
|
311
|
-
function frameAt(sample, rate, fps) {
|
|
312
|
-
const x = sample / rate * fps;
|
|
313
|
-
const floored = Math.floor(x);
|
|
314
|
-
const frac = x - floored;
|
|
315
|
-
if (frac < 0.5) return floored;
|
|
316
|
-
if (frac > 0.5) return floored + 1;
|
|
317
|
-
return floored % 2 === 0 ? floored : floored + 1;
|
|
318
|
-
}
|
|
319
|
-
function sampleAt(cue, word) {
|
|
320
|
-
if (cue.words.length > 0) return cue.words[word]?.startFrame ?? cue.endFrame;
|
|
321
|
-
const n = Math.max(words(cue.text).length, 1);
|
|
322
|
-
const t = Math.min(word, n) / n;
|
|
323
|
-
return cue.speechStartFrame + t * (cue.endFrame - cue.speechStartFrame);
|
|
324
|
-
}
|
|
325
|
-
function secondsAt(narration, sample) {
|
|
326
|
-
return frameAt(sample, narration.sampleRate, FPS) / FPS;
|
|
327
|
-
}
|
|
328
|
-
function scriptBeats(narration, text) {
|
|
329
|
-
const beats = [];
|
|
330
|
-
for (let n = 0; n < text.paragraphs.length; n++) {
|
|
331
|
-
const p = text.paragraphs[n];
|
|
332
|
-
const cue = narration.cues[n + 1];
|
|
333
|
-
if (p === void 0 || cue === void 0) break;
|
|
334
|
-
const firstWord = (index) => p.says.slice(0, index).reduce((sum, say) => sum + words(say.text).length, 0);
|
|
335
|
-
for (let k = 0; k < p.says.length; k++) {
|
|
336
|
-
const say = p.says[k];
|
|
337
|
-
if (say === void 0) continue;
|
|
338
|
-
const onScreen = p.moves.filter((m) => m.say === k).map((m) => m.note);
|
|
339
|
-
beats.push({
|
|
340
|
-
seconds: secondsAt(narration, sampleAt(cue, firstWord(k))),
|
|
341
|
-
kind: "say",
|
|
342
|
-
text: say.text,
|
|
343
|
-
onScreen
|
|
344
|
-
});
|
|
345
|
-
for (const e of p.embeds.filter((embed) => embed.say === k)) {
|
|
346
|
-
const start = secondsAt(narration, sampleAt(cue, firstWord(k + 1))) - (e.frames + EMBED_TAIL) / FPS;
|
|
347
|
-
beats.push({ seconds: start, kind: "embed", text: e.note, onScreen: [] });
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
return beats;
|
|
352
|
-
}
|
|
353
450
|
function timedChapter(index, name, text, narration) {
|
|
354
451
|
return {
|
|
355
452
|
index,
|
|
@@ -364,7 +461,6 @@ function timedChapter(index, name, text, narration) {
|
|
|
364
461
|
async function loadTimed(project, host, narrator, only) {
|
|
365
462
|
const names = chapterNames(project);
|
|
366
463
|
const indexes = only.length === 0 ? project.chapters.map((_, i) => i + 1) : only.map((name) => chapterIndex(names, name));
|
|
367
|
-
if (indexes.includes(0)) throw wrongArgument("the title card has no timeline: give a chapter name");
|
|
368
464
|
const loaded = /* @__PURE__ */ new Map();
|
|
369
465
|
for (const index of indexes) loaded.set(index, chapterText(project, host, index));
|
|
370
466
|
const all = project.chapters.map((_, i) => {
|
|
@@ -486,10 +582,13 @@ async function loadBuiltProjects(bundled, host, modules, player, engineLoaded) {
|
|
|
486
582
|
return { _tag: "Right", right: out };
|
|
487
583
|
}
|
|
488
584
|
var folderOfModule = (module) => module.slice(0, Math.max(0, module.lastIndexOf("/")));
|
|
489
|
-
function listedProjects(projects) {
|
|
490
|
-
if (
|
|
585
|
+
function listedProjects(projects, options = {}) {
|
|
586
|
+
if (options.includeDrafts) return [...projects];
|
|
491
587
|
return projects.filter((project) => !project.draft);
|
|
492
588
|
}
|
|
589
|
+
function draftSkipMessage(folder) {
|
|
590
|
+
return `skipping ${folder} because it is a draft (pass --include-drafts to check it)`;
|
|
591
|
+
}
|
|
493
592
|
function localProject(name, folder, section, definition, host) {
|
|
494
593
|
const count = definition.chapters.length + 1;
|
|
495
594
|
return {
|
|
@@ -532,16 +631,20 @@ function localProject(name, folder, section, definition, host) {
|
|
|
532
631
|
}
|
|
533
632
|
|
|
534
633
|
export {
|
|
634
|
+
narrateScript,
|
|
635
|
+
scriptAudio,
|
|
636
|
+
wav,
|
|
637
|
+
wordNotes,
|
|
638
|
+
noteLine,
|
|
639
|
+
notesLine,
|
|
535
640
|
clock,
|
|
641
|
+
clockWithUnclear,
|
|
536
642
|
narrationAt,
|
|
537
643
|
checkProject,
|
|
538
644
|
chapterIndexes,
|
|
539
645
|
exportCheck,
|
|
540
646
|
clipPlan,
|
|
541
647
|
overlayPlan,
|
|
542
|
-
wordNotes,
|
|
543
|
-
noteLine,
|
|
544
|
-
notesLine,
|
|
545
648
|
previewTargets,
|
|
546
649
|
targetChapters,
|
|
547
650
|
previewJobs,
|
|
@@ -553,5 +656,6 @@ export {
|
|
|
553
656
|
scriptView,
|
|
554
657
|
workspaceHost,
|
|
555
658
|
loadBuiltProjects,
|
|
556
|
-
listedProjects
|
|
659
|
+
listedProjects,
|
|
660
|
+
draftSkipMessage
|
|
557
661
|
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
renderDiagnostic
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-V3GJ4XSW.js";
|
|
4
4
|
import {
|
|
5
5
|
withSource
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-2VD3JPLV.js";
|
|
7
7
|
import {
|
|
8
8
|
loadEngine
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-T7S65ZHW.js";
|
|
10
10
|
|
|
11
11
|
// src/problems.ts
|
|
12
12
|
async function printDiagnostics(capabilities, root, diagnostics, print = (text) => capabilities.log.out(text)) {
|