@softure-ai/marketing-kit 0.15.0 → 0.17.0
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/CHANGELOG.md +91 -0
- package/README.md +138 -16
- package/dist/config/schema.d.ts +2 -1
- package/dist/config/schema.d.ts.map +1 -1
- package/dist/config/schema.js +7 -0
- package/dist/config/schema.js.map +1 -1
- package/dist/footage/clip-sound.d.ts +58 -0
- package/dist/footage/clip-sound.d.ts.map +1 -0
- package/dist/footage/clip-sound.js +103 -0
- package/dist/footage/clip-sound.js.map +1 -0
- package/dist/footage/declick.d.ts +1 -1
- package/dist/footage/declick.d.ts.map +1 -1
- package/dist/footage/declick.js +3 -4
- package/dist/footage/declick.js.map +1 -1
- package/dist/footage/draft.d.ts +19 -5
- package/dist/footage/draft.d.ts.map +1 -1
- package/dist/footage/draft.js +92 -22
- package/dist/footage/draft.js.map +1 -1
- package/dist/footage/elevenlabs.d.ts +5 -0
- package/dist/footage/elevenlabs.d.ts.map +1 -1
- package/dist/footage/elevenlabs.js +10 -3
- package/dist/footage/elevenlabs.js.map +1 -1
- package/dist/footage/failure.d.ts +12 -1
- package/dist/footage/failure.d.ts.map +1 -1
- package/dist/footage/failure.js +10 -1
- package/dist/footage/failure.js.map +1 -1
- package/dist/footage/fake.d.ts +10 -1
- package/dist/footage/fake.d.ts.map +1 -1
- package/dist/footage/fake.js +19 -4
- package/dist/footage/fake.js.map +1 -1
- package/dist/footage/hyperframes-capture.d.ts +30 -0
- package/dist/footage/hyperframes-capture.d.ts.map +1 -0
- package/dist/footage/hyperframes-capture.js +80 -0
- package/dist/footage/hyperframes-capture.js.map +1 -0
- package/dist/footage/isolate-ranges.d.ts +34 -6
- package/dist/footage/isolate-ranges.d.ts.map +1 -1
- package/dist/footage/isolate-ranges.js +90 -23
- package/dist/footage/isolate-ranges.js.map +1 -1
- package/dist/footage/loudness.d.ts +16 -2
- package/dist/footage/loudness.d.ts.map +1 -1
- package/dist/footage/loudness.js +10 -7
- package/dist/footage/loudness.js.map +1 -1
- package/dist/footage/paid.d.ts +12 -2
- package/dist/footage/paid.d.ts.map +1 -1
- package/dist/footage/paid.js +8 -3
- package/dist/footage/paid.js.map +1 -1
- package/dist/footage/pipeline.d.ts +14 -2
- package/dist/footage/pipeline.d.ts.map +1 -1
- package/dist/footage/pipeline.js +55 -46
- package/dist/footage/pipeline.js.map +1 -1
- package/dist/footage/providers.d.ts +5 -0
- package/dist/footage/providers.d.ts.map +1 -1
- package/dist/footage/providers.js.map +1 -1
- package/dist/footage/render.d.ts +1 -1
- package/dist/footage/render.d.ts.map +1 -1
- package/dist/footage/render.js +4 -3
- package/dist/footage/render.js.map +1 -1
- package/dist/footage/speech-ranges.d.ts +79 -11
- package/dist/footage/speech-ranges.d.ts.map +1 -1
- package/dist/footage/speech-ranges.js +137 -17
- package/dist/footage/speech-ranges.js.map +1 -1
- package/dist/index.d.ts +9 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -5
- package/dist/index.js.map +1 -1
- package/dist/og/index.d.ts +2 -0
- package/dist/og/index.d.ts.map +1 -1
- package/dist/og/index.js +2 -0
- package/dist/og/index.js.map +1 -1
- package/dist/og/photo-cover.d.ts +74 -0
- package/dist/og/photo-cover.d.ts.map +1 -0
- package/dist/og/photo-cover.js +357 -0
- package/dist/og/photo-cover.js.map +1 -0
- package/dist/og/photo.d.ts +51 -0
- package/dist/og/photo.d.ts.map +1 -0
- package/dist/og/photo.js +154 -0
- package/dist/og/photo.js.map +1 -0
- package/dist/voice/provider-failure.d.ts +41 -0
- package/dist/voice/provider-failure.d.ts.map +1 -0
- package/dist/voice/provider-failure.js +68 -0
- package/dist/voice/provider-failure.js.map +1 -0
- package/dist/voice/provider.d.ts +7 -1
- package/dist/voice/provider.d.ts.map +1 -1
- package/dist/voice/provider.js +1 -1
- package/dist/voice/provider.js.map +1 -1
- package/package.json +2 -1
- package/schema/marketing.schema.json +6 -0
- package/src/config/schema.ts +7 -0
- package/src/footage/clip-sound.ts +124 -0
- package/src/footage/declick.ts +3 -4
- package/src/footage/draft.ts +123 -22
- package/src/footage/elevenlabs.ts +11 -3
- package/src/footage/failure.ts +14 -1
- package/src/footage/fake.ts +28 -4
- package/src/footage/hyperframes-capture.ts +100 -0
- package/src/footage/isolate-ranges.ts +124 -29
- package/src/footage/loudness.ts +17 -8
- package/src/footage/paid.ts +25 -3
- package/src/footage/pipeline.ts +68 -47
- package/src/footage/providers.ts +5 -0
- package/src/footage/render.ts +4 -3
- package/src/footage/speech-ranges.ts +184 -19
- package/src/index.ts +49 -1
- package/src/og/index.ts +28 -0
- package/src/og/photo-cover.ts +442 -0
- package/src/og/photo.ts +177 -0
- package/src/voice/provider-failure.ts +98 -0
- package/src/voice/provider.ts +7 -2
package/dist/og/photo.js
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { err, ok } from "./result.js";
|
|
2
|
+
const PNG_SIGNATURE = Buffer.from([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]);
|
|
3
|
+
const EXIF_HEADER = Buffer.from("Exif\0\0", "latin1");
|
|
4
|
+
const ORIENTATION_TAG = 0x0112;
|
|
5
|
+
const SHORT_TYPE = 3;
|
|
6
|
+
function isOrientation(value) {
|
|
7
|
+
return Number.isInteger(value) && value >= 1 && value <= 8;
|
|
8
|
+
}
|
|
9
|
+
/** The orientation in a TIFF block (an EXIF payload after `Exif\0\0`, or a PNG `eXIf` chunk); 1 when absent. */
|
|
10
|
+
export function readTiffOrientation(tiff) {
|
|
11
|
+
if (tiff.length < 8)
|
|
12
|
+
return 1;
|
|
13
|
+
const order = tiff.toString("latin1", 0, 2);
|
|
14
|
+
if (order !== "II" && order !== "MM")
|
|
15
|
+
return 1;
|
|
16
|
+
const isLittle = order === "II";
|
|
17
|
+
const u16 = (offset) => (isLittle ? tiff.readUInt16LE(offset) : tiff.readUInt16BE(offset));
|
|
18
|
+
const u32 = (offset) => (isLittle ? tiff.readUInt32LE(offset) : tiff.readUInt32BE(offset));
|
|
19
|
+
if (u16(2) !== 42)
|
|
20
|
+
return 1;
|
|
21
|
+
const ifd = u32(4);
|
|
22
|
+
if (ifd + 2 > tiff.length)
|
|
23
|
+
return 1;
|
|
24
|
+
const count = u16(ifd);
|
|
25
|
+
for (let index = 0; index < count; index += 1) {
|
|
26
|
+
const entry = ifd + 2 + index * 12;
|
|
27
|
+
if (entry + 12 > tiff.length)
|
|
28
|
+
return 1;
|
|
29
|
+
if (u16(entry) !== ORIENTATION_TAG)
|
|
30
|
+
continue;
|
|
31
|
+
if (u16(entry + 2) !== SHORT_TYPE)
|
|
32
|
+
return 1;
|
|
33
|
+
const value = u16(entry + 8);
|
|
34
|
+
return isOrientation(value) ? value : 1;
|
|
35
|
+
}
|
|
36
|
+
return 1;
|
|
37
|
+
}
|
|
38
|
+
/** SOFn markers carry the frame size; C4 (DHT), C8 (JPG) and CC (DAC) share the range but are not frames. */
|
|
39
|
+
function isStartOfFrame(marker) {
|
|
40
|
+
return marker >= 0xc0 && marker <= 0xcf && marker !== 0xc4 && marker !== 0xc8 && marker !== 0xcc;
|
|
41
|
+
}
|
|
42
|
+
function readJpegInfo(bytes) {
|
|
43
|
+
let orientation = 1;
|
|
44
|
+
let offset = 2;
|
|
45
|
+
while (offset + 4 <= bytes.length) {
|
|
46
|
+
if (bytes[offset] !== 0xff)
|
|
47
|
+
return err("the JPEG's markers are damaged");
|
|
48
|
+
const marker = bytes[offset + 1] ?? 0;
|
|
49
|
+
// Fill bytes and markers without a length (RSTn, TEM) carry no segment.
|
|
50
|
+
if (marker === 0xff) {
|
|
51
|
+
offset += 1;
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
if (marker === 0x01 || (marker >= 0xd0 && marker <= 0xd7)) {
|
|
55
|
+
offset += 2;
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
if (marker === 0xd9 || marker === 0xda)
|
|
59
|
+
break;
|
|
60
|
+
const length = bytes.readUInt16BE(offset + 2);
|
|
61
|
+
const start = offset + 4;
|
|
62
|
+
const end = offset + 2 + length;
|
|
63
|
+
if (length < 2 || end > bytes.length)
|
|
64
|
+
return err("the JPEG ends inside a segment");
|
|
65
|
+
if (marker === 0xe1 && bytes.subarray(start, start + EXIF_HEADER.length).equals(EXIF_HEADER)) {
|
|
66
|
+
orientation = readTiffOrientation(bytes.subarray(start + EXIF_HEADER.length, end));
|
|
67
|
+
}
|
|
68
|
+
if (isStartOfFrame(marker)) {
|
|
69
|
+
if (length < 7)
|
|
70
|
+
return err("the JPEG's frame header is too short");
|
|
71
|
+
const height = bytes.readUInt16BE(start + 1);
|
|
72
|
+
const width = bytes.readUInt16BE(start + 3);
|
|
73
|
+
if (width === 0 || height === 0)
|
|
74
|
+
return err("the JPEG has no pixel size");
|
|
75
|
+
return ok({ format: "jpeg", width, height, orientation });
|
|
76
|
+
}
|
|
77
|
+
offset = end;
|
|
78
|
+
}
|
|
79
|
+
return err("the JPEG has no frame header");
|
|
80
|
+
}
|
|
81
|
+
function readPngInfo(bytes) {
|
|
82
|
+
if (bytes.length < 33 || bytes.toString("latin1", 12, 16) !== "IHDR")
|
|
83
|
+
return err("the PNG has no IHDR chunk");
|
|
84
|
+
const width = bytes.readUInt32BE(16);
|
|
85
|
+
const height = bytes.readUInt32BE(20);
|
|
86
|
+
if (width === 0 || height === 0)
|
|
87
|
+
return err("the PNG has no pixel size");
|
|
88
|
+
let orientation = 1;
|
|
89
|
+
let offset = 8;
|
|
90
|
+
while (offset + 8 <= bytes.length) {
|
|
91
|
+
const length = bytes.readUInt32BE(offset);
|
|
92
|
+
const type = bytes.toString("latin1", offset + 4, offset + 8);
|
|
93
|
+
const end = offset + 12 + length;
|
|
94
|
+
if (end > bytes.length)
|
|
95
|
+
break;
|
|
96
|
+
if (type === "eXIf")
|
|
97
|
+
orientation = readTiffOrientation(bytes.subarray(offset + 8, offset + 8 + length));
|
|
98
|
+
if (type === "IDAT" || type === "IEND")
|
|
99
|
+
break;
|
|
100
|
+
offset = end;
|
|
101
|
+
}
|
|
102
|
+
return ok({ format: "png", width, height, orientation });
|
|
103
|
+
}
|
|
104
|
+
/** The format, stored size and orientation of a JPEG or PNG; anything else is an error naming what is wrong. */
|
|
105
|
+
export function readPhotoInfo(bytes) {
|
|
106
|
+
if (bytes.length >= 3 && bytes[0] === 0xff && bytes[1] === 0xd8 && bytes[2] === 0xff)
|
|
107
|
+
return readJpegInfo(bytes);
|
|
108
|
+
if (bytes.subarray(0, PNG_SIGNATURE.length).equals(PNG_SIGNATURE))
|
|
109
|
+
return readPngInfo(bytes);
|
|
110
|
+
return err("it is neither a JPEG nor a PNG");
|
|
111
|
+
}
|
|
112
|
+
/** The size a viewer shows: orientations 5-8 turn the photo a quarter, swapping width and height. */
|
|
113
|
+
export function getOrientedSize(info) {
|
|
114
|
+
return info.orientation >= 5 ? { width: info.height, height: info.width } : { width: info.width, height: info.height };
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* The SVG `matrix(a b c d e f)` that maps the stored pixels (`width` × `height`) onto the upright photo, so that
|
|
118
|
+
* `x' = a·x + c·y + e` and `y' = b·x + d·y + f`.
|
|
119
|
+
*/
|
|
120
|
+
export function getOrientationMatrix(orientation, width, height) {
|
|
121
|
+
switch (orientation) {
|
|
122
|
+
case 1:
|
|
123
|
+
return [1, 0, 0, 1, 0, 0];
|
|
124
|
+
case 2:
|
|
125
|
+
return [-1, 0, 0, 1, width, 0];
|
|
126
|
+
case 3:
|
|
127
|
+
return [-1, 0, 0, -1, width, height];
|
|
128
|
+
case 4:
|
|
129
|
+
return [1, 0, 0, -1, 0, height];
|
|
130
|
+
case 5:
|
|
131
|
+
return [0, 1, 1, 0, 0, 0];
|
|
132
|
+
case 6:
|
|
133
|
+
return [0, 1, -1, 0, height, 0];
|
|
134
|
+
case 7:
|
|
135
|
+
return [0, -1, -1, 0, height, width];
|
|
136
|
+
case 8:
|
|
137
|
+
return [0, -1, 1, 0, 0, width];
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Scales the upright photo to cover `frame` and shifts it so the focus point sits as near the frame's centre as the
|
|
142
|
+
* photo allows: an edge of the photo never comes inside the frame.
|
|
143
|
+
*/
|
|
144
|
+
export function getCoverCrop(photo, frame, focus) {
|
|
145
|
+
const [width, height] = frame;
|
|
146
|
+
const scale = Math.max(width / photo.width, height / photo.height);
|
|
147
|
+
const place = (length, target, at) => {
|
|
148
|
+
const scaled = length * scale;
|
|
149
|
+
const offset = target / 2 - at * scaled;
|
|
150
|
+
return Math.min(0, Math.max(target - scaled, offset));
|
|
151
|
+
};
|
|
152
|
+
return { scale, x: place(photo.width, width, focus.x), y: place(photo.height, height, focus.y) };
|
|
153
|
+
}
|
|
154
|
+
//# sourceMappingURL=photo.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"photo.js","sourceRoot":"","sources":["../../src/og/photo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,EAAE,EAAiB,MAAM,aAAa,CAAC;AAqBrD,MAAM,aAAa,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;AACpF,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;AACtD,MAAM,eAAe,GAAG,MAAM,CAAC;AAC/B,MAAM,UAAU,GAAG,CAAC,CAAC;AAErB,SAAS,aAAa,CAAC,KAAa;IAClC,OAAO,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;AAC7D,CAAC;AAED,gHAAgH;AAChH,MAAM,UAAU,mBAAmB,CAAC,IAAY;IAC9C,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,C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AE,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;AACnG,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Why a paid provider call failed, as values an app can log and act on (issue #1141). Every field is safe to log:
|
|
3
|
+
* no key, path, transcript or audio content. `message` is the provider's own message, truncated.
|
|
4
|
+
* - `refused`: the provider answered a 4xx other than 408 and 429 (a bad input, key or balance). Asking again fails
|
|
5
|
+
* the same way.
|
|
6
|
+
* - `rate_limited`: 429. `unavailable`: 5xx. `timeout`: 408 or the request timed out. `connection`: no answer.
|
|
7
|
+
*/
|
|
8
|
+
export interface ProviderFailure {
|
|
9
|
+
kind: ProviderFailureKind;
|
|
10
|
+
/** The HTTP status; null when the provider never answered. */
|
|
11
|
+
status: number | null;
|
|
12
|
+
/** The provider's error code (e.g. `audio_too_short`); null when it gave none. */
|
|
13
|
+
code: string | null;
|
|
14
|
+
/** The provider's message, at most `PROVIDER_MESSAGE_LENGTH` characters; null when it gave none. */
|
|
15
|
+
message: string | null;
|
|
16
|
+
/** The provider's request id (header `request-id` or `x-request-id`, or the body's `request_id`). */
|
|
17
|
+
requestId: string | null;
|
|
18
|
+
/** True for 5xx, 408, 429, a timeout and a failed connection: asking again may succeed. */
|
|
19
|
+
isRetryable: boolean;
|
|
20
|
+
}
|
|
21
|
+
export type ProviderFailureKind = "refused" | "rate_limited" | "unavailable" | "timeout" | "connection";
|
|
22
|
+
export declare const PROVIDER_MESSAGE_LENGTH = 300;
|
|
23
|
+
/** The kind of an HTTP status the provider answered (not 2xx). */
|
|
24
|
+
export declare function getProviderFailureKind(status: number): ProviderFailureKind;
|
|
25
|
+
interface ErrorBody {
|
|
26
|
+
code: string | null;
|
|
27
|
+
message: string | null;
|
|
28
|
+
requestId: string | null;
|
|
29
|
+
}
|
|
30
|
+
/** The provider's code, message and request id from an error body: `{ detail: { code | status, message, request_id } }`, `{ detail: "…" }` or text. */
|
|
31
|
+
export declare function readProviderErrorBody(text: string): ErrorBody;
|
|
32
|
+
/** The failure of a response that is not 2xx, from its status, headers and body text. */
|
|
33
|
+
export declare function getProviderFailure(response: Response, text: string): ProviderFailure;
|
|
34
|
+
/** The failure of a request that got no answer: `timeout` when it timed out, `connection` otherwise. */
|
|
35
|
+
export declare function getConnectionFailure(error: unknown): ProviderFailure;
|
|
36
|
+
/** A failure the kit decides before any request (e.g. a missing key): `refused`, with the kit's own code. */
|
|
37
|
+
export declare function getLocalRefusal(code: string): ProviderFailure;
|
|
38
|
+
/** The failure in one line for a log: kind, status, code, request id and message. */
|
|
39
|
+
export declare function describeProviderFailure(failure: ProviderFailure): string;
|
|
40
|
+
export {};
|
|
41
|
+
//# sourceMappingURL=provider-failure.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider-failure.d.ts","sourceRoot":"","sources":["../../src/voice/provider-failure.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,mBAAmB,CAAC;IAC1B,8DAA8D;IAC9D,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,kFAAkF;IAClF,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,oGAAoG;IACpG,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,qGAAqG;IACrG,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,2FAA2F;IAC3F,WAAW,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,MAAM,mBAAmB,GAAG,SAAS,GAAG,cAAc,GAAG,aAAa,GAAG,SAAS,GAAG,YAAY,CAAC;AAExG,eAAO,MAAM,uBAAuB,MAAM,CAAC;AAI3C,kEAAkE;AAClE,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,GAAG,mBAAmB,CAK1E;AAWD,UAAU,SAAS;IACjB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAED,uJAAuJ;AACvJ,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAiB7D;AAED,yFAAyF;AACzF,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,GAAG,eAAe,CAKpF;AAED,wGAAwG;AACxG,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,eAAe,CAGpE;AAED,6GAA6G;AAC7G,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,CAE7D;AAED,qFAAqF;AACrF,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,eAAe,GAAG,MAAM,CAOxE"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
export const PROVIDER_MESSAGE_LENGTH = 300;
|
|
2
|
+
const REQUEST_ID_HEADERS = ["request-id", "x-request-id"];
|
|
3
|
+
/** The kind of an HTTP status the provider answered (not 2xx). */
|
|
4
|
+
export function getProviderFailureKind(status) {
|
|
5
|
+
if (status === 429)
|
|
6
|
+
return "rate_limited";
|
|
7
|
+
if (status === 408)
|
|
8
|
+
return "timeout";
|
|
9
|
+
if (status >= 500)
|
|
10
|
+
return "unavailable";
|
|
11
|
+
return "refused";
|
|
12
|
+
}
|
|
13
|
+
const isRetryableKind = (kind) => kind !== "refused";
|
|
14
|
+
const truncate = (text) => {
|
|
15
|
+
const trimmed = text.trim();
|
|
16
|
+
return trimmed.length === 0 ? null : trimmed.slice(0, PROVIDER_MESSAGE_LENGTH);
|
|
17
|
+
};
|
|
18
|
+
const readString = (value) => (typeof value === "string" && value.trim().length > 0 ? value.trim() : null);
|
|
19
|
+
/** The provider's code, message and request id from an error body: `{ detail: { code | status, message, request_id } }`, `{ detail: "…" }` or text. */
|
|
20
|
+
export function readProviderErrorBody(text) {
|
|
21
|
+
let body;
|
|
22
|
+
try {
|
|
23
|
+
body = JSON.parse(text);
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
return { code: null, message: truncate(text), requestId: null };
|
|
27
|
+
}
|
|
28
|
+
const root = typeof body === "object" && body !== null ? body : {};
|
|
29
|
+
const detail = root.detail ?? root.error ?? root;
|
|
30
|
+
if (typeof detail === "string")
|
|
31
|
+
return { code: null, message: truncate(detail), requestId: readString(root.request_id) };
|
|
32
|
+
const fields = typeof detail === "object" && detail !== null ? detail : {};
|
|
33
|
+
const message = readString(fields.message);
|
|
34
|
+
return {
|
|
35
|
+
code: readString(fields.code) ?? readString(fields.status) ?? readString(fields.type),
|
|
36
|
+
message: message === null ? null : truncate(message),
|
|
37
|
+
requestId: readString(fields.request_id) ?? readString(root.request_id),
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
/** The failure of a response that is not 2xx, from its status, headers and body text. */
|
|
41
|
+
export function getProviderFailure(response, text) {
|
|
42
|
+
const body = readProviderErrorBody(text);
|
|
43
|
+
const header = REQUEST_ID_HEADERS.map((name) => readString(response.headers.get(name))).find((value) => value !== null) ?? null;
|
|
44
|
+
const kind = getProviderFailureKind(response.status);
|
|
45
|
+
return { kind, status: response.status, code: body.code, message: body.message, requestId: header ?? body.requestId, isRetryable: isRetryableKind(kind) };
|
|
46
|
+
}
|
|
47
|
+
/** The failure of a request that got no answer: `timeout` when it timed out, `connection` otherwise. */
|
|
48
|
+
export function getConnectionFailure(error) {
|
|
49
|
+
const kind = error instanceof Error && error.name === "TimeoutError" ? "timeout" : "connection";
|
|
50
|
+
return { kind, status: null, code: null, message: null, requestId: null, isRetryable: true };
|
|
51
|
+
}
|
|
52
|
+
/** A failure the kit decides before any request (e.g. a missing key): `refused`, with the kit's own code. */
|
|
53
|
+
export function getLocalRefusal(code) {
|
|
54
|
+
return { kind: "refused", status: null, code, message: null, requestId: null, isRetryable: false };
|
|
55
|
+
}
|
|
56
|
+
/** The failure in one line for a log: kind, status, code, request id and message. */
|
|
57
|
+
export function describeProviderFailure(failure) {
|
|
58
|
+
const parts = [failure.kind];
|
|
59
|
+
if (failure.status !== null)
|
|
60
|
+
parts.push(String(failure.status));
|
|
61
|
+
if (failure.code !== null)
|
|
62
|
+
parts.push(failure.code);
|
|
63
|
+
if (failure.requestId !== null)
|
|
64
|
+
parts.push(`request ${failure.requestId}`);
|
|
65
|
+
const head = parts.join(", ");
|
|
66
|
+
return failure.message === null ? head : `${head}: ${failure.message}`;
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=provider-failure.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider-failure.js","sourceRoot":"","sources":["../../src/voice/provider-failure.ts"],"names":[],"mappings":"AAuBA,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,CAAC;AAE3C,MAAM,kBAAkB,GAAG,CAAC,YAAY,EAAE,cAAc,CAAC,CAAC;AAE1D,kEAAkE;AAClE,MAAM,UAAU,sBAAsB,CAAC,MAAc;IACnD,IAAI,MAAM,KAAK,GAAG;QAAE,OAAO,cAAc,CAAC;IAC1C,IAAI,MAAM,KAAK,GAAG;QAAE,OAAO,SAAS,CAAC;IACrC,IAAI,MAAM,IAAI,GAAG;QAAE,OAAO,aAAa,CAAC;IACxC,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,MAAM,eAAe,GAAG,CAAC,IAAyB,EAAW,EAAE,CAAC,IAAI,KAAK,SAAS,CAAC;AAEnF,MAAM,QAAQ,GAAG,CAAC,IAAY,EAAiB,EAAE;IAC/C,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;IAC5B,OAAO,OAAO,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,uBAAuB,CAAC,CAAC;AACjF,CAAC,CAAC;AAEF,MAAM,UAAU,GAAG,CAAC,KAAc,EAAiB,EAAE,CAAC,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,I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AAe,CAAC,IAAY;IAC1C,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC;AACrG,CAAC;AAED,qFAAqF;AACrF,MAAM,UAAU,uBAAuB,CAAC,OAAwB;IAC9D,MAAM,KAAK,GAAa,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACvC,IAAI,OAAO,CAAC,MAAM,KAAK,IAAI;QAAE,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;IAChE,IAAI,OAAO,CAAC,IAAI,KAAK,IAAI;QAAE,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACpD,IAAI,OAAO,CAAC,SAAS,KAAK,IAAI;QAAE,KAAK,CAAC,IAAI,CAAC,WAAW,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC;IAC3E,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC9B,OAAO,OAAO,CAAC,OAAO,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,KAAK,OAAO,CAAC,OAAO,EAAE,CAAC;AACzE,CAAC"}
|
package/dist/voice/provider.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ProviderFailure } from "./provider-failure.js";
|
|
1
2
|
import type { TimedWord } from "./voiceover.js";
|
|
2
3
|
/** What a provider speaks: the text in one voice, model and language. */
|
|
3
4
|
export interface TtsInput {
|
|
@@ -22,12 +23,17 @@ export interface TtsEstimate {
|
|
|
22
23
|
maxCost: number;
|
|
23
24
|
unit: string;
|
|
24
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* A provider's answer. A failure carries `error`, the sentence for logs, and, when the provider answered (or the kit
|
|
28
|
+
* refused before asking), `providerFailure`: what an app logs and reads to decide whether to ask again (#1141).
|
|
29
|
+
*/
|
|
25
30
|
export type TtsResult<T> = {
|
|
26
31
|
ok: true;
|
|
27
32
|
value: T;
|
|
28
33
|
} | {
|
|
29
34
|
ok: false;
|
|
30
35
|
error: string;
|
|
36
|
+
providerFailure?: ProviderFailure;
|
|
31
37
|
};
|
|
32
38
|
/**
|
|
33
39
|
* A text-to-speech service. `estimate` is free and needs no credentials; `synthesize` may spend
|
|
@@ -39,5 +45,5 @@ export interface TtsProvider {
|
|
|
39
45
|
synthesize(input: TtsInput): Promise<TtsResult<TtsRecording>>;
|
|
40
46
|
}
|
|
41
47
|
export declare const ok: <T>(value: T) => TtsResult<T>;
|
|
42
|
-
export declare const err: <T>(error: string) => TtsResult<T>;
|
|
48
|
+
export declare const err: <T>(error: string, providerFailure?: ProviderFailure) => TtsResult<T>;
|
|
43
49
|
//# sourceMappingURL=provider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../src/voice/provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD,yEAAyE;AACzE,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,kDAAkD;IAClD,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,sFAAsF;AACtF,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,SAAS,EAAE,CAAC;IACnB,sGAAsG;IACtG,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB;AAED,mEAAmE;AACnE,MAAM,WAAW,WAAW;IAC1B,yCAAyC;IACzC,UAAU,EAAE,MAAM,CAAC;IACnB,4FAA4F;IAC5F,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,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AAC;IACpB,QAAQ,CAAC,KAAK,EAAE,QAAQ,GAAG,WAAW,CAAC;IACvC,UAAU,CAAC,KAAK,EAAE,QAAQ,GAAG,OAAO,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC,CAAC;CAC/D;AAED,eAAO,MAAM,EAAE,GAAI,CAAC,EAAE,OAAO,CAAC,KAAG,SAAS,CAAC,CAAC,CAA0B,CAAC;AACvE,eAAO,MAAM,GAAG,GAAI,CAAC,EAAE,OAAO,MAAM,EAAE,kBAAkB,eAAe,KAAG,SAAS,CAAC,CAAC,CAAmG,CAAC"}
|
package/dist/voice/provider.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export const ok = (value) => ({ ok: true, value });
|
|
2
|
-
export const err = (error) => ({ ok: false, error });
|
|
2
|
+
export const err = (error, providerFailure) => (providerFailure === undefined ? { ok: false, error } : { ok: false, error, providerFailure });
|
|
3
3
|
//# sourceMappingURL=provider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../../src/voice/provider.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../../src/voice/provider.ts"],"names":[],"mappings":"AA6CA,MAAM,CAAC,MAAM,EAAE,GAAG,CAAI,KAAQ,EAAgB,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;AACvE,MAAM,CAAC,MAAM,GAAG,GAAG,CAAI,KAAa,EAAE,eAAiC,EAAgB,EAAE,CAAC,CAAC,eAAe,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,eAAe,EAAE,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@softure-ai/marketing-kit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.0",
|
|
4
4
|
"description": "SOFTURE AI marketing kit: a CLI that turns a project's real app into a vertical film (cached voiceover, frame-by-frame recording, HTML composition, hyperframes render) plus per-platform post copy and OG images.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -51,6 +51,7 @@
|
|
|
51
51
|
"@resvg/resvg-js": "^2.6.2",
|
|
52
52
|
"gsap": "^3.15.0",
|
|
53
53
|
"hyperframes": "0.9.6",
|
|
54
|
+
"jpeg-js": "^0.4.4",
|
|
54
55
|
"playwright": "^1.63.0",
|
|
55
56
|
"satori": "0.63.2",
|
|
56
57
|
"tsx": "^4.23.0",
|
|
@@ -3069,6 +3069,12 @@
|
|
|
3069
3069
|
"type": "number",
|
|
3070
3070
|
"minimum": 0.2,
|
|
3071
3071
|
"maximum": 3
|
|
3072
|
+
},
|
|
3073
|
+
"audioBitrateKbps": {
|
|
3074
|
+
"description": "The finished sound's AAC bitrate in kbps (192 to 512, default 192): the film's only lossy audio encode.",
|
|
3075
|
+
"type": "integer",
|
|
3076
|
+
"minimum": 192,
|
|
3077
|
+
"maximum": 512
|
|
3072
3078
|
}
|
|
3073
3079
|
},
|
|
3074
3080
|
"additionalProperties": false
|
package/src/config/schema.ts
CHANGED
|
@@ -643,6 +643,13 @@ const footageSchema = z
|
|
|
643
643
|
.describe(
|
|
644
644
|
"A near-miss band in LU (0.2 to 3, at least tolerance): a mix outside target ± tolerance but inside target ± warnTolerance, under the true peak limit, finishes with a warning instead of failing.",
|
|
645
645
|
),
|
|
646
|
+
audioBitrateKbps: z
|
|
647
|
+
.number()
|
|
648
|
+
.int()
|
|
649
|
+
.min(192)
|
|
650
|
+
.max(512)
|
|
651
|
+
.optional()
|
|
652
|
+
.describe("The finished sound's AAC bitrate in kbps (192 to 512, default 192): the film's only lossy audio encode."),
|
|
646
653
|
})
|
|
647
654
|
.refine((mix) => mix.warnTolerance === undefined || mix.warnTolerance >= (mix.tolerance ?? 1), { path: ["warnTolerance"], message: "must be at least tolerance (default 1)" }),
|
|
648
655
|
])
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { mkdirSync } from "node:fs";
|
|
2
|
+
import { dirname, extname, join } from "node:path";
|
|
3
|
+
|
|
4
|
+
import type { FootageClip } from "./film.js";
|
|
5
|
+
import { isSilent, readLoudnessMeasurement, type LoudnessMeasurement } from "./loudness.js";
|
|
6
|
+
import { FOOTAGE_SAMPLE_RATE } from "./normalize.js";
|
|
7
|
+
import { runFfmpeg, runProcess } from "./process.js";
|
|
8
|
+
import type { FootageProbe } from "./probe.js";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Each clip's sound for the speech chain (issue #1139): read from the clip's source with the normalize step's own seek
|
|
12
|
+
* and length (so the EDL's times hold), brought to 48 kHz stereo, raised by one linear pre-gain to about
|
|
13
|
+
* `SPEECH_PRE_GAIN.target` with its true peak kept under `SPEECH_PRE_GAIN.peakCeiling`, and written as 24-bit PCM WAV.
|
|
14
|
+
* Quiet phone speech is then never encoded lossily at its quiet level: the voice isolator, the speech to text, the cut,
|
|
15
|
+
* the declick and the loudness pass all work on lossless sound, and the film's final AAC is the only lossy encode.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/** Where the pre-gain brings a talking clip's sound: integrated loudness in LUFS, and the true peak's ceiling in dBTP. */
|
|
19
|
+
export const SPEECH_PRE_GAIN = { target: -23, peakCeiling: -3 } as const;
|
|
20
|
+
|
|
21
|
+
/** The loudness range `loudnorm` measures with; the pre-gain itself is a plain linear `volume`. */
|
|
22
|
+
const MEASURE_RANGE = 11;
|
|
23
|
+
|
|
24
|
+
/** The clip as the normalize step reads it: its trim, its source file and what the probe found. */
|
|
25
|
+
export interface ClipSoundInput {
|
|
26
|
+
clip: Pick<FootageClip, "id" | "role" | "trim">;
|
|
27
|
+
/** The source as read (a URL's downloaded copy). */
|
|
28
|
+
source: string;
|
|
29
|
+
probe: Pick<FootageProbe, "hasAudio">;
|
|
30
|
+
/** Seconds after the trim. */
|
|
31
|
+
duration: number;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** A clip's lossless, pre-gained sound and the gain it got in dB. */
|
|
35
|
+
export interface ClipSound {
|
|
36
|
+
file: string;
|
|
37
|
+
gainDb: number;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const toFormat = `aformat=sample_rates=${String(FOOTAGE_SAMPLE_RATE)}:channel_layouts=stereo`;
|
|
41
|
+
|
|
42
|
+
/** The seek and the length of the trimmed clip, as `buildNormalizeArgs` reads its source. */
|
|
43
|
+
function getTrimArgs(input: ClipSoundInput): { seek: string[]; length: string[] } {
|
|
44
|
+
return { seek: input.clip.trim.start > 0 ? ["-ss", String(input.clip.trim.start)] : [], length: ["-t", input.duration.toFixed(3)] };
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** The measuring pass over the trimmed clip's sound, after the same format change the extraction makes; writes nothing. */
|
|
48
|
+
export function buildClipSoundMeasureArgs(input: ClipSoundInput): string[] {
|
|
49
|
+
const { seek, length } = getTrimArgs(input);
|
|
50
|
+
const measure = `loudnorm=I=${String(SPEECH_PRE_GAIN.target)}:TP=${String(SPEECH_PRE_GAIN.peakCeiling)}:LRA=${String(MEASURE_RANGE)}:print_format=json`;
|
|
51
|
+
return ["-hide_banner", "-nostats", ...seek, "-i", input.source, ...length, "-map", "0:a:0", "-vn", "-af", `${toFormat},${measure}`, "-f", "null", "-"];
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* The pre-gain in dB for a measured clip: up (or down) to `SPEECH_PRE_GAIN.target`, but never past the gain that puts
|
|
56
|
+
* its true peak at `SPEECH_PRE_GAIN.peakCeiling`; 0 for silence. Rounded to a hundredth of a dB.
|
|
57
|
+
*/
|
|
58
|
+
export function getPreGainDb(measurement: LoudnessMeasurement | null): number {
|
|
59
|
+
if (measurement === null || isSilent(measurement)) return 0;
|
|
60
|
+
const toTarget = SPEECH_PRE_GAIN.target - measurement.inputI;
|
|
61
|
+
const toCeiling = Number.isFinite(measurement.inputTp) ? SPEECH_PRE_GAIN.peakCeiling - measurement.inputTp : toTarget;
|
|
62
|
+
return Math.round(Math.min(toTarget, toCeiling) * 100) / 100 || 0;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** The trimmed clip's sound, gained by `gainDb`, as a 24-bit 48 kHz stereo WAV; silence as long as the clip when it has none. */
|
|
66
|
+
export function buildClipSoundArgs(input: ClipSoundInput & { gainDb: number; output: string }): string[] {
|
|
67
|
+
const codec = ["-ar", String(FOOTAGE_SAMPLE_RATE), "-ac", "2", "-c:a", "pcm_s24le", input.output];
|
|
68
|
+
const { seek, length } = getTrimArgs(input);
|
|
69
|
+
if (!input.probe.hasAudio) return ["-v", "error", "-y", "-f", "lavfi", "-i", `anullsrc=r=${String(FOOTAGE_SAMPLE_RATE)}:cl=stereo`, ...length, ...codec];
|
|
70
|
+
return ["-v", "error", "-y", ...seek, "-i", input.source, ...length, "-map", "0:a:0", "-vn", "-af", `${toFormat},volume=${String(input.gainDb)}dB`, ...codec];
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** Where a clip's sound goes in the build folder. */
|
|
74
|
+
export function getClipSoundPath(buildDir: string, clipId: string): string {
|
|
75
|
+
return join(buildDir, "audio", `${clipId}.wav`);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** Measures one clip's sound; null when the clip has none. Throws naming the clip when ffmpeg fails. */
|
|
79
|
+
async function measureClipSound(input: ClipSoundInput, signal: AbortSignal | undefined): Promise<LoudnessMeasurement | null> {
|
|
80
|
+
if (!input.probe.hasAudio) return null;
|
|
81
|
+
const step = `Measuring the sound of clip ${input.clip.id}`;
|
|
82
|
+
const measured = await runProcess({ command: "ffmpeg", args: buildClipSoundMeasureArgs(input), ...(signal === undefined ? {} : { signal }) });
|
|
83
|
+
if (measured.kind === "not-started") throw new Error(`${step}: ffmpeg did not start (${measured.error}).`);
|
|
84
|
+
if (measured.code !== 0) throw new Error(`${step}: ffmpeg ended with code ${String(measured.code)}: ${measured.stderr.trim().split("\n").slice(-3).join(" | ")}.`);
|
|
85
|
+
const measurement = readLoudnessMeasurement(measured.stderr);
|
|
86
|
+
if (measurement === null) throw new Error(`${step}: ffmpeg printed no loudnorm measurement for ${input.source}.`);
|
|
87
|
+
return measurement;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Every clip's lossless, pre-gained sound under `<buildDir>/audio/<id>.wav`, by clip id. A talking clip is gained by its
|
|
92
|
+
* own measurement (`getPreGainDb`); any other clip by the mean of the talking clips' gains (0 dB without one), so a
|
|
93
|
+
* b-roll's own sound under the speech keeps its relation to it. Throws naming the clip when ffmpeg fails.
|
|
94
|
+
*/
|
|
95
|
+
export async function prepareClipSounds(clips: readonly ClipSoundInput[], options: { buildDir: string; signal?: AbortSignal }): Promise<Record<string, ClipSound>> {
|
|
96
|
+
const { signal } = options;
|
|
97
|
+
const gains = new Map<string, number>();
|
|
98
|
+
for (const clip of clips) {
|
|
99
|
+
if (clip.clip.role !== "talk") continue;
|
|
100
|
+
gains.set(clip.clip.id, getPreGainDb(await measureClipSound(clip, signal)));
|
|
101
|
+
}
|
|
102
|
+
const talking = [...gains.values()];
|
|
103
|
+
const sharedGain = talking.length === 0 ? 0 : Math.round((talking.reduce((sum, gain) => sum + gain, 0) / talking.length) * 100) / 100 || 0;
|
|
104
|
+
const sounds: Record<string, ClipSound> = {};
|
|
105
|
+
for (const clip of clips) {
|
|
106
|
+
const gainDb = gains.get(clip.clip.id) ?? sharedGain;
|
|
107
|
+
const output = getClipSoundPath(options.buildDir, clip.clip.id);
|
|
108
|
+
mkdirSync(dirname(output), { recursive: true });
|
|
109
|
+
await runFfmpeg(`Extracting the sound of clip ${clip.clip.id}`, buildClipSoundArgs({ ...clip, gainDb, output }), { ...(signal === undefined ? {} : { signal }), output });
|
|
110
|
+
sounds[clip.clip.id] = { file: output, gainDb };
|
|
111
|
+
}
|
|
112
|
+
return sounds;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* The audio codec for an intermediate file by its extension: `.wav` 32-bit float PCM (no stage clips between stages),
|
|
117
|
+
* `.flac` FLAC, anything else MP3 (an app's own `.mp3` names keep working).
|
|
118
|
+
*/
|
|
119
|
+
export function getAudioCodecArgs(output: string): string[] {
|
|
120
|
+
const extension = extname(output).toLowerCase();
|
|
121
|
+
if (extension === ".wav") return ["-c:a", "pcm_f32le"];
|
|
122
|
+
if (extension === ".flac") return ["-c:a", "flac"];
|
|
123
|
+
return ["-c:a", "libmp3lame", "-q:a", "2"];
|
|
124
|
+
}
|
package/src/footage/declick.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
2
|
-
import { extname } from "node:path";
|
|
3
2
|
|
|
4
3
|
import type { TimedWord } from "../voice/voiceover.js";
|
|
4
|
+
import { getAudioCodecArgs } from "./clip-sound.js";
|
|
5
5
|
import { FOOTAGE_SAMPLE_RATE } from "./normalize.js";
|
|
6
6
|
import { runFfmpeg } from "./process.js";
|
|
7
7
|
|
|
@@ -295,10 +295,9 @@ export function buildDeclickDecodeArgs(input: string, output: string): string[]
|
|
|
295
295
|
return ["-v", "error", "-y", "-i", input, "-vn", "-c:a", "pcm_f32le", ...PCM_FORMAT, output];
|
|
296
296
|
}
|
|
297
297
|
|
|
298
|
-
/** The declicked PCM encoded
|
|
298
|
+
/** The declicked PCM encoded by the output's extension (`getAudioCodecArgs`: `.wav` lossless float, as the chain writes it). */
|
|
299
299
|
export function buildDeclickEncodeArgs(input: string, output: string): string[] {
|
|
300
|
-
|
|
301
|
-
return ["-v", "error", "-y", ...PCM_FORMAT, "-i", input, ...codec, output];
|
|
300
|
+
return ["-v", "error", "-y", ...PCM_FORMAT, "-i", input, ...getAudioCodecArgs(output), output];
|
|
302
301
|
}
|
|
303
302
|
|
|
304
303
|
/** Raw little-endian float32 bytes as samples (copied, so the view is aligned). */
|