@cartesia/cartesia-js 0.0.4-alpha.0 → 1.0.0-alpha.2
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 +63 -45
- package/CHANGELOG.md +12 -0
- package/README.md +123 -16
- package/dist/chunk-36JBKJUN.js +119 -0
- package/dist/chunk-3F5E46FT.js +212 -0
- package/dist/{chunk-XPIMIAAE.js → chunk-3FL2SNIR.js} +1 -1
- package/dist/chunk-JGP5BIUV.js +34 -0
- package/dist/chunk-KWBSQZTY.js +25 -0
- package/dist/chunk-PQ6CIPFW.js +120 -0
- package/dist/chunk-RO7TY474.js +81 -0
- package/dist/chunk-T3RG6WV4.js +22 -0
- package/dist/{chunk-R4P7LWVZ.js → chunk-WIFMLPT5.js} +31 -6
- package/dist/chunk-WVTITUXX.js +58 -0
- package/dist/chunk-XHTDPLFR.js +19 -0
- package/dist/index.cjs +425 -166
- package/dist/index.d.cts +7 -3
- package/dist/index.d.ts +7 -3
- package/dist/index.js +13 -6
- package/dist/lib/client.cjs +49 -1
- package/dist/lib/client.d.cts +2 -0
- package/dist/lib/client.d.ts +2 -0
- package/dist/lib/client.js +3 -3
- package/dist/lib/constants.cjs +15 -8
- package/dist/lib/constants.d.cts +4 -4
- package/dist/lib/constants.d.ts +4 -4
- package/dist/lib/constants.js +6 -6
- package/dist/lib/index.cjs +310 -171
- package/dist/lib/index.d.cts +6 -2
- package/dist/lib/index.d.ts +6 -2
- package/dist/lib/index.js +9 -6
- package/dist/react/index.cjs +573 -290
- package/dist/react/index.d.cts +20 -14
- package/dist/react/index.d.ts +20 -14
- package/dist/react/index.js +157 -105
- package/dist/react/utils.js +2 -2
- package/dist/tts/index.cjs +496 -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 +181 -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 → tts}/utils.cjs +25 -60
- package/dist/tts/utils.d.cts +67 -0
- package/dist/tts/utils.d.ts +67 -0
- package/dist/{audio → tts}/utils.js +2 -7
- package/dist/tts/websocket.cjs +479 -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.d.cts +50 -1
- package/dist/types/index.d.ts +50 -1
- package/dist/voices/index.cjs +157 -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 +2 -1
- package/src/index.ts +1 -0
- package/src/lib/client.ts +15 -1
- package/src/lib/constants.ts +15 -4
- package/src/lib/index.ts +6 -3
- package/src/react/index.ts +176 -110
- package/src/tts/index.ts +17 -0
- package/src/tts/player.ts +110 -0
- package/src/tts/source.ts +115 -0
- package/src/tts/utils.ts +150 -0
- package/src/tts/websocket.ts +214 -0
- package/src/types/index.ts +63 -0
- package/src/voices/index.ts +47 -0
- package/dist/audio/index.cjs +0 -404
- package/dist/audio/index.d.cts +0 -5
- package/dist/audio/index.d.ts +0 -5
- package/dist/audio/index.js +0 -10
- package/dist/audio/utils.d.cts +0 -5
- package/dist/audio/utils.d.ts +0 -5
- package/dist/chunk-4MHF74A7.js +0 -272
- package/dist/chunk-5TSWLYOW.js +0 -113
- package/dist/chunk-MJIFZWHS.js +0 -18
- package/dist/chunk-OVI3W3GG.js +0 -12
- package/dist/chunk-S6A27RQL.js +0 -18
- package/dist/index-C2_3XFxn.d.cts +0 -163
- package/dist/index-DgwnZezj.d.ts +0 -163
- package/src/audio/index.ts +0 -297
- package/src/audio/utils.ts +0 -220
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
export { Cartesia, Cartesia as default } from './lib/index.cjs';
|
|
2
|
-
export { ClientOptions } from './types/index.cjs';
|
|
3
|
-
|
|
2
|
+
export { Chunk, ClientOptions, CloneOptions, CloneResponse, ConnectionEventData, CreateVoice, EmitteryCallbacks, Sentinel, SourceEventData, StreamRequest, Voice, WebSocketOptions } from './types/index.cjs';
|
|
3
|
+
export { default as WebPlayer } from './tts/player.cjs';
|
|
4
|
+
import './tts/index.cjs';
|
|
5
|
+
import './lib/client.cjs';
|
|
6
|
+
import './tts/websocket.cjs';
|
|
4
7
|
import 'emittery';
|
|
5
8
|
import 'partysocket';
|
|
6
|
-
import './
|
|
9
|
+
import './tts/source.cjs';
|
|
10
|
+
import './voices/index.cjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
export { Cartesia, Cartesia as default } from './lib/index.js';
|
|
2
|
-
export { ClientOptions } from './types/index.js';
|
|
3
|
-
|
|
2
|
+
export { Chunk, ClientOptions, CloneOptions, CloneResponse, ConnectionEventData, CreateVoice, EmitteryCallbacks, Sentinel, SourceEventData, StreamRequest, Voice, WebSocketOptions } from './types/index.js';
|
|
3
|
+
export { default as WebPlayer } from './tts/player.js';
|
|
4
|
+
import './tts/index.js';
|
|
5
|
+
import './lib/client.js';
|
|
6
|
+
import './tts/websocket.js';
|
|
4
7
|
import 'emittery';
|
|
5
8
|
import 'partysocket';
|
|
6
|
-
import './
|
|
9
|
+
import './tts/source.js';
|
|
10
|
+
import './voices/index.js';
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
import "./chunk-FXPGR372.js";
|
|
2
2
|
import {
|
|
3
3
|
Cartesia
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import "./chunk-
|
|
6
|
-
import "./chunk-
|
|
7
|
-
import "./chunk-
|
|
8
|
-
import "./chunk-
|
|
9
|
-
import "./chunk-
|
|
4
|
+
} from "./chunk-T3RG6WV4.js";
|
|
5
|
+
import "./chunk-WVTITUXX.js";
|
|
6
|
+
import "./chunk-KWBSQZTY.js";
|
|
7
|
+
import "./chunk-3F5E46FT.js";
|
|
8
|
+
import "./chunk-PQ6CIPFW.js";
|
|
9
|
+
import "./chunk-JGP5BIUV.js";
|
|
10
|
+
import "./chunk-XHTDPLFR.js";
|
|
11
|
+
import {
|
|
12
|
+
Player
|
|
13
|
+
} from "./chunk-36JBKJUN.js";
|
|
14
|
+
import "./chunk-RO7TY474.js";
|
|
15
|
+
import "./chunk-WIFMLPT5.js";
|
|
10
16
|
export {
|
|
11
17
|
Cartesia,
|
|
18
|
+
Player as WebPlayer,
|
|
12
19
|
Cartesia as default
|
|
13
20
|
};
|
package/dist/lib/client.cjs
CHANGED
|
@@ -1,8 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
4
|
+
var __defProps = Object.defineProperties;
|
|
3
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
7
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
9
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
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));
|
|
6
25
|
var __export = (target, all) => {
|
|
7
26
|
for (var name in all)
|
|
8
27
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -15,6 +34,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
34
|
}
|
|
16
35
|
return to;
|
|
17
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
|
+
));
|
|
18
45
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
46
|
|
|
20
47
|
// src/lib/client.ts
|
|
@@ -23,9 +50,21 @@ __export(client_exports, {
|
|
|
23
50
|
Client: () => Client
|
|
24
51
|
});
|
|
25
52
|
module.exports = __toCommonJS(client_exports);
|
|
53
|
+
var import_cross_fetch = __toESM(require("cross-fetch"), 1);
|
|
26
54
|
|
|
27
55
|
// src/lib/constants.ts
|
|
28
|
-
var BASE_URL = "https://api.cartesia.ai/
|
|
56
|
+
var BASE_URL = "https://api.cartesia.ai/";
|
|
57
|
+
var CARTESIA_VERSION = "2024-06-10";
|
|
58
|
+
var constructApiUrl = (baseUrl, path, protocol) => {
|
|
59
|
+
const normalizedPath = path.startsWith("/") ? path : `/${path}`;
|
|
60
|
+
if (!protocol) {
|
|
61
|
+
return new URL(`${baseUrl}${normalizedPath}`);
|
|
62
|
+
}
|
|
63
|
+
if (!["http", "ws"].includes(protocol)) {
|
|
64
|
+
throw new Error(`Invalid protocol: ${protocol}`);
|
|
65
|
+
}
|
|
66
|
+
return new URL(`${baseUrl.replace(/^http/, protocol)}${normalizedPath}`);
|
|
67
|
+
};
|
|
29
68
|
|
|
30
69
|
// src/lib/client.ts
|
|
31
70
|
var Client = class {
|
|
@@ -36,6 +75,15 @@ var Client = class {
|
|
|
36
75
|
this.apiKey = options.apiKey || process.env.CARTESIA_API_KEY;
|
|
37
76
|
this.baseUrl = options.baseUrl || BASE_URL;
|
|
38
77
|
}
|
|
78
|
+
fetch(path, options = {}) {
|
|
79
|
+
const url = constructApiUrl(this.baseUrl, path);
|
|
80
|
+
return (0, import_cross_fetch.default)(url.toString(), __spreadProps(__spreadValues({}, options), {
|
|
81
|
+
headers: __spreadValues({
|
|
82
|
+
"X-API-Key": this.apiKey,
|
|
83
|
+
"Cartesia-Version": CARTESIA_VERSION
|
|
84
|
+
}, options.headers)
|
|
85
|
+
}));
|
|
86
|
+
}
|
|
39
87
|
};
|
|
40
88
|
// Annotate the CommonJS export names for ESM import in node:
|
|
41
89
|
0 && (module.exports = {
|
package/dist/lib/client.d.cts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { ClientOptions } from '../types/index.cjs';
|
|
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.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
package/dist/lib/constants.cjs
CHANGED
|
@@ -21,18 +21,25 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var constants_exports = {};
|
|
22
22
|
__export(constants_exports, {
|
|
23
23
|
BASE_URL: () => BASE_URL,
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
CARTESIA_VERSION: () => CARTESIA_VERSION,
|
|
25
|
+
constructApiUrl: () => constructApiUrl
|
|
26
26
|
});
|
|
27
27
|
module.exports = __toCommonJS(constants_exports);
|
|
28
|
-
var BASE_URL = "https://api.cartesia.ai/
|
|
29
|
-
var
|
|
30
|
-
var
|
|
31
|
-
|
|
28
|
+
var BASE_URL = "https://api.cartesia.ai/";
|
|
29
|
+
var CARTESIA_VERSION = "2024-06-10";
|
|
30
|
+
var constructApiUrl = (baseUrl, path, protocol) => {
|
|
31
|
+
const normalizedPath = path.startsWith("/") ? path : `/${path}`;
|
|
32
|
+
if (!protocol) {
|
|
33
|
+
return new URL(`${baseUrl}${normalizedPath}`);
|
|
34
|
+
}
|
|
35
|
+
if (!["http", "ws"].includes(protocol)) {
|
|
36
|
+
throw new Error(`Invalid protocol: ${protocol}`);
|
|
37
|
+
}
|
|
38
|
+
return new URL(`${baseUrl.replace(/^http/, protocol)}${normalizedPath}`);
|
|
32
39
|
};
|
|
33
40
|
// Annotate the CommonJS export names for ESM import in node:
|
|
34
41
|
0 && (module.exports = {
|
|
35
42
|
BASE_URL,
|
|
36
|
-
|
|
37
|
-
|
|
43
|
+
CARTESIA_VERSION,
|
|
44
|
+
constructApiUrl
|
|
38
45
|
});
|
package/dist/lib/constants.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
declare const BASE_URL = "https://api.cartesia.ai/
|
|
2
|
-
declare const
|
|
3
|
-
declare const
|
|
1
|
+
declare const BASE_URL = "https://api.cartesia.ai/";
|
|
2
|
+
declare const CARTESIA_VERSION = "2024-06-10";
|
|
3
|
+
declare const constructApiUrl: (baseUrl: string, path: string, protocol?: string) => URL;
|
|
4
4
|
|
|
5
|
-
export { BASE_URL,
|
|
5
|
+
export { BASE_URL, CARTESIA_VERSION, constructApiUrl };
|
package/dist/lib/constants.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
declare const BASE_URL = "https://api.cartesia.ai/
|
|
2
|
-
declare const
|
|
3
|
-
declare const
|
|
1
|
+
declare const BASE_URL = "https://api.cartesia.ai/";
|
|
2
|
+
declare const CARTESIA_VERSION = "2024-06-10";
|
|
3
|
+
declare const constructApiUrl: (baseUrl: string, path: string, protocol?: string) => URL;
|
|
4
4
|
|
|
5
|
-
export { BASE_URL,
|
|
5
|
+
export { BASE_URL, CARTESIA_VERSION, constructApiUrl };
|
package/dist/lib/constants.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
BASE_URL,
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
} from "../chunk-
|
|
6
|
-
import "../chunk-
|
|
3
|
+
CARTESIA_VERSION,
|
|
4
|
+
constructApiUrl
|
|
5
|
+
} from "../chunk-XHTDPLFR.js";
|
|
6
|
+
import "../chunk-WIFMLPT5.js";
|
|
7
7
|
export {
|
|
8
8
|
BASE_URL,
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
CARTESIA_VERSION,
|
|
10
|
+
constructApiUrl
|
|
11
11
|
};
|