@nodaro/shared 1.20.0 → 1.21.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/dist/index.cjs +42 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +32 -1
- package/dist/index.d.ts +32 -1
- package/dist/index.js +41 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/__tests__/video-analysis.test.ts +69 -1
- package/src/video-analysis.ts +65 -0
package/dist/index.cjs
CHANGED
|
@@ -12189,7 +12189,28 @@ var entitySlotSchema = zod.z.object({
|
|
|
12189
12189
|
var audioLayerSchema = zod.z.object({
|
|
12190
12190
|
mode: zod.z.enum(["speech", "music", "sfx"]),
|
|
12191
12191
|
content: zod.z.string().min(1),
|
|
12192
|
-
voice: zod.z.string().optional()
|
|
12192
|
+
voice: zod.z.string().optional(),
|
|
12193
|
+
/**
|
|
12194
|
+
* SPEECH ONLY — `slotId` of the on-screen speaker saying these words.
|
|
12195
|
+
*
|
|
12196
|
+
* `voice` casts a voice ("male, proud triumphant shouting"); this says WHO it
|
|
12197
|
+
* belongs to, so a recreation can route the line to the right character
|
|
12198
|
+
* instead of guessing. Usually one person speaks per scene and the guess is
|
|
12199
|
+
* right, which is exactly why the cases with two speakers over one cut fail
|
|
12200
|
+
* silently without this field.
|
|
12201
|
+
*
|
|
12202
|
+
* Optional by design and deliberately NOT refined against `mode` here: the
|
|
12203
|
+
* window schema is the enforced decode grammar, and rejecting a whole roll
|
|
12204
|
+
* because the model tagged a music layer would be a hair-trigger failure. A
|
|
12205
|
+
* speaker on a non-speech layer, or one naming a slot that no longer exists,
|
|
12206
|
+
* is stripped structurally by `dropUnknownSpeakers` — the same
|
|
12207
|
+
* unwrap/drop/sweep philosophy the slot-token and binding channels use.
|
|
12208
|
+
*
|
|
12209
|
+
* An unseen narrator gets NO speaker: a voice with no body is never a slot
|
|
12210
|
+
* (doctrine §5), so attribution here would resurrect the phantom-entity
|
|
12211
|
+
* defect that `stripOrphanSlots` exists to kill.
|
|
12212
|
+
*/
|
|
12213
|
+
speakerSlot: zod.z.string().optional()
|
|
12193
12214
|
});
|
|
12194
12215
|
var windowSceneBase = zod.z.object({
|
|
12195
12216
|
startSec: zod.z.number().min(0),
|
|
@@ -12278,6 +12299,24 @@ function dropUnknownBindings(sv, validBySlot) {
|
|
|
12278
12299
|
}
|
|
12279
12300
|
return { kept: Object.keys(kept).length > 0 ? kept : void 0, dropped };
|
|
12280
12301
|
}
|
|
12302
|
+
function rewriteSpeakerSlots(audio, slotRenames) {
|
|
12303
|
+
if (!audio.some((a) => a.speakerSlot !== void 0 && slotRenames[a.speakerSlot])) return audio;
|
|
12304
|
+
return audio.map((a) => {
|
|
12305
|
+
const to = a.speakerSlot !== void 0 ? slotRenames[a.speakerSlot] : void 0;
|
|
12306
|
+
return to ? { ...a, speakerSlot: to } : a;
|
|
12307
|
+
});
|
|
12308
|
+
}
|
|
12309
|
+
function dropUnknownSpeakers(audio, validSlotIds) {
|
|
12310
|
+
const dropped = [];
|
|
12311
|
+
const out = audio.map((a) => {
|
|
12312
|
+
if (a.speakerSlot === void 0) return a;
|
|
12313
|
+
if (a.mode === "speech" && validSlotIds.has(a.speakerSlot)) return a;
|
|
12314
|
+
dropped.push(a.speakerSlot);
|
|
12315
|
+
const { speakerSlot: _drop, ...rest } = a;
|
|
12316
|
+
return rest;
|
|
12317
|
+
});
|
|
12318
|
+
return { audio: dropped.length > 0 ? out : audio, dropped };
|
|
12319
|
+
}
|
|
12281
12320
|
function renderAnalyzedScene(scene, slots, castMap) {
|
|
12282
12321
|
const byId = new Map(slots.map((s) => [s.slotId, s]));
|
|
12283
12322
|
return scene.visual.replace(SLOT_TOKEN_RE, (_whole, id) => castMap?.[id] ?? byId.get(id)?.description ?? id);
|
|
@@ -12839,6 +12878,7 @@ exports.describeEdgeBehavior = describeEdgeBehavior;
|
|
|
12839
12878
|
exports.describeMaskRegion = describeMaskRegion;
|
|
12840
12879
|
exports.describeSlotControl = describeSlotControl;
|
|
12841
12880
|
exports.dropUnknownBindings = dropUnknownBindings;
|
|
12881
|
+
exports.dropUnknownSpeakers = dropUnknownSpeakers;
|
|
12842
12882
|
exports.durationsByMode = durationsByMode;
|
|
12843
12883
|
exports.effectiveReasoningEffort = effectiveReasoningEffort;
|
|
12844
12884
|
exports.encodeProviderItem = encodeProviderItem;
|
|
@@ -13022,6 +13062,7 @@ exports.resolveVideoProviderForMode = resolveVideoProviderForMode;
|
|
|
13022
13062
|
exports.resolveXfadeName = resolveXfadeName;
|
|
13023
13063
|
exports.rewriteSceneBindings = rewriteSceneBindings;
|
|
13024
13064
|
exports.rewriteSlotTokens = rewriteSlotTokens;
|
|
13065
|
+
exports.rewriteSpeakerSlots = rewriteSpeakerSlots;
|
|
13025
13066
|
exports.rgbaArrayToHex = rgbaArrayToHex;
|
|
13026
13067
|
exports.roleToPhrase = roleToPhrase;
|
|
13027
13068
|
exports.runSelector = runSelector;
|