@beff/aula 0.1.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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, 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,13 +222,20 @@ 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;
228
229
  /**
229
230
  * @throws {Error & { payload: Diagnostic }} The error of the result, as the `payload` of the thrown error.
230
231
  */
231
- export function phonemize(text: string): string;
232
+ export function phonemize(text: string, lexicon: Array<LexiconEntry>): string;
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>;
232
239
  /**
233
240
  * @throws {Error & { payload: Diagnostic }} The error of the result, as the `payload` of the thrown error.
234
241
  */
@@ -520,7 +527,6 @@ export interface EngineConstants {
520
527
  }
521
528
  export interface NarrationWord {
522
529
  text: string,
523
- char: number,
524
530
  startFrame: number,
525
531
  }
526
532
  export interface NarrationCue {
@@ -539,6 +545,36 @@ export interface NarrationWait {
539
545
  sample: number,
540
546
  samples: number,
541
547
  }
548
+ export type Pronunciation = PronunciationWords | PronunciationPhonemes;
549
+ export interface PronunciationWords {
550
+ tag: 'words',
551
+ val: string,
552
+ }
553
+ export interface PronunciationPhonemes {
554
+ tag: 'phonemes',
555
+ val: string,
556
+ }
557
+ export interface SayPart {
558
+ text: string,
559
+ reading?: Pronunciation,
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
+ }
574
+ export interface LexiconEntry {
575
+ word: string,
576
+ reading: Pronunciation,
577
+ }
542
578
  /**
543
579
  * # Variants
544
580
  *
@@ -551,20 +587,16 @@ export interface NarrationWait {
551
587
  export type CueKind = "title" | "heading" | "paragraph";
552
588
  export interface ScriptCue {
553
589
  text: string,
590
+ words: Array<string>,
554
591
  kind: CueKind,
555
592
  place?: string,
556
593
  leadIn: number,
557
594
  pause: number,
558
595
  speed: number,
559
596
  }
560
- export interface SpokenWord {
561
- text: string,
562
- char: number,
563
- start: number,
564
- }
565
597
  export interface SpokenCue {
566
598
  samples: number,
567
- words: Array<SpokenWord>,
599
+ starts?: Float64Array,
568
600
  }
569
601
  export interface ParagraphFrames {
570
602
  start: number,
@@ -656,7 +688,7 @@ export class Chapter implements Disposable {
656
688
  /**
657
689
  * @throws {Error & { payload: Diagnostic }} The error of the result, as the `payload` of the thrown error.
658
690
  */
659
- header(place: Location, heading: string, metaphor: string): void;
691
+ header(place: Location, heading: Array<SayPart>, metaphor: string): void;
660
692
  /**
661
693
  * @throws {Error & { payload: Diagnostic }} The error of the result, as the `payload` of the thrown error.
662
694
  */
@@ -664,7 +696,8 @@ export class Chapter implements Disposable {
664
696
  /**
665
697
  * @throws {Error & { payload: Diagnostic }} The error of the result, as the `payload` of the thrown error.
666
698
  */
667
- say(place: Location, text: string): void;
699
+ say(place: Location, parts: Array<SayPart>): void;
700
+ lexicon(entries: Array<LexiconEntry>): void;
668
701
  /**
669
702
  * @throws {Error & { payload: Diagnostic }} The error of the result, as the `payload` of the thrown error.
670
703
  */
@@ -38,6 +38,7 @@ export interface Note {
38
38
  export interface Say {
39
39
  place: Location,
40
40
  text: string,
41
+ spoken: string,
41
42
  }
42
43
  export interface Move {
43
44
  place: Location,
@@ -55,6 +56,7 @@ export interface ParagraphText {
55
56
  export interface ChapterText {
56
57
  place?: Location,
57
58
  heading: string,
59
+ headingSpoken: string,
58
60
  metaphor: string,
59
61
  paragraphs: Array<ParagraphText>,
60
62
  }
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export * as m from "./manim.ts";
2
- export { defineChapter, defineProject, isProjectDefinition, paragraph, say, show, tagText } from "./engine.ts";
3
- export { checkChapter, readChapter, renderChapter, renderScene } from "./run.ts";
4
- export type { Card, ChapterDefinition, ChapterFields, ChapterRun, CheckedChapter, CheckedParagraph, Check, Finding, Heading, Notes, OpenMove, Leaf, SceneRun, Untimed, ProjectDefinition, ProjectFields, Instant, Row, Screen, Shown, } from "./engine.ts";
2
+ export { defineChapter, defineProject, isProjectDefinition, paragraph, pronounce, say, show, tagText, } 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
+ export type { Lexicon } from "./lexicon.ts";
package/dist/index.js CHANGED
@@ -7,5 +7,5 @@
7
7
  // readChapter, checkChapter and renderChapter run a chapter, as the CLI and the web app do.
8
8
  // renderScene runs a Manim construct, with no narration.
9
9
  export * as m from "./manim.js";
10
- export { defineChapter, defineProject, isProjectDefinition, paragraph, say, show, tagText } from "./engine.js";
11
- export { checkChapter, readChapter, renderChapter, renderScene } from "./run.js";
10
+ export { defineChapter, defineProject, isProjectDefinition, paragraph, pronounce, say, show, tagText, } from "./engine.js";
11
+ export { checkChapter, checkLexicon, checkTitle, readChapter, renderChapter, renderScene } from "./run.js";
@@ -0,0 +1,10 @@
1
+ import type { Reading } from "./engine.ts";
2
+ import type { LexiconEntry } from "./generated/interfaces/aula-engine-engine.js";
3
+ /** The project lexicon: each key is a written word, and each value is its reading, the same
4
+ * object that `pronounce` takes. A kit exports one, and a project spreads it into its own. */
5
+ export type Lexicon = Readonly<Record<string, Reading>>;
6
+ /** The entries of `lexicon` in the engine's form, in the order of the object. An entry whose
7
+ * reading has the wrong form is left out: `badReadings` gives its key. */
8
+ export declare function lexiconEntries(lexicon: Lexicon): LexiconEntry[];
9
+ /** The keys of `lexicon` whose reading is not `{ say: string }` or `{ phonemes: string }`. */
10
+ export declare function badReadings(lexicon: Lexicon): string[];
@@ -0,0 +1,23 @@
1
+ /** A reading in the engine's form, or undefined when it is not `{ say: string }` or
2
+ * `{ phonemes: string }` (a value from JavaScript with no types). */
3
+ function rawReading(reading) {
4
+ if (typeof reading !== "object" || reading === null || Object.keys(reading).length !== 1)
5
+ return undefined;
6
+ if ("say" in reading && typeof reading.say === "string")
7
+ return { tag: "words", val: reading.say };
8
+ if ("phonemes" in reading && typeof reading.phonemes === "string")
9
+ return { tag: "phonemes", val: reading.phonemes };
10
+ return undefined;
11
+ }
12
+ /** The entries of `lexicon` in the engine's form, in the order of the object. An entry whose
13
+ * reading has the wrong form is left out: `badReadings` gives its key. */
14
+ export function lexiconEntries(lexicon) {
15
+ return Object.entries(lexicon).flatMap(([word, reading]) => {
16
+ const raw = rawReading(reading);
17
+ return raw === undefined ? [] : [{ word, reading: raw }];
18
+ });
19
+ }
20
+ /** The keys of `lexicon` whose reading is not `{ say: string }` or `{ phonemes: string }`. */
21
+ export function badReadings(lexicon) {
22
+ return Object.entries(lexicon).flatMap(([word, reading]) => (rawReading(reading) === undefined ? [word] : []));
23
+ }
package/dist/run.d.ts CHANGED
@@ -59,14 +59,25 @@ export interface ReadOptions {
59
59
  }
60
60
  /** Reads chapter `index` (from 1) of `project`: its text and its text problems, with no move
61
61
  * run. The paragraph checks run only when the chapter is checked (`checkChapter`). */
62
- export declare function readChapter(project: Pick<ProjectDefinition, "title" | "chapters">, index: number, options?: ReadOptions): ChapterResult<ChapterText>;
62
+ export declare function readChapter(project: Pick<ProjectDefinition, "title" | "chapters" | "lexicon">, index: number, options?: ReadOptions): ChapterResult<ChapterText>;
63
63
  /** Checks chapter `index` (0 is the title card) of `project`, as `aula check` does: it runs
64
64
  * the moves in list order with no clock and no narration, and gives the text problems, the
65
65
  * engine's checks of the picture after each animation, the kit findings and the paragraph
66
66
  * checks. With sync by construction, no check depends on the length of a `say`. */
67
- export declare function checkChapter(project: Pick<ProjectDefinition, "title" | "chapters" | "theme" | "card">, index: number, options?: ReadOptions): ChapterResult<{
67
+ export declare function checkChapter(project: Pick<ProjectDefinition, "title" | "chapters" | "lexicon" | "theme" | "card">, index: number, options?: ReadOptions): ChapterResult<{
68
68
  diagnostics: Diagnostic[];
69
69
  }>;
70
+ /** The problems of the project lexicon (`defineProject({ lexicon })`), at the `defineProject`
71
+ * call: a key that is not one word, a reading that is not `{ say: string }` or
72
+ * `{ phonemes: string }`, an empty `say` reading, and a phoneme that is not in Kokoro's token
73
+ * table. `aula check` gives them once for the project. A chapter leaves out an entry with a
74
+ * problem. */
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[];
70
81
  /** How aula draws a chapter against a narration. */
71
82
  export interface RenderOptions extends ReadOptions {
72
83
  /** The narration of this chapter: a cue for its heading and for each paragraph. */
@@ -78,4 +89,4 @@ export interface RenderOptions extends ReadOptions {
78
89
  /** Draws chapter `index` (0 is the title card) of `project` on its narration: its Lottie, its
79
90
  * length in frames, the waits of the narration and the warnings at the moves that the
80
91
  * narration waits for. */
81
- export declare function renderChapter(project: Pick<ProjectDefinition, "title" | "chapters" | "theme" | "card">, index: number, options: RenderOptions): ChapterResult<ChapterRun>;
92
+ export declare function renderChapter(project: Pick<ProjectDefinition, "title" | "chapters" | "lexicon" | "theme" | "card">, index: number, options: RenderOptions): ChapterResult<ChapterRun>;
package/dist/run.js CHANGED
@@ -1,10 +1,11 @@
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";
5
- import { isComponentError } from "./load.js";
5
+ import { engine, isComponentError } from "./load.js";
6
6
  import { hasPending, takePending } from "./host.js";
7
7
  import { runUserCode } from "./user-code.js";
8
+ import { badReadings, lexiconEntries } from "./lexicon.js";
8
9
  export { importUserModule } from "./user-code.js";
9
10
  export { renderScene } from "./engine.js";
10
11
  /** Frames per second of the Lottie files: the engine's rate (`engine.fps()`, which
@@ -192,6 +193,7 @@ function slotOf(project, chapter, index, host) {
192
193
  source,
193
194
  file: host.name(source) ?? source,
194
195
  frames: (e) => host.frames(e),
196
+ lexicon: lexiconEntries(project.lexicon),
195
197
  };
196
198
  }
197
199
  /** Reads chapter `index` (from 1) of `project`: its text and its text problems, with no move
@@ -214,7 +216,7 @@ export function checkChapter(project, index, options = {}) {
214
216
  const card = project.card ?? defaultCard;
215
217
  const theme = project.theme ?? defaultTheme;
216
218
  if (index === 0) {
217
- return attempt("", host, () => checkTitle(project.title, theme, card, project.chapters.length));
219
+ return attempt("", host, () => checkTitleCard(project.title, theme, card, project.chapters.length));
218
220
  }
219
221
  const chapter = chapterOf(project, index);
220
222
  if (!("call" in chapter))
@@ -222,6 +224,32 @@ export function checkChapter(project, index, options = {}) {
222
224
  const slot = slotOf(project, chapter, index, host);
223
225
  return attempt(slot.source, host, () => checkRows(chapter, theme, card, slot, (p) => host.exists(p)));
224
226
  }
227
+ /** The problems of the project lexicon (`defineProject({ lexicon })`), at the `defineProject`
228
+ * call: a key that is not one word, a reading that is not `{ say: string }` or
229
+ * `{ phonemes: string }`, an empty `say` reading, and a phoneme that is not in Kokoro's token
230
+ * table. `aula check` gives them once for the project. A chapter leaves out an entry with a
231
+ * problem. */
232
+ export function checkLexicon(project, options = {}) {
233
+ const host = options.host ?? NODE;
234
+ const frame = definedAt(project, host);
235
+ const location = { file: host.name(frame.file) ?? frame.file, line: frame.line, col: frame.col };
236
+ const shapes = badReadings(project.lexicon).map((word) => error(`lexicon: the reading of ${JSON.stringify(word)} is not { say: string } or { phonemes: string }`, {
237
+ location,
238
+ hint: 'give the reading as { say: "words" } or { phonemes: "fˈQnimz" }, as for pronounce',
239
+ }));
240
+ return [...shapes, ...engine.checkLexicon(location, lexiconEntries(project.lexicon))];
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
+ }
225
253
  /** Draws chapter `index` (0 is the title card) of `project` on its narration: its Lottie, its
226
254
  * length in frames, the waits of the narration and the warnings at the moves that the
227
255
  * narration waits for. */
package/dist/text.d.ts CHANGED
@@ -1,18 +1,29 @@
1
+ import { type Lexicon } from "./lexicon.ts";
1
2
  import type { Diagnostic, Location, ChapterText } from "./generated/interfaces/aula-engine-types.js";
2
- 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";
3
4
  export type { Diagnostic, Location, ChapterText };
4
5
  export type { Frame, Move, ParagraphText, Related, Say, Severity } from "./generated/interfaces/aula-engine-types.js";
5
- 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";
6
7
  export type { Theme } from "./theme.ts";
8
+ export type { Lexicon } from "./lexicon.ts";
7
9
  /** `# <title>` and each chapter's Markdown, with the chapter line of each heading and paragraph:
8
10
  * for people to read. */
9
11
  export declare function scriptMarkdown(title: string, texts: readonly ChapterText[]): string;
10
12
  /** The narration script, one list of cues for each chapter: the title card (the title), then
11
- * each chapter (its heading and paragraphs). */
12
- export declare function narrationScript(title: string, texts: readonly ChapterText[]): ScriptCue[][];
13
+ * each chapter (its heading and paragraphs). `project` is the project (`defineProject`), or its
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. */
18
+ export declare function narrationScript(project: {
19
+ readonly title: string;
20
+ readonly titleParts?: readonly SayPart[];
21
+ readonly lexicon?: Lexicon;
22
+ }, texts: readonly ChapterText[]): ScriptCue[][];
13
23
  /** The narration of a chapter from its script `cues` and the speech of each cue (`spoken[i]`
14
- * speaks `cues[i]`), at `sampleRate`. The caller puts the
15
- * 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. */
16
27
  export declare function chapterNarration(cues: readonly ScriptCue[], spoken: readonly SpokenCue[], sampleRate: number): Narration;
17
28
  /** The engine's rules on the text of a chapter. */
18
29
  export declare function check(text: ChapterText): Diagnostic[];
@@ -25,11 +36,26 @@ export declare function timeline(narration: Narration, text: ChapterText): strin
25
36
  export declare function moveFrames(narration: Narration, text: ChapterText): ParagraphFrames[];
26
37
  /** The narration of a chapter estimated from its script cues. */
27
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[];
28
43
  /** The index of the paragraph that holds chapter line `line`. */
29
44
  export declare function paragraphAt(text: ChapterText, line: number): number | undefined;
30
- /** The phonemes of English text as Kokoro's British voices read it: misaki 0.9.4's British G2P
31
- * (crates/aula-g2p), with eSpeak NG for the words that its dictionaries do not have. The same
32
- * on every run, in Node and in the browser. Throws where misaki raises an error. */
33
- export declare function phonemize(text: string): string;
45
+ /** The phonemes of English text as Kokoro's British voices read it: the project lexicon
46
+ * `lexicon` (`defineProject({ lexicon })`), aula's pronunciation lexicon, then misaki 0.9.4's
47
+ * British G2P (crates/aula-g2p), with eSpeak NG for the words that its dictionaries do not
48
+ * have. The same on every run, in Node and in the browser. Test a reading of the project
49
+ * lexicon with it before the narration. An entry with a problem (`checkLexicon`) is left out.
50
+ * Throws where misaki raises an error. */
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[];
34
60
  /** The one plain-text form of a diagnostic. */
35
61
  export declare function renderDiagnostic(d: Diagnostic): string;
package/dist/text.js CHANGED
@@ -1,19 +1,26 @@
1
1
  // The engine's pure text rules (crates/aula-project): script, narration script, check,
2
2
  // timeline, narration estimate, and the one diagnostic text format.
3
3
  import { engine } from "./load.js";
4
+ import { lexiconEntries } from "./lexicon.js";
4
5
  /** `# <title>` and each chapter's Markdown, with the chapter line of each heading and paragraph:
5
6
  * for people to read. */
6
7
  export function scriptMarkdown(title, texts) {
7
8
  return engine.scriptMarkdown(title, [...texts]);
8
9
  }
9
10
  /** The narration script, one list of cues for each chapter: the title card (the title), then
10
- * each chapter (its heading and paragraphs). */
11
- export function narrationScript(title, texts) {
12
- return engine.narrationScript(title, [...texts]);
11
+ * each chapter (its heading and paragraphs). `project` is the project (`defineProject`), or its
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. */
16
+ export function narrationScript(project, texts) {
17
+ const title = project.titleParts ?? [{ text: project.title }];
18
+ return engine.narrationScript([...title], lexiconEntries(project.lexicon ?? {}), [...texts]);
13
19
  }
14
20
  /** The narration of a chapter from its script `cues` and the speech of each cue (`spoken[i]`
15
- * speaks `cues[i]`), at `sampleRate`. The caller puts the
16
- * 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. */
17
24
  export function chapterNarration(cues, spoken, sampleRate) {
18
25
  return engine.chapterNarration([...cues], [...spoken], sampleRate);
19
26
  }
@@ -36,15 +43,34 @@ export function moveFrames(narration, text) {
36
43
  export function estimateNarration(cues) {
37
44
  return engine.estimateNarration([...cues]);
38
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
+ }
39
52
  /** The index of the paragraph that holds chapter line `line`. */
40
53
  export function paragraphAt(text, line) {
41
54
  return engine.paragraphAt(text, line);
42
55
  }
43
- /** The phonemes of English text as Kokoro's British voices read it: misaki 0.9.4's British G2P
44
- * (crates/aula-g2p), with eSpeak NG for the words that its dictionaries do not have. The same
45
- * on every run, in Node and in the browser. Throws where misaki raises an error. */
46
- export function phonemize(text) {
47
- return engine.phonemize(text);
56
+ /** The phonemes of English text as Kokoro's British voices read it: the project lexicon
57
+ * `lexicon` (`defineProject({ lexicon })`), aula's pronunciation lexicon, then misaki 0.9.4's
58
+ * British G2P (crates/aula-g2p), with eSpeak NG for the words that its dictionaries do not
59
+ * have. The same on every run, in Node and in the browser. Test a reading of the project
60
+ * lexicon with it before the narration. An entry with a problem (`checkLexicon`) is left out.
61
+ * Throws where misaki raises an error. */
62
+ export function phonemize(text, lexicon = {}) {
63
+ return engine.phonemize(text, lexiconEntries(lexicon));
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]);
48
74
  }
49
75
  /** The one plain-text form of a diagnostic. */
50
76
  export function renderDiagnostic(d) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@beff/aula",
3
- "version": "0.1.1",
3
+ "version": "0.3.0",
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",