@storyteller-platform/align 0.1.18 → 0.1.19

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.
@@ -258,7 +258,8 @@ class Aligner {
258
258
  matchedSentence: chapterSentences[endSentence],
259
259
  nextSentence: chapterSentences[endSentence + 1] ?? null
260
260
  },
261
- chapterSentenceCount: sentenceRanges.length,
261
+ chapterSentenceCount: chapterSentences.length,
262
+ alignedSentenceCount: sentenceRanges.length,
262
263
  audioFiles: sentenceRanges.reduce((acc, range) => {
263
264
  const existing = acc.find(
264
265
  (context) => context.filepath === range.audiofile
@@ -29,6 +29,7 @@ interface ChapterReport {
29
29
  nextSentence: string | null;
30
30
  };
31
31
  chapterSentenceCount: number;
32
+ alignedSentenceCount: number;
32
33
  audioFiles: AudioFileContext[];
33
34
  }
34
35
  interface Report {
@@ -29,6 +29,7 @@ interface ChapterReport {
29
29
  nextSentence: string | null;
30
30
  };
31
31
  chapterSentenceCount: number;
32
+ alignedSentenceCount: number;
32
33
  audioFiles: AudioFileContext[];
33
34
  }
34
35
  interface Report {
@@ -192,7 +192,8 @@ class Aligner {
192
192
  matchedSentence: chapterSentences[endSentence],
193
193
  nextSentence: chapterSentences[endSentence + 1] ?? null
194
194
  },
195
- chapterSentenceCount: sentenceRanges.length,
195
+ chapterSentenceCount: chapterSentences.length,
196
+ alignedSentenceCount: sentenceRanges.length,
196
197
  audioFiles: sentenceRanges.reduce((acc, range) => {
197
198
  const existing = acc.find(
198
199
  (context) => context.filepath === range.audiofile
@@ -58,7 +58,12 @@ function liftText(root) {
58
58
  if (node.isBlock) {
59
59
  return !!node.textContent.match(/\S/);
60
60
  }
61
- if (!(node instanceof import_model.TextNode)) return true;
61
+ if (!(node instanceof import_model.TextNode)) {
62
+ if (node.isLeaf && parent.isBlock && index === parent.children.length - 1 && !text.endsWith("\n")) {
63
+ text += "\n";
64
+ }
65
+ return true;
66
+ }
62
67
  if (mapping.map(pos) - mapping.map(lastTextEnd)) {
63
68
  mapping.appendMap(
64
69
  new import_map.StepMap([
@@ -38,7 +38,12 @@ function liftText(root) {
38
38
  if (node.isBlock) {
39
39
  return !!node.textContent.match(/\S/);
40
40
  }
41
- if (!(node instanceof TextNode)) return true;
41
+ if (!(node instanceof TextNode)) {
42
+ if (node.isLeaf && parent.isBlock && index === parent.children.length - 1 && !text.endsWith("\n")) {
43
+ text += "\n";
44
+ }
45
+ return true;
46
+ }
42
47
  if (mapping.map(pos) - mapping.map(lastTextEnd)) {
43
48
  mapping.appendMap(
44
49
  new StepMap([
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storyteller-platform/align",
3
- "version": "0.1.18",
3
+ "version": "0.1.19",
4
4
  "description": "A library and CLI for automatically aligning audiobooks and EPUBs to produce Media Overlays",
5
5
  "author": "Shane Friedman",
6
6
  "license": "MIT",
@@ -61,7 +61,7 @@
61
61
  "@optique/run": "^0.10.7",
62
62
  "@storyteller-platform/audiobook": "^0.3.10",
63
63
  "@storyteller-platform/epub": "^0.4.8",
64
- "@storyteller-platform/ghost-story": "^0.1.6",
64
+ "@storyteller-platform/ghost-story": "^0.1.7",
65
65
  "@storyteller-platform/transliteration": "^3.1.1",
66
66
  "chalk": "^5.4.1",
67
67
  "cli-progress": "^3.12.0",