@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.
- package/LICENSE.txt +21 -0
- package/README.md +3 -0
- package/dist/align/align.cjs +525 -0
- package/dist/align/align.d.cts +58 -0
- package/dist/align/align.d.ts +58 -0
- package/dist/align/align.js +458 -0
- package/dist/align/fuzzy.cjs +164 -0
- package/dist/align/fuzzy.d.cts +6 -0
- package/dist/align/fuzzy.d.ts +6 -0
- package/dist/align/fuzzy.js +141 -0
- package/dist/align/getSentenceRanges.cjs +304 -0
- package/dist/align/getSentenceRanges.d.cts +31 -0
- package/dist/align/getSentenceRanges.d.ts +31 -0
- package/dist/align/getSentenceRanges.js +277 -0
- package/dist/align/parse.cjs +63 -0
- package/dist/align/parse.d.cts +30 -0
- package/dist/align/parse.d.ts +30 -0
- package/dist/align/parse.js +51 -0
- package/dist/chunk-BIEQXUOY.js +50 -0
- package/dist/cli/bin.cjs +368 -0
- package/dist/cli/bin.d.cts +1 -0
- package/dist/cli/bin.d.ts +1 -0
- package/dist/cli/bin.js +319 -0
- package/dist/common/ffmpeg.cjs +232 -0
- package/dist/common/ffmpeg.d.cts +33 -0
- package/dist/common/ffmpeg.d.ts +33 -0
- package/dist/common/ffmpeg.js +196 -0
- package/dist/common/logging.cjs +45 -0
- package/dist/common/logging.d.cts +5 -0
- package/dist/common/logging.d.ts +5 -0
- package/dist/common/logging.js +12 -0
- package/dist/common/parse.cjs +73 -0
- package/dist/common/parse.d.cts +28 -0
- package/dist/common/parse.d.ts +28 -0
- package/dist/common/parse.js +56 -0
- package/dist/common/shell.cjs +30 -0
- package/dist/common/shell.d.cts +3 -0
- package/dist/common/shell.d.ts +3 -0
- package/dist/common/shell.js +7 -0
- package/dist/index.cjs +37 -0
- package/dist/index.d.cts +12 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +11 -0
- package/dist/markup/__tests__/markup.test.cjs +464 -0
- package/dist/markup/__tests__/markup.test.d.cts +2 -0
- package/dist/markup/__tests__/markup.test.d.ts +2 -0
- package/dist/markup/__tests__/markup.test.js +441 -0
- package/dist/markup/markup.cjs +316 -0
- package/dist/markup/markup.d.cts +24 -0
- package/dist/markup/markup.d.ts +24 -0
- package/dist/markup/markup.js +254 -0
- package/dist/markup/parse.cjs +55 -0
- package/dist/markup/parse.d.cts +17 -0
- package/dist/markup/parse.d.ts +17 -0
- package/dist/markup/parse.js +43 -0
- package/dist/markup/segmentation.cjs +87 -0
- package/dist/markup/segmentation.d.cts +8 -0
- package/dist/markup/segmentation.d.ts +8 -0
- package/dist/markup/segmentation.js +67 -0
- package/dist/markup/semantics.cjs +79 -0
- package/dist/markup/semantics.d.cts +6 -0
- package/dist/markup/semantics.d.ts +6 -0
- package/dist/markup/semantics.js +53 -0
- package/dist/process/AudioEncoding.cjs +16 -0
- package/dist/process/AudioEncoding.d.cts +8 -0
- package/dist/process/AudioEncoding.d.ts +8 -0
- package/dist/process/AudioEncoding.js +0 -0
- package/dist/process/__tests__/processAudiobook.test.cjs +232 -0
- package/dist/process/__tests__/processAudiobook.test.d.cts +2 -0
- package/dist/process/__tests__/processAudiobook.test.d.ts +2 -0
- package/dist/process/__tests__/processAudiobook.test.js +209 -0
- package/dist/process/mime.cjs +43 -0
- package/dist/process/mime.d.cts +3 -0
- package/dist/process/mime.d.ts +3 -0
- package/dist/process/mime.js +24 -0
- package/dist/process/parse.cjs +84 -0
- package/dist/process/parse.d.cts +28 -0
- package/dist/process/parse.d.ts +28 -0
- package/dist/process/parse.js +73 -0
- package/dist/process/processAudiobook.cjs +220 -0
- package/dist/process/processAudiobook.d.cts +24 -0
- package/dist/process/processAudiobook.d.ts +24 -0
- package/dist/process/processAudiobook.js +166 -0
- package/dist/process/ranges.cjs +203 -0
- package/dist/process/ranges.d.cts +15 -0
- package/dist/process/ranges.d.ts +15 -0
- package/dist/process/ranges.js +137 -0
- package/dist/transcribe/parse.cjs +149 -0
- package/dist/transcribe/parse.d.cts +114 -0
- package/dist/transcribe/parse.d.ts +114 -0
- package/dist/transcribe/parse.js +143 -0
- package/dist/transcribe/transcribe.cjs +400 -0
- package/dist/transcribe/transcribe.d.cts +41 -0
- package/dist/transcribe/transcribe.d.ts +41 -0
- package/dist/transcribe/transcribe.js +330 -0
- 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,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);
|
|
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
|
+
});
|