vidspotai-shared 1.0.43 → 1.0.47
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/plans.d.ts +0 -5
- package/lib/globals/plans.d.ts.map +1 -1
- package/lib/globals/plans.js +1 -15
- package/lib/globals/ttsModels/providers/elevenlabs.js +2 -2
- package/lib/globals/ttsModels/voices.d.ts +4 -3
- package/lib/globals/ttsModels/voices.d.ts.map +1 -1
- package/lib/globals/ttsModels/voices.js +12 -5
- package/lib/models/user.model.d.ts +0 -7
- package/lib/models/user.model.d.ts.map +1 -1
- package/lib/services/credit.service.d.ts.map +1 -1
- package/lib/services/credit.service.js +6 -23
- package/lib/services/tts/providers/elevenlabs.service.d.ts.map +1 -1
- package/lib/services/tts/providers/elevenlabs.service.js +24 -0
- package/package.json +1 -1
package/lib/globals/plans.d.ts
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
1
|
import { TPaymentPlans } from "./types";
|
|
2
2
|
export declare const PAYMENT_PLANS: Partial<TPaymentPlans>;
|
|
3
|
-
export declare const CREDIT_TOPUP_MIN = 20;
|
|
4
|
-
export declare const CREDIT_TOPUP_EXPIRY_MONTHS = 12;
|
|
5
|
-
export declare const CREDIT_TOPUP_RATE: (credits: number) => number;
|
|
6
|
-
/** Returns the Stripe charge amount in cents for a given credit count */
|
|
7
|
-
export declare const CREDIT_TOPUP_AMOUNT_CENTS: (credits: number) => number;
|
|
8
3
|
//# sourceMappingURL=plans.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plans.d.ts","sourceRoot":"","sources":["../../src/globals/plans.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,aAAa,EAEd,MAAM,SAAS,CAAC;AAEjB,eAAO,MAAM,aAAa,EAAE,OAAO,CAAC,aAAa,CAqChD,CAAC
|
|
1
|
+
{"version":3,"file":"plans.d.ts","sourceRoot":"","sources":["../../src/globals/plans.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,aAAa,EAEd,MAAM,SAAS,CAAC;AAEjB,eAAO,MAAM,aAAa,EAAE,OAAO,CAAC,aAAa,CAqChD,CAAC"}
|
package/lib/globals/plans.js
CHANGED
|
@@ -3,7 +3,7 @@ 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.
|
|
6
|
+
exports.PAYMENT_PLANS = void 0;
|
|
7
7
|
const config_1 = __importDefault(require("./config"));
|
|
8
8
|
const types_1 = require("./types");
|
|
9
9
|
exports.PAYMENT_PLANS = {
|
|
@@ -44,20 +44,6 @@ exports.PAYMENT_PLANS = {
|
|
|
44
44
|
},
|
|
45
45
|
},
|
|
46
46
|
};
|
|
47
|
-
// Credit top-up pricing (tiered; always more expensive than subscription rate of $0.20/credit)
|
|
48
|
-
exports.CREDIT_TOPUP_MIN = 20;
|
|
49
|
-
exports.CREDIT_TOPUP_EXPIRY_MONTHS = 12;
|
|
50
|
-
const CREDIT_TOPUP_RATE = (credits) => {
|
|
51
|
-
if (credits < 50)
|
|
52
|
-
return 0.35;
|
|
53
|
-
if (credits < 150)
|
|
54
|
-
return 0.3;
|
|
55
|
-
return 0.25;
|
|
56
|
-
};
|
|
57
|
-
exports.CREDIT_TOPUP_RATE = CREDIT_TOPUP_RATE;
|
|
58
|
-
/** Returns the Stripe charge amount in cents for a given credit count */
|
|
59
|
-
const CREDIT_TOPUP_AMOUNT_CENTS = (credits) => Math.round(credits * (0, exports.CREDIT_TOPUP_RATE)(credits) * 100);
|
|
60
|
-
exports.CREDIT_TOPUP_AMOUNT_CENTS = CREDIT_TOPUP_AMOUNT_CENTS;
|
|
61
47
|
// export const SUBSCRIPTION_PLAN_DETAILS: TSubscriptionPlanDetails = {
|
|
62
48
|
// [ESUBSCRIPTION_PLANS.BASIC]: {
|
|
63
49
|
// price: 20,
|
|
@@ -3,11 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.elevenlabsConfig = void 0;
|
|
4
4
|
exports.elevenlabsConfig = {
|
|
5
5
|
name: "ElevenLabs",
|
|
6
|
-
/**
|
|
6
|
+
/** eleven_multilingual_v3 pay-as-you-go rate */
|
|
7
7
|
costPer1KChars: 0.3,
|
|
8
8
|
/** Sarah — neutral, clear default voice */
|
|
9
9
|
defaultVoiceId: "EXAVITQu4vr4xnSDxMaL",
|
|
10
|
-
modelId: "
|
|
10
|
+
modelId: "eleven_multilingual_v3",
|
|
11
11
|
/** ~150 words/min = 2.5 words/sec */
|
|
12
12
|
wordsPerSecond: 2.5,
|
|
13
13
|
/** ElevenLabs API limit per single TTS request */
|
|
@@ -7,15 +7,16 @@ export interface ITtsVoice {
|
|
|
7
7
|
previewUrl: string;
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
10
|
-
* Curated list of ElevenLabs voices compatible with
|
|
10
|
+
* Curated list of ElevenLabs voices compatible with eleven_multilingual_v3.
|
|
11
11
|
* Any voice can speak any supported language via the language_code parameter.
|
|
12
12
|
*/
|
|
13
13
|
export declare const ELEVENLABS_VOICES: ITtsVoice[];
|
|
14
14
|
/** Default voice ID — Sarah (female, American) */
|
|
15
15
|
export declare const DEFAULT_ELEVENLABS_VOICE_ID = "EXAVITQu4vr4xnSDxMaL";
|
|
16
16
|
/**
|
|
17
|
-
* Maps frontend language keys → ElevenLabs language_code
|
|
18
|
-
*
|
|
17
|
+
* Maps frontend language keys → ElevenLabs language_code values supported by eleven_multilingual_v3.
|
|
18
|
+
* Omitting a language lets the model auto-detect it (safe fallback).
|
|
19
|
+
* Reference: https://help.elevenlabs.io/hc/en-us/articles/13313366263441
|
|
19
20
|
*/
|
|
20
21
|
export declare const LANG_TO_ELEVENLABS_CODE: Record<string, string>;
|
|
21
22
|
//# sourceMappingURL=voices.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"voices.d.ts","sourceRoot":"","sources":["../../../src/globals/ttsModels/voices.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,GAAG,QAAQ,CAAC;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,8CAA8C;IAC9C,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;;GAGG;AACH,eAAO,MAAM,iBAAiB,EAAE,SAAS,EAuFxC,CAAC;AAEF,kDAAkD;AAClD,eAAO,MAAM,2BAA2B,yBAAyB,CAAC;AAElE
|
|
1
|
+
{"version":3,"file":"voices.d.ts","sourceRoot":"","sources":["../../../src/globals/ttsModels/voices.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,GAAG,QAAQ,CAAC;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,8CAA8C;IAC9C,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;;GAGG;AACH,eAAO,MAAM,iBAAiB,EAAE,SAAS,EAuFxC,CAAC;AAEF,kDAAkD;AAClD,eAAO,MAAM,2BAA2B,yBAAyB,CAAC;AAElE;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAuC1D,CAAC"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.LANG_TO_ELEVENLABS_CODE = exports.DEFAULT_ELEVENLABS_VOICE_ID = exports.ELEVENLABS_VOICES = void 0;
|
|
4
4
|
/**
|
|
5
|
-
* Curated list of ElevenLabs voices compatible with
|
|
5
|
+
* Curated list of ElevenLabs voices compatible with eleven_multilingual_v3.
|
|
6
6
|
* Any voice can speak any supported language via the language_code parameter.
|
|
7
7
|
*/
|
|
8
8
|
exports.ELEVENLABS_VOICES = [
|
|
@@ -96,25 +96,30 @@ exports.ELEVENLABS_VOICES = [
|
|
|
96
96
|
/** Default voice ID — Sarah (female, American) */
|
|
97
97
|
exports.DEFAULT_ELEVENLABS_VOICE_ID = "EXAVITQu4vr4xnSDxMaL";
|
|
98
98
|
/**
|
|
99
|
-
* Maps frontend language keys → ElevenLabs language_code
|
|
100
|
-
*
|
|
99
|
+
* Maps frontend language keys → ElevenLabs language_code values supported by eleven_multilingual_v3.
|
|
100
|
+
* Omitting a language lets the model auto-detect it (safe fallback).
|
|
101
|
+
* Reference: https://help.elevenlabs.io/hc/en-us/articles/13313366263441
|
|
101
102
|
*/
|
|
102
103
|
exports.LANG_TO_ELEVENLABS_CODE = {
|
|
103
104
|
en: "en",
|
|
104
105
|
ar: "ar",
|
|
105
106
|
bg: "bg",
|
|
106
|
-
ca
|
|
107
|
+
// ca (Catalan) is not in v3's supported language_code list — omitted; model auto-detects
|
|
107
108
|
"zh-cn": "zh",
|
|
109
|
+
zh: "zh",
|
|
108
110
|
hr: "hr",
|
|
109
111
|
cs: "cs",
|
|
110
112
|
da: "da",
|
|
111
113
|
nl: "nl",
|
|
112
114
|
tl: "fil",
|
|
115
|
+
fil: "fil",
|
|
113
116
|
fi: "fi",
|
|
114
117
|
fr: "fr",
|
|
115
118
|
de: "de",
|
|
116
119
|
el: "el",
|
|
117
|
-
iw: "he",
|
|
120
|
+
iw: "he", // legacy Google code for Hebrew
|
|
121
|
+
he: "he",
|
|
122
|
+
hi: "hi", // Hindi — added in v3
|
|
118
123
|
hu: "hu",
|
|
119
124
|
id: "id",
|
|
120
125
|
it: "it",
|
|
@@ -125,9 +130,11 @@ exports.LANG_TO_ELEVENLABS_CODE = {
|
|
|
125
130
|
pl: "pl",
|
|
126
131
|
pt: "pt",
|
|
127
132
|
ro: "ro",
|
|
133
|
+
ru: "ru", // Russian — added in v3
|
|
128
134
|
sk: "sk",
|
|
129
135
|
es: "es",
|
|
130
136
|
sv: "sv",
|
|
137
|
+
ta: "ta", // Tamil — added in v3
|
|
131
138
|
th: "th",
|
|
132
139
|
tr: "tr",
|
|
133
140
|
uk: "uk",
|
|
@@ -27,13 +27,6 @@ export interface IUserCredts {
|
|
|
27
27
|
total: number;
|
|
28
28
|
consumed: number;
|
|
29
29
|
reserved?: number;
|
|
30
|
-
purchased?: {
|
|
31
|
-
total: number;
|
|
32
|
-
consumed: number;
|
|
33
|
-
expiresAt: string;
|
|
34
|
-
lastPurchasedAt: string;
|
|
35
|
-
sessionId?: string;
|
|
36
|
-
};
|
|
37
30
|
}
|
|
38
31
|
export interface IUserSubscription {
|
|
39
32
|
status: ESUBSCRIPTION_STATUS;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user.model.d.ts","sourceRoot":"","sources":["../../src/models/user.model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EACL,SAAS,EACT,kBAAkB,EAElB,mBAAmB,EACnB,oBAAoB,EACrB,MAAM,kBAAkB,CAAC;AAE1B,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,YAAY,CAAC;IACtC,SAAS,EAAE,UAAU,CAAC;IACtB,SAAS,EAAE,UAAU,CAAC;IACtB,QAAQ,EAAE,YAAY,GAAG,UAAU,GAAG,WAAW,GAAG,MAAM,CAAC;IAC3D,aAAa,EAAE,OAAO,CAAC;IACvB,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB,YAAY,CAAC,EAAE,iBAAiB,CAAC;IACjC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,cAAc,CAAC,EAAE;QAEf,SAAS,EAAE,MAAM,CAAC;QAClB,aAAa,EAAE,YAAY,GAAG,WAAW,GAAG,QAAQ,CAAC;QACrD,aAAa,EAAE,IAAI,CAAC;KACrB,CAAC;IACF,QAAQ,CAAC,EAAE;QACT,SAAS,CAAC,EAAE,UAAU,CAAC;QACvB,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,CAAC;CACH;AAED,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"user.model.d.ts","sourceRoot":"","sources":["../../src/models/user.model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EACL,SAAS,EACT,kBAAkB,EAElB,mBAAmB,EACnB,oBAAoB,EACrB,MAAM,kBAAkB,CAAC;AAE1B,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,YAAY,CAAC;IACtC,SAAS,EAAE,UAAU,CAAC;IACtB,SAAS,EAAE,UAAU,CAAC;IACtB,QAAQ,EAAE,YAAY,GAAG,UAAU,GAAG,WAAW,GAAG,MAAM,CAAC;IAC3D,aAAa,EAAE,OAAO,CAAC;IACvB,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB,YAAY,CAAC,EAAE,iBAAiB,CAAC;IACjC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,cAAc,CAAC,EAAE;QAEf,SAAS,EAAE,MAAM,CAAC;QAClB,aAAa,EAAE,YAAY,GAAG,WAAW,GAAG,QAAQ,CAAC;QACrD,aAAa,EAAE,IAAI,CAAC;KACrB,CAAC;IACF,QAAQ,CAAC,EAAE;QACT,SAAS,CAAC,EAAE,UAAU,CAAC;QACvB,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,CAAC;CACH;AAED,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,oBAAoB,CAAC;IAE7B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,mBAAmB,CAAC;IAC/B,IAAI,CAAC,EAAE,kBAAkB,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,mBAAmB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAOrC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"credit.service.d.ts","sourceRoot":"","sources":["../../src/services/credit.service.ts"],"names":[],"mappings":"AAGA,qBAAa,aAAa;WACX,cAAc,CACzB,MAAM,EAAE,MAAM,EACd,gBAAgB,EAAE,MAAM,GACvB,OAAO,CAAC,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"credit.service.d.ts","sourceRoot":"","sources":["../../src/services/credit.service.ts"],"names":[],"mappings":"AAGA,qBAAa,aAAa;WACX,cAAc,CACzB,MAAM,EAAE,MAAM,EACd,gBAAgB,EAAE,MAAM,GACvB,OAAO,CAAC,IAAI,CAAC;WAyBH,aAAa,CACxB,MAAM,EAAE,MAAM,EACd,eAAe,EAAE,MAAM,GACtB,OAAO,CAAC,IAAI,CAAC;CAoBjB"}
|
|
@@ -14,32 +14,15 @@ class CreditService {
|
|
|
14
14
|
const credits = snap.data()?.credits;
|
|
15
15
|
const consumed = credits?.consumed ?? 0;
|
|
16
16
|
const total = credits?.total ?? 0;
|
|
17
|
-
|
|
18
|
-
//
|
|
19
|
-
const subAvailable = total - consumed;
|
|
20
|
-
// Purchased credits available (only if pool exists and not expired)
|
|
21
|
-
const purchasedIsValid = purchased &&
|
|
22
|
-
purchased.total > 0 &&
|
|
23
|
-
new Date(purchased.expiresAt) > new Date();
|
|
24
|
-
const purchAvailable = purchasedIsValid
|
|
25
|
-
? purchased.total - purchased.consumed
|
|
26
|
-
: 0;
|
|
27
|
-
const totalAvailable = subAvailable + purchAvailable;
|
|
17
|
+
// console.log(`Consuming ${creditsToConsume} credits for user ${userId}`);
|
|
18
|
+
// console.log(`Current credits: ${consumed}/${total}`);
|
|
28
19
|
// 🔒 HARD INVARIANT
|
|
29
|
-
if (creditsToConsume >
|
|
20
|
+
if (consumed + creditsToConsume > total) {
|
|
30
21
|
throw new Error("INSUFFICIENT_CREDITS");
|
|
31
22
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const updates = {
|
|
36
|
-
"credits.consumed": consumed + subDeduct,
|
|
37
|
-
};
|
|
38
|
-
if (purchDeduct > 0) {
|
|
39
|
-
updates["credits.purchased.consumed"] =
|
|
40
|
-
(purchased?.consumed ?? 0) + purchDeduct;
|
|
41
|
-
}
|
|
42
|
-
tx.update(userRef, updates);
|
|
23
|
+
tx.update(userRef, {
|
|
24
|
+
"credits.consumed": consumed + creditsToConsume,
|
|
25
|
+
});
|
|
43
26
|
});
|
|
44
27
|
}
|
|
45
28
|
static async refundCredits(userId, creditsToRefund) {
|
|
@@ -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;IAuFrD,SAAS,IAAI,eAAe,EAAE;IAI9B,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;CAGpD"}
|
|
@@ -61,6 +61,30 @@ class ElevenLabsService extends types_1.BaseTtsProviderService {
|
|
|
61
61
|
catch {
|
|
62
62
|
detail = Buffer.from(err.response.data).toString("utf8");
|
|
63
63
|
}
|
|
64
|
+
// If the rejection is about an unsupported language_code, retry without it —
|
|
65
|
+
// the model will auto-detect the language instead of failing the whole job.
|
|
66
|
+
if (err.response.status === 400 &&
|
|
67
|
+
languageCode &&
|
|
68
|
+
(detail.includes("language_code") || detail.includes("does not support"))) {
|
|
69
|
+
const response = await axios_1.default.post(`${this.baseUrl}/text-to-speech/${voiceId}`, {
|
|
70
|
+
text: params.text,
|
|
71
|
+
model_id: elevenlabs_1.elevenlabsConfig.modelId,
|
|
72
|
+
voice_settings: { stability: 0.5, similarity_boost: 0.75 },
|
|
73
|
+
}, {
|
|
74
|
+
headers: {
|
|
75
|
+
"xi-api-key": this.apiKey,
|
|
76
|
+
"Content-Type": "application/json",
|
|
77
|
+
Accept: "audio/mpeg",
|
|
78
|
+
},
|
|
79
|
+
responseType: "arraybuffer",
|
|
80
|
+
timeout: 60000,
|
|
81
|
+
});
|
|
82
|
+
return {
|
|
83
|
+
audioBuffer: Buffer.from(response.data),
|
|
84
|
+
mimeType: "audio/mpeg",
|
|
85
|
+
extension: "mp3",
|
|
86
|
+
};
|
|
87
|
+
}
|
|
64
88
|
throw new Error(`ElevenLabs TTS ${err.response.status}: ${detail} [voiceId=${voiceId}, languageCode=${languageCode ?? "none"}, textLen=${params.text?.length ?? 0}]`);
|
|
65
89
|
}
|
|
66
90
|
throw err;
|