@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.
Files changed (65) hide show
  1. package/README.md +6 -1
  2. package/dist/src/aula-render.core.wasm +0 -0
  3. package/dist/src/{aula-voice-tts-YOS4IQXV.js → aula-voice-tts-FEFKNA2I.js} +1 -1
  4. package/dist/src/aula.js +2 -2
  5. package/dist/src/{chunk-DC7A435Z.js → chunk-2BEUK7M7.js} +1 -1
  6. package/dist/src/{chunk-2PAZTBSE.js → chunk-2VD3JPLV.js} +3 -5
  7. package/dist/src/chunk-4N5SDSCV.js +63 -0
  8. package/dist/src/{chunk-AXQBWV7J.js → chunk-F37DXY3P.js} +219 -115
  9. package/dist/src/{chunk-PZXFW6ZD.js → chunk-FGTN34N7.js} +3 -3
  10. package/dist/src/{chunk-RAGZAJKD.js → chunk-GQSFMINU.js} +3 -33
  11. package/dist/src/chunk-N3YZ7K5L.js +111 -0
  12. package/dist/src/{chunk-DN2LVJO3.js → chunk-T7S65ZHW.js} +4307 -1645
  13. package/dist/src/{chunk-TDAWUJ2L.js → chunk-V3GJ4XSW.js} +118 -66
  14. package/dist/src/{chunk-T6CAPT32.js → chunk-VJAXVLXZ.js} +3 -2
  15. package/dist/src/{chunk-HD6FTA3H.js → chunk-Z7VLJSDG.js} +211 -92
  16. package/dist/src/cli.js +44 -155
  17. package/dist/src/{commands-BSDNHYB3.js → commands-ZTGXXVOO.js} +12 -10
  18. package/dist/src/generated/aula.core5.wasm +0 -0
  19. package/dist/src/generated/aula.js +4076 -1341
  20. package/dist/src/generated/interfaces/aula-engine-engine.d.ts +39 -0
  21. package/dist/src/problems-BDPV4IRL.js +17 -0
  22. package/dist/src/project-XHL7FN7B.js +16 -0
  23. package/dist/src/run-LZVKYMKT.js +238 -0
  24. package/dist/src/{server-TJTMSDO2.js → server-H7XOUJNL.js} +24 -21
  25. package/dist/src/{site-RGPJOWSU.js → site-7MLO35NA.js} +16 -89
  26. package/dist/src/workspace-load-OQXB2ZOC.js +16 -0
  27. package/dist/web/app/assets/{bf5dd884 → 15e78332}/aula-method.js +1 -1
  28. package/dist/web/app/assets/{bf5dd884 → 15e78332}/aula.js +1 -1
  29. package/dist/web/app/assets/15e78332/build-worker.js +2 -0
  30. package/dist/web/app/assets/15e78332/index.js +51 -0
  31. package/dist/web/app/assets/__vite-browser-external-CCI-9X_7.js +1 -0
  32. package/dist/web/app/assets/aula-voice-worker-bYZ7BKji.js +1 -0
  33. package/dist/web/app/assets/{aula.core5-CQ2oHbtB.wasm → aula.core5-CtBp7wFf.wasm} +0 -0
  34. package/dist/web/app/assets/protocol-j759xoXL.js +15 -0
  35. package/dist/web/app/assets/src-BjcN7H3T.js +6 -0
  36. package/dist/web/{site/assets/tex-mathjax-DrZV_cwB.js → app/assets/tex-mathjax-Bbh2jsAv.js} +1 -1
  37. package/dist/web/app/index.html +4 -4
  38. package/dist/web/site/assets/{07fb5cf0 → 671a8ee2}/aula-method.js +1 -1
  39. package/dist/web/site/assets/{07fb5cf0 → 671a8ee2}/aula.js +1 -1
  40. package/dist/web/site/assets/671a8ee2/build-worker.js +2 -0
  41. package/dist/web/site/assets/671a8ee2/index.js +51 -0
  42. package/dist/web/site/assets/__vite-browser-external-CrZYh5ba.js +1 -0
  43. package/dist/web/site/assets/aula-voice-worker-Doyh20uI.js +1 -0
  44. package/dist/web/site/assets/{aula.core5-CQ2oHbtB.wasm → aula.core5-CtBp7wFf.wasm} +0 -0
  45. package/dist/web/site/assets/protocol-ByKVs3Yn.js +15 -0
  46. package/dist/web/site/assets/src-BwnY0kQu.js +6 -0
  47. package/dist/web/{app/assets/tex-mathjax-eWNptbJg.js → site/assets/tex-mathjax-DKtiwFu-.js} +1 -1
  48. package/dist/web/site/index.html +4 -4
  49. package/package.json +1 -1
  50. package/dist/src/chunk-4QGX7XXO.js +0 -104
  51. package/dist/src/problems-CGKCPETU.js +0 -18
  52. package/dist/src/project-EUFMRQXR.js +0 -16
  53. package/dist/src/run-ER27SVTA.js +0 -183
  54. package/dist/web/app/assets/__vite-browser-external-BHESVS8k.js +0 -1
  55. package/dist/web/app/assets/aula-voice-worker-CJpoa9h-.js +0 -1
  56. package/dist/web/app/assets/bf5dd884/build-worker.js +0 -2
  57. package/dist/web/app/assets/bf5dd884/index.js +0 -51
  58. package/dist/web/app/assets/protocol-Dc79M9p3.js +0 -15
  59. package/dist/web/app/assets/src-DWqZcp-P.js +0 -6
  60. package/dist/web/site/assets/07fb5cf0/build-worker.js +0 -2
  61. package/dist/web/site/assets/07fb5cf0/index.js +0 -51
  62. package/dist/web/site/assets/__vite-browser-external-DQubyTsZ.js +0 -1
  63. package/dist/web/site/assets/aula-voice-worker-BRrzyFz3.js +0 -1
  64. package/dist/web/site/assets/protocol-F-4tHoAW.js +0 -15
  65. package/dist/web/site/assets/src-DfPcHwz-.js +0 -6
@@ -3,7 +3,46 @@ import {
3
3
  initG2p,
4
4
  lexiconEntries,
5
5
  loadEngine
6
- } from "./chunk-DN2LVJO3.js";
6
+ } from "./chunk-T7S65ZHW.js";
7
+
8
+ // ../aula-core/src/text.ts
9
+ function narrationScript(project, texts) {
10
+ const title = project.titleParts ?? [{ text: project.title }];
11
+ return engine.narrationScript([...title], lexiconEntries(project.lexicon ?? {}), [...texts]);
12
+ }
13
+ function chapterNarration(cues, spoken, sampleRate) {
14
+ return engine.chapterNarration([...cues], [...spoken], sampleRate);
15
+ }
16
+ function check(text) {
17
+ return engine.check(text);
18
+ }
19
+ function timeline(narration, text) {
20
+ return engine.timeline(narration, text);
21
+ }
22
+ function scriptBeats(narration, text) {
23
+ return engine.scriptBeats(narration, text);
24
+ }
25
+ function moveFrames(narration, text) {
26
+ return engine.moveFrames(narration, text);
27
+ }
28
+ function paragraphAt(text, line) {
29
+ return engine.paragraphAt(text, line);
30
+ }
31
+ function phonemize(text, lexicon = {}) {
32
+ return engine.phonemize(text, lexiconEntries(lexicon));
33
+ }
34
+ function phonemizeWithUnknowns(text, lexicon = {}) {
35
+ return engine.phonemizeWithUnknowns(text, lexiconEntries(lexicon));
36
+ }
37
+ function unclearWords(given) {
38
+ return engine.unclearWords([...given]);
39
+ }
40
+ function unclearWordsFrom(given, unknowns, alonePhonemes) {
41
+ return engine.unclearWordsFrom([...given], [...unknowns], [...alonePhonemes]);
42
+ }
43
+ function renderDiagnostic(d) {
44
+ return engine.renderDiagnostic(d);
45
+ }
7
46
 
8
47
  // ../aula-narration/src/align.ts
9
48
  function roundHalfEven(value) {
@@ -157,17 +196,17 @@ async function tokenBatches(vocab, phonemize2, text) {
157
196
  }
158
197
  var STRESS = "\u02C8\u02CC";
159
198
  var isSound = (phoneme) => new RegExp("\\p{L}", "u").test(phoneme) && !STRESS.includes(phoneme);
160
- async function timesOfWords(phonemize2, words2, timings) {
199
+ async function timesOfWords(phonemize2, words, timings) {
161
200
  const read = [];
162
- for (const word of words2) read.push(Array.from(await phonemize2(word)).filter(isSound));
201
+ for (const word of words) read.push(Array.from(await phonemize2(word)).filter(isSound));
163
202
  const spoken = timings.filter((timing) => isSound(timing.phoneme));
164
203
  if (!spoken.length) {
165
- const text = JSON.stringify(words2.join(" "));
204
+ const text = JSON.stringify(words.join(" "));
166
205
  throw new Error(
167
206
  read.some((w) => w.length > 0) ? `the narrator gave no phoneme timings for ${text}` : `Nothing to say: ${text} has no spoken sounds`
168
207
  );
169
208
  }
170
- return alignWords(words2, spoken, read);
209
+ return alignWords(words, spoken, read);
171
210
  }
172
211
 
173
212
  // ../aula-narration/src/vocab.ts
@@ -288,23 +327,25 @@ var KOKORO_VOCAB = /* @__PURE__ */ new Map([
288
327
  ["\u2198", 173],
289
328
  ["\u1D7B", 177]
290
329
  ]);
330
+ var KOKORO_SYMBOLS = Array.from(KOKORO_VOCAB.keys()).join("");
331
+ var KOKORO_PHONEMES = KOKORO_SYMBOLS.replaceAll("$", "");
291
332
 
292
333
  // ../aula-narration/src/aula-voice.ts
293
- var AULA_VOICE_RELEASE = "v0.2.4";
334
+ var AULA_VOICE_RELEASE = "v0.2.5";
294
335
  var RELEASE_URL = `https://github.com/lucasavila00/aula-voice/releases/download/${AULA_VOICE_RELEASE}`;
295
336
  var AULA_VOICE_FILES = {
296
337
  model: {
297
338
  path: "model.f16-text-fp32.safetensors",
298
339
  bytes: 21484448,
299
- sha256: "77029d5db79eca7dfbd353b67f255024cc077a578cb893cc92c41fd2ba83cf7f"
340
+ sha256: "35a016e19acf9b67d52aacd8d156f97690aba7ee9aeaf2b5ee55f58c38c3cdd5"
300
341
  },
301
342
  config: {
302
343
  path: "config.json",
303
- bytes: 2215,
304
- sha256: "1fe25ebd9f94c7ebc0f5f4f7c1320c26fc535350c8e366e339a3ce88c18b1c81"
344
+ bytes: 2214,
345
+ sha256: "3102a3d2769ed4ab7b9dce6654a921cc84d4532aae9fb8c03932c3a206819889"
305
346
  }
306
347
  };
307
- var AULA_VOICE_WEIGHTS_SHA256 = "cdf77eccfdc734e7a4ee74708e9be9fb3b9d14b0134ce84e5794c27ef1c76706";
348
+ var AULA_VOICE_WEIGHTS_SHA256 = "aec149e146b62fc3091f4310aeb596ee88c87c583258d35a023b8bbc5c42b0e1";
308
349
  var AULA_VOICE_WEIGHTS = {
309
350
  path: `aula-voice-${AULA_VOICE_WEIGHTS_SHA256.slice(0, 12)}.avw`,
310
351
  bytes: 21474688,
@@ -327,10 +368,19 @@ function limited(audio) {
327
368
  const scale = PEAK / loudest;
328
369
  return audio.map((sample) => sample * scale);
329
370
  }
330
- async function layout(parts, words2, audio) {
331
- const text = words2.join(" ");
371
+ function cuePhonemesOf(words) {
372
+ const spoken = words.join(" ");
373
+ const { phonemes, unknowns } = phonemizeWithUnknowns(spoken);
374
+ return { spoken, phonemes, unknowns, alonePhonemes: words.map((word) => phonemize(word)) };
375
+ }
376
+ function throwNoSpoken(kind, text) {
377
+ if (kind === "no-phonemes") throw new Error(`Nothing to say: ${JSON.stringify(text)} has no phonemes`);
378
+ throw new Error(`Nothing to say: ${JSON.stringify(text)} has no spoken sounds`);
379
+ }
380
+ async function layout(parts, words, audio, collectCue) {
381
+ const text = words.join(" ");
332
382
  const batches = await batchesOf(parts.phonemize, text, MAX_TOKENS);
333
- if (!batches.length) throw new Error(`Nothing to say: ${JSON.stringify(text)} has no phonemes`);
383
+ if (!batches.length) return { _tag: "Left", left: "no-phonemes" };
334
384
  const tokenized = batches.map((batch) => {
335
385
  const { ids, known } = tokenize(KOKORO_VOCAB, batch);
336
386
  if (!ids.length) {
@@ -341,7 +391,7 @@ async function layout(parts, words2, audio) {
341
391
  return { batch, ids, known };
342
392
  });
343
393
  if (!tokenized.some(({ known }) => known.some(isSound))) {
344
- throw new Error(`Nothing to say: ${JSON.stringify(text)} has no spoken sounds`);
394
+ return { _tag: "Left", left: "no-spoken" };
345
395
  }
346
396
  const pieces = [];
347
397
  const timings = [];
@@ -364,54 +414,43 @@ async function layout(parts, words2, audio) {
364
414
  pieces.push({ audio: spoken.audio?.subarray(head, tail) ?? null, length: tail - head, pause });
365
415
  offset += tail - head + pause;
366
416
  }
367
- return { pieces, total: offset, words: await timesOfWords(parts.phonemize, words2, timings) };
417
+ return {
418
+ _tag: "Right",
419
+ right: {
420
+ pieces,
421
+ total: offset,
422
+ words: await timesOfWords(parts.phonemize, words, timings),
423
+ ...collectCue ? { cue: cuePhonemesOf(words) } : {}
424
+ }
425
+ };
368
426
  }
369
427
  async function speakAulaVoice(parts, given) {
370
- const { pieces, total, words: words2 } = await layout(parts, given, true);
428
+ const text = given.join(" ");
429
+ const laid = await layout(parts, given, true, false);
430
+ if (laid._tag === "Left") throwNoSpoken(laid.left, text);
431
+ const { pieces, total, words } = laid.right;
371
432
  const samples = new Float32Array(total);
372
433
  let offset = 0;
373
434
  for (const piece of pieces) {
374
435
  if (piece.audio) samples.set(piece.audio, offset);
375
436
  offset += piece.length + piece.pause;
376
437
  }
377
- return { samples: limited(samples), sampleRate: SAMPLE_RATE, words: words2 };
438
+ return { samples: limited(samples), sampleRate: SAMPLE_RATE, words };
439
+ }
440
+ async function tryTimeAulaVoice(parts, given) {
441
+ const laid = await layout(parts, given, false, true);
442
+ if (laid._tag === "Left") return laid;
443
+ const { total, words, cue } = laid.right;
444
+ return {
445
+ _tag: "Right",
446
+ right: { samples: total, sampleRate: SAMPLE_RATE, words, ...cue === void 0 ? {} : { cue } }
447
+ };
378
448
  }
379
449
  async function timeAulaVoice(parts, given) {
380
- const { total, words: words2 } = await layout(parts, given, false);
381
- return { samples: total, sampleRate: SAMPLE_RATE, words: words2 };
382
- }
383
-
384
- // ../aula-core/src/text.ts
385
- function narrationScript(project, texts) {
386
- const title = project.titleParts ?? [{ text: project.title }];
387
- return engine.narrationScript([...title], lexiconEntries(project.lexicon ?? {}), [...texts]);
388
- }
389
- function chapterNarration(cues, spoken, sampleRate) {
390
- return engine.chapterNarration([...cues], [...spoken], sampleRate);
391
- }
392
- function check(text) {
393
- return engine.check(text);
394
- }
395
- function timeline(narration, text) {
396
- return engine.timeline(narration, text);
397
- }
398
- function moveFrames(narration, text) {
399
- return engine.moveFrames(narration, text);
400
- }
401
- function words(text) {
402
- return engine.words(text);
403
- }
404
- function paragraphAt(text, line) {
405
- return engine.paragraphAt(text, line);
406
- }
407
- function phonemize(text, lexicon = {}) {
408
- return engine.phonemize(text, lexiconEntries(lexicon));
409
- }
410
- function unclearWords(given) {
411
- return engine.unclearWords([...given]);
412
- }
413
- function renderDiagnostic(d) {
414
- return engine.renderDiagnostic(d);
450
+ const text = given.join(" ");
451
+ const timed = await tryTimeAulaVoice(parts, given);
452
+ if (timed._tag === "Left") throwNoSpoken(timed.left, text);
453
+ return timed.right;
415
454
  }
416
455
 
417
456
  // ../aula-narration/src/avw.ts
@@ -640,15 +679,37 @@ function studentWeightFile(model, config) {
640
679
  }
641
680
 
642
681
  // ../aula-narration/src/phonemize.ts
643
- function britishPhonemizer(vocab) {
682
+ function lexiconKey(lexicon) {
683
+ return JSON.stringify(Object.entries(lexicon));
684
+ }
685
+ function britishPhonemizer(vocab, lexicon = {}) {
686
+ const cache = /* @__PURE__ */ new Map();
687
+ const lex = lexiconKey(lexicon);
644
688
  return async (text) => {
645
- await loadEngine();
646
- await initG2p();
647
- return Array.from(phonemize(text)).filter((phoneme) => vocab.has(phoneme)).join("").trim();
689
+ const key = `${lex}\0${text}`;
690
+ const hit = cache.get(key);
691
+ if (hit) return hit;
692
+ const pending = (async () => {
693
+ await loadEngine();
694
+ await initG2p();
695
+ return Array.from(phonemize(text, lexicon)).filter((phoneme) => vocab.has(phoneme)).join("").trim();
696
+ })();
697
+ cache.set(key, pending);
698
+ return pending;
648
699
  };
649
700
  }
650
701
 
651
702
  export {
703
+ narrationScript,
704
+ chapterNarration,
705
+ check,
706
+ timeline,
707
+ scriptBeats,
708
+ moveFrames,
709
+ paragraphAt,
710
+ unclearWords,
711
+ unclearWordsFrom,
712
+ renderDiagnostic,
652
713
  tokenBatches,
653
714
  KOKORO_VOCAB,
654
715
  AULA_VOICE_RELEASE,
@@ -657,17 +718,8 @@ export {
657
718
  SERVER_WEIGHTS_PATH,
658
719
  aulaVoiceUrl,
659
720
  speakAulaVoice,
721
+ tryTimeAulaVoice,
660
722
  timeAulaVoice,
661
723
  studentWeightFile,
662
- narrationScript,
663
- chapterNarration,
664
- check,
665
- timeline,
666
- moveFrames,
667
- words,
668
- paragraphAt,
669
- phonemize,
670
- unclearWords,
671
- renderDiagnostic,
672
724
  britishPhonemizer
673
725
  };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  diagnosticOf
3
- } from "./chunk-DN2LVJO3.js";
3
+ } from "./chunk-T7S65ZHW.js";
4
4
 
5
5
  // ../../node_modules/.pnpm/@beff+client@1.0.1/node_modules/@beff/client/dist/esm/openapi-pp.js
6
6
  var removeNullUnionBranch = (definition) => {
@@ -1251,7 +1251,7 @@ async function projectModules(tree, root) {
1251
1251
  });
1252
1252
  return errors.length > 0 ? { _tag: "Left", left: errors } : { _tag: "Right", right: found };
1253
1253
  }
1254
- var NO_PROJECT_MESSAGE = "no project here: run from a project or playlist folder, or pass it (for example: aula web examples)";
1254
+ var NO_PROJECT_MESSAGE = "no project here: pass a project or playlist folder (for example: aula web . or aula web examples)";
1255
1255
  async function bundleProjects(bundler, tree, root, projects) {
1256
1256
  if (projects.length === 0) {
1257
1257
  throw new Error(NO_PROJECT_MESSAGE);
@@ -1313,6 +1313,7 @@ export {
1313
1313
  bundle,
1314
1314
  projectName,
1315
1315
  projectModules,
1316
+ NO_PROJECT_MESSAGE,
1316
1317
  bundleProjects,
1317
1318
  bundleWorkspace,
1318
1319
  error,