@beff/aula 0.2.0 → 0.3.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.
@@ -213,7 +213,7 @@ export function wait(): Animation;
213
213
  export function settle(anims: Array<Animation>): void;
214
214
  export function constants(): EngineConstants;
215
215
  export function scriptMarkdown(title: string, texts: Array<ChapterText>): string;
216
- export function narrationScript(title: string, lexicon: Array<LexiconEntry>, texts: Array<ChapterText>): Array<Array<ScriptCue>>;
216
+ export function narrationScript(title: Array<SayPart>, lexicon: Array<LexiconEntry>, texts: Array<ChapterText>): Array<Array<ScriptCue>>;
217
217
  /**
218
218
  * @throws {Error & { payload: Diagnostic }} The error of the result, as the `payload` of the thrown error.
219
219
  */
@@ -222,6 +222,7 @@ export function check(text: ChapterText): Array<Diagnostic>;
222
222
  export function timeline(narration: Narration, text: ChapterText): Array<string>;
223
223
  export function moveFrames(narration: Narration, text: ChapterText): Array<ParagraphFrames>;
224
224
  export function estimateNarration(cues: Array<ScriptCue>): Narration;
225
+ export function words(text: string): Array<string>;
225
226
  export function paragraphAt(text: ChapterText, line: number): number | undefined;
226
227
  export function renderDiagnostic(d: Diagnostic): string;
227
228
  export function fps(): number;
@@ -230,6 +231,11 @@ export function fps(): number;
230
231
  */
231
232
  export function phonemize(text: string, lexicon: Array<LexiconEntry>): string;
232
233
  export function checkLexicon(place: Location, entries: Array<LexiconEntry>): Array<Diagnostic>;
234
+ export function checkTitle(place: Location, parts: Array<SayPart>): Array<Diagnostic>;
235
+ /**
236
+ * @throws {Error & { payload: Diagnostic }} The error of the result, as the `payload` of the thrown error.
237
+ */
238
+ export function unclearWords(words: Array<string>): Array<UnclearWord>;
233
239
  /**
234
240
  * @throws {Error & { payload: Diagnostic }} The error of the result, as the `payload` of the thrown error.
235
241
  */
@@ -521,7 +527,6 @@ export interface EngineConstants {
521
527
  }
522
528
  export interface NarrationWord {
523
529
  text: string,
524
- char: number,
525
530
  startFrame: number,
526
531
  }
527
532
  export interface NarrationCue {
@@ -553,6 +558,19 @@ export interface SayPart {
553
558
  text: string,
554
559
  reading?: Pronunciation,
555
560
  }
561
+ /**
562
+ * # Variants
563
+ *
564
+ * ## `"ambiguous"`
565
+ *
566
+ * ## `"unknown"`
567
+ */
568
+ export type UnclearKind = "ambiguous" | "unknown";
569
+ export interface UnclearWord {
570
+ word: string,
571
+ kind: UnclearKind,
572
+ reading: string,
573
+ }
556
574
  export interface LexiconEntry {
557
575
  word: string,
558
576
  reading: Pronunciation,
@@ -569,21 +587,16 @@ export interface LexiconEntry {
569
587
  export type CueKind = "title" | "heading" | "paragraph";
570
588
  export interface ScriptCue {
571
589
  text: string,
572
- spoken: string,
590
+ words: Array<string>,
573
591
  kind: CueKind,
574
592
  place?: string,
575
593
  leadIn: number,
576
594
  pause: number,
577
595
  speed: number,
578
596
  }
579
- export interface SpokenWord {
580
- text: string,
581
- char: number,
582
- start: number,
583
- }
584
597
  export interface SpokenCue {
585
598
  samples: number,
586
- words: Array<SpokenWord>,
599
+ starts?: Float64Array,
587
600
  }
588
601
  export interface ParagraphFrames {
589
602
  start: number,
@@ -675,7 +688,7 @@ export class Chapter implements Disposable {
675
688
  /**
676
689
  * @throws {Error & { payload: Diagnostic }} The error of the result, as the `payload` of the thrown error.
677
690
  */
678
- header(place: Location, heading: string, metaphor: string): void;
691
+ header(place: Location, heading: Array<SayPart>, metaphor: string): void;
679
692
  /**
680
693
  * @throws {Error & { payload: Diagnostic }} The error of the result, as the `payload` of the thrown error.
681
694
  */
@@ -56,6 +56,7 @@ export interface ParagraphText {
56
56
  export interface ChapterText {
57
57
  place?: Location,
58
58
  heading: string,
59
+ headingSpoken: string,
59
60
  metaphor: string,
60
61
  paragraphs: Array<ParagraphText>,
61
62
  }
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export * as m from "./manim.ts";
2
2
  export { defineChapter, defineProject, isProjectDefinition, paragraph, pronounce, say, show, tagText, } from "./engine.ts";
3
- export { checkChapter, checkLexicon, readChapter, renderChapter, renderScene } from "./run.ts";
4
- export type { Card, ChapterDefinition, ChapterFields, ChapterRun, CheckedChapter, CheckedParagraph, Check, Finding, Heading, Notes, OpenMove, Leaf, Pronounce, Reading, SceneRun, Untimed, ProjectDefinition, ProjectFields, Instant, Row, Screen, Shown, } from "./engine.ts";
3
+ export { checkChapter, checkLexicon, checkTitle, readChapter, renderChapter, renderScene } from "./run.ts";
4
+ export type { Card, ChapterDefinition, ChapterFields, ChapterRun, CheckedChapter, CheckedParagraph, Check, Finding, Heading, Notes, OpenMove, Leaf, Pronounce, Reading, SceneRun, Untimed, ProjectDefinition, ProjectFields, Instant, Row, SayRow, Screen, Shown, } from "./engine.ts";
5
5
  export type { ChapterResult, Host, ReadOptions, RenderOptions, StackFrame } from "./run.ts";
6
6
  export type { Lexicon } from "./lexicon.ts";
package/dist/index.js CHANGED
@@ -8,4 +8,4 @@
8
8
  // renderScene runs a Manim construct, with no narration.
9
9
  export * as m from "./manim.js";
10
10
  export { defineChapter, defineProject, isProjectDefinition, paragraph, pronounce, say, show, tagText, } from "./engine.js";
11
- export { checkChapter, checkLexicon, readChapter, renderChapter, renderScene } from "./run.js";
11
+ export { checkChapter, checkLexicon, checkTitle, readChapter, renderChapter, renderScene } from "./run.js";
package/dist/run.d.ts CHANGED
@@ -73,6 +73,11 @@ export declare function checkChapter(project: Pick<ProjectDefinition, "title" |
73
73
  * table. `aula check` gives them once for the project. A chapter leaves out an entry with a
74
74
  * problem. */
75
75
  export declare function checkLexicon(project: Pick<ProjectDefinition, "lexicon" | "call">, options?: ReadOptions): Diagnostic[];
76
+ /** The problems of the `pronounce` words of the project title (``defineProject({ title: say`…` })``),
77
+ * at the line of its `say`: the problems that a `say` row with the same text gives (the written
78
+ * part is not one word, a phoneme is not in Kokoro's token table, the reading has no
79
+ * phonemes). `aula check` gives them once for the project. A plain string has none. */
80
+ export declare function checkTitle(project: Pick<ProjectDefinition, "titleParts" | "titleCall" | "call">, options?: ReadOptions): Diagnostic[];
76
81
  /** How aula draws a chapter against a narration. */
77
82
  export interface RenderOptions extends ReadOptions {
78
83
  /** The narration of this chapter: a cue for its heading and for each paragraph. */
package/dist/run.js CHANGED
@@ -1,4 +1,4 @@
1
- import { checkRows, checkTitle, drawRows, drawTitle, readRows } from "./engine.js";
1
+ import { checkRows, checkTitleCard, drawRows, drawTitle, readRows } from "./engine.js";
2
2
  import { card as defaultCard } from "./card.js";
3
3
  import { theme as defaultTheme } from "./theme.js";
4
4
  import { AulaError } from "./errors.js";
@@ -216,7 +216,7 @@ export function checkChapter(project, index, options = {}) {
216
216
  const card = project.card ?? defaultCard;
217
217
  const theme = project.theme ?? defaultTheme;
218
218
  if (index === 0) {
219
- return attempt("", host, () => checkTitle(project.title, theme, card, project.chapters.length));
219
+ return attempt("", host, () => checkTitleCard(project.title, theme, card, project.chapters.length));
220
220
  }
221
221
  const chapter = chapterOf(project, index);
222
222
  if (!("call" in chapter))
@@ -239,6 +239,17 @@ export function checkLexicon(project, options = {}) {
239
239
  }));
240
240
  return [...shapes, ...engine.checkLexicon(location, lexiconEntries(project.lexicon))];
241
241
  }
242
+ /** The problems of the `pronounce` words of the project title (``defineProject({ title: say`…` })``),
243
+ * at the line of its `say`: the problems that a `say` row with the same text gives (the written
244
+ * part is not one word, a phoneme is not in Kokoro's token table, the reading has no
245
+ * phonemes). `aula check` gives them once for the project. A plain string has none. */
246
+ export function checkTitle(project, options = {}) {
247
+ const host = options.host ?? NODE;
248
+ const at = definedAt(project, host);
249
+ const frame = host.frames(project.titleCall).find((f) => f.file === at.file) ?? at;
250
+ const location = { file: host.name(frame.file) ?? frame.file, line: frame.line, col: frame.col };
251
+ return engine.checkTitle(location, [...project.titleParts]);
252
+ }
242
253
  /** Draws chapter `index` (0 is the title card) of `project` on its narration: its Lottie, its
243
254
  * length in frames, the waits of the narration and the warnings at the moves that the
244
255
  * narration waits for. */
package/dist/text.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import { type Lexicon } from "./lexicon.ts";
2
2
  import type { Diagnostic, Location, ChapterText } from "./generated/interfaces/aula-engine-types.js";
3
- import type { Narration, ParagraphFrames, ScriptCue, SpokenCue } from "./generated/interfaces/aula-engine-engine.js";
3
+ import type { Narration, ParagraphFrames, SayPart, ScriptCue, SpokenCue, UnclearWord } from "./generated/interfaces/aula-engine-engine.js";
4
4
  export type { Diagnostic, Location, ChapterText };
5
5
  export type { Frame, Move, ParagraphText, Related, Say, Severity } from "./generated/interfaces/aula-engine-types.js";
6
- export type { CueKind, Narration, NarrationCue, NarrationWait, NarrationWord, ParagraphFrames, ScriptCue, SpokenCue, SpokenWord, } from "./generated/interfaces/aula-engine-engine.js";
6
+ export type { CueKind, Narration, NarrationCue, NarrationWait, NarrationWord, ParagraphFrames, SayPart, ScriptCue, SpokenCue, UnclearKind, UnclearWord, } from "./generated/interfaces/aula-engine-engine.js";
7
7
  export type { Theme } from "./theme.ts";
8
8
  export type { Lexicon } from "./lexicon.ts";
9
9
  /** `# <title>` and each chapter's Markdown, with the chapter line of each heading and paragraph:
@@ -11,15 +11,19 @@ export type { Lexicon } from "./lexicon.ts";
11
11
  export declare function scriptMarkdown(title: string, texts: readonly ChapterText[]): string;
12
12
  /** The narration script, one list of cues for each chapter: the title card (the title), then
13
13
  * each chapter (its heading and paragraphs). `project` is the project (`defineProject`), or its
14
- * title and its lexicon: the spoken text of the title and of each heading has the readings of
15
- * the project lexicon, as each `say` of `texts` has. */
14
+ * title, the parts of its title and its lexicon. The spoken text of the title has the readings of
15
+ * its `pronounce` words and of the project lexicon, as each `say` of `texts` has; without
16
+ * `titleParts`, the title is one plain part. The spoken text of each heading is the
17
+ * `headingSpoken` of its chapter text. The CLI and the browser make the script with this call. */
16
18
  export declare function narrationScript(project: {
17
19
  readonly title: string;
20
+ readonly titleParts?: readonly SayPart[];
18
21
  readonly lexicon?: Lexicon;
19
22
  }, texts: readonly ChapterText[]): ScriptCue[][];
20
23
  /** The narration of a chapter from its script `cues` and the speech of each cue (`spoken[i]`
21
- * speaks `cues[i]`), at `sampleRate`. The caller puts the
22
- * samples of each speech at the `speechStartFrame` of its cue. */
24
+ * speaks the `words` of `cues[i]`, and has the start of each of them), at `sampleRate`. The
25
+ * caller puts the samples of each speech at the `speechStartFrame` of its cue. A speech with
26
+ * another number of starts than the words of its cue is an error. */
23
27
  export declare function chapterNarration(cues: readonly ScriptCue[], spoken: readonly SpokenCue[], sampleRate: number): Narration;
24
28
  /** The engine's rules on the text of a chapter. */
25
29
  export declare function check(text: ChapterText): Diagnostic[];
@@ -32,6 +36,10 @@ export declare function timeline(narration: Narration, text: ChapterText): strin
32
36
  export declare function moveFrames(narration: Narration, text: ChapterText): ParagraphFrames[];
33
37
  /** The narration of a chapter estimated from its script cues. */
34
38
  export declare function estimateNarration(cues: readonly ScriptCue[]): Narration;
39
+ /** The words of a narration text, as the engine splits them: its runs with no space, with
40
+ * misaki's inline form as a part of one word. The engine's one word splitter: a cue of the
41
+ * script has its words already (`ScriptCue.words`). */
42
+ export declare function words(text: string): string[];
35
43
  /** The index of the paragraph that holds chapter line `line`. */
36
44
  export declare function paragraphAt(text: ChapterText, line: number): number | undefined;
37
45
  /** The phonemes of English text as Kokoro's British voices read it: the project lexicon
@@ -41,5 +49,13 @@ export declare function paragraphAt(text: ChapterText, line: number): number | u
41
49
  * lexicon with it before the narration. An entry with a problem (`checkLexicon`) is left out.
42
50
  * Throws where misaki raises an error. */
43
51
  export declare function phonemize(text: string, lexicon?: Lexicon): string;
52
+ /** The words of one narration text whose reading is not clear, in the order of the text: each
53
+ * use. `given` is the words of a script cue (`ScriptCue.words`), or the `words` of a plain text.
54
+ * A word is `ambiguous` when the context decides its reading and aula's lexicon gives it one
55
+ * reading (`sin`, `GB`, `3:00`): `reading` is that reading in words. A word is `unknown` when no
56
+ * dictionary has it, so eSpeak NG guesses it: `reading` is the phonemes of the word alone. A
57
+ * word that `pronounce` or the project lexicon decides is never in the list. `aula check` gives
58
+ * a note for each word. */
59
+ export declare function unclearWords(given: readonly string[]): UnclearWord[];
44
60
  /** The one plain-text form of a diagnostic. */
45
61
  export declare function renderDiagnostic(d: Diagnostic): string;
package/dist/text.js CHANGED
@@ -9,14 +9,18 @@ export function scriptMarkdown(title, texts) {
9
9
  }
10
10
  /** The narration script, one list of cues for each chapter: the title card (the title), then
11
11
  * each chapter (its heading and paragraphs). `project` is the project (`defineProject`), or its
12
- * title and its lexicon: the spoken text of the title and of each heading has the readings of
13
- * the project lexicon, as each `say` of `texts` has. */
12
+ * title, the parts of its title and its lexicon. The spoken text of the title has the readings of
13
+ * its `pronounce` words and of the project lexicon, as each `say` of `texts` has; without
14
+ * `titleParts`, the title is one plain part. The spoken text of each heading is the
15
+ * `headingSpoken` of its chapter text. The CLI and the browser make the script with this call. */
14
16
  export function narrationScript(project, texts) {
15
- return engine.narrationScript(project.title, lexiconEntries(project.lexicon ?? {}), [...texts]);
17
+ const title = project.titleParts ?? [{ text: project.title }];
18
+ return engine.narrationScript([...title], lexiconEntries(project.lexicon ?? {}), [...texts]);
16
19
  }
17
20
  /** The narration of a chapter from its script `cues` and the speech of each cue (`spoken[i]`
18
- * speaks `cues[i]`), at `sampleRate`. The caller puts the
19
- * samples of each speech at the `speechStartFrame` of its cue. */
21
+ * speaks the `words` of `cues[i]`, and has the start of each of them), at `sampleRate`. The
22
+ * caller puts the samples of each speech at the `speechStartFrame` of its cue. A speech with
23
+ * another number of starts than the words of its cue is an error. */
20
24
  export function chapterNarration(cues, spoken, sampleRate) {
21
25
  return engine.chapterNarration([...cues], [...spoken], sampleRate);
22
26
  }
@@ -39,6 +43,12 @@ export function moveFrames(narration, text) {
39
43
  export function estimateNarration(cues) {
40
44
  return engine.estimateNarration([...cues]);
41
45
  }
46
+ /** The words of a narration text, as the engine splits them: its runs with no space, with
47
+ * misaki's inline form as a part of one word. The engine's one word splitter: a cue of the
48
+ * script has its words already (`ScriptCue.words`). */
49
+ export function words(text) {
50
+ return engine.words(text);
51
+ }
42
52
  /** The index of the paragraph that holds chapter line `line`. */
43
53
  export function paragraphAt(text, line) {
44
54
  return engine.paragraphAt(text, line);
@@ -52,6 +62,16 @@ export function paragraphAt(text, line) {
52
62
  export function phonemize(text, lexicon = {}) {
53
63
  return engine.phonemize(text, lexiconEntries(lexicon));
54
64
  }
65
+ /** The words of one narration text whose reading is not clear, in the order of the text: each
66
+ * use. `given` is the words of a script cue (`ScriptCue.words`), or the `words` of a plain text.
67
+ * A word is `ambiguous` when the context decides its reading and aula's lexicon gives it one
68
+ * reading (`sin`, `GB`, `3:00`): `reading` is that reading in words. A word is `unknown` when no
69
+ * dictionary has it, so eSpeak NG guesses it: `reading` is the phonemes of the word alone. A
70
+ * word that `pronounce` or the project lexicon decides is never in the list. `aula check` gives
71
+ * a note for each word. */
72
+ export function unclearWords(given) {
73
+ return engine.unclearWords([...given]);
74
+ }
55
75
  /** The one plain-text form of a diagnostic. */
56
76
  export function renderDiagnostic(d) {
57
77
  return engine.renderDiagnostic(d);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@beff/aula",
3
- "version": "0.2.0",
3
+ "version": "0.3.1",
4
4
  "type": "module",
5
5
  "description": "The aula engine for narrated explainer videos: the Manim CE API, defineChapter, its rows, readChapter and renderChapter over a Rust WebAssembly component. Chapters and kits import it; the aula command is @beff/aula-cli.",
6
6
  "license": "MIT AND GPL-3.0-or-later",