vidspotai-shared 1.0.39 → 1.0.41
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/lib/globals/aiModels/enums.d.ts +1 -0
- package/lib/globals/aiModels/enums.d.ts.map +1 -1
- package/lib/globals/aiModels/enums.js +1 -0
- package/lib/globals/aiModels/providers/google.d.ts.map +1 -1
- package/lib/globals/aiModels/providers/google.js +26 -4
- package/lib/globals/aiModels/providers/kling.d.ts.map +1 -1
- package/lib/globals/aiModels/providers/kling.js +11 -3
- package/lib/globals/aiModels/types.d.ts +36 -0
- package/lib/globals/aiModels/types.d.ts.map +1 -1
- package/lib/globals/ttsModels/index.d.ts +2 -0
- package/lib/globals/ttsModels/index.d.ts.map +1 -1
- package/lib/globals/ttsModels/index.js +3 -1
- package/lib/globals/ttsModels/providers/elevenlabs.d.ts.map +1 -1
- package/lib/globals/ttsModels/providers/elevenlabs.js +16 -0
- package/lib/globals/ttsModels/types.d.ts +16 -0
- package/lib/globals/ttsModels/types.d.ts.map +1 -1
- package/lib/globals/types.d.ts +9 -2
- package/lib/globals/types.d.ts.map +1 -1
- package/lib/globals/types.js +7 -0
- package/lib/models/video.model.d.ts +2 -0
- package/lib/models/video.model.d.ts.map +1 -1
- package/lib/services/aiGen/aiGenFactory.service.d.ts.map +1 -1
- package/lib/services/aiGen/aiGenFactory.service.js +1 -0
- package/lib/services/aiGen/providers/alibaba/alibaba.d.ts +1 -1
- package/lib/services/aiGen/providers/alibaba/alibaba.d.ts.map +1 -1
- package/lib/services/aiGen/providers/alibaba/alibaba.js +8 -2
- package/lib/services/aiGen/providers/azure/azure.service.d.ts +1 -1
- package/lib/services/aiGen/providers/azure/azure.service.d.ts.map +1 -1
- package/lib/services/aiGen/providers/azure/azure.service.js +7 -2
- package/lib/services/aiGen/providers/bytedance/bytedance.service.js +3 -3
- package/lib/services/aiGen/providers/google/google.service.d.ts +1 -1
- package/lib/services/aiGen/providers/google/google.service.d.ts.map +1 -1
- package/lib/services/aiGen/providers/google/google.service.js +13 -4
- package/lib/services/aiGen/providers/kling/kling.service.d.ts +1 -1
- package/lib/services/aiGen/providers/kling/kling.service.d.ts.map +1 -1
- package/lib/services/aiGen/providers/kling/kling.service.js +51 -13
- package/lib/services/aiGen/providers/minimax/minimax.service.d.ts +1 -1
- package/lib/services/aiGen/providers/minimax/minimax.service.d.ts.map +1 -1
- package/lib/services/aiGen/providers/minimax/minimax.service.js +7 -2
- package/lib/services/aiGen/providers/openai/openai.service.d.ts +1 -1
- package/lib/services/aiGen/providers/openai/openai.service.d.ts.map +1 -1
- package/lib/services/aiGen/providers/openai/openai.service.js +7 -2
- package/lib/services/aiGen/providers/pixverse/pixverse.service.js +1 -1
- package/lib/services/aiGen/providers/runway/runway.service.d.ts +1 -1
- package/lib/services/aiGen/providers/runway/runway.service.d.ts.map +1 -1
- package/lib/services/aiGen/providers/runway/runway.service.js +8 -2
- package/lib/services/tts/providers/elevenlabs.service.d.ts +3 -1
- package/lib/services/tts/providers/elevenlabs.service.d.ts.map +1 -1
- package/lib/services/tts/providers/elevenlabs.service.js +11 -1
- package/lib/services/tts/ttsFactory.service.d.ts +1 -1
- package/lib/services/tts/ttsFactory.service.d.ts.map +1 -1
- package/lib/services/tts/ttsFactory.service.js +1 -1
- package/lib/services/tts/types.d.ts +19 -0
- package/lib/services/tts/types.d.ts.map +1 -1
- package/lib/utils/helpers.d.ts +16 -2
- package/lib/utils/helpers.d.ts.map +1 -1
- package/lib/utils/helpers.js +26 -8
- package/lib/utils/ttsUtils.d.ts +15 -0
- package/lib/utils/ttsUtils.d.ts.map +1 -1
- package/lib/utils/ttsUtils.js +41 -0
- package/package.json +1 -1
- package/lib/models/editorState.model.d.ts +0 -9
- package/lib/models/editorState.model.d.ts.map +0 -1
- package/lib/models/editorState.model.js +0 -2
|
@@ -7,6 +7,7 @@ export declare enum EVideoGenModels {
|
|
|
7
7
|
BYTEDANCE_SEEDANCE_1_0_PRO = "bytedance-seedance-1.0-pro",
|
|
8
8
|
GOOGLE_VEO_3_1 = "google-veo-3.1",
|
|
9
9
|
GOOGLE_VEO_3_1_FAST = "google-veo-3.1-fast",
|
|
10
|
+
GOOGLE_VEO_3_1_LITE = "google-veo-3.1-lite",
|
|
10
11
|
GOOGLE_VEO_3 = "google-veo-3",
|
|
11
12
|
GOOGLE_VEO_3_FAST = "google-veo-3-fast",
|
|
12
13
|
GOOGLE_VEO_2 = "google-veo-2",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enums.d.ts","sourceRoot":"","sources":["../../../src/globals/aiModels/enums.ts"],"names":[],"mappings":"AAAA,oBAAY,eAAe;IACzB,aAAa,kBAAkB;IAC/B,aAAa,kBAAkB;IAC/B,WAAW,gBAAgB;IAC3B,0BAA0B,+BAA+B;IACzD,+BAA+B,oCAAoC;IACnE,0BAA0B,+BAA+B;IACzD,cAAc,mBAAmB;IACjC,mBAAmB,wBAAwB;IAC3C,YAAY,iBAAiB;IAC7B,iBAAiB,sBAAsB;IACvC,YAAY,iBAAiB;IAC7B,aAAa,kBAAkB;IAC/B,iBAAiB,sBAAsB;IACvC,iBAAiB,sBAAsB;IACvC,eAAe,oBAAoB;IACnC,UAAU,eAAe;IACzB,iBAAiB,sBAAsB;IACvC,gBAAgB,qBAAqB;IACrC,UAAU,eAAe;IACzB,YAAY,iBAAiB;IAE7B,uBAAuB,4BAA4B;IACnD,kBAAkB,uBAAuB;IACzC,iBAAiB,sBAAsB;IAGvC,aAAa,kBAAkB;IAC/B,iBAAiB,sBAAsB;CACxC;AAED,eAAO,MAAM,eAAe;;;;;;CAMlB,CAAC;AAEX,oBAAY,cAAc;IACxB,kBAAkB,uBAAuB;IACzC,iBAAiB,sBAAsB;CACxC;AAED,MAAM,MAAM,WAAW,GAAG,eAAe,GAAG,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"enums.d.ts","sourceRoot":"","sources":["../../../src/globals/aiModels/enums.ts"],"names":[],"mappings":"AAAA,oBAAY,eAAe;IACzB,aAAa,kBAAkB;IAC/B,aAAa,kBAAkB;IAC/B,WAAW,gBAAgB;IAC3B,0BAA0B,+BAA+B;IACzD,+BAA+B,oCAAoC;IACnE,0BAA0B,+BAA+B;IACzD,cAAc,mBAAmB;IACjC,mBAAmB,wBAAwB;IAC3C,mBAAmB,wBAAwB;IAC3C,YAAY,iBAAiB;IAC7B,iBAAiB,sBAAsB;IACvC,YAAY,iBAAiB;IAC7B,aAAa,kBAAkB;IAC/B,iBAAiB,sBAAsB;IACvC,iBAAiB,sBAAsB;IACvC,eAAe,oBAAoB;IACnC,UAAU,eAAe;IACzB,iBAAiB,sBAAsB;IACvC,gBAAgB,qBAAqB;IACrC,UAAU,eAAe;IACzB,YAAY,iBAAiB;IAE7B,uBAAuB,4BAA4B;IACnD,kBAAkB,uBAAuB;IACzC,iBAAiB,sBAAsB;IAGvC,aAAa,kBAAkB;IAC/B,iBAAiB,sBAAsB;CACxC;AAED,eAAO,MAAM,eAAe;;;;;;CAMlB,CAAC;AAEX,oBAAY,cAAc;IACxB,kBAAkB,uBAAuB;IACzC,iBAAiB,sBAAsB;CACxC;AAED,MAAM,MAAM,WAAW,GAAG,eAAe,GAAG,cAAc,CAAC"}
|
|
@@ -11,6 +11,7 @@ var EVideoGenModels;
|
|
|
11
11
|
EVideoGenModels["BYTEDANCE_SEEDANCE_1_0_PRO"] = "bytedance-seedance-1.0-pro";
|
|
12
12
|
EVideoGenModels["GOOGLE_VEO_3_1"] = "google-veo-3.1";
|
|
13
13
|
EVideoGenModels["GOOGLE_VEO_3_1_FAST"] = "google-veo-3.1-fast";
|
|
14
|
+
EVideoGenModels["GOOGLE_VEO_3_1_LITE"] = "google-veo-3.1-lite";
|
|
14
15
|
EVideoGenModels["GOOGLE_VEO_3"] = "google-veo-3";
|
|
15
16
|
EVideoGenModels["GOOGLE_VEO_3_FAST"] = "google-veo-3-fast";
|
|
16
17
|
EVideoGenModels["GOOGLE_VEO_2"] = "google-veo-2";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"google.d.ts","sourceRoot":"","sources":["../../../../src/globals/aiModels/providers/google.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAExC,eAAO,MAAM,aAAa,EAAE,OAAO,CAAC,MAAM,CAAC,WAAW,EAAE,YAAY,CAAC,
|
|
1
|
+
{"version":3,"file":"google.d.ts","sourceRoot":"","sources":["../../../../src/globals/aiModels/providers/google.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAExC,eAAO,MAAM,aAAa,EAAE,OAAO,CAAC,MAAM,CAAC,WAAW,EAAE,YAAY,CAAC,CAsIpE,CAAC"}
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.googleConfigs = void 0;
|
|
4
4
|
exports.googleConfigs = {
|
|
5
5
|
"google-veo-3.1": {
|
|
6
|
-
modelId: "veo-3.1-generate-
|
|
6
|
+
modelId: "veo-3.1-generate-preview",
|
|
7
7
|
type: ["text-to-video", "image-to-video"],
|
|
8
8
|
fields: {
|
|
9
9
|
prompt: { required: true },
|
|
@@ -25,7 +25,7 @@ exports.googleConfigs = {
|
|
|
25
25
|
},
|
|
26
26
|
},
|
|
27
27
|
"google-veo-3.1-fast": {
|
|
28
|
-
modelId: "veo-3.1-fast-generate-
|
|
28
|
+
modelId: "veo-3.1-fast-generate-preview",
|
|
29
29
|
type: ["text-to-video", "image-to-video"],
|
|
30
30
|
fields: {
|
|
31
31
|
prompt: { required: true },
|
|
@@ -43,7 +43,29 @@ exports.googleConfigs = {
|
|
|
43
43
|
},
|
|
44
44
|
requestPerMin: 10,
|
|
45
45
|
cost: {
|
|
46
|
-
|
|
46
|
+
perResolution: { "720p": 0.10, "1080p": 0.12 },
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
"google-veo-3.1-lite": {
|
|
50
|
+
modelId: "veo-3.1-lite-generate-preview",
|
|
51
|
+
type: ["text-to-video", "image-to-video"],
|
|
52
|
+
fields: {
|
|
53
|
+
prompt: { required: true },
|
|
54
|
+
aspectRatio: { allowedValues: ["16:9", "9:16"] },
|
|
55
|
+
resolution: { allowedValues: ["720p", "1080p"] },
|
|
56
|
+
duration: { allowedValues: [4, 6, 8] },
|
|
57
|
+
imageUrl: {},
|
|
58
|
+
negative_prompt: {},
|
|
59
|
+
audio: {},
|
|
60
|
+
},
|
|
61
|
+
durationRules: {
|
|
62
|
+
4: ["720p"],
|
|
63
|
+
6: ["720p"],
|
|
64
|
+
8: ["720p", "1080p"],
|
|
65
|
+
},
|
|
66
|
+
requestPerMin: 10,
|
|
67
|
+
cost: {
|
|
68
|
+
perResolution: { "720p": 0.05, "1080p": 0.08 },
|
|
47
69
|
},
|
|
48
70
|
},
|
|
49
71
|
"google-veo-3": {
|
|
@@ -86,7 +108,7 @@ exports.googleConfigs = {
|
|
|
86
108
|
},
|
|
87
109
|
requestPerMin: 10,
|
|
88
110
|
cost: {
|
|
89
|
-
|
|
111
|
+
perResolution: { "720p": 0.10, "1080p": 0.12 },
|
|
90
112
|
},
|
|
91
113
|
},
|
|
92
114
|
"google-veo-2": {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kling.d.ts","sourceRoot":"","sources":["../../../../src/globals/aiModels/providers/kling.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAsB,YAAY,EAAE,MAAM,UAAU,CAAC;AAE5D,eAAO,MAAM,YAAY,EAAE,OAAO,CAAC,MAAM,CAAC,WAAW,EAAE,YAAY,CAAC,
|
|
1
|
+
{"version":3,"file":"kling.d.ts","sourceRoot":"","sources":["../../../../src/globals/aiModels/providers/kling.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAsB,YAAY,EAAE,MAAM,UAAU,CAAC;AAE5D,eAAO,MAAM,YAAY,EAAE,OAAO,CAAC,MAAM,CAAC,WAAW,EAAE,YAAY,CAAC,CA2InE,CAAC"}
|
|
@@ -116,14 +116,22 @@ exports.klingConfigs = {
|
|
|
116
116
|
},
|
|
117
117
|
concurrentRequests: 3,
|
|
118
118
|
cost: {
|
|
119
|
-
// per-second pricing by mode
|
|
120
|
-
|
|
121
|
-
|
|
119
|
+
// per-second pricing by mode — read via cost.perMode[mode].perSecond
|
|
120
|
+
// TODO: confirm exact per-second pricing from Kling dashboard
|
|
121
|
+
perMode: {
|
|
122
|
+
std: { perSecond: 0.014 },
|
|
123
|
+
pro: { perSecond: 0.028 },
|
|
124
|
+
},
|
|
122
125
|
},
|
|
123
126
|
avatar: {
|
|
124
127
|
audioDurationMin: 2,
|
|
125
128
|
audioDurationMax: 300,
|
|
126
129
|
ttsProvider: "elevenlabs",
|
|
130
|
+
// 12-min poll window per BullMQ run. On timeout the job auto re-queues
|
|
131
|
+
// (up to maxAutoRequeueAttempts times) so the worker is never blocked > 12 min.
|
|
132
|
+
// Total possible wait: 12 min × 5 = 60 min.
|
|
133
|
+
pollTimeoutMs: 12 * 60 * 1000,
|
|
134
|
+
maxAutoRequeueAttempts: 5,
|
|
127
135
|
},
|
|
128
136
|
},
|
|
129
137
|
};
|
|
@@ -12,6 +12,32 @@ export interface IAvatarModelConfig {
|
|
|
12
12
|
audioDurationMax: number;
|
|
13
13
|
/** Default TTS provider used when the request includes ttsText */
|
|
14
14
|
ttsProvider: TtsProvider;
|
|
15
|
+
/**
|
|
16
|
+
* How often to poll the provider for clip status (milliseconds).
|
|
17
|
+
* Tune per provider — fast providers can use 5s, slow ones like Kling use 10s.
|
|
18
|
+
* Defaults to 10s if not set.
|
|
19
|
+
*/
|
|
20
|
+
pollIntervalMs?: number;
|
|
21
|
+
/**
|
|
22
|
+
* Per-run poll window per BullMQ job execution (milliseconds).
|
|
23
|
+
* When this expires the run saves scene state (TIMED_OUT + task IDs) and
|
|
24
|
+
* auto re-queues — the worker is freed rather than blocked for the full duration.
|
|
25
|
+
* Defaults to 12 min if not set.
|
|
26
|
+
*/
|
|
27
|
+
pollTimeoutMs?: number;
|
|
28
|
+
/**
|
|
29
|
+
* Maximum number of automatic re-queues before giving up and marking the job failed.
|
|
30
|
+
* Each re-queue resumes polling the same provider task IDs — no extra API submission cost.
|
|
31
|
+
* Total possible wait = pollTimeoutMs × maxAutoRequeueAttempts.
|
|
32
|
+
* Defaults to 5 if not set.
|
|
33
|
+
*/
|
|
34
|
+
maxAutoRequeueAttempts?: number;
|
|
35
|
+
/**
|
|
36
|
+
* Delay in milliseconds before the auto re-queued job is picked up again.
|
|
37
|
+
* Gives the provider time to make progress before the next poll window starts.
|
|
38
|
+
* Defaults to 60s if not set.
|
|
39
|
+
*/
|
|
40
|
+
autoRequeueDelayMs?: number;
|
|
15
41
|
}
|
|
16
42
|
export interface ISchemaField {
|
|
17
43
|
required?: boolean;
|
|
@@ -32,6 +58,16 @@ export interface IModelSchema {
|
|
|
32
58
|
concurrentRequests?: number;
|
|
33
59
|
requestPerMin?: number;
|
|
34
60
|
requestPerDay?: number;
|
|
61
|
+
/**
|
|
62
|
+
* How often to poll for scene status (milliseconds). Defaults to 10s.
|
|
63
|
+
* Set lower for fast providers, higher for slow/expensive ones.
|
|
64
|
+
*/
|
|
65
|
+
pollIntervalMs?: number;
|
|
66
|
+
/**
|
|
67
|
+
* Max time to poll a single scene before marking it TIMED_OUT (milliseconds).
|
|
68
|
+
* Defaults to 15 min. Set per-provider based on observed generation times.
|
|
69
|
+
*/
|
|
70
|
+
pollTimeoutMs?: number;
|
|
35
71
|
cost?: {
|
|
36
72
|
perSecond?: number;
|
|
37
73
|
per1KTokens?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/globals/aiModels/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD,MAAM,MAAM,cAAc,GACtB,eAAe,GACf,gBAAgB,GAChB,gBAAgB,GAChB,cAAc,GACd,cAAc,GACd,eAAe,CAAC;AAEpB;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IACjC,wFAAwF;IACxF,gBAAgB,EAAE,MAAM,CAAC;IACzB,gDAAgD;IAChD,gBAAgB,EAAE,MAAM,CAAC;IACzB,kEAAkE;IAClE,WAAW,EAAE,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/globals/aiModels/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD,MAAM,MAAM,cAAc,GACtB,eAAe,GACf,gBAAgB,GAChB,gBAAgB,GAChB,cAAc,GACd,cAAc,GACd,eAAe,CAAC;AAEpB;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IACjC,wFAAwF;IACxF,gBAAgB,EAAE,MAAM,CAAC;IACzB,gDAAgD;IAChD,gBAAgB,EAAE,MAAM,CAAC;IACzB,kEAAkE;IAClE,WAAW,EAAE,WAAW,CAAC;IACzB;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;;;OAKG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;;;OAKG;IACH,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,GAAG,OAAO,EAAE,CAAC;IAChD,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;CACrC;AAED,MAAM,WAAW,UAAU;IACzB,CAAC,GAAG,EAAE,MAAM,GAAG;QACb,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;KACvB,CAAC;CACH;AAED,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,cAAc,EAAE,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IAErC,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IAC3C,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IACzC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,IAAI,CAAC,EAAE;QACL,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,KAAK,CAAC,EAAE,UAAU,CAAC;QACnB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;KACpB,CAAC;IACF,4FAA4F;IAC5F,MAAM,CAAC,EAAE,kBAAkB,CAAC;IAC5B,kHAAkH;IAClH,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAC;CACjC"}
|
|
@@ -3,4 +3,6 @@ export * from "./voices";
|
|
|
3
3
|
import { TtsProvider, ITtsProviderConfig } from "./types";
|
|
4
4
|
export { elevenlabsConfig } from "./providers/elevenlabs";
|
|
5
5
|
export declare const ttsProviderConfigs: Record<TtsProvider, ITtsProviderConfig>;
|
|
6
|
+
/** Fallback TTS provider used when a model config does not specify one. */
|
|
7
|
+
export declare const DEFAULT_TTS_PROVIDER: TtsProvider;
|
|
6
8
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/globals/ttsModels/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AAEzB,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAG1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,WAAW,EAAE,kBAAkB,CAEtE,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/globals/ttsModels/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AAEzB,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAG1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,WAAW,EAAE,kBAAkB,CAEtE,CAAC;AAEF,2EAA2E;AAC3E,eAAO,MAAM,oBAAoB,EAAE,WAA0B,CAAC"}
|
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.ttsProviderConfigs = exports.elevenlabsConfig = void 0;
|
|
17
|
+
exports.DEFAULT_TTS_PROVIDER = exports.ttsProviderConfigs = exports.elevenlabsConfig = void 0;
|
|
18
18
|
__exportStar(require("./types"), exports);
|
|
19
19
|
__exportStar(require("./voices"), exports);
|
|
20
20
|
const elevenlabs_1 = require("./providers/elevenlabs");
|
|
@@ -23,3 +23,5 @@ Object.defineProperty(exports, "elevenlabsConfig", { enumerable: true, get: func
|
|
|
23
23
|
exports.ttsProviderConfigs = {
|
|
24
24
|
elevenlabs: elevenlabs_1.elevenlabsConfig,
|
|
25
25
|
};
|
|
26
|
+
/** Fallback TTS provider used when a model config does not specify one. */
|
|
27
|
+
exports.DEFAULT_TTS_PROVIDER = "elevenlabs";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"elevenlabs.d.ts","sourceRoot":"","sources":["../../../../src/globals/ttsModels/providers/elevenlabs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAE9C,eAAO,MAAM,gBAAgB,EAAE,
|
|
1
|
+
{"version":3,"file":"elevenlabs.d.ts","sourceRoot":"","sources":["../../../../src/globals/ttsModels/providers/elevenlabs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAE9C,eAAO,MAAM,gBAAgB,EAAE,kBAyB9B,CAAC"}
|
|
@@ -10,4 +10,20 @@ exports.elevenlabsConfig = {
|
|
|
10
10
|
modelId: "eleven_multilingual_v2",
|
|
11
11
|
/** ~150 words/min = 2.5 words/sec */
|
|
12
12
|
wordsPerSecond: 2.5,
|
|
13
|
+
/** ElevenLabs API limit per single TTS request */
|
|
14
|
+
maxCharsPerRequest: 10000,
|
|
15
|
+
/**
|
|
16
|
+
* 100s buffer on a 300s clip limit (~33%).
|
|
17
|
+
* ElevenLabs voices vary from 1.8–3.5 wps (nominal: 2.5 wps).
|
|
18
|
+
* At the slowest documented rate (1.8 wps) a 200s estimated chunk produces
|
|
19
|
+
* 200 × (2.5/1.8) ≈ 278s of actual audio — safely under the 300s hard limit.
|
|
20
|
+
* Formula: buffer = audioDurationMax × (1 - minWps/nominalWps)
|
|
21
|
+
* = 300 × (1 - 1.8/2.5) = 300 × 0.28 = 84 → rounded up to 100 for safety.
|
|
22
|
+
*
|
|
23
|
+
* This was confirmed by a real failure: a chunk estimated at 270s was generated
|
|
24
|
+
* as 351.6s by ElevenLabs (1.9 wps actual), causing a Kling 400 "duration exceeded" error.
|
|
25
|
+
*/
|
|
26
|
+
durationSafetyBufferSeconds: 100,
|
|
27
|
+
/** ElevenLabs allows up to 5 concurrent TTS requests on paid plans */
|
|
28
|
+
concurrentRequests: 5,
|
|
13
29
|
};
|
|
@@ -11,5 +11,21 @@ export interface ITtsProviderConfig {
|
|
|
11
11
|
modelId: string;
|
|
12
12
|
/** Average spoken words per second for duration estimation (~150 wpm = 2.5 wps) */
|
|
13
13
|
wordsPerSecond: number;
|
|
14
|
+
/**
|
|
15
|
+
* Maximum characters allowed in a single TTS API call.
|
|
16
|
+
* Used by splitTtsTextByDuration to cap chunk size.
|
|
17
|
+
*/
|
|
18
|
+
maxCharsPerRequest: number;
|
|
19
|
+
/**
|
|
20
|
+
* Safety buffer (seconds) subtracted from audioDurationMax when deciding
|
|
21
|
+
* whether to split into multiple scenes and when capping per-chunk duration.
|
|
22
|
+
* Absorbs the variance between estimated and actual TTS speaking rate.
|
|
23
|
+
* A larger buffer = safer but slightly more splits; tune per provider accuracy.
|
|
24
|
+
*/
|
|
25
|
+
durationSafetyBufferSeconds: number;
|
|
26
|
+
/** Maximum number of concurrent TTS API requests. Used by TTS rate limiter. */
|
|
27
|
+
concurrentRequests?: number;
|
|
28
|
+
/** Maximum TTS requests per minute. Used by TTS rate limiter. */
|
|
29
|
+
requestPerMin?: number;
|
|
14
30
|
}
|
|
15
31
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/globals/ttsModels/types.ts"],"names":[],"mappings":"AAAA,mFAAmF;AACnF,MAAM,MAAM,WAAW,GAAG,YAAY,CAAC;AAEvC,MAAM,WAAW,kBAAkB;IACjC,mCAAmC;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,4DAA4D;IAC5D,cAAc,EAAE,MAAM,CAAC;IACvB,gDAAgD;IAChD,cAAc,EAAE,MAAM,CAAC;IACvB,mDAAmD;IACnD,OAAO,EAAE,MAAM,CAAC;IAChB,mFAAmF;IACnF,cAAc,EAAE,MAAM,CAAC;CACxB"}
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/globals/ttsModels/types.ts"],"names":[],"mappings":"AAAA,mFAAmF;AACnF,MAAM,MAAM,WAAW,GAAG,YAAY,CAAC;AAEvC,MAAM,WAAW,kBAAkB;IACjC,mCAAmC;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,4DAA4D;IAC5D,cAAc,EAAE,MAAM,CAAC;IACvB,gDAAgD;IAChD,cAAc,EAAE,MAAM,CAAC;IACvB,mDAAmD;IACnD,OAAO,EAAE,MAAM,CAAC;IAChB,mFAAmF;IACnF,cAAc,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,kBAAkB,EAAE,MAAM,CAAC;IAC3B;;;;;OAKG;IACH,2BAA2B,EAAE,MAAM,CAAC;IACpC,+EAA+E;IAC/E,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,iEAAiE;IACjE,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB"}
|
package/lib/globals/types.d.ts
CHANGED
|
@@ -22,8 +22,15 @@ export declare enum EVideoSceneStatus {
|
|
|
22
22
|
IN_PROGRESS = "inProgress",// for scene: scene is queued for generation in prepare scenes (set in prepare scene)
|
|
23
23
|
TRIGGERED = "triggered",// for scene: when provider video generation function is called in trigger video generation
|
|
24
24
|
PENDING = "pending",// for scene: triggered, status checked but still in progress (wont be setting it in scene status or in firestore, just a status return by provider status method)
|
|
25
|
-
FAILED = "failed",// for scene: scene generation failed
|
|
26
|
-
COMPLETED = "completed"
|
|
25
|
+
FAILED = "failed",// for scene: scene generation failed (provider confirmed failure)
|
|
26
|
+
COMPLETED = "completed",// for scene: video has been generated
|
|
27
|
+
/**
|
|
28
|
+
* Our local poll window expired but the provider task may still be running.
|
|
29
|
+
* Different from FAILED — the provider did NOT report a failure.
|
|
30
|
+
* On reprocess: check if the task completed/is still running before re-submitting.
|
|
31
|
+
* scene.task holds the provider task ID for resumption.
|
|
32
|
+
*/
|
|
33
|
+
TIMED_OUT = "timedOut"
|
|
27
34
|
}
|
|
28
35
|
export declare enum ERedisQueues {
|
|
29
36
|
VIDEO_JOBS = "video-job-queue"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/globals/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,CAAC,MAAM,KAAK,CAAC;AAEpB,MAAM,WAAW,WAAW;IAC1B,QAAQ,EAAE,OAAO,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE;QACT,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,cAAc,CAAC;QACrB,OAAO,EAAE,MAAM,CAAC;QAChB,KAAK,EAAE,MAAM,CAAC;KACf,EAAE,CAAC;IACJ,MAAM,EAAE,GAAG,EAAE,CAAC;CACf;AAED,oBAAY,eAAe;IACzB,MAAM,WAAW,CAAE,wCAAwC;IAC3D,WAAW,eAAe,CAAE,2DAA2D;IAGvF,SAAS,cAAc,CAAE,8CAA8C;IACvE,MAAM,WAAW,CAAE,+BAA+B;IAClD,mBAAmB,uBAAuB;CAC3C;AAED,oBAAY,iBAAiB;IAC3B,WAAW,eAAe,CAAE,qFAAqF;IACjH,SAAS,cAAc,CAAE,2FAA2F;IACpH,OAAO,YAAY,CAAE,kKAAkK;IACvL,MAAM,WAAW,CAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/globals/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,CAAC,MAAM,KAAK,CAAC;AAEpB,MAAM,WAAW,WAAW;IAC1B,QAAQ,EAAE,OAA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G,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAE5D,eAAO,MAAM,yBAAyB;;;;iBAapC,CAAC;AAEH,eAAO,MAAM,qBAAqB;;;;;;iBAEhC,CAAC;AAEH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC"}
|
package/lib/globals/types.js
CHANGED
|
@@ -21,6 +21,13 @@ var EVideoSceneStatus;
|
|
|
21
21
|
EVideoSceneStatus["PENDING"] = "pending";
|
|
22
22
|
EVideoSceneStatus["FAILED"] = "failed";
|
|
23
23
|
EVideoSceneStatus["COMPLETED"] = "completed";
|
|
24
|
+
/**
|
|
25
|
+
* Our local poll window expired but the provider task may still be running.
|
|
26
|
+
* Different from FAILED — the provider did NOT report a failure.
|
|
27
|
+
* On reprocess: check if the task completed/is still running before re-submitting.
|
|
28
|
+
* scene.task holds the provider task ID for resumption.
|
|
29
|
+
*/
|
|
30
|
+
EVideoSceneStatus["TIMED_OUT"] = "timedOut";
|
|
24
31
|
})(EVideoSceneStatus || (exports.EVideoSceneStatus = EVideoSceneStatus = {}));
|
|
25
32
|
// export const ERedisQueues = {
|
|
26
33
|
// videoJobs: "video-job-queue",
|
|
@@ -53,7 +53,9 @@ export interface IVideoJobModel {
|
|
|
53
53
|
ttsVoiceId?: string;
|
|
54
54
|
ttsLanguageCode?: string;
|
|
55
55
|
generatedAudioUrl?: string;
|
|
56
|
+
audioDurationSeconds?: number;
|
|
56
57
|
createdAt: FieldValue;
|
|
57
58
|
updatedAt: FieldValue;
|
|
59
|
+
reprocessedAt?: FieldValue;
|
|
58
60
|
}
|
|
59
61
|
//# sourceMappingURL=video.model.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"video.model.d.ts","sourceRoot":"","sources":["../../src/models/video.model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,e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,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IAGvB,WAAW,CAAC,EAAE,OAAO,GAAG,cAAc,CAAC;IACvC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAG9B,SAAS,EAAE,UAAU,CAAC;IACtB,SAAS,EAAE,UAAU,CAAC;IACtB,aAAa,CAAC,EAAE,UAAU,CAAC;CAC5B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aiGenFactory.service.d.ts","sourceRoot":"","sources":["../../../src/services/aiGen/aiGenFactory.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,uCAAuC,CAAC;AACjF,OAAO,EACL,cAAc,EACd,eAAe,EACf,WAAW,EACZ,MAAM,wBAAwB,CAAC;AAYhC,KAAK,uBAAuB,GAAG,UAAU,wBAAwB,CAAC;AAElE,eAAO,MAAM,gBAAgB,EAAE,MAAM,CACnC,eAAe,EACf,uBAAuB,
|
|
1
|
+
{"version":3,"file":"aiGenFactory.service.d.ts","sourceRoot":"","sources":["../../../src/services/aiGen/aiGenFactory.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,uCAAuC,CAAC;AACjF,OAAO,EACL,cAAc,EACd,eAAe,EACf,WAAW,EACZ,MAAM,wBAAwB,CAAC;AAYhC,KAAK,uBAAuB,GAAG,UAAU,wBAAwB,CAAC;AAElE,eAAO,MAAM,gBAAgB,EAAE,MAAM,CACnC,eAAe,EACf,uBAAuB,CAoDxB,CAAC;AAUF,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,cAAc,EAAE,uBAAuB,CAQzE,CAAC;AAEJ,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,WAAW,GACpB,wBAAwB,CAY1B"}
|
|
@@ -23,6 +23,7 @@ exports.videoServicesMap = {
|
|
|
23
23
|
// --- Google ---
|
|
24
24
|
"google-veo-3.1": google_service_1.GoogleService,
|
|
25
25
|
"google-veo-3.1-fast": google_service_1.GoogleService,
|
|
26
|
+
"google-veo-3.1-lite": google_service_1.GoogleService,
|
|
26
27
|
"google-veo-3": google_service_1.GoogleService,
|
|
27
28
|
"google-veo-3-fast": google_service_1.GoogleService,
|
|
28
29
|
"google-veo-2": google_service_1.GoogleService,
|
|
@@ -7,6 +7,6 @@ export declare class AlibabaService extends BaseAiGenProviderService {
|
|
|
7
7
|
private request;
|
|
8
8
|
generateVideo(params: VideoGenerationParams): Promise<VideoGenerationResult>;
|
|
9
9
|
checkVideoStatus({ task, outputFilename, outputFilePath, }: VideoStatusParams): Promise<VideoStatusResult>;
|
|
10
|
-
getCreditUsed({ modelKey, resolution, aspectRatio, duration, }: CreditUsageParams): number;
|
|
10
|
+
getCreditUsed({ modelKey, resolution, aspectRatio, duration, multiClip, }: CreditUsageParams): number;
|
|
11
11
|
}
|
|
12
12
|
//# sourceMappingURL=alibaba.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"alibaba.d.ts","sourceRoot":"","sources":["../../../../../src/services/aiGen/providers/alibaba/alibaba.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EACrB,qBAAqB,EACrB,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"alibaba.d.ts","sourceRoot":"","sources":["../../../../../src/services/aiGen/providers/alibaba/alibaba.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EACrB,qBAAqB,EACrB,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,UAAU,CAAC;AAQlB,qBAAa,cAAe,SAAQ,wBAAwB;IAC1D,OAAO,CAAC,QAAQ,CAAC,OAAO,CACsE;IAC9F,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;;YASnB,OAAO;IAqBf,aAAa,CACjB,MAAM,EAAE,qBAAqB,GAC5B,OAAO,CAAC,qBAAqB,CAAC;IAqC3B,gBAAgB,CAAC,EACrB,IAAI,EACJ,cAAc,EACd,cAAyB,GAC1B,EAAE,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAuEjD,aAAa,CAAC,EACZ,QAAQ,EACR,UAAU,EACV,WAAW,EACX,QAAQ,EACR,SAAiB,GAClB,EAAE,iBAAiB,GAAG,MAAM;CAU9B"}
|
|
@@ -12,6 +12,7 @@ const firebase_1 = require("../../../../libs/firebase");
|
|
|
12
12
|
const helpers_1 = require("./helpers");
|
|
13
13
|
const helpers_2 = require("../../helpers");
|
|
14
14
|
const utils_1 = require("../../../../utils");
|
|
15
|
+
const logger_1 = require("../../../../utils/logger");
|
|
15
16
|
class AlibabaService extends baseAiGenProvider_service_1.BaseAiGenProviderService {
|
|
16
17
|
constructor() {
|
|
17
18
|
super();
|
|
@@ -120,10 +121,15 @@ class AlibabaService extends baseAiGenProvider_service_1.BaseAiGenProviderServic
|
|
|
120
121
|
}
|
|
121
122
|
return { status: types_1.EVideoSceneStatus.PENDING };
|
|
122
123
|
}
|
|
123
|
-
getCreditUsed({ modelKey, resolution, aspectRatio, duration, }) {
|
|
124
|
+
getCreditUsed({ modelKey, resolution, aspectRatio, duration, multiClip = false, }) {
|
|
124
125
|
const modelConfig = aiModels_1.aiModelConfigs[modelKey];
|
|
125
126
|
const dimensions = (0, helpers_1.getAlibabaDimensions)(resolution, aspectRatio);
|
|
126
|
-
|
|
127
|
+
const cost = modelConfig.cost?.table?.[dimensions]?.[duration];
|
|
128
|
+
if (!cost) {
|
|
129
|
+
logger_1.logger.warn(`Alibaba getCreditUsed: no cost entry for modelKey="${modelKey}" dimensions="${dimensions}" duration=${duration} — returning fallback`, { modelKey, dimensions, duration, resolution, aspectRatio });
|
|
130
|
+
return (0, utils_1.getCreditsFromCost)(1.0, !multiClip);
|
|
131
|
+
}
|
|
132
|
+
return (0, utils_1.getCreditsFromCost)(cost, !multiClip);
|
|
127
133
|
}
|
|
128
134
|
}
|
|
129
135
|
exports.AlibabaService = AlibabaService;
|
|
@@ -9,6 +9,6 @@ export declare class AzureService extends BaseAiGenProviderService {
|
|
|
9
9
|
private request;
|
|
10
10
|
generateVideo(params: VideoGenerationParams): Promise<VideoGenerationResult>;
|
|
11
11
|
checkVideoStatus({ task, outputFilename, outputFilePath, }: VideoStatusParams): Promise<VideoStatusResult>;
|
|
12
|
-
getCreditUsed({ modelKey, dimensions, duration, }: CreditUsageParams): number;
|
|
12
|
+
getCreditUsed({ modelKey, dimensions, duration, multiClip, }: CreditUsageParams): number;
|
|
13
13
|
}
|
|
14
14
|
//# sourceMappingURL=azure.service.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"azure.service.d.ts","sourceRoot":"","sources":["../../../../../src/services/aiGen/providers/azure/azure.service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"azure.service.d.ts","sourceRoot":"","sources":["../../../../../src/services/aiGen/providers/azure/azure.service.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EACrB,qBAAqB,EACrB,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,UAAU,CAAC;AAElB,qBAAa,YAAa,SAAQ,wBAAwB;IACxD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAa;IACxC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;;YAiBnB,OAAO;IAwBf,aAAa,CACjB,MAAM,EAAE,qBAAqB,GAC5B,OAAO,CAAC,qBAAqB,CAAC;IA6B3B,gBAAgB,CAAC,EACrB,IAAI,EACJ,cAAc,EACd,cAAyB,GAC1B,EAAE,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAgDjD,aAAa,CAAC,EACZ,QAAQ,EACR,UAAsB,EACtB,QAAY,EACZ,SAAiB,GAClB,EAAE,iBAAiB,GAAG,MAAM;CAS9B"}
|
|
@@ -9,6 +9,7 @@ const aiModels_1 = require("../../../../globals/aiModels");
|
|
|
9
9
|
const types_1 = require("../../../../globals/types");
|
|
10
10
|
const firebase_1 = require("../../../../libs/firebase");
|
|
11
11
|
const helpers_1 = require("../../../../utils/helpers");
|
|
12
|
+
const logger_1 = require("../../../../utils/logger");
|
|
12
13
|
const helpers_2 = require("../../helpers");
|
|
13
14
|
const baseAiGenProvider_service_1 = require("../baseAiGenProvider.service");
|
|
14
15
|
class AzureService extends baseAiGenProvider_service_1.BaseAiGenProviderService {
|
|
@@ -94,10 +95,14 @@ class AzureService extends baseAiGenProvider_service_1.BaseAiGenProviderService
|
|
|
94
95
|
}
|
|
95
96
|
return { status: types_1.EVideoSceneStatus.PENDING };
|
|
96
97
|
}
|
|
97
|
-
getCreditUsed({ modelKey, dimensions = "480x480", duration = 5, }) {
|
|
98
|
+
getCreditUsed({ modelKey, dimensions = "480x480", duration = 5, multiClip = false, }) {
|
|
98
99
|
const modelConfig = aiModels_1.aiModelConfigs[modelKey];
|
|
99
100
|
const cost = modelConfig.cost?.table?.[dimensions]?.[duration];
|
|
100
|
-
|
|
101
|
+
if (cost === undefined || cost === null) {
|
|
102
|
+
logger_1.logger.warn(`Azure getCreditUsed: no cost entry for modelKey="${modelKey}" dimensions="${dimensions}" duration=${duration} — returning fallback`, { modelKey, dimensions, duration });
|
|
103
|
+
return (0, helpers_1.getCreditsFromCost)(1.0, !multiClip);
|
|
104
|
+
}
|
|
105
|
+
return (0, helpers_1.getCreditsFromCost)(cost, !multiClip);
|
|
101
106
|
}
|
|
102
107
|
}
|
|
103
108
|
exports.AzureService = AzureService;
|
|
@@ -65,10 +65,10 @@ class ByteDanceService extends baseAiGenProvider_service_1.BaseAiGenProviderServ
|
|
|
65
65
|
const code = parsed?.error?.code;
|
|
66
66
|
const param = parsed?.error?.param;
|
|
67
67
|
const message = parsed?.error?.message ?? "";
|
|
68
|
-
if (code
|
|
68
|
+
if (code?.startsWith("InputTextSensitiveContentDetected")) {
|
|
69
69
|
throw new errors_1.UserFacingError("Your prompt contains content that violates the content policy. Please modify your prompt and try again.");
|
|
70
70
|
}
|
|
71
|
-
if (code
|
|
71
|
+
if (code?.startsWith("InputImageSensitiveContentDetected")) {
|
|
72
72
|
throw new errors_1.UserFacingError("Your input image contains sensitive content and cannot be processed. Please use a different image.");
|
|
73
73
|
}
|
|
74
74
|
if (code === "InvalidParameter.UnsupportedImageFormat" || (code?.includes("UnsupportedImageFormat"))) {
|
|
@@ -183,7 +183,7 @@ class ByteDanceService extends baseAiGenProvider_service_1.BaseAiGenProviderServ
|
|
|
183
183
|
const FRAME_RATE = 24;
|
|
184
184
|
const tokensConsumed = Math.ceil((dims.width * dims.height * FRAME_RATE * params.duration) / 1024);
|
|
185
185
|
const cost = (per1KTokens * tokensConsumed) / 1000;
|
|
186
|
-
return (0, helpers_2.getCreditsFromCost)(cost);
|
|
186
|
+
return (0, helpers_2.getCreditsFromCost)(cost, !params.multiClip);
|
|
187
187
|
}
|
|
188
188
|
}
|
|
189
189
|
exports.ByteDanceService = ByteDanceService;
|
|
@@ -5,6 +5,6 @@ export declare class GoogleService extends BaseAiGenProviderService {
|
|
|
5
5
|
constructor();
|
|
6
6
|
generateVideo(params: VideoGenerationParams): Promise<VideoGenerationResult>;
|
|
7
7
|
checkVideoStatus({ task, outputFilename, outputFilePath, }: VideoStatusParams): Promise<VideoStatusResult>;
|
|
8
|
-
getCreditUsed({ modelKey, duration }: CreditUsageParams): number;
|
|
8
|
+
getCreditUsed({ modelKey, duration, resolution, multiClip }: CreditUsageParams): number;
|
|
9
9
|
}
|
|
10
10
|
//# sourceMappingURL=google.service.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"google.service.d.ts","sourceRoot":"","sources":["../../../../../src/services/aiGen/providers/google/google.service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"google.service.d.ts","sourceRoot":"","sources":["../../../../../src/services/aiGen/providers/google/google.service.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EACrB,qBAAqB,EACrB,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,UAAU,CAAC;AAIlB,qBAAa,aAAc,SAAQ,wBAAwB;IACzD,OAAO,CAAC,EAAE,CAAc;;IAOlB,aAAa,CACjB,MAAM,EAAE,qBAAqB,GAC5B,OAAO,CAAC,qBAAqB,CAAC;IAqC3B,gBAAgB,CAAC,EACrB,IAAI,EACJ,cAAc,EACd,cAAyB,GAC1B,EAAE,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAmEjD,aAAa,CAAC,EAAE,QAAQ,EAAE,QAAY,EAAE,UAAmB,EAAE,SAAiB,EAAE,EAAE,iBAAiB,GAAG,MAAM;CAiB7G"}
|
|
@@ -11,6 +11,7 @@ const aiModels_1 = require("../../../../globals/aiModels");
|
|
|
11
11
|
const types_1 = require("../../../../globals/types");
|
|
12
12
|
const firebase_1 = require("../../../../libs/firebase");
|
|
13
13
|
const helpers_1 = require("../../../../utils/helpers");
|
|
14
|
+
const logger_1 = require("../../../../utils/logger");
|
|
14
15
|
const helpers_2 = require("../../helpers");
|
|
15
16
|
const baseAiGenProvider_service_1 = require("../baseAiGenProvider.service");
|
|
16
17
|
const fs_1 = require("fs");
|
|
@@ -101,11 +102,19 @@ class GoogleService extends baseAiGenProvider_service_1.BaseAiGenProviderService
|
|
|
101
102
|
}
|
|
102
103
|
return { status: types_1.EVideoSceneStatus.PENDING };
|
|
103
104
|
}
|
|
104
|
-
getCreditUsed({ modelKey, duration = 8 }) {
|
|
105
|
+
getCreditUsed({ modelKey, duration = 8, resolution = "720p", multiClip = false }) {
|
|
105
106
|
const modelConfig = aiModels_1.aiModelConfigs[modelKey];
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
107
|
+
const cost = modelConfig.cost;
|
|
108
|
+
const applyFloor = !multiClip;
|
|
109
|
+
if (cost?.perResolution) {
|
|
110
|
+
const ratePerSecond = cost.perResolution[resolution] ?? cost.perResolution["720p"];
|
|
111
|
+
return (0, helpers_1.getCreditsFromCost)(ratePerSecond * duration, applyFloor);
|
|
112
|
+
}
|
|
113
|
+
if (cost?.perSecond) {
|
|
114
|
+
return (0, helpers_1.getCreditsFromCost)(cost.perSecond * duration, applyFloor);
|
|
115
|
+
}
|
|
116
|
+
logger_1.logger.warn(`Google getCreditUsed: no cost config found for modelKey="${modelKey}" — returning fallback`, { modelKey, duration, resolution });
|
|
117
|
+
return (0, helpers_1.getCreditsFromCost)(1.0, applyFloor);
|
|
109
118
|
}
|
|
110
119
|
}
|
|
111
120
|
exports.GoogleService = GoogleService;
|
|
@@ -13,6 +13,6 @@ export declare class KlingService extends BaseAiGenProviderService {
|
|
|
13
13
|
private checkRegularVideoStatus;
|
|
14
14
|
private checkAvatarVideoStatus;
|
|
15
15
|
encodeJwtToken(): string;
|
|
16
|
-
getCreditUsed({ modelKey, mode, duration, }: CreditUsageParams): number;
|
|
16
|
+
getCreditUsed({ modelKey, mode, duration, multiClip, }: CreditUsageParams): number;
|
|
17
17
|
}
|
|
18
18
|
//# sourceMappingURL=kling.service.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kling.service.d.ts","sourceRoot":"","sources":["../../../../../src/services/aiGen/providers/kling/kling.service.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EACrB,qBAAqB,EACrB,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,UAAU,CAAC;AAYlB,qBAAa,YAAa,SAAQ,wBAAwB;IACxD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAuC;IAC/D,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAW;IAC3C,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAU;;YAW1B,OAAO;IA8Bf,aAAa,CACjB,MAAM,EAAE,qBAAqB,GAC5B,OAAO,CAAC,qBAAqB,CAAC;YAqCnB,mBAAmB;YAqCnB,uBAAuB;
|
|
1
|
+
{"version":3,"file":"kling.service.d.ts","sourceRoot":"","sources":["../../../../../src/services/aiGen/providers/kling/kling.service.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EACrB,qBAAqB,EACrB,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,UAAU,CAAC;AAYlB,qBAAa,YAAa,SAAQ,wBAAwB;IACxD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAuC;IAC/D,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAW;IAC3C,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAU;;YAW1B,OAAO;IA8Bf,aAAa,CACjB,MAAM,EAAE,qBAAqB,GAC5B,OAAO,CAAC,qBAAqB,CAAC;YAqCnB,mBAAmB;YAqCnB,uBAAuB;IA4E/B,gBAAgB,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC;YAO/D,uBAAuB;YAgEvB,sBAAsB;IA6DpC,cAAc,IAAI,MAAM;IAexB,aAAa,CAAC,EACZ,QAAQ,EACR,IAA8B,EAC9B,QAAY,EACZ,SAAiB,GAClB,EAAE,iBAAiB,GAAG,MAAM;CAmB9B"}
|
|
@@ -95,24 +95,57 @@ class KlingService extends baseAiGenProvider_service_1.BaseAiGenProviderService
|
|
|
95
95
|
return await this.request(endpoint, method, body, timeout);
|
|
96
96
|
}
|
|
97
97
|
catch (err) {
|
|
98
|
+
const httpStatus = err.response?.status;
|
|
99
|
+
const klingCode = err.response?.data?.code;
|
|
98
100
|
const isTimeout = err.code === "ECONNABORTED" || err.message?.includes("timeout");
|
|
99
101
|
const isNetworkError = err.code === "ECONNRESET" ||
|
|
100
102
|
err.code === "ECONNREFUSED" ||
|
|
101
103
|
err.code === "ENOTFOUND" ||
|
|
102
104
|
err.code === "ERR_NETWORK" ||
|
|
103
105
|
err?.name === "AggregateError";
|
|
104
|
-
|
|
105
|
-
|
|
106
|
+
// Kling code 1102 = "Account balance not enough".
|
|
107
|
+
// Kling returns HTTP 429 for this, but it is NOT a transient rate-limit —
|
|
108
|
+
// retrying will always fail until the account is topped up.
|
|
109
|
+
const isInsufficientBalance = klingCode === 1102;
|
|
110
|
+
// True rate-limit (HTTP 429 without the balance code) — worth retrying with backoff.
|
|
111
|
+
const isRateLimit = httpStatus === 429 && !isInsufficientBalance;
|
|
112
|
+
const isRetryable = (isTimeout || isNetworkError || isRateLimit) && !isInsufficientBalance;
|
|
113
|
+
// Insufficient balance is a critical ops issue — surface immediately to Slack.
|
|
114
|
+
if (isInsufficientBalance) {
|
|
115
|
+
logger_1.logger.error("Kling account balance too low — top up required to continue video generation", {
|
|
116
|
+
endpoint,
|
|
117
|
+
klingCode,
|
|
118
|
+
klingMessage: err.response?.data?.message,
|
|
119
|
+
httpStatus,
|
|
120
|
+
});
|
|
106
121
|
throw err;
|
|
107
|
-
|
|
122
|
+
}
|
|
123
|
+
if (!isRetryable || attempt === maxAttempts) {
|
|
124
|
+
logger_1.logger.error("Kling API request failed (non-retryable or max attempts reached)", {
|
|
125
|
+
endpoint,
|
|
126
|
+
attempt,
|
|
127
|
+
maxAttempts,
|
|
128
|
+
httpStatus,
|
|
129
|
+
responseData: err.response?.data,
|
|
130
|
+
errorCode: err.code,
|
|
131
|
+
errorName: err?.name,
|
|
132
|
+
errorMessage: err.message,
|
|
133
|
+
});
|
|
134
|
+
throw err;
|
|
135
|
+
}
|
|
136
|
+
const backoffMs = isRateLimit ? 10000 : 1000;
|
|
137
|
+
logger_1.logger.warn("Kling request failed — retrying", {
|
|
108
138
|
endpoint,
|
|
109
139
|
attempt,
|
|
110
140
|
maxAttempts,
|
|
111
141
|
timeoutMs: timeout,
|
|
142
|
+
httpStatus,
|
|
143
|
+
responseData: err.response?.data,
|
|
112
144
|
errorCode: err.code,
|
|
113
145
|
errorName: err?.name,
|
|
146
|
+
backoffMs,
|
|
114
147
|
});
|
|
115
|
-
await new Promise((r) => setTimeout(r,
|
|
148
|
+
await new Promise((r) => setTimeout(r, backoffMs));
|
|
116
149
|
}
|
|
117
150
|
}
|
|
118
151
|
throw new Error("Unreachable");
|
|
@@ -163,7 +196,7 @@ class KlingService extends baseAiGenProvider_service_1.BaseAiGenProviderService
|
|
|
163
196
|
if (result.data.task_status === "failed") {
|
|
164
197
|
return {
|
|
165
198
|
status: types_1.EVideoSceneStatus.FAILED,
|
|
166
|
-
errorMessage:
|
|
199
|
+
errorMessage: result.data.task_status_msg || result.message || "Kling task failed (no reason provided)",
|
|
167
200
|
};
|
|
168
201
|
}
|
|
169
202
|
return { status: types_1.EVideoSceneStatus.PENDING };
|
|
@@ -171,7 +204,7 @@ class KlingService extends baseAiGenProvider_service_1.BaseAiGenProviderService
|
|
|
171
204
|
async checkAvatarVideoStatus({ task, outputFilename, outputFilePath = "videos", }) {
|
|
172
205
|
const startTime = Date.now();
|
|
173
206
|
const result = await this.requestWithTimeoutRetry(`/v1/videos/avatar/image2video/${task}`, "GET");
|
|
174
|
-
logger_1.logger.info("Kling checkAvatarVideoStatus polled", { task, durationMs: Date.now() - startTime, status: result?.data?.task_status });
|
|
207
|
+
logger_1.logger.info("Kling checkAvatarVideoStatus polled", { task, durationMs: Date.now() - startTime, status: result?.data?.task_status, statusMsg: result?.data?.task_status_msg || undefined });
|
|
175
208
|
if (!result) {
|
|
176
209
|
return {
|
|
177
210
|
status: types_1.EVideoSceneStatus.FAILED,
|
|
@@ -206,7 +239,7 @@ class KlingService extends baseAiGenProvider_service_1.BaseAiGenProviderService
|
|
|
206
239
|
if (result.data.task_status === "failed") {
|
|
207
240
|
return {
|
|
208
241
|
status: types_1.EVideoSceneStatus.FAILED,
|
|
209
|
-
errorMessage:
|
|
242
|
+
errorMessage: result.data.task_status_msg || result.message || "Kling avatar task failed (no reason provided)",
|
|
210
243
|
};
|
|
211
244
|
}
|
|
212
245
|
return { status: types_1.EVideoSceneStatus.PENDING };
|
|
@@ -223,17 +256,22 @@ class KlingService extends baseAiGenProvider_service_1.BaseAiGenProviderService
|
|
|
223
256
|
};
|
|
224
257
|
return jsonwebtoken_1.default.sign(payload, process.env.KLING_SECRET_KEY, options);
|
|
225
258
|
}
|
|
226
|
-
getCreditUsed({ modelKey, mode = types_2.EVideoMode.PROFESSIONAL, duration = 5, }) {
|
|
259
|
+
getCreditUsed({ modelKey, mode = types_2.EVideoMode.PROFESSIONAL, duration = 5, multiClip = false, }) {
|
|
227
260
|
const modelConfig = aiModels_1.aiModelConfigs[modelKey];
|
|
228
|
-
|
|
261
|
+
const applyFloor = !multiClip;
|
|
262
|
+
// Avatar: per-second pricing based on mode (cost.perMode[mode].perSecond)
|
|
229
263
|
if (modelKey === "kling-avatar") {
|
|
230
|
-
const perSecond = modelConfig?.cost?.[mode]?.perSecond
|
|
231
|
-
?? modelConfig?.cost?.["std"]?.perSecond
|
|
264
|
+
const perSecond = modelConfig?.cost?.perMode?.[mode]?.perSecond
|
|
265
|
+
?? modelConfig?.cost?.perMode?.["std"]?.perSecond
|
|
232
266
|
?? 0.014;
|
|
233
|
-
return (0, helpers_2.getCreditsFromCost)(perSecond * duration);
|
|
267
|
+
return (0, helpers_2.getCreditsFromCost)(perSecond * duration, applyFloor);
|
|
234
268
|
}
|
|
235
269
|
const cost = modelConfig?.cost?.table?.[mode]?.[duration];
|
|
236
|
-
|
|
270
|
+
if (cost === undefined || cost === null) {
|
|
271
|
+
logger_1.logger.warn(`Kling getCreditUsed: no cost entry for modelKey="${modelKey}" mode="${mode}" duration=${duration} — returning fallback`, { modelKey, mode, duration });
|
|
272
|
+
return (0, helpers_2.getCreditsFromCost)(1.0, applyFloor);
|
|
273
|
+
}
|
|
274
|
+
return (0, helpers_2.getCreditsFromCost)(cost, applyFloor);
|
|
237
275
|
}
|
|
238
276
|
}
|
|
239
277
|
exports.KlingService = KlingService;
|
|
@@ -7,6 +7,6 @@ export declare class MinimaxService extends BaseAiGenProviderService {
|
|
|
7
7
|
private request;
|
|
8
8
|
generateVideo(params: VideoGenerationParams): Promise<VideoGenerationResult>;
|
|
9
9
|
checkVideoStatus({ task, outputFilename, outputFilePath, }: VideoStatusParams): Promise<VideoStatusResult>;
|
|
10
|
-
getCreditUsed({ modelKey, resolution, duration, }: CreditUsageParams): number;
|
|
10
|
+
getCreditUsed({ modelKey, resolution, duration, multiClip, }: CreditUsageParams): number;
|
|
11
11
|
}
|
|
12
12
|
//# sourceMappingURL=minimax.service.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"minimax.service.d.ts","sourceRoot":"","sources":["../../../../../src/services/aiGen/providers/minimax/minimax.service.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EACrB,qBAAqB,EACrB,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"minimax.service.d.ts","sourceRoot":"","sources":["../../../../../src/services/aiGen/providers/minimax/minimax.service.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EACrB,qBAAqB,EACrB,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,UAAU,CAAC;AAUlB,qBAAa,cAAe,SAAQ,wBAAwB;IAC1D,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA4B;IAEpD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;;YAUlB,OAAO;IAiCf,aAAa,CACjB,MAAM,EAAE,qBAAqB,GAC5B,OAAO,CAAC,qBAAqB,CAAC;IA4B3B,gBAAgB,CAAC,EACrB,IAAI,EACJ,cAAc,EACd,cAAyB,GAC1B,EAAE,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IA6EjD,aAAa,CAAC,EACZ,QAAQ,EACR,UAAmB,EACnB,QAAY,EACZ,SAAiB,GAClB,EAAE,iBAAiB,GAAG,MAAM;CAW9B"}
|
|
@@ -11,6 +11,7 @@ const types_1 = require("../../../../globals/types");
|
|
|
11
11
|
const helpers_1 = require("../../helpers");
|
|
12
12
|
const baseAiGenProvider_service_1 = require("../baseAiGenProvider.service");
|
|
13
13
|
const helpers_2 = require("../../../../utils/helpers");
|
|
14
|
+
const logger_1 = require("../../../../utils/logger");
|
|
14
15
|
class MinimaxService extends baseAiGenProvider_service_1.BaseAiGenProviderService {
|
|
15
16
|
constructor() {
|
|
16
17
|
super();
|
|
@@ -108,11 +109,15 @@ class MinimaxService extends baseAiGenProvider_service_1.BaseAiGenProviderServic
|
|
|
108
109
|
// rest status are pending forms
|
|
109
110
|
return { status: types_1.EVideoSceneStatus.PENDING };
|
|
110
111
|
}
|
|
111
|
-
getCreditUsed({ modelKey, resolution = "512P", duration = 6, }) {
|
|
112
|
+
getCreditUsed({ modelKey, resolution = "512P", duration = 6, multiClip = false, }) {
|
|
112
113
|
const modelConfig = aiModels_1.aiModelConfigs[modelKey];
|
|
113
114
|
const cost = modelConfig.cost?.fixed ??
|
|
114
115
|
modelConfig.cost?.table?.[resolution]?.[duration];
|
|
115
|
-
|
|
116
|
+
if (cost === undefined || cost === null) {
|
|
117
|
+
logger_1.logger.warn(`Minimax getCreditUsed: no cost entry for modelKey="${modelKey}" resolution="${resolution}" duration=${duration} — returning fallback`, { modelKey, resolution, duration });
|
|
118
|
+
return (0, helpers_2.getCreditsFromCost)(1.0, !multiClip);
|
|
119
|
+
}
|
|
120
|
+
return (0, helpers_2.getCreditsFromCost)(cost, !multiClip);
|
|
116
121
|
}
|
|
117
122
|
}
|
|
118
123
|
exports.MinimaxService = MinimaxService;
|
|
@@ -7,6 +7,6 @@ export declare class OpenaiService extends BaseAiGenProviderService {
|
|
|
7
7
|
generateVideo(params: VideoGenerationParams): Promise<VideoGenerationResult>;
|
|
8
8
|
checkVideoStatus({ task, outputFilename, outputFilePath, }: VideoStatusParams): Promise<VideoStatusResult>;
|
|
9
9
|
generateText(params: TextGenerationParams): Promise<TextGenerationResult>;
|
|
10
|
-
getCreditUsed({ modelKey, resolution, duration, }: CreditUsageParams): number;
|
|
10
|
+
getCreditUsed({ modelKey, resolution, duration, multiClip, }: CreditUsageParams): number;
|
|
11
11
|
}
|
|
12
12
|
//# sourceMappingURL=openai.service.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openai.service.d.ts","sourceRoot":"","sources":["../../../../../src/services/aiGen/providers/openai/openai.service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"openai.service.d.ts","sourceRoot":"","sources":["../../../../../src/services/aiGen/providers/openai/openai.service.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,EACL,iBAAiB,EACjB,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,EACrB,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,UAAU,CAAC;AAElB,qBAAa,aAAc,SAAQ,wBAAwB;IACzD,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAa;IACxC,OAAO,CAAC,MAAM,CAAS;;IAQjB,aAAa,CACjB,MAAM,EAAE,qBAAqB,GAC5B,OAAO,CAAC,qBAAqB,CAAC;IAoB3B,gBAAgB,CAAC,EACrB,IAAI,EACJ,cAAc,EACd,cAAyB,GAC1B,EAAE,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAsC3C,YAAY,CAChB,MAAM,EAAE,oBAAoB,GAC3B,OAAO,CAAC,oBAAoB,CAAC;IA2ChC,aAAa,CAAC,EACZ,QAAQ,EACR,UAAuB,EACvB,QAAY,EACZ,SAAiB,GAClB,EAAE,iBAAiB,GAAG,MAAM;CAS9B"}
|
|
@@ -10,6 +10,7 @@ const aiModels_1 = require("../../../../globals/aiModels");
|
|
|
10
10
|
const types_1 = require("../../../../globals/types");
|
|
11
11
|
const firebase_1 = require("../../../../libs/firebase");
|
|
12
12
|
const utils_1 = require("../../../../utils");
|
|
13
|
+
const logger_1 = require("../../../../utils/logger");
|
|
13
14
|
const helpers_1 = require("../../helpers");
|
|
14
15
|
const baseAiGenProvider_service_1 = require("../baseAiGenProvider.service");
|
|
15
16
|
class OpenaiService extends baseAiGenProvider_service_1.BaseAiGenProviderService {
|
|
@@ -102,10 +103,14 @@ class OpenaiService extends baseAiGenProvider_service_1.BaseAiGenProviderService
|
|
|
102
103
|
text,
|
|
103
104
|
};
|
|
104
105
|
}
|
|
105
|
-
getCreditUsed({ modelKey, resolution = "720x1280", duration = 5, }) {
|
|
106
|
+
getCreditUsed({ modelKey, resolution = "720x1280", duration = 5, multiClip = false, }) {
|
|
106
107
|
const modelConfig = aiModels_1.aiModelConfigs[modelKey];
|
|
107
108
|
const cost = modelConfig?.cost?.table?.[resolution]?.[duration];
|
|
108
|
-
|
|
109
|
+
if (cost === undefined || cost === null) {
|
|
110
|
+
logger_1.logger.warn(`OpenAI getCreditUsed: no cost entry for modelKey="${modelKey}" resolution="${resolution}" duration=${duration} — returning fallback`, { modelKey, resolution, duration });
|
|
111
|
+
return (0, utils_1.getCreditsFromCost)(1.0, !multiClip);
|
|
112
|
+
}
|
|
113
|
+
return (0, utils_1.getCreditsFromCost)(cost, !multiClip);
|
|
109
114
|
}
|
|
110
115
|
}
|
|
111
116
|
exports.OpenaiService = OpenaiService;
|
|
@@ -177,7 +177,7 @@ class PixVerseService extends baseAiGenProvider_service_1.BaseAiGenProviderServi
|
|
|
177
177
|
logger_1.logger.warn(`Unsupported combination for PixVerse credit calc: ${JSON.stringify(params)}`);
|
|
178
178
|
return 10;
|
|
179
179
|
}
|
|
180
|
-
return (0, helpers_2.getCreditsFromCost)(cost);
|
|
180
|
+
return (0, helpers_2.getCreditsFromCost)(cost, !multiClip);
|
|
181
181
|
}
|
|
182
182
|
catch (err) {
|
|
183
183
|
logger_1.logger.error(`PixVerse credit calculation failed`, err);
|
|
@@ -7,6 +7,6 @@ export declare class RunwayService extends BaseAiGenProviderService {
|
|
|
7
7
|
private request;
|
|
8
8
|
generateVideo(params: VideoGenerationParams): Promise<VideoGenerationResult>;
|
|
9
9
|
checkVideoStatus({ task, outputFilename, outputFilePath, }: VideoStatusParams): Promise<VideoStatusResult>;
|
|
10
|
-
getCreditUsed({ modelKey, duration }: CreditUsageParams): number;
|
|
10
|
+
getCreditUsed({ modelKey, duration, multiClip }: CreditUsageParams): number;
|
|
11
11
|
}
|
|
12
12
|
//# sourceMappingURL=runway.service.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runway.service.d.ts","sourceRoot":"","sources":["../../../../../src/services/aiGen/providers/runway/runway.service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"runway.service.d.ts","sourceRoot":"","sources":["../../../../../src/services/aiGen/providers/runway/runway.service.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EACrB,qBAAqB,EACrB,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,UAAU,CAAC;AAGlB,qBAAa,aAAc,SAAQ,wBAAwB;IACzD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAqC;IAC7D,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;;YAUlB,OAAO;IAgCf,aAAa,CACjB,MAAM,EAAE,qBAAqB,GAC5B,OAAO,CAAC,qBAAqB,CAAC;IAqD3B,gBAAgB,CAAC,EACrB,IAAI,EACJ,cAAc,EACd,cAAyB,GAC1B,EAAE,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IA4DjD,aAAa,CAAC,EAAE,QAAQ,EAAE,QAAY,EAAE,SAAiB,EAAE,EAAE,iBAAiB,GAAG,MAAM;CASxF"}
|
|
@@ -9,6 +9,7 @@ const aiModels_1 = require("../../../../globals/aiModels");
|
|
|
9
9
|
const types_1 = require("../../../../globals/types");
|
|
10
10
|
const firebase_1 = require("../../../../libs/firebase");
|
|
11
11
|
const helpers_1 = require("../../../../utils/helpers");
|
|
12
|
+
const logger_1 = require("../../../../utils/logger");
|
|
12
13
|
const helpers_2 = require("../../helpers");
|
|
13
14
|
const baseAiGenProvider_service_1 = require("../baseAiGenProvider.service");
|
|
14
15
|
class RunwayService extends baseAiGenProvider_service_1.BaseAiGenProviderService {
|
|
@@ -126,9 +127,14 @@ class RunwayService extends baseAiGenProvider_service_1.BaseAiGenProviderService
|
|
|
126
127
|
// Still processing
|
|
127
128
|
return { status: types_1.EVideoSceneStatus.PENDING };
|
|
128
129
|
}
|
|
129
|
-
getCreditUsed({ modelKey, duration = 5 }) {
|
|
130
|
+
getCreditUsed({ modelKey, duration = 5, multiClip = false }) {
|
|
130
131
|
const modelConfig = aiModels_1.aiModelConfigs[modelKey];
|
|
131
|
-
|
|
132
|
+
const perSecond = modelConfig.cost?.perSecond;
|
|
133
|
+
if (perSecond === undefined || perSecond === null) {
|
|
134
|
+
logger_1.logger.warn(`Runway getCreditUsed: no perSecond cost config for modelKey="${modelKey}" — returning fallback`, { modelKey, duration });
|
|
135
|
+
return (0, helpers_1.getCreditsFromCost)(1.0, !multiClip);
|
|
136
|
+
}
|
|
137
|
+
return (0, helpers_1.getCreditsFromCost)(perSecond * duration, !multiClip);
|
|
132
138
|
}
|
|
133
139
|
}
|
|
134
140
|
exports.RunwayService = RunwayService;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { BaseTtsProviderService, TtsParams, TtsResult } from "../types";
|
|
1
|
+
import { BaseTtsProviderService, ITtsVoiceOption, TtsParams, TtsResult } from "../types";
|
|
2
2
|
export declare class ElevenLabsService extends BaseTtsProviderService {
|
|
3
3
|
private readonly baseUrl;
|
|
4
4
|
private readonly apiKey;
|
|
5
5
|
constructor();
|
|
6
6
|
generate(params: TtsParams): Promise<TtsResult>;
|
|
7
|
+
getVoices(): ITtsVoiceOption[];
|
|
8
|
+
mapLanguageCode(locale: string): string | undefined;
|
|
7
9
|
}
|
|
8
10
|
//# sourceMappingURL=elevenlabs.service.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"elevenlabs.service.d.ts","sourceRoot":"","sources":["../../../../src/services/tts/providers/elevenlabs.service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"elevenlabs.service.d.ts","sourceRoot":"","sources":["../../../../src/services/tts/providers/elevenlabs.service.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,sBAAsB,EAAE,eAAe,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAEzF,qBAAa,iBAAkB,SAAQ,sBAAsB;IAC3D,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAkC;IAE1D,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;;IAW1B,QAAQ,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;IAmCrD,SAAS,IAAI,eAAe,EAAE;IAI9B,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;CAGpD"}
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.ElevenLabsService = void 0;
|
|
7
7
|
const axios_1 = __importDefault(require("axios"));
|
|
8
8
|
const elevenlabs_1 = require("../../../globals/ttsModels/providers/elevenlabs");
|
|
9
|
+
const voices_1 = require("../../../globals/ttsModels/voices");
|
|
9
10
|
const types_1 = require("../types");
|
|
10
11
|
class ElevenLabsService extends types_1.BaseTtsProviderService {
|
|
11
12
|
constructor() {
|
|
@@ -19,10 +20,13 @@ class ElevenLabsService extends types_1.BaseTtsProviderService {
|
|
|
19
20
|
}
|
|
20
21
|
async generate(params) {
|
|
21
22
|
const voiceId = params.voiceId ?? elevenlabs_1.elevenlabsConfig.defaultVoiceId;
|
|
23
|
+
const languageCode = params.languageCode
|
|
24
|
+
? this.mapLanguageCode(params.languageCode)
|
|
25
|
+
: undefined;
|
|
22
26
|
const response = await axios_1.default.post(`${this.baseUrl}/text-to-speech/${voiceId}`, {
|
|
23
27
|
text: params.text,
|
|
24
28
|
model_id: elevenlabs_1.elevenlabsConfig.modelId,
|
|
25
|
-
language_code:
|
|
29
|
+
language_code: languageCode,
|
|
26
30
|
voice_settings: {
|
|
27
31
|
stability: 0.5,
|
|
28
32
|
similarity_boost: 0.75,
|
|
@@ -42,5 +46,11 @@ class ElevenLabsService extends types_1.BaseTtsProviderService {
|
|
|
42
46
|
extension: "mp3",
|
|
43
47
|
};
|
|
44
48
|
}
|
|
49
|
+
getVoices() {
|
|
50
|
+
return voices_1.ELEVENLABS_VOICES;
|
|
51
|
+
}
|
|
52
|
+
mapLanguageCode(locale) {
|
|
53
|
+
return voices_1.LANG_TO_ELEVENLABS_CODE[locale] ?? locale;
|
|
54
|
+
}
|
|
45
55
|
}
|
|
46
56
|
exports.ElevenLabsService = ElevenLabsService;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { TtsProvider } from "../../globals/ttsModels/types";
|
|
2
2
|
import { BaseTtsProviderService } from "./types";
|
|
3
|
-
export declare function getTtsProviderService(provider
|
|
3
|
+
export declare function getTtsProviderService(provider: TtsProvider): BaseTtsProviderService;
|
|
4
4
|
//# sourceMappingURL=ttsFactory.service.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ttsFactory.service.d.ts","sourceRoot":"","sources":["../../../src/services/tts/ttsFactory.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAE5D,OAAO,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAEjD,wBAAgB,qBAAqB,CAAC,QAAQ,
|
|
1
|
+
{"version":3,"file":"ttsFactory.service.d.ts","sourceRoot":"","sources":["../../../src/services/tts/ttsFactory.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAE5D,OAAO,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAEjD,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,WAAW,GAAG,sBAAsB,CAOnF"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getTtsProviderService = getTtsProviderService;
|
|
4
4
|
const elevenlabs_service_1 = require("./providers/elevenlabs.service");
|
|
5
|
-
function getTtsProviderService(provider
|
|
5
|
+
function getTtsProviderService(provider) {
|
|
6
6
|
switch (provider) {
|
|
7
7
|
case "elevenlabs":
|
|
8
8
|
return new elevenlabs_service_1.ElevenLabsService();
|
|
@@ -8,7 +8,26 @@ export interface TtsResult {
|
|
|
8
8
|
mimeType: string;
|
|
9
9
|
extension: string;
|
|
10
10
|
}
|
|
11
|
+
export interface ITtsVoiceOption {
|
|
12
|
+
id: string;
|
|
13
|
+
name: string;
|
|
14
|
+
gender?: "male" | "female";
|
|
15
|
+
accent?: string;
|
|
16
|
+
/** Public preview audio URL hosted by the provider (optional — not all providers offer this). */
|
|
17
|
+
previewUrl?: string;
|
|
18
|
+
}
|
|
11
19
|
export declare abstract class BaseTtsProviderService {
|
|
12
20
|
abstract generate(params: TtsParams): Promise<TtsResult>;
|
|
21
|
+
/**
|
|
22
|
+
* Returns the list of voices available for this provider.
|
|
23
|
+
* Used by controllers for voice validation and the /voices endpoint.
|
|
24
|
+
*/
|
|
25
|
+
abstract getVoices(): ITtsVoiceOption[];
|
|
26
|
+
/**
|
|
27
|
+
* Maps a standard locale code (e.g. "en", "fr-FR") to the provider's
|
|
28
|
+
* expected language code format. Returns undefined if no mapping needed.
|
|
29
|
+
* Each provider implements its own mapping table internally.
|
|
30
|
+
*/
|
|
31
|
+
abstract mapLanguageCode(locale: string): string | undefined;
|
|
13
32
|
}
|
|
14
33
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/services/tts/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,SAAS;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,8BAAsB,sBAAsB;IAC1C,QAAQ,CAAC,QAAQ,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/services/tts/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,SAAS;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,GAAG,QAAQ,CAAC;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,iGAAiG;IACjG,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,8BAAsB,sBAAsB;IAC1C,QAAQ,CAAC,QAAQ,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;IAExD;;;OAGG;IACH,QAAQ,CAAC,SAAS,IAAI,eAAe,EAAE;IAEvC;;;;OAIG;IACH,QAAQ,CAAC,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;CAC7D"}
|
package/lib/utils/helpers.d.ts
CHANGED
|
@@ -1,10 +1,24 @@
|
|
|
1
|
-
import { ELANGUAGE_CODE, ERENEWAL_FREQUENCY, ESUBSCRIPTION_PLANS, IDetectLang } from "../globals/types";
|
|
1
|
+
import { ELANGUAGE_CODE, ERENEWAL_FREQUENCY, ESUBSCRIPTION_PLANS, EVideoDurationType, IDetectLang } from "../globals/types";
|
|
2
2
|
import z from "zod";
|
|
3
3
|
import { ETextGenModels } from "../globals";
|
|
4
4
|
export declare const getPlanTypeById: (priceId: string) => ESUBSCRIPTION_PLANS | null;
|
|
5
5
|
export declare const getFreqById: (priceId: string) => ERENEWAL_FREQUENCY | null;
|
|
6
6
|
export declare const getPriceIdByType: (type: ESUBSCRIPTION_PLANS, freq?: ERENEWAL_FREQUENCY) => string;
|
|
7
|
-
export declare const getCreditsFromCost: (cost: number) => number;
|
|
7
|
+
export declare const getCreditsFromCost: (cost: number, applyFloor?: boolean) => number;
|
|
8
|
+
/**
|
|
9
|
+
* Discount factors applied to the total clip cost for multi-clip video types.
|
|
10
|
+
* Implements economies-of-scale pricing: higher volume → lower per-clip margin.
|
|
11
|
+
*
|
|
12
|
+
* Factors are calibrated so annual-plan users ($0.15/credit) retain ≥20% gross margin
|
|
13
|
+
* on every video type. The break-even condition is: factor × $0.15 / $0.10 ≥ 1.25.
|
|
14
|
+
*
|
|
15
|
+
* SHORT: 1.00 (no discount) → monthly 50% margin | annual 33% margin
|
|
16
|
+
* MEDIUM: 0.90 (10% discount) → monthly 46% margin | annual 26% margin
|
|
17
|
+
* LONG: 0.85 (15% discount) → monthly 41% margin | annual 21% margin
|
|
18
|
+
* VERY_LONG: 0.80 (20% discount) → monthly 36% margin | annual 20% margin
|
|
19
|
+
*/
|
|
20
|
+
export declare const MULTI_CLIP_DISCOUNT_FACTORS: Partial<Record<EVideoDurationType, number>>;
|
|
21
|
+
export declare function getMultiClipDiscountFactor(durationType: EVideoDurationType): number;
|
|
8
22
|
export declare const getTranslationWrapper: (text: string, from: ELANGUAGE_CODE, to?: ELANGUAGE_CODE, version?: "v1" | "v2") => Promise<string>;
|
|
9
23
|
export declare const detectLang: (text: string) => Promise<IDetectLang>;
|
|
10
24
|
export declare function waitForFile(path: string, timeout?: number, interval?: number): Promise<boolean>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/utils/helpers.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,cAAc,EACd,kBAAkB,EAClB,mBAAmB,
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/utils/helpers.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,cAAc,EACd,kBAAkB,EAClB,mBAAmB,EACnB,kBAAkB,EAElB,WAAW,EACZ,MAAM,kBAAkB,CAAC;AAE1B,OAAO,CAAC,MAAM,KAAK,CAAC;AAEpB,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5C,eAAO,MAAM,eAAe,GAC1B,SAAS,MAAM,KACd,mBAAmB,GAAG,IASxB,CAAC;AAEF,eAAO,MAAM,WAAW,GAAI,SAAS,MAAM,KAAG,kBAAkB,GAAG,IASlE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CAC3B,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AA+CrB,wBAAgB,yBAAyB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAatE"}
|
package/lib/utils/helpers.js
CHANGED
|
@@ -3,7 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.detectLang = exports.getTranslationWrapper = exports.getCreditsFromCost = exports.getPriceIdByType = exports.getFreqById = exports.getPlanTypeById = void 0;
|
|
6
|
+
exports.detectLang = exports.getTranslationWrapper = exports.MULTI_CLIP_DISCOUNT_FACTORS = exports.getCreditsFromCost = exports.getPriceIdByType = exports.getFreqById = exports.getPlanTypeById = void 0;
|
|
7
|
+
exports.getMultiClipDiscountFactor = getMultiClipDiscountFactor;
|
|
7
8
|
exports.waitForFile = waitForFile;
|
|
8
9
|
exports.generateAndValidate = generateAndValidate;
|
|
9
10
|
exports.getVideoDurationRangeText = getVideoDurationRangeText;
|
|
@@ -48,18 +49,35 @@ const getPriceIdByType = (type, freq = types_1.ERENEWAL_FREQUENCY.MONTHLY) => {
|
|
|
48
49
|
: planDetails?.monthly?.id;
|
|
49
50
|
};
|
|
50
51
|
exports.getPriceIdByType = getPriceIdByType;
|
|
51
|
-
const getCreditsFromCost = (cost) => {
|
|
52
|
-
const
|
|
53
|
-
const costPerCredit = 0.1; // multiple
|
|
52
|
+
const getCreditsFromCost = (cost, applyFloor = true) => {
|
|
53
|
+
const costPerCredit = 0.1;
|
|
54
54
|
const minCredits = 10;
|
|
55
55
|
if (cost <= 0)
|
|
56
56
|
return 0;
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
const credits = Math.ceil(rawCredits);
|
|
60
|
-
return Math.max(credits, minCredits);
|
|
57
|
+
const credits = Math.ceil(cost / costPerCredit);
|
|
58
|
+
return applyFloor ? Math.max(credits, minCredits) : credits;
|
|
61
59
|
};
|
|
62
60
|
exports.getCreditsFromCost = getCreditsFromCost;
|
|
61
|
+
/**
|
|
62
|
+
* Discount factors applied to the total clip cost for multi-clip video types.
|
|
63
|
+
* Implements economies-of-scale pricing: higher volume → lower per-clip margin.
|
|
64
|
+
*
|
|
65
|
+
* Factors are calibrated so annual-plan users ($0.15/credit) retain ≥20% gross margin
|
|
66
|
+
* on every video type. The break-even condition is: factor × $0.15 / $0.10 ≥ 1.25.
|
|
67
|
+
*
|
|
68
|
+
* SHORT: 1.00 (no discount) → monthly 50% margin | annual 33% margin
|
|
69
|
+
* MEDIUM: 0.90 (10% discount) → monthly 46% margin | annual 26% margin
|
|
70
|
+
* LONG: 0.85 (15% discount) → monthly 41% margin | annual 21% margin
|
|
71
|
+
* VERY_LONG: 0.80 (20% discount) → monthly 36% margin | annual 20% margin
|
|
72
|
+
*/
|
|
73
|
+
exports.MULTI_CLIP_DISCOUNT_FACTORS = {
|
|
74
|
+
[types_1.EVideoDurationType.MEDIUM]: 0.90,
|
|
75
|
+
[types_1.EVideoDurationType.LONG]: 0.85,
|
|
76
|
+
[types_1.EVideoDurationType.VERY_LONG]: 0.80,
|
|
77
|
+
};
|
|
78
|
+
function getMultiClipDiscountFactor(durationType) {
|
|
79
|
+
return exports.MULTI_CLIP_DISCOUNT_FACTORS[durationType] ?? 1.0;
|
|
80
|
+
}
|
|
63
81
|
const getTranslationWrapper = async (text, from, to = types_1.ELANGUAGE_CODE.en, version = "v2") => {
|
|
64
82
|
try {
|
|
65
83
|
const res = await axios_1.default.post("https://us-central1-translation-service-3931b.cloudfunctions.net/translate", { text, from, to, version }, {
|
package/lib/utils/ttsUtils.d.ts
CHANGED
|
@@ -8,4 +8,19 @@
|
|
|
8
8
|
* @param wordsPerSecond - Speaking rate from the TTS provider config
|
|
9
9
|
*/
|
|
10
10
|
export declare function estimateTtsDurationSeconds(text: string, wordsPerSecond: number): number;
|
|
11
|
+
/**
|
|
12
|
+
* Splits a long TTS text into chunks whose estimated spoken duration is at or
|
|
13
|
+
* below `maxDurationSeconds`.
|
|
14
|
+
*
|
|
15
|
+
* Splitting happens at sentence-boundary punctuation (., !, ?, newlines) so
|
|
16
|
+
* the generated audio sounds natural. Each chunk is also capped at `maxCharsPerRequest`
|
|
17
|
+
* (the provider's per-call character limit from ITtsProviderConfig).
|
|
18
|
+
*
|
|
19
|
+
* @param text - The full TTS input text
|
|
20
|
+
* @param wordsPerSecond - Speaking rate from the TTS provider config
|
|
21
|
+
* @param maxDurationSeconds - Maximum spoken duration per chunk (should include safety buffer)
|
|
22
|
+
* @param maxCharsPerRequest - Provider's per-call character limit from ITtsProviderConfig
|
|
23
|
+
* @returns Array of text chunks, each safe to send in a single TTS API call
|
|
24
|
+
*/
|
|
25
|
+
export declare function splitTtsTextByDuration(text: string, wordsPerSecond: number, maxDurationSeconds: number, maxCharsPerRequest: number): string[];
|
|
11
26
|
//# sourceMappingURL=ttsUtils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ttsUtils.d.ts","sourceRoot":"","sources":["../../src/utils/ttsUtils.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,MAAM,CAGvF"}
|
|
1
|
+
{"version":3,"file":"ttsUtils.d.ts","sourceRoot":"","sources":["../../src/utils/ttsUtils.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,MAAM,CAGvF;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,MAAM,EACZ,cAAc,EAAE,MAAM,EACtB,kBAAkB,EAAE,MAAM,EAC1B,kBAAkB,EAAE,MAAM,GACzB,MAAM,EAAE,CA8BV"}
|
package/lib/utils/ttsUtils.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.estimateTtsDurationSeconds = estimateTtsDurationSeconds;
|
|
4
|
+
exports.splitTtsTextByDuration = splitTtsTextByDuration;
|
|
4
5
|
/**
|
|
5
6
|
* Estimates the spoken duration of a TTS text in seconds.
|
|
6
7
|
*
|
|
@@ -14,3 +15,43 @@ function estimateTtsDurationSeconds(text, wordsPerSecond) {
|
|
|
14
15
|
const words = text.trim().split(/\s+/).length;
|
|
15
16
|
return Math.ceil(words / wordsPerSecond);
|
|
16
17
|
}
|
|
18
|
+
/**
|
|
19
|
+
* Splits a long TTS text into chunks whose estimated spoken duration is at or
|
|
20
|
+
* below `maxDurationSeconds`.
|
|
21
|
+
*
|
|
22
|
+
* Splitting happens at sentence-boundary punctuation (., !, ?, newlines) so
|
|
23
|
+
* the generated audio sounds natural. Each chunk is also capped at `maxCharsPerRequest`
|
|
24
|
+
* (the provider's per-call character limit from ITtsProviderConfig).
|
|
25
|
+
*
|
|
26
|
+
* @param text - The full TTS input text
|
|
27
|
+
* @param wordsPerSecond - Speaking rate from the TTS provider config
|
|
28
|
+
* @param maxDurationSeconds - Maximum spoken duration per chunk (should include safety buffer)
|
|
29
|
+
* @param maxCharsPerRequest - Provider's per-call character limit from ITtsProviderConfig
|
|
30
|
+
* @returns Array of text chunks, each safe to send in a single TTS API call
|
|
31
|
+
*/
|
|
32
|
+
function splitTtsTextByDuration(text, wordsPerSecond, maxDurationSeconds, maxCharsPerRequest) {
|
|
33
|
+
const maxWords = Math.floor(maxDurationSeconds * wordsPerSecond);
|
|
34
|
+
// Split at sentence boundaries, keeping the delimiter attached to the sentence
|
|
35
|
+
const sentences = text.match(/[^.!?\n]+[.!?\n]?/g) ?? [text];
|
|
36
|
+
const chunks = [];
|
|
37
|
+
let currentChunk = "";
|
|
38
|
+
let currentWords = 0;
|
|
39
|
+
for (const sentence of sentences) {
|
|
40
|
+
const sentenceWords = sentence.trim().split(/\s+/).length;
|
|
41
|
+
const wouldExceedDuration = currentWords + sentenceWords > maxWords;
|
|
42
|
+
const wouldExceedChars = currentChunk.length + sentence.length > maxCharsPerRequest;
|
|
43
|
+
if (currentChunk && (wouldExceedDuration || wouldExceedChars)) {
|
|
44
|
+
chunks.push(currentChunk.trim());
|
|
45
|
+
currentChunk = sentence;
|
|
46
|
+
currentWords = sentenceWords;
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
currentChunk += sentence;
|
|
50
|
+
currentWords += sentenceWords;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
if (currentChunk.trim()) {
|
|
54
|
+
chunks.push(currentChunk.trim());
|
|
55
|
+
}
|
|
56
|
+
return chunks.filter(Boolean);
|
|
57
|
+
}
|
package/package.json
CHANGED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { FieldValue } from "firebase-admin/firestore";
|
|
2
|
-
export interface IEditorStateModel {
|
|
3
|
-
videoJobId: string;
|
|
4
|
-
userId: string;
|
|
5
|
-
design: Record<string, any>;
|
|
6
|
-
createdAt: FieldValue;
|
|
7
|
-
updatedAt: FieldValue;
|
|
8
|
-
}
|
|
9
|
-
//# sourceMappingURL=editorState.model.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"editorState.model.d.ts","sourceRoot":"","sources":["../../src/models/editorState.model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAEtD,MAAM,WAAW,iBAAiB;IAChC,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC5B,SAAS,EAAE,UAAU,CAAC;IACtB,SAAS,EAAE,UAAU,CAAC;CACvB"}
|