vidspotai-shared 1.0.40 → 1.0.42
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/services/aiGen/providers/minimax/minimax.service.d.ts.map +1 -1
- package/lib/services/aiGen/providers/minimax/minimax.service.js +23 -1
- package/lib/services/tts/providers/elevenlabs.service.d.ts.map +1 -1
- package/lib/services/tts/providers/elevenlabs.service.js +42 -22
- package/lib/utils/helpers.d.ts +7 -4
- package/lib/utils/helpers.d.ts.map +1 -1
- package/lib/utils/helpers.js +10 -7
- package/package.json +1 -1
|
@@ -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;AAiClB,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"}
|
|
@@ -12,6 +12,28 @@ const helpers_1 = require("../../helpers");
|
|
|
12
12
|
const baseAiGenProvider_service_1 = require("../baseAiGenProvider.service");
|
|
13
13
|
const helpers_2 = require("../../../../utils/helpers");
|
|
14
14
|
const logger_1 = require("../../../../utils/logger");
|
|
15
|
+
/**
|
|
16
|
+
* Maps Minimax base_resp status codes to user-facing error messages.
|
|
17
|
+
* Raw codes like "1026 input new_sensitive" are never shown to users.
|
|
18
|
+
*/
|
|
19
|
+
function minimaxStatusToUserMessage(code, msg) {
|
|
20
|
+
const lower = msg.toLowerCase();
|
|
21
|
+
switch (code) {
|
|
22
|
+
case 1026:
|
|
23
|
+
// Input (prompt or image) flagged by content moderation
|
|
24
|
+
return "Your request was declined because the prompt or input image contains content that violates the content policy. Please modify your prompt or use a different image and try again.";
|
|
25
|
+
case 1027:
|
|
26
|
+
// Generated output flagged by content moderation
|
|
27
|
+
return "Your request was declined because the generated content was flagged for sensitive material. Please adjust your prompt and try again.";
|
|
28
|
+
case 1002:
|
|
29
|
+
return "The request was rejected due to a rate limit or quota issue. Please try again in a moment.";
|
|
30
|
+
case 1004:
|
|
31
|
+
return "Authorization failed for the video generation service. Please contact support.";
|
|
32
|
+
default:
|
|
33
|
+
// Unknown code — return the raw message so ops can see it but strip internal codes
|
|
34
|
+
return msg || `Generation failed (code ${code})`;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
15
37
|
class MinimaxService extends baseAiGenProvider_service_1.BaseAiGenProviderService {
|
|
16
38
|
constructor() {
|
|
17
39
|
super();
|
|
@@ -64,7 +86,7 @@ class MinimaxService extends baseAiGenProvider_service_1.BaseAiGenProviderServic
|
|
|
64
86
|
if (result.status === "Fail") {
|
|
65
87
|
return {
|
|
66
88
|
status: types_1.EVideoSceneStatus.FAILED,
|
|
67
|
-
errorMessage:
|
|
89
|
+
errorMessage: minimaxStatusToUserMessage(result.base_resp.status_code, result.base_resp.status_msg),
|
|
68
90
|
};
|
|
69
91
|
}
|
|
70
92
|
else if (result.status === "Success") {
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
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;IAuDrD,SAAS,IAAI,eAAe,EAAE;IAI9B,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;CAGpD"}
|
|
@@ -23,28 +23,48 @@ class ElevenLabsService extends types_1.BaseTtsProviderService {
|
|
|
23
23
|
const languageCode = params.languageCode
|
|
24
24
|
? this.mapLanguageCode(params.languageCode)
|
|
25
25
|
: undefined;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
26
|
+
try {
|
|
27
|
+
const response = await axios_1.default.post(`${this.baseUrl}/text-to-speech/${voiceId}`, {
|
|
28
|
+
text: params.text,
|
|
29
|
+
model_id: elevenlabs_1.elevenlabsConfig.modelId,
|
|
30
|
+
language_code: languageCode,
|
|
31
|
+
voice_settings: {
|
|
32
|
+
stability: 0.5,
|
|
33
|
+
similarity_boost: 0.75,
|
|
34
|
+
},
|
|
35
|
+
}, {
|
|
36
|
+
headers: {
|
|
37
|
+
"xi-api-key": this.apiKey,
|
|
38
|
+
"Content-Type": "application/json",
|
|
39
|
+
Accept: "audio/mpeg",
|
|
40
|
+
},
|
|
41
|
+
responseType: "arraybuffer",
|
|
42
|
+
timeout: 60000,
|
|
43
|
+
});
|
|
44
|
+
return {
|
|
45
|
+
audioBuffer: Buffer.from(response.data),
|
|
46
|
+
mimeType: "audio/mpeg",
|
|
47
|
+
extension: "mp3",
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
catch (err) {
|
|
51
|
+
// responseType:"arraybuffer" causes error bodies to arrive as Buffer/ArrayBuffer,
|
|
52
|
+
// making err.message just "Request failed with status code N". Decode it here so
|
|
53
|
+
// the actual ElevenLabs reason (e.g. invalid voice, unsupported language_code) is visible.
|
|
54
|
+
if (err.response?.data) {
|
|
55
|
+
let detail = "";
|
|
56
|
+
try {
|
|
57
|
+
const bodyStr = Buffer.from(err.response.data).toString("utf8");
|
|
58
|
+
const parsed = JSON.parse(bodyStr);
|
|
59
|
+
detail = parsed?.detail?.message ?? parsed?.detail ?? bodyStr;
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
detail = Buffer.from(err.response.data).toString("utf8");
|
|
63
|
+
}
|
|
64
|
+
throw new Error(`ElevenLabs TTS ${err.response.status}: ${detail} [voiceId=${voiceId}, languageCode=${languageCode ?? "none"}, textLen=${params.text?.length ?? 0}]`);
|
|
65
|
+
}
|
|
66
|
+
throw err;
|
|
67
|
+
}
|
|
48
68
|
}
|
|
49
69
|
getVoices() {
|
|
50
70
|
return voices_1.ELEVENLABS_VOICES;
|
package/lib/utils/helpers.d.ts
CHANGED
|
@@ -9,10 +9,13 @@ export declare const getCreditsFromCost: (cost: number, applyFloor?: boolean) =>
|
|
|
9
9
|
* Discount factors applied to the total clip cost for multi-clip video types.
|
|
10
10
|
* Implements economies-of-scale pricing: higher volume → lower per-clip margin.
|
|
11
11
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
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
|
|
16
19
|
*/
|
|
17
20
|
export declare const MULTI_CLIP_DISCOUNT_FACTORS: Partial<Record<EVideoDurationType, number>>;
|
|
18
21
|
export declare function getMultiClipDiscountFactor(durationType: EVideoDurationType): number;
|
|
@@ -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,EACnB,kBAAkB,EAElB,WAAW,EACZ,MAAM,kBAAkB,CAAC;AAE1B,OAAO,CAAC,MA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ACtC,UAAS,IAAI,GAAG,IAAW,KAC1B,OAAO,CAAC,MAAM,CAmBhB,CAAC;AAEF,eAAO,MAAM,UAAU,GAAU,MAAM,MAAM,KAAG,OAAO,CAAC,WAAW,CAqBlE,CAAC;AAEF,wBAAsB,WAAW,CAC/B,IAAI,EAAE,MAAM,EACZ,OAAO,SAAQ,EACf,QAAQ,SAAM,oBAQf;AAGD,wBAAsB,mBAAmB,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE;IAC1E,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,GAAG,CAAC;IACjB,SAAS,EAAE,CAAC,CAAC;IACb,QAAQ,CAAC,EAAE,cAAc,CAAC;CAC3B,GAAG,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;AAGxB,wBAAsB,mBAAmB,CAAC,IAAI,EAAE;IAC9C,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,GAAG,CAAC;IACjB,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,QAAQ,CAAC,EAAE,cAAc,CAAC;CAC3B,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AA+CrB,wBAAgB,yBAAyB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAatE"}
|
package/lib/utils/helpers.js
CHANGED
|
@@ -62,15 +62,18 @@ exports.getCreditsFromCost = getCreditsFromCost;
|
|
|
62
62
|
* Discount factors applied to the total clip cost for multi-clip video types.
|
|
63
63
|
* Implements economies-of-scale pricing: higher volume → lower per-clip margin.
|
|
64
64
|
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
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
|
|
69
72
|
*/
|
|
70
73
|
exports.MULTI_CLIP_DISCOUNT_FACTORS = {
|
|
71
|
-
[types_1.EVideoDurationType.MEDIUM]: 0.
|
|
72
|
-
[types_1.EVideoDurationType.LONG]: 0.
|
|
73
|
-
[types_1.EVideoDurationType.VERY_LONG]: 0.
|
|
74
|
+
[types_1.EVideoDurationType.MEDIUM]: 0.90,
|
|
75
|
+
[types_1.EVideoDurationType.LONG]: 0.85,
|
|
76
|
+
[types_1.EVideoDurationType.VERY_LONG]: 0.80,
|
|
74
77
|
};
|
|
75
78
|
function getMultiClipDiscountFactor(durationType) {
|
|
76
79
|
return exports.MULTI_CLIP_DISCOUNT_FACTORS[durationType] ?? 1.0;
|