@nodaro/shared 3.63.0 → 3.65.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/{chunk-3K24DWOH.js → chunk-222QM7CO.js} +3 -3
- package/dist/{chunk-3K24DWOH.js.map → chunk-222QM7CO.js.map} +1 -1
- package/dist/chunk-27HA6YOL.cjs +377 -0
- package/dist/chunk-27HA6YOL.cjs.map +1 -0
- package/dist/{chunk-4DVWXEB6.js → chunk-2NKF476Z.js} +3 -3
- package/dist/{chunk-4DVWXEB6.js.map → chunk-2NKF476Z.js.map} +1 -1
- package/dist/chunk-3AU52TSW.js +143 -0
- package/dist/chunk-3AU52TSW.js.map +1 -0
- package/dist/{chunk-F6WGGYQW.cjs → chunk-5NVGKXJV.cjs} +68 -29
- package/dist/chunk-5NVGKXJV.cjs.map +1 -0
- package/dist/{chunk-HWQ2SYNA.js → chunk-5SSMPYE5.js} +99 -9
- package/dist/chunk-5SSMPYE5.js.map +1 -0
- package/dist/{chunk-WRSWH7US.cjs → chunk-6BRWPJPP.cjs} +17 -2
- package/dist/chunk-6BRWPJPP.cjs.map +1 -0
- package/dist/{chunk-KHH54GRP.cjs → chunk-6ET3KDO4.cjs} +15 -338
- package/dist/chunk-6ET3KDO4.cjs.map +1 -0
- package/dist/{chunk-TM5JYSJF.cjs → chunk-6OSIOVF7.cjs} +98 -37
- package/dist/chunk-6OSIOVF7.cjs.map +1 -0
- package/dist/{chunk-YUER7TJG.js → chunk-6X5PBAC4.js} +13 -4
- package/dist/chunk-6X5PBAC4.js.map +1 -0
- package/dist/chunk-7BN4EDIC.cjs +185 -0
- package/dist/chunk-7BN4EDIC.cjs.map +1 -0
- package/dist/{chunk-6M563QE6.js → chunk-7OWXHW7Z.js} +78 -28
- package/dist/chunk-7OWXHW7Z.js.map +1 -0
- package/dist/{chunk-FXGNRYQQ.js → chunk-AT53ZQUC.js} +3 -3
- package/dist/{chunk-FXGNRYQQ.js.map → chunk-AT53ZQUC.js.map} +1 -1
- package/dist/{chunk-HSHCCBIV.js → chunk-BQYCZLMF.js} +16 -3
- package/dist/chunk-BQYCZLMF.js.map +1 -0
- package/dist/{chunk-34QLPTSA.js → chunk-BSTAAGLY.js} +3 -3
- package/dist/{chunk-34QLPTSA.js.map → chunk-BSTAAGLY.js.map} +1 -1
- package/dist/{chunk-PSKZKLDG.js → chunk-CW6MMQNO.js} +562 -26
- package/dist/chunk-CW6MMQNO.js.map +1 -0
- package/dist/{chunk-EPXGG27L.js → chunk-D5Y3EYRM.js} +5 -5
- package/dist/{chunk-EPXGG27L.js.map → chunk-D5Y3EYRM.js.map} +1 -1
- package/dist/{chunk-XGVJGNZW.cjs → chunk-DQ2PARNH.cjs} +15 -5
- package/dist/chunk-DQ2PARNH.cjs.map +1 -0
- package/dist/{chunk-6BZC2ZHC.cjs → chunk-E66HSC2E.cjs} +9 -9
- package/dist/{chunk-6BZC2ZHC.cjs.map → chunk-E66HSC2E.cjs.map} +1 -1
- package/dist/{chunk-NIAFR5EE.js → chunk-FGBGKBML.js} +32 -3
- package/dist/chunk-FGBGKBML.js.map +1 -0
- package/dist/{chunk-M5OCFGHF.cjs → chunk-FI3HJZWM.cjs} +588 -25
- package/dist/chunk-FI3HJZWM.cjs.map +1 -0
- package/dist/{chunk-L2TVY6XN.cjs → chunk-FJZTQTF4.cjs} +4 -4
- package/dist/{chunk-L2TVY6XN.cjs.map → chunk-FJZTQTF4.cjs.map} +1 -1
- package/dist/{chunk-XGGZWA4A.cjs → chunk-GJ3D5X4X.cjs} +52 -49
- package/dist/chunk-GJ3D5X4X.cjs.map +1 -0
- package/dist/{chunk-Q6IES3U2.js → chunk-H5KHWTAE.js} +5 -2
- package/dist/chunk-H5KHWTAE.js.map +1 -0
- package/dist/{chunk-MD4XHED4.js → chunk-H745DQ6V.js} +3 -3
- package/dist/{chunk-MD4XHED4.js.map → chunk-H745DQ6V.js.map} +1 -1
- package/dist/{chunk-KCZHQH2O.js → chunk-HAH2F7LT.js} +4 -4
- package/dist/{chunk-KCZHQH2O.js.map → chunk-HAH2F7LT.js.map} +1 -1
- package/dist/{chunk-V5EEQR2U.cjs → chunk-JQMFJAYU.cjs} +21 -21
- package/dist/{chunk-V5EEQR2U.cjs.map → chunk-JQMFJAYU.cjs.map} +1 -1
- package/dist/{chunk-WZVIBAKN.cjs → chunk-JYU5EIRM.cjs} +12 -12
- package/dist/{chunk-WZVIBAKN.cjs.map → chunk-JYU5EIRM.cjs.map} +1 -1
- package/dist/{chunk-Y35JQPT6.cjs → chunk-K6RIN3LW.cjs} +142 -45
- package/dist/chunk-K6RIN3LW.cjs.map +1 -0
- package/dist/{chunk-BLJUCPMV.cjs → chunk-KSHAAPQF.cjs} +5 -2
- package/dist/chunk-KSHAAPQF.cjs.map +1 -0
- package/dist/{chunk-2PU3AGGS.cjs → chunk-KTCEKGBJ.cjs} +7 -7
- package/dist/{chunk-2PU3AGGS.cjs.map → chunk-KTCEKGBJ.cjs.map} +1 -1
- package/dist/{chunk-LH72PQO2.cjs → chunk-KWYS4IIM.cjs} +165 -50
- package/dist/chunk-KWYS4IIM.cjs.map +1 -0
- package/dist/{chunk-GSKLPI3J.cjs → chunk-MIT2USTS.cjs} +118 -61
- package/dist/chunk-MIT2USTS.cjs.map +1 -0
- package/dist/{chunk-Y4GCJJPF.cjs → chunk-NYZQOIXJ.cjs} +35 -2
- package/dist/chunk-NYZQOIXJ.cjs.map +1 -0
- package/dist/{chunk-A2PX5IRC.cjs → chunk-PERUFUVH.cjs} +13 -13
- package/dist/{chunk-A2PX5IRC.cjs.map → chunk-PERUFUVH.cjs.map} +1 -1
- package/dist/{chunk-X5BAFW3Q.cjs → chunk-PGDR7CO3.cjs} +8 -8
- package/dist/{chunk-X5BAFW3Q.cjs.map → chunk-PGDR7CO3.cjs.map} +1 -1
- package/dist/{chunk-OV3JTKBY.js → chunk-PL7AQQV7.js} +123 -22
- package/dist/chunk-PL7AQQV7.js.map +1 -0
- package/dist/chunk-Q4YOLT4M.js +164 -0
- package/dist/chunk-Q4YOLT4M.js.map +1 -0
- package/dist/{chunk-GMBDLNLD.cjs → chunk-R5ILCNCC.cjs} +197 -60
- package/dist/chunk-R5ILCNCC.cjs.map +1 -0
- package/dist/chunk-RP4KQUNU.cjs +168 -0
- package/dist/chunk-RP4KQUNU.cjs.map +1 -0
- package/dist/{chunk-77WU3V3J.cjs → chunk-SPU7MUWE.cjs} +6 -6
- package/dist/{chunk-77WU3V3J.cjs.map → chunk-SPU7MUWE.cjs.map} +1 -1
- package/dist/{chunk-XBTYGQ6Z.js → chunk-ST7OBB5J.js} +8 -5
- package/dist/chunk-ST7OBB5J.js.map +1 -0
- package/dist/{chunk-2QKF7M2Z.js → chunk-TAPBDT47.js} +3 -3
- package/dist/{chunk-2QKF7M2Z.js.map → chunk-TAPBDT47.js.map} +1 -1
- package/dist/{chunk-BMJVKYVB.js → chunk-V5NLQ4L5.js} +123 -7
- package/dist/chunk-V5NLQ4L5.js.map +1 -0
- package/dist/{chunk-KMGCHV6O.js → chunk-V6OXSXIX.js} +63 -30
- package/dist/chunk-V6OXSXIX.js.map +1 -0
- package/dist/{chunk-LMAQUR55.cjs → chunk-WQMPIURW.cjs} +6 -6
- package/dist/{chunk-LMAQUR55.cjs.map → chunk-WQMPIURW.cjs.map} +1 -1
- package/dist/{chunk-ZPE2ZTJ4.cjs → chunk-WZG6GZIL.cjs} +4 -4
- package/dist/{chunk-ZPE2ZTJ4.cjs.map → chunk-WZG6GZIL.cjs.map} +1 -1
- package/dist/{chunk-AE3AAJ4O.js → chunk-XJANKTIL.js} +3 -3
- package/dist/{chunk-AE3AAJ4O.js.map → chunk-XJANKTIL.js.map} +1 -1
- package/dist/{chunk-O7RZRUMZ.js → chunk-XJWED257.js} +14 -309
- package/dist/chunk-XJWED257.js.map +1 -0
- package/dist/chunk-XSSLNINL.js +346 -0
- package/dist/chunk-XSSLNINL.js.map +1 -0
- package/dist/{chunk-6TGB7ECA.cjs → chunk-YD4XY74W.cjs} +12 -8
- package/dist/chunk-YD4XY74W.cjs.map +1 -0
- package/dist/{chunk-YX6TFX7H.js → chunk-YMZUE2IX.js} +66 -11
- package/dist/chunk-YMZUE2IX.js.map +1 -0
- package/dist/{chunk-4MMZD63H.js → chunk-Z77M7Q2R.js} +3 -3
- package/dist/{chunk-4MMZD63H.js.map → chunk-Z77M7Q2R.js.map} +1 -1
- package/dist/{chunk-CZ5IQB3L.js → chunk-ZSRXY5YT.js} +8 -5
- package/dist/chunk-ZSRXY5YT.js.map +1 -0
- package/dist/entries/apps.cjs +43 -42
- package/dist/entries/apps.js +8 -7
- package/dist/entries/captions.cjs +38 -30
- package/dist/entries/captions.d.cts +48 -2
- package/dist/entries/captions.d.ts +48 -2
- package/dist/entries/captions.js +1 -1
- package/dist/entries/credits.cjs +319 -191
- package/dist/entries/credits.d.cts +260 -19
- package/dist/entries/credits.d.ts +260 -19
- package/dist/entries/credits.js +11 -11
- package/dist/entries/entities.cjs +202 -193
- package/dist/entries/entities.d.cts +44 -9
- package/dist/entries/entities.d.ts +44 -9
- package/dist/entries/entities.js +2 -1
- package/dist/entries/llm-models.cjs +86 -62
- package/dist/entries/llm-models.d.cts +73 -20
- package/dist/entries/llm-models.d.ts +73 -20
- package/dist/entries/llm-models.js +2 -2
- package/dist/entries/media.cjs +79 -63
- package/dist/entries/media.d.cts +154 -1
- package/dist/entries/media.d.ts +154 -1
- package/dist/entries/media.js +1 -1
- package/dist/entries/model-catalog.cjs +205 -109
- package/dist/entries/model-catalog.d.cts +65 -58
- package/dist/entries/model-catalog.d.ts +65 -58
- package/dist/entries/model-catalog.js +4 -4
- package/dist/entries/models.cjs +527 -346
- package/dist/entries/models.d.cts +86 -7
- package/dist/entries/models.d.ts +86 -7
- package/dist/entries/models.js +6 -5
- package/dist/entries/nodes.cjs +220 -211
- package/dist/entries/nodes.d.cts +46 -3
- package/dist/entries/nodes.d.ts +46 -3
- package/dist/entries/nodes.js +10 -9
- package/dist/entries/pipeline.cjs +156 -152
- package/dist/entries/pipeline.d.cts +14 -4
- package/dist/entries/pipeline.d.ts +14 -4
- package/dist/entries/pipeline.js +3 -3
- package/dist/entries/social.cjs +177 -177
- package/dist/entries/social.js +2 -2
- package/dist/entries/ugc.cjs +71 -71
- package/dist/entries/ugc.js +4 -4
- package/dist/entries/video.cjs +174 -145
- package/dist/entries/video.d.cts +114 -2
- package/dist/entries/video.d.ts +114 -2
- package/dist/entries/video.js +7 -6
- package/dist/entries/workflow.cjs +150 -150
- package/dist/entries/workflow.d.cts +1 -1
- package/dist/entries/workflow.d.ts +1 -1
- package/dist/entries/workflow.js +2 -2
- package/dist/index.cjs +2430 -1929
- package/dist/index.d.cts +13 -12
- package/dist/index.d.ts +13 -12
- package/dist/index.js +28 -27
- package/dist/{model-catalog-C_Eo35tL.d.cts → model-catalog-BoUKGFNl.d.cts} +182 -3
- package/dist/{model-catalog-C_Eo35tL.d.ts → model-catalog-BoUKGFNl.d.ts} +182 -3
- package/dist/{model-constants-DWcxOmaY.d.cts → model-constants-BElS3AeE.d.ts} +142 -23
- package/dist/{model-constants-Bg4ccSQb.d.ts → model-constants-CpQz1bGa.d.cts} +142 -23
- package/dist/tts-capabilities-BtnDWK9K.d.ts +133 -0
- package/dist/tts-capabilities-C52UccTI.d.cts +133 -0
- package/package.json +1 -1
- package/src/__tests__/add-captions-nemotron-pricing.test.ts +111 -0
- package/src/__tests__/dialogue-capabilities.test.ts +167 -6
- package/src/__tests__/extend-providers.test.ts +353 -26
- package/src/__tests__/fixtures/mask-composite-quote-parity.json +1 -1
- package/src/__tests__/fixtures/measured-input-quote-parity.json +1435 -0
- package/src/__tests__/fixtures/planned-length-quote-parity.json +1866 -0
- package/src/__tests__/fixtures/video-utility-quote-parity.json +2343 -0
- package/src/__tests__/flux-3-klein.test.ts +203 -0
- package/src/__tests__/gpt-image-2-6-formats.test.ts +3 -1
- package/src/__tests__/kling4-catalog.test.ts +1 -1
- package/src/__tests__/llm-models.test.ts +48 -13
- package/src/__tests__/llm-price-key.test.ts +12 -0
- package/src/__tests__/model-makers.test.ts +3 -0
- package/src/__tests__/node-runtime-keys.test.ts +7 -0
- package/src/__tests__/normalize-node-params.test.ts +147 -1
- package/src/__tests__/retired-lip-sync-providers.test.ts +43 -0
- package/src/__tests__/seedance-extend-source-credit-id.test.ts +89 -0
- package/src/__tests__/sequence-execution.test.ts +22 -1
- package/src/__tests__/speech-pricing.test.ts +62 -1
- package/src/__tests__/suno-credit-type.test.ts +21 -2
- package/src/__tests__/transcribe-capabilities.test.ts +4 -2
- package/src/__tests__/tts-capabilities.test.ts +160 -4
- package/src/__tests__/video-analysis-catalog-sync.test.ts +4 -2
- package/src/__tests__/video-analysis-pricing.test.ts +22 -9
- package/src/__tests__/video-subjects.test.ts +192 -0
- package/src/__tests__/wired-character-names.test.ts +142 -0
- package/src/caption-styles.ts +62 -0
- package/src/credit-estimators/add-captions-nemotron.ts +73 -0
- package/src/credit-estimators/index.ts +14 -0
- package/src/credit-estimators/speech.ts +57 -9
- package/src/credit-identifiers.ts +284 -13
- package/src/dialogue-capabilities.ts +220 -3
- package/src/dubbing-structure.ts +186 -0
- package/src/entries/captions.ts +2 -0
- package/src/entries/credits.ts +25 -1
- package/src/entries/entities.ts +2 -0
- package/src/entries/llm-models.ts +7 -0
- package/src/entries/media.ts +3 -1
- package/src/entries/model-catalog.ts +30 -0
- package/src/entries/models.ts +54 -0
- package/src/entries/nodes.ts +2 -0
- package/src/entries/pipeline.ts +1 -1
- package/src/entries/video.ts +8 -1
- package/src/flux-3-klein.ts +69 -0
- package/src/gemini-tts.ts +144 -0
- package/src/input-image-pricing.ts +23 -6
- package/src/llm-models.ts +130 -36
- package/src/model-catalog.ts +539 -25
- package/src/model-constants.ts +247 -25
- package/src/node-default-mappings.ts +3 -0
- package/src/node-runtime-keys.ts +3 -0
- package/src/normalize-node-params.ts +123 -2
- package/src/seedance-extend-rate.ts +116 -0
- package/src/sequence-execution.ts +24 -0
- package/src/transcribe-preflight.ts +23 -0
- package/src/tts-capabilities.ts +193 -1
- package/src/video-analysis-pricing.ts +39 -15
- package/src/video-character-refs.ts +160 -3
- package/src/wired-character-names.ts +134 -18
- package/src/wired-character-video-subjects.ts +63 -0
- package/dist/chunk-63H4C56Q.cjs +0 -38
- package/dist/chunk-63H4C56Q.cjs.map +0 -1
- package/dist/chunk-6M563QE6.js.map +0 -1
- package/dist/chunk-6TGB7ECA.cjs.map +0 -1
- package/dist/chunk-6XUG4L7X.cjs +0 -54
- package/dist/chunk-6XUG4L7X.cjs.map +0 -1
- package/dist/chunk-BLJUCPMV.cjs.map +0 -1
- package/dist/chunk-BMJVKYVB.js.map +0 -1
- package/dist/chunk-CZ5IQB3L.js.map +0 -1
- package/dist/chunk-F6WGGYQW.cjs.map +0 -1
- package/dist/chunk-GMBDLNLD.cjs.map +0 -1
- package/dist/chunk-GSKLPI3J.cjs.map +0 -1
- package/dist/chunk-HBXF6RUU.js +0 -31
- package/dist/chunk-HBXF6RUU.js.map +0 -1
- package/dist/chunk-HSHCCBIV.js.map +0 -1
- package/dist/chunk-HWQ2SYNA.js.map +0 -1
- package/dist/chunk-IY3Y462W.js +0 -42
- package/dist/chunk-IY3Y462W.js.map +0 -1
- package/dist/chunk-KHH54GRP.cjs.map +0 -1
- package/dist/chunk-KMGCHV6O.js.map +0 -1
- package/dist/chunk-LH72PQO2.cjs.map +0 -1
- package/dist/chunk-M5OCFGHF.cjs.map +0 -1
- package/dist/chunk-NIAFR5EE.js.map +0 -1
- package/dist/chunk-O7RZRUMZ.js.map +0 -1
- package/dist/chunk-OV3JTKBY.js.map +0 -1
- package/dist/chunk-PSKZKLDG.js.map +0 -1
- package/dist/chunk-Q6IES3U2.js.map +0 -1
- package/dist/chunk-TM5JYSJF.cjs.map +0 -1
- package/dist/chunk-WRSWH7US.cjs.map +0 -1
- package/dist/chunk-XBTYGQ6Z.js.map +0 -1
- package/dist/chunk-XGGZWA4A.cjs.map +0 -1
- package/dist/chunk-XGVJGNZW.cjs.map +0 -1
- package/dist/chunk-Y35JQPT6.cjs.map +0 -1
- package/dist/chunk-Y4GCJJPF.cjs.map +0 -1
- package/dist/chunk-YUER7TJG.js.map +0 -1
- package/dist/chunk-YX6TFX7H.js.map +0 -1
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest"
|
|
2
|
+
import {
|
|
3
|
+
characterReferencesFromWired,
|
|
4
|
+
characterVideoUrls,
|
|
5
|
+
pricedReferenceVideoUrls,
|
|
6
|
+
seatCharacterVideos,
|
|
7
|
+
videoCharacterClipsBilledAsReferenceVideo,
|
|
8
|
+
videoCharacterVideoCap,
|
|
9
|
+
videoCharacterVideoProviders,
|
|
10
|
+
} from "../entries/video.js"
|
|
11
|
+
import {
|
|
12
|
+
VIDEO_CHARACTER_CLIP_DURATION_LIMITS,
|
|
13
|
+
VIDEO_REF_LIMITS_BY_PROVIDER,
|
|
14
|
+
VIDEO_REF_VIDEO_DURATION_LIMITS,
|
|
15
|
+
checkCharacterClipDurations,
|
|
16
|
+
} from "../entries/models.js"
|
|
17
|
+
import { CHARACTER_NODE_DEFAULT_LABEL, wiredCharacterVideoUrls } from "../entries/entities.js"
|
|
18
|
+
import type { ConnectedReference } from "../types.js"
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Video subjects on Kling 4.0 / Kling 4.0 Flash (decided 2026-11-13): a
|
|
22
|
+
* character made from a short clip of itself. KIE takes at most 3 of them,
|
|
23
|
+
* counts them with the reference videos (5 in all) and bills their seconds as
|
|
24
|
+
* reference-video seconds — so the clip is SEATED among the reference videos,
|
|
25
|
+
* and every reference-video seam measures and prices it.
|
|
26
|
+
*/
|
|
27
|
+
const clip = (n: number) => `https://cdn.example/clip-${n}.mp4`
|
|
28
|
+
const ref = (n: number) => `https://cdn.example/ref-${n}.mp4`
|
|
29
|
+
const character = (videoUrl?: string) => ({ imageUrl: "https://cdn.example/p.png", description: "d", ...(videoUrl ? { videoUrl } : {}) })
|
|
30
|
+
|
|
31
|
+
describe("which models take video subjects (data)", () => {
|
|
32
|
+
it("Kling 4.0 and Kling 4.0 Flash, 3 each; nothing else", () => {
|
|
33
|
+
expect(videoCharacterVideoProviders()).toEqual(["kling-4", "kling-4-flash"])
|
|
34
|
+
expect(videoCharacterVideoCap("kling-4")).toBe(3)
|
|
35
|
+
expect(videoCharacterVideoCap("kling-4-flash")).toBe(3)
|
|
36
|
+
expect(videoCharacterVideoCap("gemini-omni-video")).toBe(0)
|
|
37
|
+
expect(videoCharacterVideoCap("seedance-2")).toBe(0)
|
|
38
|
+
expect(videoCharacterVideoCap(undefined)).toBe(0)
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
it("a model that takes video subjects bills reference-video seconds and bounds a clip at 3-8 s", () => {
|
|
42
|
+
for (const id of videoCharacterVideoProviders()) {
|
|
43
|
+
expect(VIDEO_REF_VIDEO_DURATION_LIMITS[id], id).toBeDefined()
|
|
44
|
+
expect(VIDEO_CHARACTER_CLIP_DURATION_LIMITS[id], id).toEqual({ minSec: 3, maxSec: 8 })
|
|
45
|
+
expect(VIDEO_REF_LIMITS_BY_PROVIDER[id]?.videos, id).toBe(5)
|
|
46
|
+
}
|
|
47
|
+
})
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
// Decided 2026-11-14, from a measured run: Kling 4.0 Flash bills a video subject
|
|
51
|
+
// like an image subject; Kling 4.0 keeps pricing it as a reference video.
|
|
52
|
+
describe("how a video subject is priced, per model (data)", () => {
|
|
53
|
+
it("Kling 4.0 bills it as reference video; Kling 4.0 Flash does not", () => {
|
|
54
|
+
expect(videoCharacterClipsBilledAsReferenceVideo("kling-4")).toBe(true)
|
|
55
|
+
expect(videoCharacterClipsBilledAsReferenceVideo("kling-4-flash")).toBe(false)
|
|
56
|
+
expect(videoCharacterClipsBilledAsReferenceVideo(undefined)).toBe(false)
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
it("pricedReferenceVideoUrls: a character's clip leaves the priced list on Flash only; plain reference videos stay", () => {
|
|
60
|
+
const seated = [ref(1), clip(1)]
|
|
61
|
+
const characters = [character(clip(1)), character()]
|
|
62
|
+
expect(pricedReferenceVideoUrls({ provider: "kling-4-flash", referenceVideoUrls: seated, characterReferences: characters })).toEqual([ref(1)])
|
|
63
|
+
expect(pricedReferenceVideoUrls({ provider: "kling-4-flash", referenceVideoUrls: [clip(1)], characterReferences: characters })).toEqual([])
|
|
64
|
+
const asSent = pricedReferenceVideoUrls({ provider: "kling-4", referenceVideoUrls: seated, characterReferences: characters })
|
|
65
|
+
expect(asSent).toBe(seated)
|
|
66
|
+
// Nothing to leave out: the same value.
|
|
67
|
+
const plain = [ref(1)]
|
|
68
|
+
expect(pricedReferenceVideoUrls({ provider: "kling-4-flash", referenceVideoUrls: plain, characterReferences: characters })).toBe(plain)
|
|
69
|
+
expect(pricedReferenceVideoUrls({ provider: "kling-4-flash", referenceVideoUrls: undefined, characterReferences: undefined })).toBeUndefined()
|
|
70
|
+
})
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
describe("seatCharacterVideos — a character's clip rides as one more reference video", () => {
|
|
74
|
+
it("no clip: the list as it came, the same value — within the model's cap", () => {
|
|
75
|
+
const refs = [ref(1)]
|
|
76
|
+
const out = seatCharacterVideos({ provider: "kling-4", referenceVideoUrls: refs, characterReferences: [character()] })
|
|
77
|
+
expect(out).toEqual({ ok: true, referenceVideoUrls: refs })
|
|
78
|
+
expect(out.ok && out.referenceVideoUrls).toBe(refs)
|
|
79
|
+
expect(seatCharacterVideos({ provider: "seedance-2", referenceVideoUrls: undefined, characterReferences: undefined })).toEqual({ ok: true, referenceVideoUrls: undefined })
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
it("clips follow the reference videos, in character order", () => {
|
|
83
|
+
expect(seatCharacterVideos({ provider: "kling-4-flash", referenceVideoUrls: [ref(1)], characterReferences: [character(clip(1)), character(), character(clip(2))] }))
|
|
84
|
+
.toEqual({ ok: true, referenceVideoUrls: [ref(1), clip(1), clip(2)] })
|
|
85
|
+
expect(seatCharacterVideos({ provider: "kling-4", referenceVideoUrls: undefined, characterReferences: [character(` ${clip(1)} `)] }))
|
|
86
|
+
.toEqual({ ok: true, referenceVideoUrls: [clip(1)] })
|
|
87
|
+
})
|
|
88
|
+
|
|
89
|
+
it("a clip already wired as a reference video keeps its seat (it is the subject only)", () => {
|
|
90
|
+
expect(seatCharacterVideos({ provider: "kling-4", referenceVideoUrls: [clip(1), ref(1)], characterReferences: [character(clip(1))] }))
|
|
91
|
+
.toEqual({ ok: true, referenceVideoUrls: [clip(1), ref(1)] })
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
it("refused on a model that takes none, naming the ones that do", () => {
|
|
95
|
+
const out = seatCharacterVideos({ provider: "gemini-omni-video", referenceVideoUrls: [], characterReferences: [character(clip(1))] })
|
|
96
|
+
expect(out.ok).toBe(false)
|
|
97
|
+
if (!out.ok) {
|
|
98
|
+
expect(out.code).toBe("character_video_unsupported")
|
|
99
|
+
expect(out.message).toContain("kling-4, kling-4-flash")
|
|
100
|
+
}
|
|
101
|
+
})
|
|
102
|
+
|
|
103
|
+
it("refused past 3 characters made from a video", () => {
|
|
104
|
+
const out = seatCharacterVideos({ provider: "kling-4", referenceVideoUrls: [], characterReferences: [1, 2, 3, 4].map((n) => character(clip(n))) })
|
|
105
|
+
expect(out.ok === false && out.code).toBe("character_videos_over_limit")
|
|
106
|
+
})
|
|
107
|
+
|
|
108
|
+
it("refused when two characters carry the same clip", () => {
|
|
109
|
+
const out = seatCharacterVideos({ provider: "kling-4", referenceVideoUrls: [], characterReferences: [character(clip(1)), character(clip(1))] })
|
|
110
|
+
expect(out.ok === false && out.code).toBe("character_video_shared")
|
|
111
|
+
})
|
|
112
|
+
|
|
113
|
+
it("refused when reference videos and clips together pass the model's 5 videos", () => {
|
|
114
|
+
const four = [1, 2, 3, 4].map(ref)
|
|
115
|
+
expect(seatCharacterVideos({ provider: "kling-4-flash", referenceVideoUrls: four, characterReferences: [character(clip(1))] }).ok).toBe(true)
|
|
116
|
+
const out = seatCharacterVideos({ provider: "kling-4-flash", referenceVideoUrls: four, characterReferences: [character(clip(1)), character(clip(2))] })
|
|
117
|
+
expect(out.ok === false && out.code).toBe("reference_videos_over_limit")
|
|
118
|
+
if (!out.ok) expect(out.message).toContain("This run has 6")
|
|
119
|
+
})
|
|
120
|
+
|
|
121
|
+
// Decided 2026-11-13: on a model whose reference videos and video subjects
|
|
122
|
+
// share one cap, plain reference videos past it are refused, never left out.
|
|
123
|
+
it("plain reference videos alone past 5 are refused on Kling 4.0 and Flash; another model's list is not judged", () => {
|
|
124
|
+
const six = [1, 2, 3, 4, 5, 6].map(ref)
|
|
125
|
+
for (const provider of ["kling-4", "kling-4-flash"]) {
|
|
126
|
+
const out = seatCharacterVideos({ provider, referenceVideoUrls: six, characterReferences: undefined })
|
|
127
|
+
expect(out.ok === false && out.code, provider).toBe("reference_videos_over_limit")
|
|
128
|
+
if (!out.ok) {
|
|
129
|
+
expect(out.message).toContain("This run has 6")
|
|
130
|
+
expect(out.message).not.toContain("from a character")
|
|
131
|
+
}
|
|
132
|
+
expect(seatCharacterVideos({ provider, referenceVideoUrls: six.slice(0, 5), characterReferences: [] }).ok).toBe(true)
|
|
133
|
+
}
|
|
134
|
+
expect(seatCharacterVideos({ provider: "seedance-2-5", referenceVideoUrls: six, characterReferences: undefined })).toEqual({ ok: true, referenceVideoUrls: six })
|
|
135
|
+
})
|
|
136
|
+
|
|
137
|
+
it("characterVideoUrls reads only non-empty string clips", () => {
|
|
138
|
+
expect(characterVideoUrls([character(clip(1)), character(), { videoUrl: " " }, { videoUrl: 7 }, null])).toEqual([clip(1)])
|
|
139
|
+
})
|
|
140
|
+
})
|
|
141
|
+
|
|
142
|
+
describe("checkCharacterClipDurations — 3-8 s, measured", () => {
|
|
143
|
+
it("in bounds passes; outside is refused with the clip's length", () => {
|
|
144
|
+
expect(checkCharacterClipDurations("kling-4", [3, 8, 5.5])).toEqual({ ok: true })
|
|
145
|
+
const short = checkCharacterClipDurations("kling-4-flash", [2.4])
|
|
146
|
+
expect(short.ok === false && short.code).toBe("video_too_long")
|
|
147
|
+
if (!short.ok) expect(short.message).toContain("one is 2.40 s")
|
|
148
|
+
expect(checkCharacterClipDurations("kling-4", [8.6]).ok).toBe(false)
|
|
149
|
+
// The measured length, rounded up to hundredths: 8.03 s never reads as 8.0.
|
|
150
|
+
const justOver = checkCharacterClipDurations("kling-4", [8.0281])
|
|
151
|
+
expect(justOver.ok === false && justOver.message).toContain("one is 8.03 s")
|
|
152
|
+
const tiny = checkCharacterClipDurations("kling-4", [8.001])
|
|
153
|
+
expect(tiny.ok === false && tiny.message).toContain("one is 8.01 s")
|
|
154
|
+
expect(checkCharacterClipDurations("seedance-2", [30])).toEqual({ ok: true })
|
|
155
|
+
})
|
|
156
|
+
|
|
157
|
+
// Decided 2026-11-13: a character's clip must be measured to be accepted.
|
|
158
|
+
it("a clip the probe could not read (NaN, 0) is refused, unlike a reference video", () => {
|
|
159
|
+
for (const d of [Number.NaN, 0]) {
|
|
160
|
+
const out = checkCharacterClipDurations("kling-4", [5, d])
|
|
161
|
+
expect(out.ok === false && out.code).toBe("character_video_unreadable")
|
|
162
|
+
}
|
|
163
|
+
})
|
|
164
|
+
})
|
|
165
|
+
|
|
166
|
+
describe("a wired Character node's clip reaches its character reference", () => {
|
|
167
|
+
const characterNode = (id: string, data: Record<string, unknown>) => ({ id, type: "character", data: { label: CHARACTER_NODE_DEFAULT_LABEL, characterName: "", ...data } })
|
|
168
|
+
const wire = (source: string) => ({ source, target: "gv", sourceHandle: "characterRef" })
|
|
169
|
+
|
|
170
|
+
it("wiredCharacterVideoUrls: by the slug the node goes by; the first clip of a merged name wins; a plain image wire gives none", () => {
|
|
171
|
+
const nodes = [
|
|
172
|
+
characterNode("a", { characterName: "Maya", subjectVideoUrl: clip(1) }),
|
|
173
|
+
characterNode("b", { characterName: "Maya", subjectVideoUrl: clip(2) }),
|
|
174
|
+
characterNode("u", { subjectVideoUrl: ` ${clip(3)} ` }),
|
|
175
|
+
characterNode("i", { characterName: "Leo", subjectVideoUrl: clip(4) }),
|
|
176
|
+
characterNode("n", { characterName: "Noa" }),
|
|
177
|
+
]
|
|
178
|
+
const edges = [wire("a"), wire("b"), wire("u"), { source: "i", target: "gv", sourceHandle: "image" }, wire("n")]
|
|
179
|
+
expect([...wiredCharacterVideoUrls("gv", nodes, edges)]).toEqual([["maya", clip(1)], ["character-1", clip(3)]])
|
|
180
|
+
})
|
|
181
|
+
|
|
182
|
+
it("characterReferencesFromWired carries the clip of the character it names", () => {
|
|
183
|
+
const entry = (slug: string, name: string): ConnectedReference => ({
|
|
184
|
+
id: `char_${slug}`, defaultName: name, source: "wired-character", url: `https://cdn.example/${slug}.png`, characterSlug: slug,
|
|
185
|
+
})
|
|
186
|
+
const refs = characterReferencesFromWired([entry("maya", "Maya"), entry("leo", "Leo")], new Map([["maya", clip(1)]]))
|
|
187
|
+
expect(refs.map((r) => [r.name, r.videoUrl])).toEqual([["Maya", clip(1)], ["Leo", undefined]])
|
|
188
|
+
expect("videoUrl" in refs[1]!).toBe(false)
|
|
189
|
+
// Without the map (a model that takes no video subjects): no clip at all.
|
|
190
|
+
expect(characterReferencesFromWired([entry("maya", "Maya")]).every((r) => !("videoUrl" in r))).toBe(true)
|
|
191
|
+
})
|
|
192
|
+
})
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
wiredCharacterNamesOf,
|
|
8
8
|
wiredCharacterBySlug,
|
|
9
9
|
wiredCharacterKey,
|
|
10
|
+
wiredCharacterSlug,
|
|
10
11
|
aliasRetiredCharacterMentions,
|
|
11
12
|
entityImageUrl,
|
|
12
13
|
type WiredCharacterSource,
|
|
@@ -129,6 +130,125 @@ describe("wiredCharacterNames — what each wired Character node is called by th
|
|
|
129
130
|
])
|
|
130
131
|
})
|
|
131
132
|
|
|
133
|
+
// Decided 2026-11-12: the same-name rule holds in every script, as for Latin.
|
|
134
|
+
describe("the same typed name in any script is one character", () => {
|
|
135
|
+
for (const [locale, typed] of [["en", "Maya"], ["ja", "マヤ"], ["he", "מאיה"], ["ko", "마야"]] as const) {
|
|
136
|
+
it(`${locale}: two "${typed}" nodes share one key; the next unnamed node takes the next number`, () => {
|
|
137
|
+
const m = wiredCharacterNames([named("a", typed), unnamed("u"), named("b", typed)])
|
|
138
|
+
expect(m.get("a")?.slug).toBe(m.get("b")?.slug)
|
|
139
|
+
expect([m.get("a")?.name, m.get("b")?.name]).toEqual([typed, typed])
|
|
140
|
+
expect(new Set([...m.values()].map((n) => n.slug)).size).toBe(2)
|
|
141
|
+
expect(m.get("u")?.name).toBe(locale === "en" ? "Character 1" : "Character 2")
|
|
142
|
+
})
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
it("non-Latin: the duplicate takes no number of its own", () => {
|
|
146
|
+
expect(names([named("a", "マヤ"), unnamed("u"), named("b", "マヤ")])).toEqual([
|
|
147
|
+
["a", "マヤ", "character-1"],
|
|
148
|
+
["u", "Character 2", "character-2"],
|
|
149
|
+
["b", "マヤ", "character-1"],
|
|
150
|
+
])
|
|
151
|
+
})
|
|
152
|
+
|
|
153
|
+
it("Latin is unchanged: Maya / maya / MAYA and 'Maya Lee' / 'maya-lee' are one by their slug", () => {
|
|
154
|
+
expect(names([named("a", "Maya"), named("b", "maya"), named("c", "MAYA")])).toEqual([
|
|
155
|
+
["a", "Maya", "maya"],
|
|
156
|
+
["b", "maya", "maya"],
|
|
157
|
+
["c", "MAYA", "maya"],
|
|
158
|
+
])
|
|
159
|
+
expect(names([named("a", "Maya Lee"), named("b", "maya-lee")])).toEqual([
|
|
160
|
+
["a", "Maya Lee", "maya-lee"],
|
|
161
|
+
["b", "maya-lee", "maya-lee"],
|
|
162
|
+
])
|
|
163
|
+
})
|
|
164
|
+
|
|
165
|
+
it("two different non-Latin names stay two (he / ja / ko)", () => {
|
|
166
|
+
for (const [x, y] of [["מאיה", "נועה"], ["マヤ", "レオ"], ["마야", "레오"]] as const) {
|
|
167
|
+
expect(names([named("a", x), named("b", y)])).toEqual([
|
|
168
|
+
["a", x, "character-1"],
|
|
169
|
+
["b", y, "character-2"],
|
|
170
|
+
])
|
|
171
|
+
}
|
|
172
|
+
})
|
|
173
|
+
|
|
174
|
+
it("the same name as Unicode reads it: half-width katakana, decomposed Hangul, letter case, spacing", () => {
|
|
175
|
+
const same = (x: string, y: string) => {
|
|
176
|
+
const m = wiredCharacterNames([named("a", x), named("b", y)])
|
|
177
|
+
return m.get("a")?.slug === m.get("b")?.slug
|
|
178
|
+
}
|
|
179
|
+
expect(same("マヤ", "マヤ")).toBe(true)
|
|
180
|
+
expect(same("마야", "마야".normalize("NFD"))).toBe(true)
|
|
181
|
+
expect(same("Мая", "мая")).toBe(true)
|
|
182
|
+
expect(same("マヤ・リー", "マヤ リー")).toBe(true)
|
|
183
|
+
// A combining mark is part of the name: ガ (ga) is not カ (ka).
|
|
184
|
+
expect(same("ガク", "カク")).toBe(false)
|
|
185
|
+
})
|
|
186
|
+
|
|
187
|
+
// Decided 2026-11-13: a name with a letter of another script is the WHOLE
|
|
188
|
+
// name, never its Latin remainder.
|
|
189
|
+
it("mixed-script names that share a Latin remainder are different characters, on their own keys", () => {
|
|
190
|
+
expect(names([named("a", "マヤ1"), named("b", "レオ1")])).toEqual([
|
|
191
|
+
["a", "マヤ1", "character-1"],
|
|
192
|
+
["b", "レオ1", "character-2"],
|
|
193
|
+
])
|
|
194
|
+
expect(names([named("a", "マヤ A"), named("b", "A")])).toEqual([
|
|
195
|
+
["a", "マヤ A", "character-1"],
|
|
196
|
+
["b", "A", "a"],
|
|
197
|
+
])
|
|
198
|
+
expect(names([named("b", "A"), unnamed("u"), named("a", "マヤ A")])).toEqual([
|
|
199
|
+
["b", "A", "a"],
|
|
200
|
+
["u", "Character 1", "character-1"],
|
|
201
|
+
["a", "マヤ A", "character-2"],
|
|
202
|
+
])
|
|
203
|
+
})
|
|
204
|
+
|
|
205
|
+
it("the same mixed-script name twice is one character", () => {
|
|
206
|
+
expect(names([named("a", "マヤ1"), named("b", "マヤ1")])).toEqual([
|
|
207
|
+
["a", "マヤ1", "1"],
|
|
208
|
+
["b", "マヤ1", "1"],
|
|
209
|
+
])
|
|
210
|
+
const m = wiredCharacterNames([named("a", "マヤ A"), named("b", "マヤ a"), named("c", "レオ1"), named("d", "レオ1"), named("e", "ハナ1")])
|
|
211
|
+
expect(m.get("a")?.slug).toBe(m.get("b")?.slug)
|
|
212
|
+
expect(m.get("c")?.slug).toBe(m.get("d")?.slug)
|
|
213
|
+
expect(new Set([...m.values()].map((n) => n.slug)).size).toBe(3)
|
|
214
|
+
})
|
|
215
|
+
|
|
216
|
+
it("a mixed-script name no other character claims keeps its old mention key", () => {
|
|
217
|
+
expect(names([named("a", "マヤ A"), named("b", "Leo"), unnamed("u")])).toEqual([
|
|
218
|
+
["a", "マヤ A", "a"],
|
|
219
|
+
["b", "Leo", "leo"],
|
|
220
|
+
["u", "Character 1", "character-1"],
|
|
221
|
+
])
|
|
222
|
+
})
|
|
223
|
+
|
|
224
|
+
it("a name whose letters are all Latin, accents included, keeps its slug as before", () => {
|
|
225
|
+
expect(names([named("a", "José"), named("b", "Ana-María")])).toEqual([
|
|
226
|
+
["a", "José", "jos"],
|
|
227
|
+
["b", "Ana-María", "ana-mar-a"],
|
|
228
|
+
])
|
|
229
|
+
})
|
|
230
|
+
|
|
231
|
+
// An all-Latin name the slug cannot spell follows the same-name rule (decided 2026-11-13).
|
|
232
|
+
it("all-Latin names the slug cannot spell: the same one twice is one character, two different ones stay two", () => {
|
|
233
|
+
expect(names([named("a", "Ñ"), named("b", "Ñ")])).toEqual([
|
|
234
|
+
["a", "Ñ", "character-1"],
|
|
235
|
+
["b", "Ñ", "character-1"],
|
|
236
|
+
])
|
|
237
|
+
expect(names([named("a", "Ñ"), named("b", "Ö")])).toEqual([
|
|
238
|
+
["a", "Ñ", "character-1"],
|
|
239
|
+
["b", "Ö", "character-2"],
|
|
240
|
+
])
|
|
241
|
+
expect(names([named("a", "Ö"), named("b", "ö")]).map(([, , slug]) => slug)).toEqual(["character-1", "character-1"])
|
|
242
|
+
})
|
|
243
|
+
|
|
244
|
+
it("a name with no letter or digit never matches another", () => {
|
|
245
|
+
expect(names([named("a", "!!!"), named("b", "!!!")])).toEqual([
|
|
246
|
+
["a", "!!!", "character-1"],
|
|
247
|
+
["b", "!!!", "character-2"],
|
|
248
|
+
])
|
|
249
|
+
})
|
|
250
|
+
})
|
|
251
|
+
|
|
132
252
|
it("unnamed flags the nodes with no name of their own (a slug-less typed name is not one)", () => {
|
|
133
253
|
const m = wiredCharacterNames([named("a", "Maya"), unnamed("b"), named("c", "マヤ")])
|
|
134
254
|
expect(m.get("a")?.unnamed).toBe(false)
|
|
@@ -167,6 +287,28 @@ describe("wiredCharacterKey — where a Character node's own elements are filed"
|
|
|
167
287
|
expect(wiredCharacterKey(m, "c", { characterName: "Maya" })).toBe("maya")
|
|
168
288
|
expect(wiredCharacterKey(m, "d", { label: CHARACTER_NODE_DEFAULT_LABEL })).toBe("node:d")
|
|
169
289
|
})
|
|
290
|
+
it("a non-Latin name wired only as a plain image: the key of the wired character with the same name", () => {
|
|
291
|
+
const withMaya = wiredCharacterNames([unnamed("b"), named("a", "マヤ")])
|
|
292
|
+
expect(wiredCharacterKey(withMaya, "c", { characterName: "マヤ" })).toBe("character-2")
|
|
293
|
+
expect(wiredCharacterSlug(withMaya, "c", { characterName: "マヤ" })).toBe("character-2")
|
|
294
|
+
// No wired character has it: a key of its own, never an unnamed node's.
|
|
295
|
+
expect(wiredCharacterKey(withMaya, "d", { characterName: "レオ" })).toBe("node:d")
|
|
296
|
+
expect(wiredCharacterSlug(withMaya, "d", { characterName: "レオ" })).toBe("")
|
|
297
|
+
})
|
|
298
|
+
it("a mixed-script name wired only as a plain image is never filed under a Latin character sharing its remainder", () => {
|
|
299
|
+
const withA = wiredCharacterNames([named("b", "A"), named("m", "マヤ A")])
|
|
300
|
+
expect(wiredCharacterKey(withA, "c", { characterName: "マヤ A" })).toBe(withA.get("m")!.slug)
|
|
301
|
+
expect(wiredCharacterKey(withA, "c", { characterName: "レオ A" })).toBe("node:c")
|
|
302
|
+
expect(wiredCharacterKey(withA, "d", { characterName: "A" })).toBe("a")
|
|
303
|
+
})
|
|
304
|
+
it("a Latin name wired only as a plain image is never filed under a mixed-script character that goes by its slug", () => {
|
|
305
|
+
const onlyMaya = wiredCharacterNames([named("m", "マヤ A")])
|
|
306
|
+
expect(onlyMaya.get("m")?.slug).toBe("a")
|
|
307
|
+
expect(wiredCharacterKey(onlyMaya, "c", { characterName: "A" })).toBe("node:c")
|
|
308
|
+
expect(wiredCharacterSlug(onlyMaya, "c", { characterName: "A" })).toBe("")
|
|
309
|
+
// With no wired character on its slug, a Latin name keeps its own, as before.
|
|
310
|
+
expect(wiredCharacterKey(onlyMaya, "d", { characterName: "Leo" })).toBe("leo")
|
|
311
|
+
})
|
|
170
312
|
})
|
|
171
313
|
|
|
172
314
|
describe("aliasRetiredCharacterMentions — a mention saved before unnamed characters were numbered", () => {
|
package/src/caption-styles.ts
CHANGED
|
@@ -129,6 +129,68 @@ export function captionRoutesToRemotion(input: {
|
|
|
129
129
|
return false
|
|
130
130
|
}
|
|
131
131
|
|
|
132
|
+
/**
|
|
133
|
+
* Is this render's caption source a STATIC TEXT BLOCK — the caller's `text`,
|
|
134
|
+
* burned once for the whole clip — rather than timed words?
|
|
135
|
+
*
|
|
136
|
+
* On `subtitle`, `text` IS the caption: one block, `\n` a forced line break,
|
|
137
|
+
* never transcribed over, whichever renderer draws it (the cheap FFmpeg drawtext
|
|
138
|
+
* burn with no styling lever, the Remotion SubtitleOverlay with one). On a
|
|
139
|
+
* KINETIC style the same `text` stays what it always was — a FALLBACK, spread
|
|
140
|
+
* evenly across the clip as synthetic word timings when transcription returns
|
|
141
|
+
* nothing.
|
|
142
|
+
*
|
|
143
|
+
* Source precedence is unchanged: `captions[]` > wired transcript > (`text` on
|
|
144
|
+
* subtitle) > auto-transcription. `auto_transcribe` is deliberately NOT read: on
|
|
145
|
+
* a subtitle the caller's text wins either way.
|
|
146
|
+
*
|
|
147
|
+
* Shared by the WORKER (which must not pay for a transcription it then discards)
|
|
148
|
+
* and the ROUTE/DAG ingress, so the two cannot disagree about where the words
|
|
149
|
+
* come from.
|
|
150
|
+
*/
|
|
151
|
+
export function isStaticTextCaptionSource(input: {
|
|
152
|
+
style?: string | null
|
|
153
|
+
text?: string | null
|
|
154
|
+
captions?: readonly unknown[] | null
|
|
155
|
+
transcript?: unknown
|
|
156
|
+
segments?: readonly unknown[] | null
|
|
157
|
+
}): boolean {
|
|
158
|
+
if (input.segments && input.segments.length > 0) return false
|
|
159
|
+
if (isKineticCaptionStyle(input.style)) return false
|
|
160
|
+
if (input.captions && input.captions.length > 0) return false
|
|
161
|
+
if (input.transcript !== undefined && input.transcript !== null) return false
|
|
162
|
+
return typeof input.text === "string" && /\S/.test(input.text)
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Whether an Add Captions render transcribes its audio: it carries no caption
|
|
167
|
+
* source of its own — no captions, no wired transcript, no static text block —
|
|
168
|
+
* auto-transcribe is not turned off, and its segments (when it has any) do not
|
|
169
|
+
* all carry their own text or captions. The worker decides with it; the route's
|
|
170
|
+
* credit guard asks it so a request is judged on its transcription model only
|
|
171
|
+
* when one will run, and every place that prices a run on an engine charged by
|
|
172
|
+
* the video's length (Nemotron 3.5 Transcribe) holds that price only when it does.
|
|
173
|
+
*/
|
|
174
|
+
export function captionsNeedTranscription(input: {
|
|
175
|
+
style?: string | null
|
|
176
|
+
text?: string | null
|
|
177
|
+
captions?: readonly unknown[] | null
|
|
178
|
+
transcript?: unknown
|
|
179
|
+
segments?: ReadonlyArray<{ readonly text?: unknown; readonly captions?: readonly unknown[] | null }> | null
|
|
180
|
+
auto_transcribe?: boolean | null
|
|
181
|
+
}): boolean {
|
|
182
|
+
const hasSegments = !!(input.segments && input.segments.length > 0)
|
|
183
|
+
const hasTranscript = input.transcript !== undefined && input.transcript !== null
|
|
184
|
+
const someSegmentNeedsShared = hasSegments && input.segments!.some((s) => !(s.text || (s.captions && s.captions.length > 0)))
|
|
185
|
+
return (
|
|
186
|
+
!isStaticTextCaptionSource(input) &&
|
|
187
|
+
!input.captions?.length &&
|
|
188
|
+
!hasTranscript &&
|
|
189
|
+
input.auto_transcribe !== false &&
|
|
190
|
+
(!hasSegments || someSegmentNeedsShared)
|
|
191
|
+
)
|
|
192
|
+
}
|
|
193
|
+
|
|
132
194
|
/**
|
|
133
195
|
* `maxWordsPerLine` — caps how many words a caption LINE (or tiktok-words page)
|
|
134
196
|
* may hold, on top of the frame-width budget, sentence ends and pauses that
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Add Captions transcribing on Nemotron 3.5 Transcribe — ONE charge for the
|
|
3
|
+
* render and its transcription (decided 2026-11-13).
|
|
4
|
+
*
|
|
5
|
+
* Every Add Captions render that transcribes is a Remotion render
|
|
6
|
+
* (`captionRoutesToRemotion`), billed at the kinetic row. On the other engines
|
|
7
|
+
* that flat row covers the transcription too. Nemotron is priced by the
|
|
8
|
+
* video's length, so its caption run holds
|
|
9
|
+
* `add-captions:kinetic:nemotron:<N>m` (N = started minutes of the video,
|
|
10
|
+
* 1..60): the kinetic row plus Nemotron's own per-minute price (its four-minute
|
|
11
|
+
* rate row × N ÷ 4, rounded up once), summed into one base and marked up once
|
|
12
|
+
* — never a row of its own, so a retune of either row moves every price
|
|
13
|
+
* together. The id keeps the `add-captions` prefix, so Add Captions' margin
|
|
14
|
+
* applies to the whole charge.
|
|
15
|
+
*
|
|
16
|
+
* It is held only when a transcription will actually run on Nemotron; a
|
|
17
|
+
* Nemotron node that brings its own captions, transcript or static text holds
|
|
18
|
+
* the plain kinetic row. Like the Transcribe node's id it is the HOLD: the run
|
|
19
|
+
* is charged for the minutes the provider reports it decoded, up or down
|
|
20
|
+
* (backend `lib/nemotron-transcribe-settle.ts`).
|
|
21
|
+
*/
|
|
22
|
+
import {
|
|
23
|
+
NEMOTRON_TRANSCRIBE_PRICING,
|
|
24
|
+
nemotronTranscribeBaseCredits,
|
|
25
|
+
nemotronTranscribeStartedMinutes,
|
|
26
|
+
} from "./nemotron-transcribe.js"
|
|
27
|
+
|
|
28
|
+
/** The Remotion render's row — every Add Captions render that transcribes. */
|
|
29
|
+
export const ADD_CAPTIONS_KINETIC_CREDIT_ID = "add-captions:kinetic"
|
|
30
|
+
|
|
31
|
+
/** The prefix of the per-minute ids a Nemotron caption run holds. */
|
|
32
|
+
export const ADD_CAPTIONS_NEMOTRON_ID_PREFIX = `${ADD_CAPTIONS_KINETIC_CREDIT_ID}:nemotron`
|
|
33
|
+
|
|
34
|
+
/** `add-captions:kinetic:nemotron:<N>m` for N started minutes (1..60, clamped). */
|
|
35
|
+
export function addCaptionsNemotronMinutesId(minutes: number): string {
|
|
36
|
+
const n = Math.min(NEMOTRON_TRANSCRIBE_PRICING.MAX_MINUTES, Math.max(1, Math.ceil(minutes)))
|
|
37
|
+
return `${ADD_CAPTIONS_NEMOTRON_ID_PREFIX}:${n}m`
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** The id a Nemotron caption run on a video of `durationSec` seconds holds (its started minutes). */
|
|
41
|
+
export function addCaptionsNemotronCreditId(durationSec: number | null | undefined): string {
|
|
42
|
+
return addCaptionsNemotronMinutesId(nemotronTranscribeStartedMinutes(durationSec))
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* The id a QUOTE names for a video of `durationSec` seconds — every estimate
|
|
47
|
+
* before a run. A known length is the id its run holds; an UNKNOWN length is
|
|
48
|
+
* the 60-minute id, the most any run can be charged (a run measures the video
|
|
49
|
+
* first, holds 60 minutes for one whose length cannot be read, and refuses one
|
|
50
|
+
* over 60 minutes).
|
|
51
|
+
*/
|
|
52
|
+
export function addCaptionsNemotronQuoteCreditId(durationSec: number | null | undefined): string {
|
|
53
|
+
const known = typeof durationSec === "number" && Number.isFinite(durationSec) && durationSec > 0
|
|
54
|
+
return addCaptionsNemotronCreditId(known ? durationSec : NEMOTRON_TRANSCRIBE_PRICING.MAX_DURATION_SEC)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** The minutes of an `add-captions:kinetic:nemotron:<N>m` id (1 ≤ N ≤ 60), or `undefined` for any other id. */
|
|
58
|
+
export function parseAddCaptionsNemotronCreditId(id: string): { minutes: number } | undefined {
|
|
59
|
+
const m = /^add-captions:kinetic:nemotron:(\d+)m$/.exec(id)
|
|
60
|
+
if (!m) return undefined
|
|
61
|
+
const minutes = Number(m[1])
|
|
62
|
+
if (!Number.isInteger(minutes) || minutes < 1 || minutes > NEMOTRON_TRANSCRIBE_PRICING.MAX_MINUTES) return undefined
|
|
63
|
+
return { minutes }
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* The base of a Nemotron caption run of `minutes` started minutes: the kinetic
|
|
68
|
+
* row's base plus Nemotron's per-minute base for those minutes (`ratePerBlock`
|
|
69
|
+
* credits per four minutes, rounded up once). Marked up once, as one charge.
|
|
70
|
+
*/
|
|
71
|
+
export function addCaptionsNemotronBaseCredits(kineticBase: number, ratePerBlock: number, minutes: number): number {
|
|
72
|
+
return kineticBase + nemotronTranscribeBaseCredits(ratePerBlock, minutes)
|
|
73
|
+
}
|
|
@@ -46,9 +46,13 @@ export {
|
|
|
46
46
|
SPEECH_PRICE_UNIT_CHARS,
|
|
47
47
|
SPEECH_FLOOR_UNITS,
|
|
48
48
|
SPEECH_UNIT_CREDIT_SUFFIX,
|
|
49
|
+
SPEECH_PER_1K_CREDIT_SUFFIX,
|
|
49
50
|
speechUnitCreditId,
|
|
51
|
+
speechRowUnits,
|
|
52
|
+
speechRowCredits,
|
|
50
53
|
speechPriceUnits,
|
|
51
54
|
speechCredits,
|
|
55
|
+
speechCreditsFor,
|
|
52
56
|
speechQuoteCreditId,
|
|
53
57
|
parseSpeechQuoteCreditId,
|
|
54
58
|
isSpeechLengthPriceId,
|
|
@@ -92,6 +96,16 @@ export {
|
|
|
92
96
|
nemotronTranscribeBaseCredits,
|
|
93
97
|
} from "./nemotron-transcribe.js"
|
|
94
98
|
|
|
99
|
+
export {
|
|
100
|
+
ADD_CAPTIONS_KINETIC_CREDIT_ID,
|
|
101
|
+
ADD_CAPTIONS_NEMOTRON_ID_PREFIX,
|
|
102
|
+
addCaptionsNemotronMinutesId,
|
|
103
|
+
addCaptionsNemotronCreditId,
|
|
104
|
+
addCaptionsNemotronQuoteCreditId,
|
|
105
|
+
parseAddCaptionsNemotronCreditId,
|
|
106
|
+
addCaptionsNemotronBaseCredits,
|
|
107
|
+
} from "./add-captions-nemotron.js"
|
|
108
|
+
|
|
95
109
|
export {
|
|
96
110
|
VIDEO_OVERLAY_PRICING,
|
|
97
111
|
VIDEO_OVERLAY_REMEASURE_SLACK_SEC,
|
|
@@ -18,6 +18,14 @@
|
|
|
18
18
|
* whole number of units times a charged unit price never under-quotes the
|
|
19
19
|
* charge (the same property the per-second video rows rely on).
|
|
20
20
|
*
|
|
21
|
+
* A model whose rate is below one credit per 100 characters (a row holds
|
|
22
|
+
* whole credits) quotes its row per 1,000 instead — `<model>:per-1k-chars`,
|
|
23
|
+
* its sheet's `ratePer1kChars` (decided 2026-11-12). The count is the same
|
|
24
|
+
* (started 100s, at least 8), and a request costs its hundreds × the row ÷ 10,
|
|
25
|
+
* rounded up once (`speechRowCredits`). Its request quote keeps the one id
|
|
26
|
+
* shape, `<model>:per-100-chars:<N>u`, N in started hundreds, so a client
|
|
27
|
+
* that builds that id quotes every model alike.
|
|
28
|
+
*
|
|
21
29
|
* Decided 2026-10-06. Every name here is a published contract.
|
|
22
30
|
*/
|
|
23
31
|
import { canonicalTtsProvider, findTtsCapabilities } from "../tts-capabilities.js"
|
|
@@ -33,13 +41,39 @@ export const SPEECH_FLOOR_UNITS = 8
|
|
|
33
41
|
/** Appended to a speech model's id to name its per-unit price row. */
|
|
34
42
|
export const SPEECH_UNIT_CREDIT_SUFFIX = ":per-100-chars"
|
|
35
43
|
|
|
44
|
+
/** Appended to a speech model's id to name its rate row quoted per 1,000 characters (`TtsCapabilities.ratePer1kChars`). */
|
|
45
|
+
export const SPEECH_PER_1K_CREDIT_SUFFIX = ":per-1k-chars"
|
|
46
|
+
|
|
36
47
|
/**
|
|
37
|
-
*
|
|
48
|
+
* How many units (started 100 characters) one rate row of the model prices:
|
|
49
|
+
* 10 for a model whose row is quoted per 1,000 characters, else 1. The
|
|
50
|
+
* legacy alias resolved; an id with no speech sheet is 1.
|
|
51
|
+
*/
|
|
52
|
+
export function speechRowUnits(modelId: string): 1 | 10 {
|
|
53
|
+
const id = canonicalTtsProvider(modelId)
|
|
54
|
+
return (findTtsCapabilities(id) ?? findDialogueCapabilities(id))?.ratePer1kChars ? 10 : 1
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* The price-row id of the rate the model a request runs as is charged at:
|
|
59
|
+
* `<model>:per-100-chars` (one unit), or `<model>:per-1k-chars` for a model
|
|
60
|
+
* quoted per 1,000 characters ({@link speechRowUnits}). The legacy
|
|
38
61
|
* `elevenlabs` alias prices on turbo's row, as it runs on turbo; any other id
|
|
39
62
|
* (including the dialogue model) is used as given.
|
|
40
63
|
*/
|
|
41
64
|
export function speechUnitCreditId(modelId: string): string {
|
|
42
|
-
|
|
65
|
+
const id = canonicalTtsProvider(modelId)
|
|
66
|
+
return `${id}${speechRowUnits(id) === 10 ? SPEECH_PER_1K_CREDIT_SUFFIX : SPEECH_UNIT_CREDIT_SUFFIX}`
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Base credits of `units` (started hundreds) at a rate row of `rowCredits`
|
|
71
|
+
* that prices `rowUnits` units: `ceil(units × row ÷ rowUnits)`, in whole
|
|
72
|
+
* numbers so it never rounds a hair high. With `rowUnits` 1 it is exactly
|
|
73
|
+
* units × the row (every per-100 row is a whole number).
|
|
74
|
+
*/
|
|
75
|
+
export function speechRowCredits(units: number, rowCredits: number, rowUnits: number = 1): number {
|
|
76
|
+
return rowUnits === 1 ? units * rowCredits : Math.ceil((units * rowCredits) / rowUnits)
|
|
43
77
|
}
|
|
44
78
|
|
|
45
79
|
/**
|
|
@@ -57,6 +91,16 @@ export function speechCredits(chars: number, perUnitCredits: number): number {
|
|
|
57
91
|
return speechPriceUnits(chars) * perUnitCredits
|
|
58
92
|
}
|
|
59
93
|
|
|
94
|
+
/**
|
|
95
|
+
* Base credits for `chars` characters on `modelId` at its rate row
|
|
96
|
+
* (`speechUnitCreditId(modelId)`, read as `rowCredits`): per-100 or per-1K,
|
|
97
|
+
* whichever the model is quoted in. What every seam that reserves speech, and
|
|
98
|
+
* every client that quotes it, computes.
|
|
99
|
+
*/
|
|
100
|
+
export function speechCreditsFor(modelId: string, chars: number, rowCredits: number): number {
|
|
101
|
+
return speechRowCredits(speechPriceUnits(chars), rowCredits, speechRowUnits(modelId))
|
|
102
|
+
}
|
|
103
|
+
|
|
60
104
|
/**
|
|
61
105
|
* The id of the exact charge of a whole request of `units` units on `modelId`:
|
|
62
106
|
* `<model>:per-100-chars:<N>u`. Never a row of its own — a price lookup prices
|
|
@@ -65,17 +109,20 @@ export function speechCredits(chars: number, perUnitCredits: number): number {
|
|
|
65
109
|
* row it is priced from.
|
|
66
110
|
*/
|
|
67
111
|
export function speechQuoteCreditId(modelId: string, units: number): string {
|
|
68
|
-
|
|
112
|
+
// Always the per-100 shape, whatever the model's rate row: N is started hundreds.
|
|
113
|
+
return unitQuoteCreditId(`${canonicalTtsProvider(modelId)}${SPEECH_UNIT_CREDIT_SUFFIX}`, units)
|
|
69
114
|
}
|
|
70
115
|
|
|
71
116
|
/** A `<model>:per-100-chars:<N>u` id, read back. */
|
|
72
117
|
export interface SpeechQuoteCreditIdParts {
|
|
73
118
|
/** The speech model (canonical id) the request runs as. */
|
|
74
119
|
model: string
|
|
75
|
-
/** Its `<model>:per-100-chars`
|
|
120
|
+
/** Its rate row: `<model>:per-100-chars`, or `<model>:per-1k-chars` for a model quoted per 1,000. */
|
|
76
121
|
unitId: string
|
|
77
122
|
/** Units priced: at least the floor, at most the model's per-request cap in started hundreds. */
|
|
78
123
|
units: number
|
|
124
|
+
/** How many units one `unitId` row prices (10 for a per-1,000 row, else 1): the request is `speechRowCredits(units, row, rowUnits)`. */
|
|
125
|
+
rowUnits: 1 | 10
|
|
79
126
|
}
|
|
80
127
|
|
|
81
128
|
const SPEECH_QUOTE_ID = /^(.+):per-100-chars:(\d{1,6})u$/
|
|
@@ -96,16 +143,17 @@ export function parseSpeechQuoteCreditId(id: string): SpeechQuoteCreditIdParts |
|
|
|
96
143
|
if (!caps) return undefined
|
|
97
144
|
const units = Number(m[2])
|
|
98
145
|
if (!Number.isInteger(units) || units < SPEECH_FLOOR_UNITS || units > speechPriceUnits(caps.maxChars)) return undefined
|
|
99
|
-
return { model, unitId: speechUnitCreditId(model), units }
|
|
146
|
+
return { model, unitId: speechUnitCreditId(model), units, rowUnits: speechRowUnits(model) }
|
|
100
147
|
}
|
|
101
148
|
|
|
102
149
|
/**
|
|
103
150
|
* Whether an id is a length price of speech — a `<model>:per-100-chars` unit
|
|
104
|
-
* row or a `<model>:per-100-chars:<N>u`
|
|
105
|
-
*
|
|
151
|
+
* row, a `<model>:per-1k-chars` rate row or a `<model>:per-100-chars:<N>u`
|
|
152
|
+
* request quote — by its shape alone. All are served only while the server
|
|
153
|
+
* prices speech by length.
|
|
106
154
|
*/
|
|
107
155
|
export function isSpeechLengthPriceId(id: string): boolean {
|
|
108
|
-
return typeof id === "string" &&
|
|
156
|
+
return typeof id === "string" && /(?::per-100-chars(?::\d+u)?|:per-1k-chars)$/.test(id)
|
|
109
157
|
}
|
|
110
158
|
|
|
111
159
|
/**
|
|
@@ -115,5 +163,5 @@ export function isSpeechLengthPriceId(id: string): boolean {
|
|
|
115
163
|
*/
|
|
116
164
|
export function speechLengthPriceModel(id: string): string | undefined {
|
|
117
165
|
if (!isSpeechLengthPriceId(id)) return undefined
|
|
118
|
-
return id.replace(
|
|
166
|
+
return id.replace(/(?::per-100-chars(?::\d+u)?|:per-1k-chars)$/, "")
|
|
119
167
|
}
|