@storyteller-platform/align 0.0.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 (96) hide show
  1. package/LICENSE.txt +21 -0
  2. package/README.md +3 -0
  3. package/dist/align/align.cjs +525 -0
  4. package/dist/align/align.d.cts +58 -0
  5. package/dist/align/align.d.ts +58 -0
  6. package/dist/align/align.js +458 -0
  7. package/dist/align/fuzzy.cjs +164 -0
  8. package/dist/align/fuzzy.d.cts +6 -0
  9. package/dist/align/fuzzy.d.ts +6 -0
  10. package/dist/align/fuzzy.js +141 -0
  11. package/dist/align/getSentenceRanges.cjs +304 -0
  12. package/dist/align/getSentenceRanges.d.cts +31 -0
  13. package/dist/align/getSentenceRanges.d.ts +31 -0
  14. package/dist/align/getSentenceRanges.js +277 -0
  15. package/dist/align/parse.cjs +63 -0
  16. package/dist/align/parse.d.cts +30 -0
  17. package/dist/align/parse.d.ts +30 -0
  18. package/dist/align/parse.js +51 -0
  19. package/dist/chunk-BIEQXUOY.js +50 -0
  20. package/dist/cli/bin.cjs +368 -0
  21. package/dist/cli/bin.d.cts +1 -0
  22. package/dist/cli/bin.d.ts +1 -0
  23. package/dist/cli/bin.js +319 -0
  24. package/dist/common/ffmpeg.cjs +232 -0
  25. package/dist/common/ffmpeg.d.cts +33 -0
  26. package/dist/common/ffmpeg.d.ts +33 -0
  27. package/dist/common/ffmpeg.js +196 -0
  28. package/dist/common/logging.cjs +45 -0
  29. package/dist/common/logging.d.cts +5 -0
  30. package/dist/common/logging.d.ts +5 -0
  31. package/dist/common/logging.js +12 -0
  32. package/dist/common/parse.cjs +73 -0
  33. package/dist/common/parse.d.cts +28 -0
  34. package/dist/common/parse.d.ts +28 -0
  35. package/dist/common/parse.js +56 -0
  36. package/dist/common/shell.cjs +30 -0
  37. package/dist/common/shell.d.cts +3 -0
  38. package/dist/common/shell.d.ts +3 -0
  39. package/dist/common/shell.js +7 -0
  40. package/dist/index.cjs +37 -0
  41. package/dist/index.d.cts +12 -0
  42. package/dist/index.d.ts +12 -0
  43. package/dist/index.js +11 -0
  44. package/dist/markup/__tests__/markup.test.cjs +464 -0
  45. package/dist/markup/__tests__/markup.test.d.cts +2 -0
  46. package/dist/markup/__tests__/markup.test.d.ts +2 -0
  47. package/dist/markup/__tests__/markup.test.js +441 -0
  48. package/dist/markup/markup.cjs +316 -0
  49. package/dist/markup/markup.d.cts +24 -0
  50. package/dist/markup/markup.d.ts +24 -0
  51. package/dist/markup/markup.js +254 -0
  52. package/dist/markup/parse.cjs +55 -0
  53. package/dist/markup/parse.d.cts +17 -0
  54. package/dist/markup/parse.d.ts +17 -0
  55. package/dist/markup/parse.js +43 -0
  56. package/dist/markup/segmentation.cjs +87 -0
  57. package/dist/markup/segmentation.d.cts +8 -0
  58. package/dist/markup/segmentation.d.ts +8 -0
  59. package/dist/markup/segmentation.js +67 -0
  60. package/dist/markup/semantics.cjs +79 -0
  61. package/dist/markup/semantics.d.cts +6 -0
  62. package/dist/markup/semantics.d.ts +6 -0
  63. package/dist/markup/semantics.js +53 -0
  64. package/dist/process/AudioEncoding.cjs +16 -0
  65. package/dist/process/AudioEncoding.d.cts +8 -0
  66. package/dist/process/AudioEncoding.d.ts +8 -0
  67. package/dist/process/AudioEncoding.js +0 -0
  68. package/dist/process/__tests__/processAudiobook.test.cjs +232 -0
  69. package/dist/process/__tests__/processAudiobook.test.d.cts +2 -0
  70. package/dist/process/__tests__/processAudiobook.test.d.ts +2 -0
  71. package/dist/process/__tests__/processAudiobook.test.js +209 -0
  72. package/dist/process/mime.cjs +43 -0
  73. package/dist/process/mime.d.cts +3 -0
  74. package/dist/process/mime.d.ts +3 -0
  75. package/dist/process/mime.js +24 -0
  76. package/dist/process/parse.cjs +84 -0
  77. package/dist/process/parse.d.cts +28 -0
  78. package/dist/process/parse.d.ts +28 -0
  79. package/dist/process/parse.js +73 -0
  80. package/dist/process/processAudiobook.cjs +220 -0
  81. package/dist/process/processAudiobook.d.cts +24 -0
  82. package/dist/process/processAudiobook.d.ts +24 -0
  83. package/dist/process/processAudiobook.js +166 -0
  84. package/dist/process/ranges.cjs +203 -0
  85. package/dist/process/ranges.d.cts +15 -0
  86. package/dist/process/ranges.d.ts +15 -0
  87. package/dist/process/ranges.js +137 -0
  88. package/dist/transcribe/parse.cjs +149 -0
  89. package/dist/transcribe/parse.d.cts +114 -0
  90. package/dist/transcribe/parse.d.ts +114 -0
  91. package/dist/transcribe/parse.js +143 -0
  92. package/dist/transcribe/transcribe.cjs +400 -0
  93. package/dist/transcribe/transcribe.d.cts +41 -0
  94. package/dist/transcribe/transcribe.d.ts +41 -0
  95. package/dist/transcribe/transcribe.js +330 -0
  96. package/package.json +96 -0
@@ -0,0 +1,17 @@
1
+ import * as _optique_core from '@optique/core';
2
+
3
+ declare const markupCommand: _optique_core.Parser<"sync", {
4
+ readonly action: "markup";
5
+ readonly input: string;
6
+ readonly output: string;
7
+ } & {
8
+ readonly granularity: "word" | "sentence";
9
+ } & {
10
+ readonly language: Intl.Locale | undefined;
11
+ } & {
12
+ readonly noProgress: boolean;
13
+ readonly logLevel: "silent" | "debug" | "info" | "warn" | "error";
14
+ readonly time: boolean;
15
+ }, ["matched", string] | ["parsing", Record<string | symbol, unknown>] | undefined>;
16
+
17
+ export { markupCommand };
@@ -0,0 +1,43 @@
1
+ import "../chunk-BIEQXUOY.js";
2
+ import {
3
+ argument,
4
+ command,
5
+ constant,
6
+ merge,
7
+ message,
8
+ object
9
+ } from "@optique/core";
10
+ import { path } from "@optique/run/valueparser";
11
+ import {
12
+ granularityParser,
13
+ languageParser,
14
+ loggingParser
15
+ } from "../common/parse.js";
16
+ const markupCommand = command(
17
+ "markup",
18
+ merge(
19
+ object({
20
+ action: constant("markup"),
21
+ input: argument(
22
+ path({
23
+ mustExist: true,
24
+ type: "file",
25
+ extensions: [".epub"],
26
+ metavar: "INPUT_PATH"
27
+ })
28
+ ),
29
+ output: argument(
30
+ path({ type: "file", extensions: [".epub"], metavar: "OUTPUT_PATH" })
31
+ )
32
+ }),
33
+ granularityParser,
34
+ languageParser,
35
+ loggingParser
36
+ ),
37
+ {
38
+ description: message`Mark up an EPUB file at the provided granularity level`
39
+ }
40
+ );
41
+ export {
42
+ markupCommand
43
+ };
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var segmentation_exports = {};
20
+ __export(segmentation_exports, {
21
+ getXhtmlSegmentation: () => getXhtmlSegmentation
22
+ });
23
+ module.exports = __toCommonJS(segmentation_exports);
24
+ var import_text_segmentation = require("@echogarden/text-segmentation");
25
+ var import_epub = require("@storyteller-platform/epub");
26
+ var import_semantics = require("./semantics.cjs");
27
+ async function getXhtmlSegmentation(xml, options) {
28
+ const result = {
29
+ words: new import_text_segmentation.WordSequence(),
30
+ sentences: [],
31
+ segmentSentenceRanges: []
32
+ };
33
+ let stagedText = "";
34
+ for (const child of xml) {
35
+ if (import_epub.Epub.isXmlTextNode(child)) {
36
+ stagedText += child["#text"];
37
+ continue;
38
+ }
39
+ const childName = import_epub.Epub.getXmlElementName(child);
40
+ if (!import_semantics.BLOCKS.includes(childName)) {
41
+ stagedText += import_epub.Epub.getXhtmlTextContent(import_epub.Epub.getXmlChildren(child));
42
+ continue;
43
+ }
44
+ mergeSegmentations(
45
+ result,
46
+ await (0, import_text_segmentation.segmentText)(collapseWhitespace(stagedText), {
47
+ ...options.primaryLocale && {
48
+ language: options.primaryLocale.language
49
+ },
50
+ enableEastAsianPostprocessing: true
51
+ })
52
+ );
53
+ stagedText = "";
54
+ mergeSegmentations(
55
+ result,
56
+ await getXhtmlSegmentation(import_epub.Epub.getXmlChildren(child), options)
57
+ );
58
+ }
59
+ mergeSegmentations(
60
+ result,
61
+ await (0, import_text_segmentation.segmentText)(collapseWhitespace(stagedText), {
62
+ ...options.primaryLocale && {
63
+ language: options.primaryLocale.language
64
+ },
65
+ enableEastAsianPostprocessing: true
66
+ })
67
+ );
68
+ return result;
69
+ }
70
+ function collapseWhitespace(text) {
71
+ return text.replace(/^\s*/, "").replace(/\s*$/, "").replaceAll(/\s+/g, " ");
72
+ }
73
+ function mergeSegmentations(first, second) {
74
+ for (const wordEntry of second.words.entries) {
75
+ first.words.addWord(
76
+ wordEntry.text,
77
+ wordEntry.startOffset,
78
+ wordEntry.isPunctuation
79
+ );
80
+ }
81
+ first.sentences.push(...second.sentences);
82
+ first.segmentSentenceRanges.push(...second.segmentSentenceRanges);
83
+ }
84
+ // Annotate the CommonJS export names for ESM import in node:
85
+ 0 && (module.exports = {
86
+ getXhtmlSegmentation
87
+ });
@@ -0,0 +1,8 @@
1
+ import { SegmentationResult } from '@echogarden/text-segmentation';
2
+ import { ParsedXml } from '@storyteller-platform/epub';
3
+
4
+ declare function getXhtmlSegmentation(xml: ParsedXml, options: {
5
+ primaryLocale?: Intl.Locale | null;
6
+ }): Promise<SegmentationResult>;
7
+
8
+ export { getXhtmlSegmentation };
@@ -0,0 +1,8 @@
1
+ import { SegmentationResult } from '@echogarden/text-segmentation';
2
+ import { ParsedXml } from '@storyteller-platform/epub';
3
+
4
+ declare function getXhtmlSegmentation(xml: ParsedXml, options: {
5
+ primaryLocale?: Intl.Locale | null;
6
+ }): Promise<SegmentationResult>;
7
+
8
+ export { getXhtmlSegmentation };
@@ -0,0 +1,67 @@
1
+ import "../chunk-BIEQXUOY.js";
2
+ import {
3
+ WordSequence,
4
+ segmentText
5
+ } from "@echogarden/text-segmentation";
6
+ import { Epub } from "@storyteller-platform/epub";
7
+ import { BLOCKS } from "./semantics.js";
8
+ async function getXhtmlSegmentation(xml, options) {
9
+ const result = {
10
+ words: new WordSequence(),
11
+ sentences: [],
12
+ segmentSentenceRanges: []
13
+ };
14
+ let stagedText = "";
15
+ for (const child of xml) {
16
+ if (Epub.isXmlTextNode(child)) {
17
+ stagedText += child["#text"];
18
+ continue;
19
+ }
20
+ const childName = Epub.getXmlElementName(child);
21
+ if (!BLOCKS.includes(childName)) {
22
+ stagedText += Epub.getXhtmlTextContent(Epub.getXmlChildren(child));
23
+ continue;
24
+ }
25
+ mergeSegmentations(
26
+ result,
27
+ await segmentText(collapseWhitespace(stagedText), {
28
+ ...options.primaryLocale && {
29
+ language: options.primaryLocale.language
30
+ },
31
+ enableEastAsianPostprocessing: true
32
+ })
33
+ );
34
+ stagedText = "";
35
+ mergeSegmentations(
36
+ result,
37
+ await getXhtmlSegmentation(Epub.getXmlChildren(child), options)
38
+ );
39
+ }
40
+ mergeSegmentations(
41
+ result,
42
+ await segmentText(collapseWhitespace(stagedText), {
43
+ ...options.primaryLocale && {
44
+ language: options.primaryLocale.language
45
+ },
46
+ enableEastAsianPostprocessing: true
47
+ })
48
+ );
49
+ return result;
50
+ }
51
+ function collapseWhitespace(text) {
52
+ return text.replace(/^\s*/, "").replace(/\s*$/, "").replaceAll(/\s+/g, " ");
53
+ }
54
+ function mergeSegmentations(first, second) {
55
+ for (const wordEntry of second.words.entries) {
56
+ first.words.addWord(
57
+ wordEntry.text,
58
+ wordEntry.startOffset,
59
+ wordEntry.isPunctuation
60
+ );
61
+ }
62
+ first.sentences.push(...second.sentences);
63
+ first.segmentSentenceRanges.push(...second.segmentSentenceRanges);
64
+ }
65
+ export {
66
+ getXhtmlSegmentation
67
+ };
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var semantics_exports = {};
20
+ __export(semantics_exports, {
21
+ BLOCKS: () => BLOCKS,
22
+ CONTENT_SECTIONING: () => CONTENT_SECTIONING,
23
+ TABLE_PARTS: () => TABLE_PARTS,
24
+ TEXT_CONTENT: () => TEXT_CONTENT
25
+ });
26
+ module.exports = __toCommonJS(semantics_exports);
27
+ const CONTENT_SECTIONING = [
28
+ "address",
29
+ "article",
30
+ "aside",
31
+ "footer",
32
+ "header",
33
+ "h1",
34
+ "h2",
35
+ "h3",
36
+ "h4",
37
+ "h5",
38
+ "h6",
39
+ "hgroup",
40
+ "main",
41
+ "nav",
42
+ "section",
43
+ "search"
44
+ ];
45
+ const TEXT_CONTENT = [
46
+ "blockquote",
47
+ "dd",
48
+ "div",
49
+ "dl",
50
+ "dt",
51
+ "figcaption",
52
+ "figure",
53
+ "hr",
54
+ "li",
55
+ "menu",
56
+ "ol",
57
+ "p",
58
+ "pre",
59
+ "ul"
60
+ ];
61
+ const TABLE_PARTS = [
62
+ "table",
63
+ "thead",
64
+ "th",
65
+ "tbody",
66
+ "tr",
67
+ "td",
68
+ "colgroup",
69
+ "caption",
70
+ "tfoot"
71
+ ];
72
+ const BLOCKS = [...TEXT_CONTENT, ...CONTENT_SECTIONING, ...TABLE_PARTS];
73
+ // Annotate the CommonJS export names for ESM import in node:
74
+ 0 && (module.exports = {
75
+ BLOCKS,
76
+ CONTENT_SECTIONING,
77
+ TABLE_PARTS,
78
+ TEXT_CONTENT
79
+ });
@@ -0,0 +1,6 @@
1
+ declare const CONTENT_SECTIONING: string[];
2
+ declare const TEXT_CONTENT: string[];
3
+ declare const TABLE_PARTS: string[];
4
+ declare const BLOCKS: string[];
5
+
6
+ export { BLOCKS, CONTENT_SECTIONING, TABLE_PARTS, TEXT_CONTENT };
@@ -0,0 +1,6 @@
1
+ declare const CONTENT_SECTIONING: string[];
2
+ declare const TEXT_CONTENT: string[];
3
+ declare const TABLE_PARTS: string[];
4
+ declare const BLOCKS: string[];
5
+
6
+ export { BLOCKS, CONTENT_SECTIONING, TABLE_PARTS, TEXT_CONTENT };
@@ -0,0 +1,53 @@
1
+ import "../chunk-BIEQXUOY.js";
2
+ const CONTENT_SECTIONING = [
3
+ "address",
4
+ "article",
5
+ "aside",
6
+ "footer",
7
+ "header",
8
+ "h1",
9
+ "h2",
10
+ "h3",
11
+ "h4",
12
+ "h5",
13
+ "h6",
14
+ "hgroup",
15
+ "main",
16
+ "nav",
17
+ "section",
18
+ "search"
19
+ ];
20
+ const TEXT_CONTENT = [
21
+ "blockquote",
22
+ "dd",
23
+ "div",
24
+ "dl",
25
+ "dt",
26
+ "figcaption",
27
+ "figure",
28
+ "hr",
29
+ "li",
30
+ "menu",
31
+ "ol",
32
+ "p",
33
+ "pre",
34
+ "ul"
35
+ ];
36
+ const TABLE_PARTS = [
37
+ "table",
38
+ "thead",
39
+ "th",
40
+ "tbody",
41
+ "tr",
42
+ "td",
43
+ "colgroup",
44
+ "caption",
45
+ "tfoot"
46
+ ];
47
+ const BLOCKS = [...TEXT_CONTENT, ...CONTENT_SECTIONING, ...TABLE_PARTS];
48
+ export {
49
+ BLOCKS,
50
+ CONTENT_SECTIONING,
51
+ TABLE_PARTS,
52
+ TEXT_CONTENT
53
+ };
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+ var AudioEncoding_exports = {};
16
+ module.exports = __toCommonJS(AudioEncoding_exports);
@@ -0,0 +1,8 @@
1
+ type AudioCodec = string;
2
+ type Bitrate = string;
3
+ interface AudioEncoding {
4
+ codec?: AudioCodec | null | undefined;
5
+ bitrate?: Bitrate | null | undefined;
6
+ }
7
+
8
+ export type { AudioCodec, AudioEncoding, Bitrate };
@@ -0,0 +1,8 @@
1
+ type AudioCodec = string;
2
+ type Bitrate = string;
3
+ interface AudioEncoding {
4
+ codec?: AudioCodec | null | undefined;
5
+ bitrate?: Bitrate | null | undefined;
6
+ }
7
+
8
+ export type { AudioCodec, AudioEncoding, Bitrate };
File without changes
@@ -0,0 +1,232 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") {
10
+ for (let key of __getOwnPropNames(from))
11
+ if (!__hasOwnProp.call(to, key) && key !== except)
12
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
+ }
14
+ return to;
15
+ };
16
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
17
+ // If the importer is in node compatibility mode or this is not an ESM
18
+ // file that has been converted to a CommonJS file using a Babel-
19
+ // compatible transform (i.e. "__esModule" has not been set), then set
20
+ // "default" to the CommonJS "module.exports" for node compatibility.
21
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
+ mod
23
+ ));
24
+ var import_node_assert = __toESM(require("node:assert"), 1);
25
+ var import_node_crypto = require("node:crypto");
26
+ var import_promises = require("node:fs/promises");
27
+ var import_node_os = require("node:os");
28
+ var import_node_path = require("node:path");
29
+ var import_node_test = require("node:test");
30
+ var import_async_semaphore = require("@esfx/async-semaphore");
31
+ var import_logging = require("../../common/logging.cjs");
32
+ var import_processAudiobook = require("../processAudiobook.cjs");
33
+ function createTestLogger() {
34
+ return (0, import_logging.createLogger)(process.env["CI"] ? "silent" : "info");
35
+ }
36
+ void (0, import_node_test.describe)("processFile", () => {
37
+ void (0, import_node_test.it)("can process mpeg4 files", async () => {
38
+ const input = (0, import_node_path.join)(
39
+ "src",
40
+ "__fixtures__",
41
+ "mpeg4",
42
+ "MobyDickOrTheWhalePart1_librivox.m4b"
43
+ );
44
+ const outDir = (0, import_node_path.join)("src", "__fixtures__", "__output__", (0, import_node_crypto.randomUUID)());
45
+ await (0, import_promises.mkdir)(outDir, { recursive: true });
46
+ await (0, import_processAudiobook.processFile)(input, outDir, "00000-", {
47
+ lock: new import_async_semaphore.AsyncSemaphore((0, import_node_os.availableParallelism)() - 1),
48
+ logger: createTestLogger()
49
+ });
50
+ const outFiles = await (0, import_promises.readdir)(outDir);
51
+ import_node_assert.default.deepStrictEqual(outFiles, [
52
+ "00000-00001.mp4",
53
+ "00000-00002.mp4",
54
+ "00000-00003.mp4",
55
+ "00000-00004.mp4",
56
+ "00000-00005.mp4",
57
+ "00000-00006.mp4",
58
+ "00000-00007.mp4",
59
+ "00000-00008.mp4",
60
+ "00000-00009.mp4",
61
+ "00000-00010.mp4",
62
+ "00000-00011.mp4"
63
+ ]);
64
+ });
65
+ void (0, import_node_test.it)("can process mp3 files", async () => {
66
+ const input = (0, import_node_path.join)(
67
+ "src",
68
+ "__fixtures__",
69
+ "mp3",
70
+ "MobyDickOrTheWhalePart1_librivox.mp3"
71
+ );
72
+ const outDir = (0, import_node_path.join)("src", "__fixtures__", "__output__", (0, import_node_crypto.randomUUID)());
73
+ await (0, import_promises.mkdir)(outDir, { recursive: true });
74
+ await (0, import_processAudiobook.processFile)(input, outDir, "00000-", {
75
+ lock: new import_async_semaphore.AsyncSemaphore((0, import_node_os.availableParallelism)() - 1),
76
+ logger: createTestLogger()
77
+ });
78
+ const outFiles = await (0, import_promises.readdir)(outDir);
79
+ import_node_assert.default.deepStrictEqual(outFiles, [
80
+ "00000-00001.mp3",
81
+ "00000-00002.mp3",
82
+ "00000-00003.mp3",
83
+ "00000-00004.mp3",
84
+ "00000-00005.mp3",
85
+ "00000-00006.mp3",
86
+ "00000-00007.mp3",
87
+ "00000-00008.mp3",
88
+ "00000-00009.mp3",
89
+ "00000-00010.mp3",
90
+ "00000-00011.mp3"
91
+ ]);
92
+ });
93
+ void (0, import_node_test.it)("can process opus files", async () => {
94
+ const input = (0, import_node_path.join)(
95
+ "src",
96
+ "__fixtures__",
97
+ "opus",
98
+ "MobyDickOrTheWhalePart1_librivox.opus"
99
+ );
100
+ const outDir = (0, import_node_path.join)("src", "__fixtures__", "__output__", (0, import_node_crypto.randomUUID)());
101
+ await (0, import_promises.mkdir)(outDir, { recursive: true });
102
+ await (0, import_processAudiobook.processFile)(input, outDir, "00000-", {
103
+ lock: new import_async_semaphore.AsyncSemaphore((0, import_node_os.availableParallelism)() - 1),
104
+ logger: createTestLogger()
105
+ });
106
+ const outFiles = await (0, import_promises.readdir)(outDir);
107
+ import_node_assert.default.deepStrictEqual(outFiles, [
108
+ "00000-00001.mp4",
109
+ "00000-00002.mp4",
110
+ "00000-00003.mp4",
111
+ "00000-00004.mp4",
112
+ "00000-00005.mp4",
113
+ "00000-00006.mp4",
114
+ "00000-00007.mp4",
115
+ "00000-00008.mp4",
116
+ "00000-00009.mp4",
117
+ "00000-00010.mp4",
118
+ "00000-00011.mp4"
119
+ ]);
120
+ });
121
+ void (0, import_node_test.it)("can handle nonstandard audio file", async () => {
122
+ const input = (0, import_node_path.join)("src", "__fixtures__", "flac", "mobydick.flac");
123
+ const outDir = (0, import_node_path.join)("src", "__fixtures__", "__output__", (0, import_node_crypto.randomUUID)());
124
+ await (0, import_promises.mkdir)(outDir, { recursive: true });
125
+ await (0, import_processAudiobook.processFile)(input, outDir, "00000-", {
126
+ lock: new import_async_semaphore.AsyncSemaphore((0, import_node_os.availableParallelism)() - 1),
127
+ logger: createTestLogger()
128
+ });
129
+ const outFiles = await (0, import_promises.readdir)(outDir);
130
+ import_node_assert.default.deepStrictEqual(outFiles, ["00000-00001.flac"]);
131
+ });
132
+ void (0, import_node_test.it)("can transcode nonstandard audio file", async () => {
133
+ const input = (0, import_node_path.join)("src", "__fixtures__", "flac", "mobydick.flac");
134
+ const outDir = (0, import_node_path.join)("src", "__fixtures__", "__output__", (0, import_node_crypto.randomUUID)());
135
+ await (0, import_promises.mkdir)(outDir, { recursive: true });
136
+ await (0, import_processAudiobook.processFile)(input, outDir, "00000-", {
137
+ encoding: { codec: "libopus" },
138
+ lock: new import_async_semaphore.AsyncSemaphore((0, import_node_os.availableParallelism)() - 1),
139
+ logger: createTestLogger()
140
+ });
141
+ const outFiles = await (0, import_promises.readdir)(outDir);
142
+ import_node_assert.default.deepStrictEqual(outFiles, ["00000-00001.mp4"]);
143
+ });
144
+ void (0, import_node_test.it)("can process zip files", async () => {
145
+ const input = (0, import_node_path.join)("src", "__fixtures__", "zip", "moby-dick-1-7-audio.zip");
146
+ const outDir = (0, import_node_path.join)("src", "__fixtures__", "__output__", (0, import_node_crypto.randomUUID)());
147
+ await (0, import_promises.mkdir)(outDir, { recursive: true });
148
+ await (0, import_processAudiobook.processFile)(input, outDir, "00000-", {
149
+ lock: new import_async_semaphore.AsyncSemaphore((0, import_node_os.availableParallelism)() - 1),
150
+ logger: createTestLogger()
151
+ });
152
+ const outFiles = await (0, import_promises.readdir)(outDir);
153
+ import_node_assert.default.deepStrictEqual(outFiles, [
154
+ "00000-00001.mp3",
155
+ "00000-00002.mp3",
156
+ "00000-00003.mp3"
157
+ ]);
158
+ });
159
+ void (0, import_node_test.it)("splits files longer than the max length", async () => {
160
+ const input = (0, import_node_path.join)("src", "__fixtures__", "zip", "moby-dick-1-7-audio.zip");
161
+ const outDir = (0, import_node_path.join)("src", "__fixtures__", "__output__", (0, import_node_crypto.randomUUID)());
162
+ await (0, import_promises.mkdir)(outDir, { recursive: true });
163
+ await (0, import_processAudiobook.processFile)(input, outDir, "00000-", {
164
+ maxLength: 0.1,
165
+ lock: new import_async_semaphore.AsyncSemaphore((0, import_node_os.availableParallelism)() - 1),
166
+ logger: createTestLogger()
167
+ });
168
+ const outFiles = await (0, import_promises.readdir)(outDir);
169
+ import_node_assert.default.deepStrictEqual(outFiles, [
170
+ "00000-00001.mp3",
171
+ "00000-00002.mp3",
172
+ "00000-00003.mp3",
173
+ "00000-00004.mp3",
174
+ "00000-00005.mp3",
175
+ "00000-00006.mp3",
176
+ "00000-00007.mp3",
177
+ "00000-00008.mp3",
178
+ "00000-00009.mp3",
179
+ "00000-00010.mp3",
180
+ "00000-00011.mp3",
181
+ "00000-00012.mp3",
182
+ "00000-00013.mp3",
183
+ "00000-00014.mp3",
184
+ "00000-00015.mp3",
185
+ "00000-00016.mp3",
186
+ "00000-00017.mp3"
187
+ ]);
188
+ });
189
+ void (0, import_node_test.it)("splits files longer than the max length, even if they have chapters", async () => {
190
+ const input = (0, import_node_path.join)(
191
+ "src",
192
+ "__fixtures__",
193
+ "mpeg4",
194
+ "MobyDickOrTheWhalePart1_librivox.m4b"
195
+ );
196
+ const outDir = (0, import_node_path.join)("src", "__fixtures__", "__output__", (0, import_node_crypto.randomUUID)());
197
+ await (0, import_promises.mkdir)(outDir, { recursive: true });
198
+ await (0, import_processAudiobook.processFile)(input, outDir, "00000-", {
199
+ maxLength: 0.25,
200
+ lock: new import_async_semaphore.AsyncSemaphore((0, import_node_os.availableParallelism)() - 1),
201
+ logger: createTestLogger()
202
+ });
203
+ const outFiles = await (0, import_promises.readdir)(outDir);
204
+ import_node_assert.default.deepStrictEqual(outFiles, [
205
+ "00000-00001.mp4",
206
+ "00000-00002.mp4",
207
+ "00000-00003.mp4",
208
+ "00000-00004.mp4",
209
+ "00000-00005.mp4",
210
+ "00000-00006.mp4",
211
+ "00000-00007.mp4",
212
+ "00000-00008.mp4",
213
+ "00000-00009.mp4",
214
+ "00000-00010.mp4",
215
+ "00000-00011.mp4",
216
+ "00000-00012.mp4",
217
+ "00000-00013.mp4",
218
+ "00000-00014.mp4",
219
+ "00000-00015.mp4",
220
+ "00000-00016.mp4",
221
+ "00000-00017.mp4",
222
+ "00000-00018.mp4",
223
+ "00000-00019.mp4",
224
+ "00000-00020.mp4",
225
+ "00000-00021.mp4",
226
+ "00000-00022.mp4",
227
+ "00000-00023.mp4",
228
+ "00000-00024.mp4",
229
+ "00000-00025.mp4"
230
+ ]);
231
+ });
232
+ });
@@ -0,0 +1,2 @@
1
+
2
+ export { }
@@ -0,0 +1,2 @@
1
+
2
+ export { }