@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,209 @@
1
+ import assert from "node:assert";
2
+ import { randomUUID } from "node:crypto";
3
+ import { mkdir, readdir } from "node:fs/promises";
4
+ import { availableParallelism } from "node:os";
5
+ import { join } from "node:path";
6
+ import { describe, it } from "node:test";
7
+ import { AsyncSemaphore } from "@esfx/async-semaphore";
8
+ import { createLogger } from "../../common/logging.js";
9
+ import { processFile } from "../processAudiobook.js";
10
+ function createTestLogger() {
11
+ return createLogger(process.env["CI"] ? "silent" : "info");
12
+ }
13
+ void describe("processFile", () => {
14
+ void it("can process mpeg4 files", async () => {
15
+ const input = join(
16
+ "src",
17
+ "__fixtures__",
18
+ "mpeg4",
19
+ "MobyDickOrTheWhalePart1_librivox.m4b"
20
+ );
21
+ const outDir = join("src", "__fixtures__", "__output__", randomUUID());
22
+ await mkdir(outDir, { recursive: true });
23
+ await processFile(input, outDir, "00000-", {
24
+ lock: new AsyncSemaphore(availableParallelism() - 1),
25
+ logger: createTestLogger()
26
+ });
27
+ const outFiles = await readdir(outDir);
28
+ assert.deepStrictEqual(outFiles, [
29
+ "00000-00001.mp4",
30
+ "00000-00002.mp4",
31
+ "00000-00003.mp4",
32
+ "00000-00004.mp4",
33
+ "00000-00005.mp4",
34
+ "00000-00006.mp4",
35
+ "00000-00007.mp4",
36
+ "00000-00008.mp4",
37
+ "00000-00009.mp4",
38
+ "00000-00010.mp4",
39
+ "00000-00011.mp4"
40
+ ]);
41
+ });
42
+ void it("can process mp3 files", async () => {
43
+ const input = join(
44
+ "src",
45
+ "__fixtures__",
46
+ "mp3",
47
+ "MobyDickOrTheWhalePart1_librivox.mp3"
48
+ );
49
+ const outDir = join("src", "__fixtures__", "__output__", randomUUID());
50
+ await mkdir(outDir, { recursive: true });
51
+ await processFile(input, outDir, "00000-", {
52
+ lock: new AsyncSemaphore(availableParallelism() - 1),
53
+ logger: createTestLogger()
54
+ });
55
+ const outFiles = await readdir(outDir);
56
+ assert.deepStrictEqual(outFiles, [
57
+ "00000-00001.mp3",
58
+ "00000-00002.mp3",
59
+ "00000-00003.mp3",
60
+ "00000-00004.mp3",
61
+ "00000-00005.mp3",
62
+ "00000-00006.mp3",
63
+ "00000-00007.mp3",
64
+ "00000-00008.mp3",
65
+ "00000-00009.mp3",
66
+ "00000-00010.mp3",
67
+ "00000-00011.mp3"
68
+ ]);
69
+ });
70
+ void it("can process opus files", async () => {
71
+ const input = join(
72
+ "src",
73
+ "__fixtures__",
74
+ "opus",
75
+ "MobyDickOrTheWhalePart1_librivox.opus"
76
+ );
77
+ const outDir = join("src", "__fixtures__", "__output__", randomUUID());
78
+ await mkdir(outDir, { recursive: true });
79
+ await processFile(input, outDir, "00000-", {
80
+ lock: new AsyncSemaphore(availableParallelism() - 1),
81
+ logger: createTestLogger()
82
+ });
83
+ const outFiles = await readdir(outDir);
84
+ assert.deepStrictEqual(outFiles, [
85
+ "00000-00001.mp4",
86
+ "00000-00002.mp4",
87
+ "00000-00003.mp4",
88
+ "00000-00004.mp4",
89
+ "00000-00005.mp4",
90
+ "00000-00006.mp4",
91
+ "00000-00007.mp4",
92
+ "00000-00008.mp4",
93
+ "00000-00009.mp4",
94
+ "00000-00010.mp4",
95
+ "00000-00011.mp4"
96
+ ]);
97
+ });
98
+ void it("can handle nonstandard audio file", async () => {
99
+ const input = join("src", "__fixtures__", "flac", "mobydick.flac");
100
+ const outDir = join("src", "__fixtures__", "__output__", randomUUID());
101
+ await mkdir(outDir, { recursive: true });
102
+ await processFile(input, outDir, "00000-", {
103
+ lock: new AsyncSemaphore(availableParallelism() - 1),
104
+ logger: createTestLogger()
105
+ });
106
+ const outFiles = await readdir(outDir);
107
+ assert.deepStrictEqual(outFiles, ["00000-00001.flac"]);
108
+ });
109
+ void it("can transcode nonstandard audio file", async () => {
110
+ const input = join("src", "__fixtures__", "flac", "mobydick.flac");
111
+ const outDir = join("src", "__fixtures__", "__output__", randomUUID());
112
+ await mkdir(outDir, { recursive: true });
113
+ await processFile(input, outDir, "00000-", {
114
+ encoding: { codec: "libopus" },
115
+ lock: new AsyncSemaphore(availableParallelism() - 1),
116
+ logger: createTestLogger()
117
+ });
118
+ const outFiles = await readdir(outDir);
119
+ assert.deepStrictEqual(outFiles, ["00000-00001.mp4"]);
120
+ });
121
+ void it("can process zip files", async () => {
122
+ const input = join("src", "__fixtures__", "zip", "moby-dick-1-7-audio.zip");
123
+ const outDir = join("src", "__fixtures__", "__output__", randomUUID());
124
+ await mkdir(outDir, { recursive: true });
125
+ await processFile(input, outDir, "00000-", {
126
+ lock: new AsyncSemaphore(availableParallelism() - 1),
127
+ logger: createTestLogger()
128
+ });
129
+ const outFiles = await readdir(outDir);
130
+ assert.deepStrictEqual(outFiles, [
131
+ "00000-00001.mp3",
132
+ "00000-00002.mp3",
133
+ "00000-00003.mp3"
134
+ ]);
135
+ });
136
+ void it("splits files longer than the max length", async () => {
137
+ const input = join("src", "__fixtures__", "zip", "moby-dick-1-7-audio.zip");
138
+ const outDir = join("src", "__fixtures__", "__output__", randomUUID());
139
+ await mkdir(outDir, { recursive: true });
140
+ await processFile(input, outDir, "00000-", {
141
+ maxLength: 0.1,
142
+ lock: new AsyncSemaphore(availableParallelism() - 1),
143
+ logger: createTestLogger()
144
+ });
145
+ const outFiles = await readdir(outDir);
146
+ assert.deepStrictEqual(outFiles, [
147
+ "00000-00001.mp3",
148
+ "00000-00002.mp3",
149
+ "00000-00003.mp3",
150
+ "00000-00004.mp3",
151
+ "00000-00005.mp3",
152
+ "00000-00006.mp3",
153
+ "00000-00007.mp3",
154
+ "00000-00008.mp3",
155
+ "00000-00009.mp3",
156
+ "00000-00010.mp3",
157
+ "00000-00011.mp3",
158
+ "00000-00012.mp3",
159
+ "00000-00013.mp3",
160
+ "00000-00014.mp3",
161
+ "00000-00015.mp3",
162
+ "00000-00016.mp3",
163
+ "00000-00017.mp3"
164
+ ]);
165
+ });
166
+ void it("splits files longer than the max length, even if they have chapters", async () => {
167
+ const input = join(
168
+ "src",
169
+ "__fixtures__",
170
+ "mpeg4",
171
+ "MobyDickOrTheWhalePart1_librivox.m4b"
172
+ );
173
+ const outDir = join("src", "__fixtures__", "__output__", randomUUID());
174
+ await mkdir(outDir, { recursive: true });
175
+ await processFile(input, outDir, "00000-", {
176
+ maxLength: 0.25,
177
+ lock: new AsyncSemaphore(availableParallelism() - 1),
178
+ logger: createTestLogger()
179
+ });
180
+ const outFiles = await readdir(outDir);
181
+ assert.deepStrictEqual(outFiles, [
182
+ "00000-00001.mp4",
183
+ "00000-00002.mp4",
184
+ "00000-00003.mp4",
185
+ "00000-00004.mp4",
186
+ "00000-00005.mp4",
187
+ "00000-00006.mp4",
188
+ "00000-00007.mp4",
189
+ "00000-00008.mp4",
190
+ "00000-00009.mp4",
191
+ "00000-00010.mp4",
192
+ "00000-00011.mp4",
193
+ "00000-00012.mp4",
194
+ "00000-00013.mp4",
195
+ "00000-00014.mp4",
196
+ "00000-00015.mp4",
197
+ "00000-00016.mp4",
198
+ "00000-00017.mp4",
199
+ "00000-00018.mp4",
200
+ "00000-00019.mp4",
201
+ "00000-00020.mp4",
202
+ "00000-00021.mp4",
203
+ "00000-00022.mp4",
204
+ "00000-00023.mp4",
205
+ "00000-00024.mp4",
206
+ "00000-00025.mp4"
207
+ ]);
208
+ });
209
+ });
@@ -0,0 +1,43 @@
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 mime_exports = {};
20
+ __export(mime_exports, {
21
+ areSameType: () => areSameType
22
+ });
23
+ module.exports = __toCommonJS(mime_exports);
24
+ var import_audiobook = require("@storyteller-platform/audiobook");
25
+ function areSameType(filepathA, filepathB) {
26
+ if (filepathA === filepathB) {
27
+ return true;
28
+ }
29
+ if (import_audiobook.MPEG4_FILE_EXTENSIONS.some((ext) => filepathA.endsWith(ext)) && import_audiobook.MPEG4_FILE_EXTENSIONS.some((ext) => filepathB.endsWith(ext))) {
30
+ return true;
31
+ }
32
+ if (import_audiobook.MP3_FILE_EXTENSIONS.some((ext) => filepathA.endsWith(ext)) && import_audiobook.MP3_FILE_EXTENSIONS.some((ext) => filepathB.endsWith(ext))) {
33
+ return true;
34
+ }
35
+ if (import_audiobook.OPUS_FILE_EXTENSIONS.some((ext) => filepathA.endsWith(ext)) && import_audiobook.OPUS_FILE_EXTENSIONS.some((ext) => filepathB.endsWith(ext))) {
36
+ return true;
37
+ }
38
+ return false;
39
+ }
40
+ // Annotate the CommonJS export names for ESM import in node:
41
+ 0 && (module.exports = {
42
+ areSameType
43
+ });
@@ -0,0 +1,3 @@
1
+ declare function areSameType(filepathA: string, filepathB: string): boolean;
2
+
3
+ export { areSameType };
@@ -0,0 +1,3 @@
1
+ declare function areSameType(filepathA: string, filepathB: string): boolean;
2
+
3
+ export { areSameType };
@@ -0,0 +1,24 @@
1
+ import "../chunk-BIEQXUOY.js";
2
+ import {
3
+ MP3_FILE_EXTENSIONS,
4
+ MPEG4_FILE_EXTENSIONS,
5
+ OPUS_FILE_EXTENSIONS
6
+ } from "@storyteller-platform/audiobook";
7
+ function areSameType(filepathA, filepathB) {
8
+ if (filepathA === filepathB) {
9
+ return true;
10
+ }
11
+ if (MPEG4_FILE_EXTENSIONS.some((ext) => filepathA.endsWith(ext)) && MPEG4_FILE_EXTENSIONS.some((ext) => filepathB.endsWith(ext))) {
12
+ return true;
13
+ }
14
+ if (MP3_FILE_EXTENSIONS.some((ext) => filepathA.endsWith(ext)) && MP3_FILE_EXTENSIONS.some((ext) => filepathB.endsWith(ext))) {
15
+ return true;
16
+ }
17
+ if (OPUS_FILE_EXTENSIONS.some((ext) => filepathA.endsWith(ext)) && OPUS_FILE_EXTENSIONS.some((ext) => filepathB.endsWith(ext))) {
18
+ return true;
19
+ }
20
+ return false;
21
+ }
22
+ export {
23
+ areSameType
24
+ };
@@ -0,0 +1,84 @@
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 parse_exports = {};
20
+ __export(parse_exports, {
21
+ processCommand: () => processCommand,
22
+ processParser: () => processParser
23
+ });
24
+ module.exports = __toCommonJS(parse_exports);
25
+ var import_core = require("@optique/core");
26
+ var import_valueparser = require("@optique/run/valueparser");
27
+ var import_parse = require("../common/parse.cjs");
28
+ const codecParser = (0, import_core.dependency)((0, import_core.choice)(["libopus", "lipmp3lame", "aac", "copy"]));
29
+ const bitrateParser = codecParser.derive({
30
+ metavar: "BITRATE",
31
+ factory: (codec) => {
32
+ switch (codec) {
33
+ case "libopus": {
34
+ return (0, import_core.choice)(["16K", "32K", "64K", "96K"]);
35
+ }
36
+ case "lipmp3lame": {
37
+ return (0, import_core.choice)(["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]);
38
+ }
39
+ default:
40
+ return (0, import_core.choice)([]);
41
+ }
42
+ },
43
+ defaultValue: () => "copy"
44
+ });
45
+ const processParser = (0, import_core.object)("Audio processing", {
46
+ codec: (0, import_core.withDefault)(
47
+ (0, import_core.option)("--codec", codecParser, {
48
+ description: import_core.message`The audio codec to transcode to. If unspecified, will copy audio data without transcoding.`
49
+ }),
50
+ "copy"
51
+ ),
52
+ bitrate: (0, import_core.optional)(
53
+ (0, import_core.option)("--bitrate", bitrateParser, {
54
+ description: import_core.message`The audio bitrate to transcode to ()`
55
+ })
56
+ ),
57
+ maxLength: (0, import_core.withDefault)(
58
+ (0, import_core.option)("--max-length", (0, import_core.integer)(), {
59
+ description: import_core.message`The maximum allowed length of a processed audio track, in minutes`
60
+ }),
61
+ 120
62
+ )
63
+ });
64
+ const processCommand = (0, import_core.command)(
65
+ "process",
66
+ (0, import_core.merge)(
67
+ (0, import_core.object)({
68
+ action: (0, import_core.constant)("process"),
69
+ input: (0, import_core.argument)(
70
+ (0, import_valueparser.path)({ type: "directory", mustExist: true, metavar: "INPUT" })
71
+ ),
72
+ output: (0, import_core.argument)((0, import_valueparser.path)({ metavar: "OUTPUT", type: "directory" }))
73
+ }),
74
+ import_parse.parallelismParser,
75
+ processParser,
76
+ import_parse.loggingParser
77
+ ),
78
+ { description: import_core.message`Process audiobook files for transcription.` }
79
+ );
80
+ // Annotate the CommonJS export names for ESM import in node:
81
+ 0 && (module.exports = {
82
+ processCommand,
83
+ processParser
84
+ });
@@ -0,0 +1,28 @@
1
+ import * as _optique_core from '@optique/core';
2
+
3
+ declare const processParser: _optique_core.Parser<"sync", {
4
+ readonly codec: "libopus" | "lipmp3lame" | "aac" | "copy";
5
+ readonly bitrate: "0" | "1" | "2" | "3" | "16K" | "32K" | "64K" | "96K" | "4" | "5" | "6" | "7" | "8" | "9" | undefined;
6
+ readonly maxLength: number;
7
+ }, {
8
+ readonly codec: [_optique_core.ValueParserResult<"libopus" | "lipmp3lame" | "aac" | "copy"> | undefined] | undefined;
9
+ readonly bitrate: [_optique_core.ValueParserResult<"0" | "1" | "2" | "3" | "16K" | "32K" | "64K" | "96K" | "4" | "5" | "6" | "7" | "8" | "9"> | undefined] | undefined;
10
+ readonly maxLength: [_optique_core.ValueParserResult<number> | undefined] | undefined;
11
+ }>;
12
+ declare const processCommand: _optique_core.Parser<"sync", {
13
+ readonly action: "process";
14
+ readonly input: string;
15
+ readonly output: string;
16
+ } & {
17
+ readonly parallelism: number;
18
+ } & {
19
+ readonly codec: "libopus" | "lipmp3lame" | "aac" | "copy";
20
+ readonly bitrate: "0" | "1" | "2" | "3" | "16K" | "32K" | "64K" | "96K" | "4" | "5" | "6" | "7" | "8" | "9" | undefined;
21
+ readonly maxLength: number;
22
+ } & {
23
+ readonly noProgress: boolean;
24
+ readonly logLevel: "silent" | "debug" | "info" | "warn" | "error";
25
+ readonly time: boolean;
26
+ }, ["matched", string] | ["parsing", Record<string | symbol, unknown>] | undefined>;
27
+
28
+ export { processCommand, processParser };
@@ -0,0 +1,28 @@
1
+ import * as _optique_core from '@optique/core';
2
+
3
+ declare const processParser: _optique_core.Parser<"sync", {
4
+ readonly codec: "libopus" | "lipmp3lame" | "aac" | "copy";
5
+ readonly bitrate: "0" | "1" | "2" | "3" | "16K" | "32K" | "64K" | "96K" | "4" | "5" | "6" | "7" | "8" | "9" | undefined;
6
+ readonly maxLength: number;
7
+ }, {
8
+ readonly codec: [_optique_core.ValueParserResult<"libopus" | "lipmp3lame" | "aac" | "copy"> | undefined] | undefined;
9
+ readonly bitrate: [_optique_core.ValueParserResult<"0" | "1" | "2" | "3" | "16K" | "32K" | "64K" | "96K" | "4" | "5" | "6" | "7" | "8" | "9"> | undefined] | undefined;
10
+ readonly maxLength: [_optique_core.ValueParserResult<number> | undefined] | undefined;
11
+ }>;
12
+ declare const processCommand: _optique_core.Parser<"sync", {
13
+ readonly action: "process";
14
+ readonly input: string;
15
+ readonly output: string;
16
+ } & {
17
+ readonly parallelism: number;
18
+ } & {
19
+ readonly codec: "libopus" | "lipmp3lame" | "aac" | "copy";
20
+ readonly bitrate: "0" | "1" | "2" | "3" | "16K" | "32K" | "64K" | "96K" | "4" | "5" | "6" | "7" | "8" | "9" | undefined;
21
+ readonly maxLength: number;
22
+ } & {
23
+ readonly noProgress: boolean;
24
+ readonly logLevel: "silent" | "debug" | "info" | "warn" | "error";
25
+ readonly time: boolean;
26
+ }, ["matched", string] | ["parsing", Record<string | symbol, unknown>] | undefined>;
27
+
28
+ export { processCommand, processParser };
@@ -0,0 +1,73 @@
1
+ import "../chunk-BIEQXUOY.js";
2
+ import {
3
+ argument,
4
+ choice,
5
+ command,
6
+ constant,
7
+ dependency,
8
+ integer,
9
+ merge,
10
+ message,
11
+ object,
12
+ option,
13
+ optional,
14
+ withDefault
15
+ } from "@optique/core";
16
+ import { path } from "@optique/run/valueparser";
17
+ import { loggingParser, parallelismParser } from "../common/parse.js";
18
+ const codecParser = dependency(choice(["libopus", "lipmp3lame", "aac", "copy"]));
19
+ const bitrateParser = codecParser.derive({
20
+ metavar: "BITRATE",
21
+ factory: (codec) => {
22
+ switch (codec) {
23
+ case "libopus": {
24
+ return choice(["16K", "32K", "64K", "96K"]);
25
+ }
26
+ case "lipmp3lame": {
27
+ return choice(["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]);
28
+ }
29
+ default:
30
+ return choice([]);
31
+ }
32
+ },
33
+ defaultValue: () => "copy"
34
+ });
35
+ const processParser = object("Audio processing", {
36
+ codec: withDefault(
37
+ option("--codec", codecParser, {
38
+ description: message`The audio codec to transcode to. If unspecified, will copy audio data without transcoding.`
39
+ }),
40
+ "copy"
41
+ ),
42
+ bitrate: optional(
43
+ option("--bitrate", bitrateParser, {
44
+ description: message`The audio bitrate to transcode to ()`
45
+ })
46
+ ),
47
+ maxLength: withDefault(
48
+ option("--max-length", integer(), {
49
+ description: message`The maximum allowed length of a processed audio track, in minutes`
50
+ }),
51
+ 120
52
+ )
53
+ });
54
+ const processCommand = command(
55
+ "process",
56
+ merge(
57
+ object({
58
+ action: constant("process"),
59
+ input: argument(
60
+ path({ type: "directory", mustExist: true, metavar: "INPUT" })
61
+ ),
62
+ output: argument(path({ metavar: "OUTPUT", type: "directory" }))
63
+ }),
64
+ parallelismParser,
65
+ processParser,
66
+ loggingParser
67
+ ),
68
+ { description: message`Process audiobook files for transcription.` }
69
+ );
70
+ export {
71
+ processCommand,
72
+ processParser
73
+ };