@cartesia/cartesia-js 0.0.3 → 1.0.0-alpha.1
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/.turbo/turbo-build.log +68 -38
- package/CHANGELOG.md +12 -0
- package/README.md +123 -16
- package/dist/chunk-3FL2SNIR.js +17 -0
- package/dist/chunk-3GBZUGUD.js +17 -0
- package/dist/chunk-4RMSIQLG.js +25 -0
- package/dist/chunk-BCQ63627.js +32 -0
- package/dist/chunk-JOHSCOLW.js +106 -0
- package/dist/chunk-LYPTISWL.js +75 -0
- package/dist/chunk-NDNN326Q.js +207 -0
- package/dist/chunk-WBK6LLXX.js +58 -0
- package/dist/chunk-WE63M7PJ.js +119 -0
- package/dist/{chunk-HNLIBHEN.mjs → chunk-WIFMLPT5.js} +31 -16
- package/dist/chunk-X7SJMF2R.js +22 -0
- package/dist/index.cjs +652 -0
- package/dist/index.d.cts +10 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +20 -0
- package/dist/lib/client.cjs +89 -0
- package/dist/lib/client.d.cts +11 -0
- package/dist/lib/client.d.ts +2 -0
- package/dist/lib/client.js +7 -42
- package/dist/lib/constants.cjs +42 -0
- package/dist/lib/constants.d.cts +4 -0
- package/dist/lib/constants.d.ts +2 -3
- package/dist/lib/constants.js +8 -37
- package/dist/lib/index.cjs +531 -0
- package/dist/lib/index.d.cts +16 -0
- package/dist/lib/index.d.ts +6 -2
- package/dist/lib/index.js +13 -409
- package/dist/react/index.cjs +846 -0
- package/dist/react/index.d.cts +33 -0
- package/dist/react/index.d.ts +20 -13
- package/dist/react/index.js +161 -501
- package/dist/react/utils.cjs +57 -0
- package/dist/react/utils.d.cts +7 -0
- package/dist/react/utils.d.ts +7 -0
- package/dist/react/utils.js +7 -0
- package/dist/tts/index.cjs +470 -0
- package/dist/tts/index.d.cts +17 -0
- package/dist/tts/index.d.ts +17 -0
- package/dist/tts/index.js +12 -0
- package/dist/tts/player.cjs +198 -0
- package/dist/tts/player.d.cts +43 -0
- package/dist/tts/player.d.ts +43 -0
- package/dist/tts/player.js +8 -0
- package/dist/tts/source.cjs +167 -0
- package/dist/tts/source.d.cts +53 -0
- package/dist/tts/source.d.ts +53 -0
- package/dist/tts/source.js +7 -0
- package/dist/{audio/utils.js → tts/utils.cjs} +13 -54
- package/dist/tts/utils.d.cts +67 -0
- package/dist/tts/utils.d.ts +67 -0
- package/dist/{audio/utils.mjs → tts/utils.js} +2 -6
- package/dist/tts/websocket.cjs +453 -0
- package/dist/tts/websocket.d.cts +53 -0
- package/dist/tts/websocket.d.ts +53 -0
- package/dist/tts/websocket.js +11 -0
- package/dist/types/index.cjs +18 -0
- package/dist/types/index.d.cts +55 -0
- package/dist/types/index.d.ts +50 -1
- package/dist/types/index.js +1 -18
- package/dist/voices/index.cjs +155 -0
- package/dist/voices/index.d.cts +12 -0
- package/dist/voices/index.d.ts +12 -0
- package/dist/voices/index.js +9 -0
- package/package.json +11 -7
- package/src/index.ts +4 -0
- package/src/lib/client.ts +14 -1
- package/src/lib/constants.ts +13 -3
- package/src/lib/index.ts +6 -3
- package/src/react/index.ts +167 -75
- package/src/react/utils.ts +11 -0
- package/src/tts/index.ts +17 -0
- package/src/tts/player.ts +109 -0
- package/src/tts/source.ts +98 -0
- package/src/{audio → tts}/utils.ts +19 -97
- package/src/tts/websocket.ts +210 -0
- package/src/types/index.ts +63 -0
- package/src/voices/index.ts +47 -0
- package/dist/audio/index.d.mts +0 -5
- package/dist/audio/index.d.ts +0 -5
- package/dist/audio/index.js +0 -396
- package/dist/audio/index.mjs +0 -9
- package/dist/audio/utils.d.mts +0 -5
- package/dist/audio/utils.d.ts +0 -5
- package/dist/chunk-3CYTAFLF.mjs +0 -262
- package/dist/chunk-FRIBQZPN.mjs +0 -113
- package/dist/chunk-XSFPHPPG.mjs +0 -18
- package/dist/index-DSBmfK9-.d.mts +0 -158
- package/dist/index-qwAyxV5I.d.ts +0 -158
- package/dist/lib/client.d.mts +0 -9
- package/dist/lib/client.mjs +0 -7
- package/dist/lib/constants.d.mts +0 -5
- package/dist/lib/constants.mjs +0 -10
- package/dist/lib/index.d.mts +0 -12
- package/dist/lib/index.mjs +0 -19
- package/dist/react/index.d.mts +0 -26
- package/dist/react/index.mjs +0 -130
- package/dist/types/index.d.mts +0 -6
- package/index.ts +0 -3
- package/src/audio/index.ts +0 -282
- /package/dist/{types/index.mjs → chunk-FXPGR372.js} +0 -0
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __defProps = Object.defineProperties;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
7
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
9
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
10
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
11
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
12
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
13
|
+
var __spreadValues = (a, b) => {
|
|
14
|
+
for (var prop in b || (b = {}))
|
|
15
|
+
if (__hasOwnProp.call(b, prop))
|
|
16
|
+
__defNormalProp(a, prop, b[prop]);
|
|
17
|
+
if (__getOwnPropSymbols)
|
|
18
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
19
|
+
if (__propIsEnum.call(b, prop))
|
|
20
|
+
__defNormalProp(a, prop, b[prop]);
|
|
21
|
+
}
|
|
22
|
+
return a;
|
|
23
|
+
};
|
|
24
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
25
|
+
var __export = (target, all) => {
|
|
26
|
+
for (var name in all)
|
|
27
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
28
|
+
};
|
|
29
|
+
var __copyProps = (to, from, except, desc) => {
|
|
30
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
31
|
+
for (let key of __getOwnPropNames(from))
|
|
32
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
33
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
34
|
+
}
|
|
35
|
+
return to;
|
|
36
|
+
};
|
|
37
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
38
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
39
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
40
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
41
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
42
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
43
|
+
mod
|
|
44
|
+
));
|
|
45
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
46
|
+
|
|
47
|
+
// src/lib/client.ts
|
|
48
|
+
var client_exports = {};
|
|
49
|
+
__export(client_exports, {
|
|
50
|
+
Client: () => Client
|
|
51
|
+
});
|
|
52
|
+
module.exports = __toCommonJS(client_exports);
|
|
53
|
+
var import_cross_fetch = __toESM(require("cross-fetch"), 1);
|
|
54
|
+
|
|
55
|
+
// src/lib/constants.ts
|
|
56
|
+
var BASE_URL = "https://api.cartesia.ai/v0";
|
|
57
|
+
var constructApiUrl = (baseUrl, path, protocol) => {
|
|
58
|
+
const normalizedPath = path.startsWith("/") ? path : `/${path}`;
|
|
59
|
+
if (!protocol) {
|
|
60
|
+
return new URL(`${baseUrl}${normalizedPath}`);
|
|
61
|
+
}
|
|
62
|
+
if (!["http", "ws"].includes(protocol)) {
|
|
63
|
+
throw new Error(`Invalid protocol: ${protocol}`);
|
|
64
|
+
}
|
|
65
|
+
return new URL(`${baseUrl.replace(/^http/, protocol)}${normalizedPath}`);
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
// src/lib/client.ts
|
|
69
|
+
var Client = class {
|
|
70
|
+
constructor(options = {}) {
|
|
71
|
+
if (!(options.apiKey || process.env.CARTESIA_API_KEY)) {
|
|
72
|
+
throw new Error("Missing Cartesia API key.");
|
|
73
|
+
}
|
|
74
|
+
this.apiKey = options.apiKey || process.env.CARTESIA_API_KEY;
|
|
75
|
+
this.baseUrl = options.baseUrl || BASE_URL;
|
|
76
|
+
}
|
|
77
|
+
fetch(path, options = {}) {
|
|
78
|
+
const url = constructApiUrl(this.baseUrl, path);
|
|
79
|
+
return (0, import_cross_fetch.default)(url.toString(), __spreadProps(__spreadValues({}, options), {
|
|
80
|
+
headers: __spreadValues({
|
|
81
|
+
"X-API-KEY": this.apiKey
|
|
82
|
+
}, options.headers)
|
|
83
|
+
}));
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
87
|
+
0 && (module.exports = {
|
|
88
|
+
Client
|
|
89
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ClientOptions } from '../types/index.cjs';
|
|
2
|
+
import 'emittery';
|
|
3
|
+
|
|
4
|
+
declare class Client {
|
|
5
|
+
apiKey: string;
|
|
6
|
+
baseUrl: string;
|
|
7
|
+
constructor(options?: ClientOptions);
|
|
8
|
+
fetch(path: string, options?: RequestInit): Promise<Response>;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export { Client };
|
package/dist/lib/client.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { ClientOptions } from '../types/index.js';
|
|
2
|
+
import 'emittery';
|
|
2
3
|
|
|
3
4
|
declare class Client {
|
|
4
5
|
apiKey: string;
|
|
5
6
|
baseUrl: string;
|
|
6
7
|
constructor(options?: ClientOptions);
|
|
8
|
+
fetch(path: string, options?: RequestInit): Promise<Response>;
|
|
7
9
|
}
|
|
8
10
|
|
|
9
11
|
export { Client };
|
package/dist/lib/client.js
CHANGED
|
@@ -1,43 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/lib/client.ts
|
|
21
|
-
var client_exports = {};
|
|
22
|
-
__export(client_exports, {
|
|
23
|
-
Client: () => Client
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(client_exports);
|
|
26
|
-
|
|
27
|
-
// src/lib/constants.ts
|
|
28
|
-
var BASE_URL = "https://api.cartesia.ai/v0";
|
|
29
|
-
|
|
30
|
-
// src/lib/client.ts
|
|
31
|
-
var Client = class {
|
|
32
|
-
constructor(options = {}) {
|
|
33
|
-
if (!(options.apiKey || process.env.CARTESIA_API_KEY)) {
|
|
34
|
-
throw new Error("Missing Cartesia API key.");
|
|
35
|
-
}
|
|
36
|
-
this.apiKey = options.apiKey || process.env.CARTESIA_API_KEY;
|
|
37
|
-
this.baseUrl = options.baseUrl || BASE_URL;
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
41
|
-
0 && (module.exports = {
|
|
1
|
+
import {
|
|
42
2
|
Client
|
|
43
|
-
}
|
|
3
|
+
} from "../chunk-BCQ63627.js";
|
|
4
|
+
import "../chunk-3GBZUGUD.js";
|
|
5
|
+
import "../chunk-WIFMLPT5.js";
|
|
6
|
+
export {
|
|
7
|
+
Client
|
|
8
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/lib/constants.ts
|
|
21
|
+
var constants_exports = {};
|
|
22
|
+
__export(constants_exports, {
|
|
23
|
+
BASE_URL: () => BASE_URL,
|
|
24
|
+
constructApiUrl: () => constructApiUrl
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(constants_exports);
|
|
27
|
+
var BASE_URL = "https://api.cartesia.ai/v0";
|
|
28
|
+
var constructApiUrl = (baseUrl, path, protocol) => {
|
|
29
|
+
const normalizedPath = path.startsWith("/") ? path : `/${path}`;
|
|
30
|
+
if (!protocol) {
|
|
31
|
+
return new URL(`${baseUrl}${normalizedPath}`);
|
|
32
|
+
}
|
|
33
|
+
if (!["http", "ws"].includes(protocol)) {
|
|
34
|
+
throw new Error(`Invalid protocol: ${protocol}`);
|
|
35
|
+
}
|
|
36
|
+
return new URL(`${baseUrl.replace(/^http/, protocol)}${normalizedPath}`);
|
|
37
|
+
};
|
|
38
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
39
|
+
0 && (module.exports = {
|
|
40
|
+
BASE_URL,
|
|
41
|
+
constructApiUrl
|
|
42
|
+
});
|
package/dist/lib/constants.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
declare const BASE_URL = "https://api.cartesia.ai/v0";
|
|
2
|
-
declare const
|
|
3
|
-
declare const constructWebsocketUrl: (baseUrl: string) => URL;
|
|
2
|
+
declare const constructApiUrl: (baseUrl: string, path: string, protocol?: string) => URL;
|
|
4
3
|
|
|
5
|
-
export { BASE_URL,
|
|
4
|
+
export { BASE_URL, constructApiUrl };
|
package/dist/lib/constants.js
CHANGED
|
@@ -1,38 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/lib/constants.ts
|
|
21
|
-
var constants_exports = {};
|
|
22
|
-
__export(constants_exports, {
|
|
23
|
-
BASE_URL: () => BASE_URL,
|
|
24
|
-
SAMPLE_RATE: () => SAMPLE_RATE,
|
|
25
|
-
constructWebsocketUrl: () => constructWebsocketUrl
|
|
26
|
-
});
|
|
27
|
-
module.exports = __toCommonJS(constants_exports);
|
|
28
|
-
var BASE_URL = "https://api.cartesia.ai/v0";
|
|
29
|
-
var SAMPLE_RATE = 44100;
|
|
30
|
-
var constructWebsocketUrl = (baseUrl) => {
|
|
31
|
-
return new URL(`${baseUrl.replace(/^http/, "ws")}/audio/websocket`);
|
|
32
|
-
};
|
|
33
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
34
|
-
0 && (module.exports = {
|
|
1
|
+
import {
|
|
35
2
|
BASE_URL,
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
3
|
+
constructApiUrl
|
|
4
|
+
} from "../chunk-3GBZUGUD.js";
|
|
5
|
+
import "../chunk-WIFMLPT5.js";
|
|
6
|
+
export {
|
|
7
|
+
BASE_URL,
|
|
8
|
+
constructApiUrl
|
|
9
|
+
};
|