@cartesia/cartesia-js 1.0.0-alpha.2 → 1.0.0-alpha.3
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 +32 -32
- package/CHANGELOG.md +6 -0
- package/dist/chunk-2BFEKY3F.js +16 -0
- package/dist/{chunk-3F5E46FT.js → chunk-IQAXBRHU.js} +6 -7
- package/dist/{chunk-T3RG6WV4.js → chunk-ISRU7PLL.js} +3 -3
- package/dist/{chunk-JGP5BIUV.js → chunk-PQ5EVEEH.js} +1 -1
- package/dist/{chunk-WVTITUXX.js → chunk-SGXUEFII.js} +1 -1
- package/dist/{chunk-KWBSQZTY.js → chunk-VK7LBMVI.js} +2 -2
- package/dist/index.cjs +10 -14
- package/dist/index.js +6 -6
- package/dist/lib/client.cjs +6 -9
- package/dist/lib/client.js +2 -2
- package/dist/lib/constants.cjs +6 -9
- package/dist/lib/constants.d.cts +13 -2
- package/dist/lib/constants.d.ts +13 -2
- package/dist/lib/constants.js +1 -1
- package/dist/lib/index.cjs +10 -14
- package/dist/lib/index.js +6 -6
- package/dist/react/index.cjs +10 -14
- package/dist/react/index.js +6 -6
- package/dist/tts/index.cjs +10 -14
- package/dist/tts/index.js +4 -4
- package/dist/tts/websocket.cjs +10 -14
- package/dist/tts/websocket.js +3 -3
- package/dist/voices/index.cjs +6 -9
- package/dist/voices/index.js +3 -3
- package/package.json +1 -1
- package/src/lib/constants.ts +17 -9
- package/src/tts/websocket.ts +4 -5
- package/dist/chunk-XHTDPLFR.js +0 -19
package/.turbo/turbo-build.log
CHANGED
|
@@ -5,50 +5,50 @@ $ tsup src/ --format cjs,esm --dts
|
|
|
5
5
|
[34mCLI[39m Target: es6
|
|
6
6
|
[34mCJS[39m Build start
|
|
7
7
|
[34mESM[39m Build start
|
|
8
|
-
[32mCJS[39m [1mdist/index.cjs [22m[32m21.16 KB[39m
|
|
9
|
-
[32mCJS[39m [1mdist/lib/client.cjs [22m[32m3.51 KB[39m
|
|
10
|
-
[32mCJS[39m [1mdist/react/index.cjs [22m[32m27.38 KB[39m
|
|
11
|
-
[32mCJS[39m [1mdist/tts/index.cjs [22m[32m15.80 KB[39m
|
|
12
|
-
[32mCJS[39m [1mdist/types/index.cjs [22m[32m764.00 B[39m
|
|
13
|
-
[32mCJS[39m [1mdist/voices/index.cjs [22m[32m5.21 KB[39m
|
|
14
|
-
[32mCJS[39m [1mdist/lib/constants.cjs [22m[32m1.61 KB[39m
|
|
15
|
-
[32mCJS[39m [1mdist/lib/index.cjs [22m[32m17.33 KB[39m
|
|
16
|
-
[32mCJS[39m [1mdist/react/utils.cjs [22m[32m1.80 KB[39m
|
|
17
|
-
[32mCJS[39m [1mdist/tts/player.cjs [22m[32m6.66 KB[39m
|
|
18
|
-
[32mCJS[39m [1mdist/tts/source.cjs [22m[32m6.63 KB[39m
|
|
19
|
-
[32mCJS[39m [1mdist/tts/utils.cjs [22m[32m3.87 KB[39m
|
|
20
|
-
[32mCJS[39m [1mdist/tts/websocket.cjs [22m[32m15.49 KB[39m
|
|
21
|
-
[32mCJS[39m ⚡️ Build success in 134ms
|
|
22
|
-
[32mESM[39m [1mdist/chunk-FXPGR372.js [22m[32m0 B[39m
|
|
23
|
-
[32mESM[39m [1mdist/tts/source.js [22m[32m112.00 B[39m
|
|
24
|
-
[32mESM[39m [1mdist/tts/utils.js [22m[32m395.00 B[39m
|
|
25
|
-
[32mESM[39m [1mdist/tts/websocket.js [22m[32m242.00 B[39m
|
|
26
|
-
[32mESM[39m [1mdist/types/index.js [22m[32m31.00 B[39m
|
|
27
|
-
[32mESM[39m [1mdist/voices/index.js [22m[32m174.00 B[39m
|
|
28
8
|
[32mESM[39m [1mdist/index.js [22m[32m437.00 B[39m
|
|
9
|
+
[32mESM[39m [1mdist/chunk-FXPGR372.js [22m[32m0 B[39m
|
|
29
10
|
[32mESM[39m [1mdist/lib/client.js [22m[32m132.00 B[39m
|
|
11
|
+
[32mESM[39m [1mdist/react/index.js [22m[32m6.22 KB[39m
|
|
12
|
+
[32mESM[39m [1mdist/tts/index.js [22m[32m261.00 B[39m
|
|
30
13
|
[32mESM[39m [1mdist/lib/constants.js [22m[32m183.00 B[39m
|
|
31
14
|
[32mESM[39m [1mdist/lib/index.js [22m[32m322.00 B[39m
|
|
32
|
-
[32mESM[39m [1mdist/
|
|
33
|
-
[32mESM[39m [1mdist/chunk-
|
|
34
|
-
[32mESM[39m [1mdist/chunk-WVTITUXX.js [22m[32m1.35 KB[39m
|
|
15
|
+
[32mESM[39m [1mdist/chunk-ISRU7PLL.js [22m[32m353.00 B[39m
|
|
16
|
+
[32mESM[39m [1mdist/chunk-SGXUEFII.js [22m[32m1.35 KB[39m
|
|
35
17
|
[32mESM[39m [1mdist/react/utils.js [22m[32m109.00 B[39m
|
|
36
18
|
[32mESM[39m [1mdist/chunk-3FL2SNIR.js [22m[32m337.00 B[39m
|
|
37
|
-
[32mESM[39m [1mdist/
|
|
38
|
-
[32mESM[39m [1mdist/chunk-
|
|
39
|
-
[32mESM[39m [1mdist/chunk-3F5E46FT.js [22m[32m5.81 KB[39m
|
|
19
|
+
[32mESM[39m [1mdist/chunk-VK7LBMVI.js [22m[32m439.00 B[39m
|
|
20
|
+
[32mESM[39m [1mdist/chunk-IQAXBRHU.js [22m[32m5.84 KB[39m
|
|
40
21
|
[32mESM[39m [1mdist/chunk-PQ6CIPFW.js [22m[32m4.02 KB[39m
|
|
41
|
-
[32mESM[39m [1mdist/chunk-
|
|
42
|
-
[32mESM[39m [1mdist/chunk-
|
|
22
|
+
[32mESM[39m [1mdist/chunk-PQ5EVEEH.js [22m[32m841.00 B[39m
|
|
23
|
+
[32mESM[39m [1mdist/chunk-2BFEKY3F.js [22m[32m366.00 B[39m
|
|
43
24
|
[32mESM[39m [1mdist/tts/player.js [22m[32m143.00 B[39m
|
|
44
25
|
[32mESM[39m [1mdist/chunk-36JBKJUN.js [22m[32m3.52 KB[39m
|
|
45
26
|
[32mESM[39m [1mdist/chunk-RO7TY474.js [22m[32m1.95 KB[39m
|
|
46
27
|
[32mESM[39m [1mdist/chunk-WIFMLPT5.js [22m[32m2.27 KB[39m
|
|
47
|
-
[32mESM[39m
|
|
28
|
+
[32mESM[39m [1mdist/types/index.js [22m[32m31.00 B[39m
|
|
29
|
+
[32mESM[39m [1mdist/voices/index.js [22m[32m174.00 B[39m
|
|
30
|
+
[32mESM[39m [1mdist/tts/source.js [22m[32m112.00 B[39m
|
|
31
|
+
[32mESM[39m [1mdist/tts/utils.js [22m[32m395.00 B[39m
|
|
32
|
+
[32mESM[39m [1mdist/tts/websocket.js [22m[32m242.00 B[39m
|
|
33
|
+
[32mESM[39m ⚡️ Build success in 97ms
|
|
34
|
+
[32mCJS[39m [1mdist/index.cjs [22m[32m21.01 KB[39m
|
|
35
|
+
[32mCJS[39m [1mdist/lib/client.cjs [22m[32m3.34 KB[39m
|
|
36
|
+
[32mCJS[39m [1mdist/lib/constants.cjs [22m[32m1.43 KB[39m
|
|
37
|
+
[32mCJS[39m [1mdist/lib/index.cjs [22m[32m17.18 KB[39m
|
|
38
|
+
[32mCJS[39m [1mdist/react/index.cjs [22m[32m27.24 KB[39m
|
|
39
|
+
[32mCJS[39m [1mdist/react/utils.cjs [22m[32m1.80 KB[39m
|
|
40
|
+
[32mCJS[39m [1mdist/tts/index.cjs [22m[32m15.66 KB[39m
|
|
41
|
+
[32mCJS[39m [1mdist/tts/player.cjs [22m[32m6.66 KB[39m
|
|
42
|
+
[32mCJS[39m [1mdist/tts/source.cjs [22m[32m6.63 KB[39m
|
|
43
|
+
[32mCJS[39m [1mdist/tts/utils.cjs [22m[32m3.87 KB[39m
|
|
44
|
+
[32mCJS[39m [1mdist/tts/websocket.cjs [22m[32m15.34 KB[39m
|
|
45
|
+
[32mCJS[39m [1mdist/types/index.cjs [22m[32m764.00 B[39m
|
|
46
|
+
[32mCJS[39m [1mdist/voices/index.cjs [22m[32m5.04 KB[39m
|
|
47
|
+
[32mCJS[39m ⚡️ Build success in 101ms
|
|
48
48
|
[34mDTS[39m Build start
|
|
49
|
-
[32mDTS[39m ⚡️ Build success in
|
|
49
|
+
[32mDTS[39m ⚡️ Build success in 6609ms
|
|
50
50
|
[32mDTS[39m [1mdist/index.d.cts [22m[32m509.00 B[39m
|
|
51
|
-
[32mDTS[39m [1mdist/lib/constants.d.cts [22m[
|
|
51
|
+
[32mDTS[39m [1mdist/lib/constants.d.cts [22m[32m564.00 B[39m
|
|
52
52
|
[32mDTS[39m [1mdist/lib/index.d.cts [22m[32m410.00 B[39m
|
|
53
53
|
[32mDTS[39m [1mdist/react/index.d.cts [22m[32m1018.00 B[39m
|
|
54
54
|
[32mDTS[39m [1mdist/react/utils.d.cts [22m[32m240.00 B[39m
|
|
@@ -61,7 +61,7 @@ $ tsup src/ --format cjs,esm --dts
|
|
|
61
61
|
[32mDTS[39m [1mdist/lib/client.d.cts [22m[32m267.00 B[39m
|
|
62
62
|
[32mDTS[39m [1mdist/types/index.d.cts [22m[32m1.28 KB[39m
|
|
63
63
|
[32mDTS[39m [1mdist/index.d.ts [22m[32m501.00 B[39m
|
|
64
|
-
[32mDTS[39m [1mdist/lib/constants.d.ts [22m[
|
|
64
|
+
[32mDTS[39m [1mdist/lib/constants.d.ts [22m[32m564.00 B[39m
|
|
65
65
|
[32mDTS[39m [1mdist/lib/index.d.ts [22m[32m404.00 B[39m
|
|
66
66
|
[32mDTS[39m [1mdist/react/index.d.ts [22m[32m1016.00 B[39m
|
|
67
67
|
[32mDTS[39m [1mdist/react/utils.d.ts [22m[32m240.00 B[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// src/lib/constants.ts
|
|
2
|
+
var BASE_URL = "https://api.cartesia.ai";
|
|
3
|
+
var CARTESIA_VERSION = "2024-06-10";
|
|
4
|
+
var constructApiUrl = (baseUrl, path, { websocket = false } = {}) => {
|
|
5
|
+
const url = new URL(path, baseUrl);
|
|
6
|
+
if (websocket) {
|
|
7
|
+
url.protocol = baseUrl.replace(/^http/, "ws");
|
|
8
|
+
}
|
|
9
|
+
return url;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export {
|
|
13
|
+
BASE_URL,
|
|
14
|
+
CARTESIA_VERSION,
|
|
15
|
+
constructApiUrl
|
|
16
|
+
};
|
|
@@ -3,11 +3,11 @@ import {
|
|
|
3
3
|
} from "./chunk-PQ6CIPFW.js";
|
|
4
4
|
import {
|
|
5
5
|
Client
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-PQ5EVEEH.js";
|
|
7
7
|
import {
|
|
8
8
|
CARTESIA_VERSION,
|
|
9
9
|
constructApiUrl
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-2BFEKY3F.js";
|
|
11
11
|
import {
|
|
12
12
|
base64ToArray,
|
|
13
13
|
createMessageHandlerForContextId,
|
|
@@ -137,12 +137,11 @@ var WebSocket = class extends Client {
|
|
|
137
137
|
* @throws {Error} If the WebSocket fails to connect.
|
|
138
138
|
*/
|
|
139
139
|
connect() {
|
|
140
|
-
const url = constructApiUrl(
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
"ws"
|
|
144
|
-
);
|
|
140
|
+
const url = constructApiUrl(this.baseUrl, "/tts/websocket", {
|
|
141
|
+
websocket: true
|
|
142
|
+
});
|
|
145
143
|
url.searchParams.set("api_key", this.apiKey);
|
|
144
|
+
url.searchParams.set("cartesia_version", CARTESIA_VERSION);
|
|
146
145
|
const emitter = new Emittery();
|
|
147
146
|
this.socket = new PartySocketWebSocket(url.toString());
|
|
148
147
|
this.socket.onopen = () => {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Voices
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-SGXUEFII.js";
|
|
4
4
|
import {
|
|
5
5
|
TTS
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-VK7LBMVI.js";
|
|
7
7
|
import {
|
|
8
8
|
Client
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-PQ5EVEEH.js";
|
|
10
10
|
|
|
11
11
|
// src/lib/index.ts
|
|
12
12
|
var Cartesia = class extends Client {
|
package/dist/index.cjs
CHANGED
|
@@ -99,17 +99,14 @@ module.exports = __toCommonJS(src_exports);
|
|
|
99
99
|
var import_cross_fetch = __toESM(require("cross-fetch"), 1);
|
|
100
100
|
|
|
101
101
|
// src/lib/constants.ts
|
|
102
|
-
var BASE_URL = "https://api.cartesia.ai
|
|
102
|
+
var BASE_URL = "https://api.cartesia.ai";
|
|
103
103
|
var CARTESIA_VERSION = "2024-06-10";
|
|
104
|
-
var constructApiUrl = (baseUrl, path,
|
|
105
|
-
const
|
|
106
|
-
if (
|
|
107
|
-
|
|
104
|
+
var constructApiUrl = (baseUrl, path, { websocket = false } = {}) => {
|
|
105
|
+
const url = new URL(path, baseUrl);
|
|
106
|
+
if (websocket) {
|
|
107
|
+
url.protocol = baseUrl.replace(/^http/, "ws");
|
|
108
108
|
}
|
|
109
|
-
|
|
110
|
-
throw new Error(`Invalid protocol: ${protocol}`);
|
|
111
|
-
}
|
|
112
|
-
return new URL(`${baseUrl.replace(/^http/, protocol)}${normalizedPath}`);
|
|
109
|
+
return url;
|
|
113
110
|
};
|
|
114
111
|
|
|
115
112
|
// src/lib/client.ts
|
|
@@ -425,12 +422,11 @@ var WebSocket = class extends Client {
|
|
|
425
422
|
* @throws {Error} If the WebSocket fails to connect.
|
|
426
423
|
*/
|
|
427
424
|
connect() {
|
|
428
|
-
const url = constructApiUrl(
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
"ws"
|
|
432
|
-
);
|
|
425
|
+
const url = constructApiUrl(this.baseUrl, "/tts/websocket", {
|
|
426
|
+
websocket: true
|
|
427
|
+
});
|
|
433
428
|
url.searchParams.set("api_key", this.apiKey);
|
|
429
|
+
url.searchParams.set("cartesia_version", CARTESIA_VERSION);
|
|
434
430
|
const emitter = new import_emittery2.default();
|
|
435
431
|
this.socket = new import_partysocket.WebSocket(url.toString());
|
|
436
432
|
this.socket.onopen = () => {
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import "./chunk-FXPGR372.js";
|
|
2
2
|
import {
|
|
3
3
|
Cartesia
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import "./chunk-
|
|
6
|
-
import "./chunk-
|
|
7
|
-
import "./chunk-
|
|
4
|
+
} from "./chunk-ISRU7PLL.js";
|
|
5
|
+
import "./chunk-SGXUEFII.js";
|
|
6
|
+
import "./chunk-VK7LBMVI.js";
|
|
7
|
+
import "./chunk-IQAXBRHU.js";
|
|
8
8
|
import "./chunk-PQ6CIPFW.js";
|
|
9
|
-
import "./chunk-
|
|
10
|
-
import "./chunk-
|
|
9
|
+
import "./chunk-PQ5EVEEH.js";
|
|
10
|
+
import "./chunk-2BFEKY3F.js";
|
|
11
11
|
import {
|
|
12
12
|
Player
|
|
13
13
|
} from "./chunk-36JBKJUN.js";
|
package/dist/lib/client.cjs
CHANGED
|
@@ -53,17 +53,14 @@ module.exports = __toCommonJS(client_exports);
|
|
|
53
53
|
var import_cross_fetch = __toESM(require("cross-fetch"), 1);
|
|
54
54
|
|
|
55
55
|
// src/lib/constants.ts
|
|
56
|
-
var BASE_URL = "https://api.cartesia.ai
|
|
56
|
+
var BASE_URL = "https://api.cartesia.ai";
|
|
57
57
|
var CARTESIA_VERSION = "2024-06-10";
|
|
58
|
-
var constructApiUrl = (baseUrl, path,
|
|
59
|
-
const
|
|
60
|
-
if (
|
|
61
|
-
|
|
58
|
+
var constructApiUrl = (baseUrl, path, { websocket = false } = {}) => {
|
|
59
|
+
const url = new URL(path, baseUrl);
|
|
60
|
+
if (websocket) {
|
|
61
|
+
url.protocol = baseUrl.replace(/^http/, "ws");
|
|
62
62
|
}
|
|
63
|
-
|
|
64
|
-
throw new Error(`Invalid protocol: ${protocol}`);
|
|
65
|
-
}
|
|
66
|
-
return new URL(`${baseUrl.replace(/^http/, protocol)}${normalizedPath}`);
|
|
63
|
+
return url;
|
|
67
64
|
};
|
|
68
65
|
|
|
69
66
|
// src/lib/client.ts
|
package/dist/lib/client.js
CHANGED
package/dist/lib/constants.cjs
CHANGED
|
@@ -25,17 +25,14 @@ __export(constants_exports, {
|
|
|
25
25
|
constructApiUrl: () => constructApiUrl
|
|
26
26
|
});
|
|
27
27
|
module.exports = __toCommonJS(constants_exports);
|
|
28
|
-
var BASE_URL = "https://api.cartesia.ai
|
|
28
|
+
var BASE_URL = "https://api.cartesia.ai";
|
|
29
29
|
var CARTESIA_VERSION = "2024-06-10";
|
|
30
|
-
var constructApiUrl = (baseUrl, path,
|
|
31
|
-
const
|
|
32
|
-
if (
|
|
33
|
-
|
|
30
|
+
var constructApiUrl = (baseUrl, path, { websocket = false } = {}) => {
|
|
31
|
+
const url = new URL(path, baseUrl);
|
|
32
|
+
if (websocket) {
|
|
33
|
+
url.protocol = baseUrl.replace(/^http/, "ws");
|
|
34
34
|
}
|
|
35
|
-
|
|
36
|
-
throw new Error(`Invalid protocol: ${protocol}`);
|
|
37
|
-
}
|
|
38
|
-
return new URL(`${baseUrl.replace(/^http/, protocol)}${normalizedPath}`);
|
|
35
|
+
return url;
|
|
39
36
|
};
|
|
40
37
|
// Annotate the CommonJS export names for ESM import in node:
|
|
41
38
|
0 && (module.exports = {
|
package/dist/lib/constants.d.cts
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
|
-
declare const BASE_URL = "https://api.cartesia.ai
|
|
1
|
+
declare const BASE_URL = "https://api.cartesia.ai";
|
|
2
2
|
declare const CARTESIA_VERSION = "2024-06-10";
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Construct a URL for the Cartesia API.
|
|
5
|
+
*
|
|
6
|
+
* @param baseUrl The base URL for the API.
|
|
7
|
+
* @param path The path to append to the base URL.
|
|
8
|
+
* @param options Options for the URL.
|
|
9
|
+
* @param options.websocket Whether to use the WebSocket protocol.
|
|
10
|
+
* @returns A URL object.
|
|
11
|
+
*/
|
|
12
|
+
declare const constructApiUrl: (baseUrl: string, path: string, { websocket }?: {
|
|
13
|
+
websocket?: boolean | undefined;
|
|
14
|
+
}) => URL;
|
|
4
15
|
|
|
5
16
|
export { BASE_URL, CARTESIA_VERSION, constructApiUrl };
|
package/dist/lib/constants.d.ts
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
|
-
declare const BASE_URL = "https://api.cartesia.ai
|
|
1
|
+
declare const BASE_URL = "https://api.cartesia.ai";
|
|
2
2
|
declare const CARTESIA_VERSION = "2024-06-10";
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Construct a URL for the Cartesia API.
|
|
5
|
+
*
|
|
6
|
+
* @param baseUrl The base URL for the API.
|
|
7
|
+
* @param path The path to append to the base URL.
|
|
8
|
+
* @param options Options for the URL.
|
|
9
|
+
* @param options.websocket Whether to use the WebSocket protocol.
|
|
10
|
+
* @returns A URL object.
|
|
11
|
+
*/
|
|
12
|
+
declare const constructApiUrl: (baseUrl: string, path: string, { websocket }?: {
|
|
13
|
+
websocket?: boolean | undefined;
|
|
14
|
+
}) => URL;
|
|
4
15
|
|
|
5
16
|
export { BASE_URL, CARTESIA_VERSION, constructApiUrl };
|
package/dist/lib/constants.js
CHANGED
package/dist/lib/index.cjs
CHANGED
|
@@ -97,17 +97,14 @@ module.exports = __toCommonJS(lib_exports);
|
|
|
97
97
|
var import_cross_fetch = __toESM(require("cross-fetch"), 1);
|
|
98
98
|
|
|
99
99
|
// src/lib/constants.ts
|
|
100
|
-
var BASE_URL = "https://api.cartesia.ai
|
|
100
|
+
var BASE_URL = "https://api.cartesia.ai";
|
|
101
101
|
var CARTESIA_VERSION = "2024-06-10";
|
|
102
|
-
var constructApiUrl = (baseUrl, path,
|
|
103
|
-
const
|
|
104
|
-
if (
|
|
105
|
-
|
|
102
|
+
var constructApiUrl = (baseUrl, path, { websocket = false } = {}) => {
|
|
103
|
+
const url = new URL(path, baseUrl);
|
|
104
|
+
if (websocket) {
|
|
105
|
+
url.protocol = baseUrl.replace(/^http/, "ws");
|
|
106
106
|
}
|
|
107
|
-
|
|
108
|
-
throw new Error(`Invalid protocol: ${protocol}`);
|
|
109
|
-
}
|
|
110
|
-
return new URL(`${baseUrl.replace(/^http/, protocol)}${normalizedPath}`);
|
|
107
|
+
return url;
|
|
111
108
|
};
|
|
112
109
|
|
|
113
110
|
// src/lib/client.ts
|
|
@@ -410,12 +407,11 @@ var WebSocket = class extends Client {
|
|
|
410
407
|
* @throws {Error} If the WebSocket fails to connect.
|
|
411
408
|
*/
|
|
412
409
|
connect() {
|
|
413
|
-
const url = constructApiUrl(
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
"ws"
|
|
417
|
-
);
|
|
410
|
+
const url = constructApiUrl(this.baseUrl, "/tts/websocket", {
|
|
411
|
+
websocket: true
|
|
412
|
+
});
|
|
418
413
|
url.searchParams.set("api_key", this.apiKey);
|
|
414
|
+
url.searchParams.set("cartesia_version", CARTESIA_VERSION);
|
|
419
415
|
const emitter = new import_emittery2.default();
|
|
420
416
|
this.socket = new import_partysocket.WebSocket(url.toString());
|
|
421
417
|
this.socket.onopen = () => {
|
package/dist/lib/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Cartesia
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import "../chunk-
|
|
5
|
-
import "../chunk-
|
|
6
|
-
import "../chunk-
|
|
3
|
+
} from "../chunk-ISRU7PLL.js";
|
|
4
|
+
import "../chunk-SGXUEFII.js";
|
|
5
|
+
import "../chunk-VK7LBMVI.js";
|
|
6
|
+
import "../chunk-IQAXBRHU.js";
|
|
7
7
|
import "../chunk-PQ6CIPFW.js";
|
|
8
|
-
import "../chunk-
|
|
9
|
-
import "../chunk-
|
|
8
|
+
import "../chunk-PQ5EVEEH.js";
|
|
9
|
+
import "../chunk-2BFEKY3F.js";
|
|
10
10
|
import "../chunk-RO7TY474.js";
|
|
11
11
|
import "../chunk-WIFMLPT5.js";
|
|
12
12
|
export {
|
package/dist/react/index.cjs
CHANGED
|
@@ -98,17 +98,14 @@ var import_react = require("react");
|
|
|
98
98
|
var import_cross_fetch = __toESM(require("cross-fetch"), 1);
|
|
99
99
|
|
|
100
100
|
// src/lib/constants.ts
|
|
101
|
-
var BASE_URL = "https://api.cartesia.ai
|
|
101
|
+
var BASE_URL = "https://api.cartesia.ai";
|
|
102
102
|
var CARTESIA_VERSION = "2024-06-10";
|
|
103
|
-
var constructApiUrl = (baseUrl, path,
|
|
104
|
-
const
|
|
105
|
-
if (
|
|
106
|
-
|
|
103
|
+
var constructApiUrl = (baseUrl, path, { websocket = false } = {}) => {
|
|
104
|
+
const url = new URL(path, baseUrl);
|
|
105
|
+
if (websocket) {
|
|
106
|
+
url.protocol = baseUrl.replace(/^http/, "ws");
|
|
107
107
|
}
|
|
108
|
-
|
|
109
|
-
throw new Error(`Invalid protocol: ${protocol}`);
|
|
110
|
-
}
|
|
111
|
-
return new URL(`${baseUrl.replace(/^http/, protocol)}${normalizedPath}`);
|
|
108
|
+
return url;
|
|
112
109
|
};
|
|
113
110
|
|
|
114
111
|
// src/lib/client.ts
|
|
@@ -424,12 +421,11 @@ var WebSocket = class extends Client {
|
|
|
424
421
|
* @throws {Error} If the WebSocket fails to connect.
|
|
425
422
|
*/
|
|
426
423
|
connect() {
|
|
427
|
-
const url = constructApiUrl(
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
"ws"
|
|
431
|
-
);
|
|
424
|
+
const url = constructApiUrl(this.baseUrl, "/tts/websocket", {
|
|
425
|
+
websocket: true
|
|
426
|
+
});
|
|
432
427
|
url.searchParams.set("api_key", this.apiKey);
|
|
428
|
+
url.searchParams.set("cartesia_version", CARTESIA_VERSION);
|
|
433
429
|
const emitter = new import_emittery2.default();
|
|
434
430
|
this.socket = new import_partysocket.WebSocket(url.toString());
|
|
435
431
|
this.socket.onopen = () => {
|
package/dist/react/index.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Cartesia
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import "../chunk-
|
|
3
|
+
} from "../chunk-ISRU7PLL.js";
|
|
4
|
+
import "../chunk-SGXUEFII.js";
|
|
5
5
|
import {
|
|
6
6
|
pingServer
|
|
7
7
|
} from "../chunk-3FL2SNIR.js";
|
|
8
|
-
import "../chunk-
|
|
9
|
-
import "../chunk-
|
|
8
|
+
import "../chunk-VK7LBMVI.js";
|
|
9
|
+
import "../chunk-IQAXBRHU.js";
|
|
10
10
|
import "../chunk-PQ6CIPFW.js";
|
|
11
|
-
import "../chunk-
|
|
12
|
-
import "../chunk-
|
|
11
|
+
import "../chunk-PQ5EVEEH.js";
|
|
12
|
+
import "../chunk-2BFEKY3F.js";
|
|
13
13
|
import {
|
|
14
14
|
Player
|
|
15
15
|
} from "../chunk-36JBKJUN.js";
|
package/dist/tts/index.cjs
CHANGED
|
@@ -97,17 +97,14 @@ module.exports = __toCommonJS(tts_exports);
|
|
|
97
97
|
var import_cross_fetch = __toESM(require("cross-fetch"), 1);
|
|
98
98
|
|
|
99
99
|
// src/lib/constants.ts
|
|
100
|
-
var BASE_URL = "https://api.cartesia.ai
|
|
100
|
+
var BASE_URL = "https://api.cartesia.ai";
|
|
101
101
|
var CARTESIA_VERSION = "2024-06-10";
|
|
102
|
-
var constructApiUrl = (baseUrl, path,
|
|
103
|
-
const
|
|
104
|
-
if (
|
|
105
|
-
|
|
102
|
+
var constructApiUrl = (baseUrl, path, { websocket = false } = {}) => {
|
|
103
|
+
const url = new URL(path, baseUrl);
|
|
104
|
+
if (websocket) {
|
|
105
|
+
url.protocol = baseUrl.replace(/^http/, "ws");
|
|
106
106
|
}
|
|
107
|
-
|
|
108
|
-
throw new Error(`Invalid protocol: ${protocol}`);
|
|
109
|
-
}
|
|
110
|
-
return new URL(`${baseUrl.replace(/^http/, protocol)}${normalizedPath}`);
|
|
107
|
+
return url;
|
|
111
108
|
};
|
|
112
109
|
|
|
113
110
|
// src/lib/client.ts
|
|
@@ -410,12 +407,11 @@ var WebSocket = class extends Client {
|
|
|
410
407
|
* @throws {Error} If the WebSocket fails to connect.
|
|
411
408
|
*/
|
|
412
409
|
connect() {
|
|
413
|
-
const url = constructApiUrl(
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
"ws"
|
|
417
|
-
);
|
|
410
|
+
const url = constructApiUrl(this.baseUrl, "/tts/websocket", {
|
|
411
|
+
websocket: true
|
|
412
|
+
});
|
|
418
413
|
url.searchParams.set("api_key", this.apiKey);
|
|
414
|
+
url.searchParams.set("cartesia_version", CARTESIA_VERSION);
|
|
419
415
|
const emitter = new import_emittery2.default();
|
|
420
416
|
this.socket = new import_partysocket.WebSocket(url.toString());
|
|
421
417
|
this.socket.onopen = () => {
|
package/dist/tts/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
TTS
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import "../chunk-
|
|
3
|
+
} from "../chunk-VK7LBMVI.js";
|
|
4
|
+
import "../chunk-IQAXBRHU.js";
|
|
5
5
|
import "../chunk-PQ6CIPFW.js";
|
|
6
|
-
import "../chunk-
|
|
7
|
-
import "../chunk-
|
|
6
|
+
import "../chunk-PQ5EVEEH.js";
|
|
7
|
+
import "../chunk-2BFEKY3F.js";
|
|
8
8
|
import "../chunk-RO7TY474.js";
|
|
9
9
|
import "../chunk-WIFMLPT5.js";
|
|
10
10
|
export {
|
package/dist/tts/websocket.cjs
CHANGED
|
@@ -100,17 +100,14 @@ var import_partysocket = require("partysocket");
|
|
|
100
100
|
var import_cross_fetch = __toESM(require("cross-fetch"), 1);
|
|
101
101
|
|
|
102
102
|
// src/lib/constants.ts
|
|
103
|
-
var BASE_URL = "https://api.cartesia.ai
|
|
103
|
+
var BASE_URL = "https://api.cartesia.ai";
|
|
104
104
|
var CARTESIA_VERSION = "2024-06-10";
|
|
105
|
-
var constructApiUrl = (baseUrl, path,
|
|
106
|
-
const
|
|
107
|
-
if (
|
|
108
|
-
|
|
105
|
+
var constructApiUrl = (baseUrl, path, { websocket = false } = {}) => {
|
|
106
|
+
const url = new URL(path, baseUrl);
|
|
107
|
+
if (websocket) {
|
|
108
|
+
url.protocol = baseUrl.replace(/^http/, "ws");
|
|
109
109
|
}
|
|
110
|
-
|
|
111
|
-
throw new Error(`Invalid protocol: ${protocol}`);
|
|
112
|
-
}
|
|
113
|
-
return new URL(`${baseUrl.replace(/^http/, protocol)}${normalizedPath}`);
|
|
110
|
+
return url;
|
|
114
111
|
};
|
|
115
112
|
|
|
116
113
|
// src/lib/client.ts
|
|
@@ -408,12 +405,11 @@ var WebSocket = class extends Client {
|
|
|
408
405
|
* @throws {Error} If the WebSocket fails to connect.
|
|
409
406
|
*/
|
|
410
407
|
connect() {
|
|
411
|
-
const url = constructApiUrl(
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
"ws"
|
|
415
|
-
);
|
|
408
|
+
const url = constructApiUrl(this.baseUrl, "/tts/websocket", {
|
|
409
|
+
websocket: true
|
|
410
|
+
});
|
|
416
411
|
url.searchParams.set("api_key", this.apiKey);
|
|
412
|
+
url.searchParams.set("cartesia_version", CARTESIA_VERSION);
|
|
417
413
|
const emitter = new import_emittery2.default();
|
|
418
414
|
this.socket = new import_partysocket.WebSocket(url.toString());
|
|
419
415
|
this.socket.onopen = () => {
|
package/dist/tts/websocket.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
WebSocket
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-IQAXBRHU.js";
|
|
4
4
|
import "../chunk-PQ6CIPFW.js";
|
|
5
|
-
import "../chunk-
|
|
6
|
-
import "../chunk-
|
|
5
|
+
import "../chunk-PQ5EVEEH.js";
|
|
6
|
+
import "../chunk-2BFEKY3F.js";
|
|
7
7
|
import "../chunk-RO7TY474.js";
|
|
8
8
|
import "../chunk-WIFMLPT5.js";
|
|
9
9
|
export {
|
package/dist/voices/index.cjs
CHANGED
|
@@ -75,17 +75,14 @@ module.exports = __toCommonJS(voices_exports);
|
|
|
75
75
|
var import_cross_fetch = __toESM(require("cross-fetch"), 1);
|
|
76
76
|
|
|
77
77
|
// src/lib/constants.ts
|
|
78
|
-
var BASE_URL = "https://api.cartesia.ai
|
|
78
|
+
var BASE_URL = "https://api.cartesia.ai";
|
|
79
79
|
var CARTESIA_VERSION = "2024-06-10";
|
|
80
|
-
var constructApiUrl = (baseUrl, path,
|
|
81
|
-
const
|
|
82
|
-
if (
|
|
83
|
-
|
|
80
|
+
var constructApiUrl = (baseUrl, path, { websocket = false } = {}) => {
|
|
81
|
+
const url = new URL(path, baseUrl);
|
|
82
|
+
if (websocket) {
|
|
83
|
+
url.protocol = baseUrl.replace(/^http/, "ws");
|
|
84
84
|
}
|
|
85
|
-
|
|
86
|
-
throw new Error(`Invalid protocol: ${protocol}`);
|
|
87
|
-
}
|
|
88
|
-
return new URL(`${baseUrl.replace(/^http/, protocol)}${normalizedPath}`);
|
|
85
|
+
return url;
|
|
89
86
|
};
|
|
90
87
|
|
|
91
88
|
// src/lib/client.ts
|
package/dist/voices/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Voices
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import "../chunk-
|
|
5
|
-
import "../chunk-
|
|
3
|
+
} from "../chunk-SGXUEFII.js";
|
|
4
|
+
import "../chunk-PQ5EVEEH.js";
|
|
5
|
+
import "../chunk-2BFEKY3F.js";
|
|
6
6
|
import "../chunk-WIFMLPT5.js";
|
|
7
7
|
export {
|
|
8
8
|
Voices as default
|
package/package.json
CHANGED
package/src/lib/constants.ts
CHANGED
|
@@ -1,17 +1,25 @@
|
|
|
1
|
-
export const BASE_URL = "https://api.cartesia.ai
|
|
1
|
+
export const BASE_URL = "https://api.cartesia.ai";
|
|
2
2
|
export const CARTESIA_VERSION = "2024-06-10";
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Construct a URL for the Cartesia API.
|
|
6
|
+
*
|
|
7
|
+
* @param baseUrl The base URL for the API.
|
|
8
|
+
* @param path The path to append to the base URL.
|
|
9
|
+
* @param options Options for the URL.
|
|
10
|
+
* @param options.websocket Whether to use the WebSocket protocol.
|
|
11
|
+
* @returns A URL object.
|
|
12
|
+
*/
|
|
4
13
|
export const constructApiUrl = (
|
|
5
14
|
baseUrl: string,
|
|
6
15
|
path: string,
|
|
7
|
-
|
|
16
|
+
{ websocket = false } = {},
|
|
8
17
|
) => {
|
|
9
|
-
const
|
|
10
|
-
if (
|
|
11
|
-
|
|
18
|
+
const url = new URL(path, baseUrl);
|
|
19
|
+
if (websocket) {
|
|
20
|
+
// Using find-and-replace ensures that if the base URL uses TLS, the
|
|
21
|
+
// new protocol does too.
|
|
22
|
+
url.protocol = baseUrl.replace(/^http/, "ws");
|
|
12
23
|
}
|
|
13
|
-
|
|
14
|
-
throw new Error(`Invalid protocol: ${protocol}`);
|
|
15
|
-
}
|
|
16
|
-
return new URL(`${baseUrl.replace(/^http/, protocol)}${normalizedPath}`);
|
|
24
|
+
return url;
|
|
17
25
|
};
|
package/src/tts/websocket.ts
CHANGED
|
@@ -150,12 +150,11 @@ export default class WebSocket extends Client {
|
|
|
150
150
|
* @throws {Error} If the WebSocket fails to connect.
|
|
151
151
|
*/
|
|
152
152
|
connect() {
|
|
153
|
-
const url = constructApiUrl(
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
"ws",
|
|
157
|
-
);
|
|
153
|
+
const url = constructApiUrl(this.baseUrl, "/tts/websocket", {
|
|
154
|
+
websocket: true,
|
|
155
|
+
});
|
|
158
156
|
url.searchParams.set("api_key", this.apiKey);
|
|
157
|
+
url.searchParams.set("cartesia_version", CARTESIA_VERSION);
|
|
159
158
|
const emitter = new Emittery<ConnectionEventData>();
|
|
160
159
|
this.socket = new PartySocketWebSocket(url.toString());
|
|
161
160
|
this.socket.onopen = () => {
|
package/dist/chunk-XHTDPLFR.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
// src/lib/constants.ts
|
|
2
|
-
var BASE_URL = "https://api.cartesia.ai/";
|
|
3
|
-
var CARTESIA_VERSION = "2024-06-10";
|
|
4
|
-
var constructApiUrl = (baseUrl, path, protocol) => {
|
|
5
|
-
const normalizedPath = path.startsWith("/") ? path : `/${path}`;
|
|
6
|
-
if (!protocol) {
|
|
7
|
-
return new URL(`${baseUrl}${normalizedPath}`);
|
|
8
|
-
}
|
|
9
|
-
if (!["http", "ws"].includes(protocol)) {
|
|
10
|
-
throw new Error(`Invalid protocol: ${protocol}`);
|
|
11
|
-
}
|
|
12
|
-
return new URL(`${baseUrl.replace(/^http/, protocol)}${normalizedPath}`);
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export {
|
|
16
|
-
BASE_URL,
|
|
17
|
-
CARTESIA_VERSION,
|
|
18
|
-
constructApiUrl
|
|
19
|
-
};
|