@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.
Files changed (89) hide show
  1. package/.turbo/turbo-build.log +63 -45
  2. package/CHANGELOG.md +12 -0
  3. package/README.md +123 -16
  4. package/dist/chunk-36JBKJUN.js +119 -0
  5. package/dist/chunk-3F5E46FT.js +212 -0
  6. package/dist/{chunk-XPIMIAAE.js → chunk-3FL2SNIR.js} +1 -1
  7. package/dist/chunk-JGP5BIUV.js +34 -0
  8. package/dist/chunk-KWBSQZTY.js +25 -0
  9. package/dist/chunk-PQ6CIPFW.js +120 -0
  10. package/dist/chunk-RO7TY474.js +81 -0
  11. package/dist/chunk-T3RG6WV4.js +22 -0
  12. package/dist/{chunk-R4P7LWVZ.js → chunk-WIFMLPT5.js} +31 -6
  13. package/dist/chunk-WVTITUXX.js +58 -0
  14. package/dist/chunk-XHTDPLFR.js +19 -0
  15. package/dist/index.cjs +425 -166
  16. package/dist/index.d.cts +7 -3
  17. package/dist/index.d.ts +7 -3
  18. package/dist/index.js +13 -6
  19. package/dist/lib/client.cjs +49 -1
  20. package/dist/lib/client.d.cts +2 -0
  21. package/dist/lib/client.d.ts +2 -0
  22. package/dist/lib/client.js +3 -3
  23. package/dist/lib/constants.cjs +15 -8
  24. package/dist/lib/constants.d.cts +4 -4
  25. package/dist/lib/constants.d.ts +4 -4
  26. package/dist/lib/constants.js +6 -6
  27. package/dist/lib/index.cjs +310 -171
  28. package/dist/lib/index.d.cts +6 -2
  29. package/dist/lib/index.d.ts +6 -2
  30. package/dist/lib/index.js +9 -6
  31. package/dist/react/index.cjs +573 -290
  32. package/dist/react/index.d.cts +20 -14
  33. package/dist/react/index.d.ts +20 -14
  34. package/dist/react/index.js +157 -105
  35. package/dist/react/utils.js +2 -2
  36. package/dist/tts/index.cjs +496 -0
  37. package/dist/tts/index.d.cts +17 -0
  38. package/dist/tts/index.d.ts +17 -0
  39. package/dist/tts/index.js +12 -0
  40. package/dist/tts/player.cjs +198 -0
  41. package/dist/tts/player.d.cts +43 -0
  42. package/dist/tts/player.d.ts +43 -0
  43. package/dist/tts/player.js +8 -0
  44. package/dist/tts/source.cjs +181 -0
  45. package/dist/tts/source.d.cts +53 -0
  46. package/dist/tts/source.d.ts +53 -0
  47. package/dist/tts/source.js +7 -0
  48. package/dist/{audio → tts}/utils.cjs +25 -60
  49. package/dist/tts/utils.d.cts +67 -0
  50. package/dist/tts/utils.d.ts +67 -0
  51. package/dist/{audio → tts}/utils.js +2 -7
  52. package/dist/tts/websocket.cjs +479 -0
  53. package/dist/tts/websocket.d.cts +53 -0
  54. package/dist/tts/websocket.d.ts +53 -0
  55. package/dist/tts/websocket.js +11 -0
  56. package/dist/types/index.d.cts +50 -1
  57. package/dist/types/index.d.ts +50 -1
  58. package/dist/voices/index.cjs +157 -0
  59. package/dist/voices/index.d.cts +12 -0
  60. package/dist/voices/index.d.ts +12 -0
  61. package/dist/voices/index.js +9 -0
  62. package/package.json +2 -1
  63. package/src/index.ts +1 -0
  64. package/src/lib/client.ts +15 -1
  65. package/src/lib/constants.ts +15 -4
  66. package/src/lib/index.ts +6 -3
  67. package/src/react/index.ts +176 -110
  68. package/src/tts/index.ts +17 -0
  69. package/src/tts/player.ts +110 -0
  70. package/src/tts/source.ts +115 -0
  71. package/src/tts/utils.ts +150 -0
  72. package/src/tts/websocket.ts +214 -0
  73. package/src/types/index.ts +63 -0
  74. package/src/voices/index.ts +47 -0
  75. package/dist/audio/index.cjs +0 -404
  76. package/dist/audio/index.d.cts +0 -5
  77. package/dist/audio/index.d.ts +0 -5
  78. package/dist/audio/index.js +0 -10
  79. package/dist/audio/utils.d.cts +0 -5
  80. package/dist/audio/utils.d.ts +0 -5
  81. package/dist/chunk-4MHF74A7.js +0 -272
  82. package/dist/chunk-5TSWLYOW.js +0 -113
  83. package/dist/chunk-MJIFZWHS.js +0 -18
  84. package/dist/chunk-OVI3W3GG.js +0 -12
  85. package/dist/chunk-S6A27RQL.js +0 -18
  86. package/dist/index-C2_3XFxn.d.cts +0 -163
  87. package/dist/index-DgwnZezj.d.ts +0 -163
  88. package/src/audio/index.ts +0 -297
  89. package/src/audio/utils.ts +0 -220
@@ -0,0 +1,496 @@
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
+ var __accessCheck = (obj, member, msg) => {
47
+ if (!member.has(obj))
48
+ throw TypeError("Cannot " + msg);
49
+ };
50
+ var __privateGet = (obj, member, getter) => {
51
+ __accessCheck(obj, member, "read from private field");
52
+ return getter ? getter.call(obj) : member.get(obj);
53
+ };
54
+ var __privateAdd = (obj, member, value) => {
55
+ if (member.has(obj))
56
+ throw TypeError("Cannot add the same private member more than once");
57
+ member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
58
+ };
59
+ var __privateSet = (obj, member, value, setter) => {
60
+ __accessCheck(obj, member, "write to private field");
61
+ setter ? setter.call(obj, value) : member.set(obj, value);
62
+ return value;
63
+ };
64
+ var __privateMethod = (obj, member, method) => {
65
+ __accessCheck(obj, member, "access private method");
66
+ return method;
67
+ };
68
+ var __async = (__this, __arguments, generator) => {
69
+ return new Promise((resolve, reject) => {
70
+ var fulfilled = (value) => {
71
+ try {
72
+ step(generator.next(value));
73
+ } catch (e) {
74
+ reject(e);
75
+ }
76
+ };
77
+ var rejected = (value) => {
78
+ try {
79
+ step(generator.throw(value));
80
+ } catch (e) {
81
+ reject(e);
82
+ }
83
+ };
84
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
85
+ step((generator = generator.apply(__this, __arguments)).next());
86
+ });
87
+ };
88
+
89
+ // src/tts/index.ts
90
+ var tts_exports = {};
91
+ __export(tts_exports, {
92
+ default: () => TTS
93
+ });
94
+ module.exports = __toCommonJS(tts_exports);
95
+
96
+ // src/lib/client.ts
97
+ var import_cross_fetch = __toESM(require("cross-fetch"), 1);
98
+
99
+ // src/lib/constants.ts
100
+ var BASE_URL = "https://api.cartesia.ai/";
101
+ var CARTESIA_VERSION = "2024-06-10";
102
+ var constructApiUrl = (baseUrl, path, protocol) => {
103
+ const normalizedPath = path.startsWith("/") ? path : `/${path}`;
104
+ if (!protocol) {
105
+ return new URL(`${baseUrl}${normalizedPath}`);
106
+ }
107
+ if (!["http", "ws"].includes(protocol)) {
108
+ throw new Error(`Invalid protocol: ${protocol}`);
109
+ }
110
+ return new URL(`${baseUrl.replace(/^http/, protocol)}${normalizedPath}`);
111
+ };
112
+
113
+ // src/lib/client.ts
114
+ var Client = class {
115
+ constructor(options = {}) {
116
+ if (!(options.apiKey || process.env.CARTESIA_API_KEY)) {
117
+ throw new Error("Missing Cartesia API key.");
118
+ }
119
+ this.apiKey = options.apiKey || process.env.CARTESIA_API_KEY;
120
+ this.baseUrl = options.baseUrl || BASE_URL;
121
+ }
122
+ fetch(path, options = {}) {
123
+ const url = constructApiUrl(this.baseUrl, path);
124
+ return (0, import_cross_fetch.default)(url.toString(), __spreadProps(__spreadValues({}, options), {
125
+ headers: __spreadValues({
126
+ "X-API-Key": this.apiKey,
127
+ "Cartesia-Version": CARTESIA_VERSION
128
+ }, options.headers)
129
+ }));
130
+ }
131
+ };
132
+
133
+ // src/tts/websocket.ts
134
+ var import_emittery2 = __toESM(require("emittery"), 1);
135
+ var import_human_id = require("human-id");
136
+ var import_partysocket = require("partysocket");
137
+
138
+ // src/tts/source.ts
139
+ var import_emittery = __toESM(require("emittery"), 1);
140
+ var _emitter, _buffer, _readIndex, _writeIndex, _closed, _sampleRate;
141
+ var Source = class {
142
+ /**
143
+ * Create a new Source.
144
+ *
145
+ * @param options - Options for the Source.
146
+ * @param options.sampleRate - The sample rate of the audio.
147
+ */
148
+ constructor({ sampleRate }) {
149
+ __privateAdd(this, _emitter, new import_emittery.default());
150
+ __privateAdd(this, _buffer, void 0);
151
+ __privateAdd(this, _readIndex, 0);
152
+ __privateAdd(this, _writeIndex, 0);
153
+ __privateAdd(this, _closed, false);
154
+ __privateAdd(this, _sampleRate, void 0);
155
+ this.on = __privateGet(this, _emitter).on.bind(__privateGet(this, _emitter));
156
+ this.once = __privateGet(this, _emitter).once.bind(__privateGet(this, _emitter));
157
+ this.events = __privateGet(this, _emitter).events.bind(__privateGet(this, _emitter));
158
+ this.off = __privateGet(this, _emitter).off.bind(__privateGet(this, _emitter));
159
+ __privateSet(this, _sampleRate, sampleRate);
160
+ __privateSet(this, _buffer, new Float32Array(1024));
161
+ }
162
+ get sampleRate() {
163
+ return __privateGet(this, _sampleRate);
164
+ }
165
+ /**
166
+ * Append audio to the buffer.
167
+ *
168
+ * @param src The audio to append.
169
+ */
170
+ enqueue(src) {
171
+ return __async(this, null, function* () {
172
+ const requiredCapacity = __privateGet(this, _writeIndex) + src.length;
173
+ if (requiredCapacity > __privateGet(this, _buffer).length) {
174
+ let newCapacity = __privateGet(this, _buffer).length;
175
+ while (newCapacity < requiredCapacity) {
176
+ newCapacity *= 2;
177
+ }
178
+ const newBuffer = new Float32Array(newCapacity);
179
+ newBuffer.set(__privateGet(this, _buffer));
180
+ __privateSet(this, _buffer, newBuffer);
181
+ }
182
+ __privateGet(this, _buffer).set(src, __privateGet(this, _writeIndex));
183
+ __privateSet(this, _writeIndex, __privateGet(this, _writeIndex) + src.length);
184
+ yield __privateGet(this, _emitter).emit("enqueue");
185
+ });
186
+ }
187
+ /**
188
+ * Read audio from the buffer.
189
+ *
190
+ * @param dst The buffer to read the audio into.
191
+ * @returns The number of samples read. If the source is closed, this will be
192
+ * less than the length of the provided buffer.
193
+ */
194
+ read(dst) {
195
+ return __async(this, null, function* () {
196
+ const targetReadIndex = __privateGet(this, _readIndex) + dst.length;
197
+ while (!__privateGet(this, _closed) && targetReadIndex > __privateGet(this, _writeIndex)) {
198
+ yield __privateGet(this, _emitter).emit("wait");
199
+ yield Promise.race([
200
+ __privateGet(this, _emitter).once("enqueue"),
201
+ __privateGet(this, _emitter).once("close")
202
+ ]);
203
+ yield __privateGet(this, _emitter).emit("read");
204
+ }
205
+ const read = Math.min(dst.length, __privateGet(this, _writeIndex) - __privateGet(this, _readIndex));
206
+ dst.set(__privateGet(this, _buffer).subarray(__privateGet(this, _readIndex), __privateGet(this, _readIndex) + read));
207
+ __privateSet(this, _readIndex, __privateGet(this, _readIndex) + read);
208
+ return read;
209
+ });
210
+ }
211
+ /**
212
+ * Get the number of samples in a given duration.
213
+ *
214
+ * @param durationSecs The duration in seconds.
215
+ * @returns The number of samples.
216
+ */
217
+ durationToSampleCount(durationSecs) {
218
+ return Math.trunc(durationSecs * __privateGet(this, _sampleRate));
219
+ }
220
+ get buffer() {
221
+ return __privateGet(this, _buffer);
222
+ }
223
+ get readIndex() {
224
+ return __privateGet(this, _readIndex);
225
+ }
226
+ /**
227
+ * Close the source. This signals that no more audio will be enqueued.
228
+ *
229
+ * This will emit a "close" event.
230
+ *
231
+ * @returns A promise that resolves when the source is closed.
232
+ */
233
+ close() {
234
+ return __async(this, null, function* () {
235
+ __privateSet(this, _closed, true);
236
+ yield __privateGet(this, _emitter).emit("close");
237
+ __privateGet(this, _emitter).clearListeners();
238
+ });
239
+ }
240
+ };
241
+ _emitter = new WeakMap();
242
+ _buffer = new WeakMap();
243
+ _readIndex = new WeakMap();
244
+ _writeIndex = new WeakMap();
245
+ _closed = new WeakMap();
246
+ _sampleRate = new WeakMap();
247
+
248
+ // src/tts/utils.ts
249
+ var import_base64_js = __toESM(require("base64-js"), 1);
250
+ function base64ToArray(b64) {
251
+ const byteArrays = filterSentinel(b64).map((b) => import_base64_js.default.toByteArray(b));
252
+ const totalLength = byteArrays.reduce(
253
+ (acc, arr) => acc + arr.length / Float32Array.BYTES_PER_ELEMENT,
254
+ 0
255
+ );
256
+ const result = new Float32Array(totalLength);
257
+ let offset = 0;
258
+ for (const arr of byteArrays) {
259
+ const floats = new Float32Array(arr.buffer);
260
+ result.set(floats, offset);
261
+ offset += floats.length;
262
+ }
263
+ return result;
264
+ }
265
+ function createMessageHandlerForContextId(contextId, handler) {
266
+ return (event) => {
267
+ if (typeof event.data !== "string") {
268
+ return;
269
+ }
270
+ const message = JSON.parse(event.data);
271
+ if (message.context_id !== contextId) {
272
+ return;
273
+ }
274
+ let chunk;
275
+ if (message.done) {
276
+ chunk = getSentinel();
277
+ } else {
278
+ chunk = message.data;
279
+ }
280
+ handler({ chunk, message: event.data });
281
+ };
282
+ }
283
+ function getSentinel() {
284
+ return null;
285
+ }
286
+ function isSentinel(x) {
287
+ return x === getSentinel();
288
+ }
289
+ function filterSentinel(collection) {
290
+ return collection.filter(
291
+ (x) => !isSentinel(x)
292
+ );
293
+ }
294
+ function getEmitteryCallbacks(emitter) {
295
+ return {
296
+ on: emitter.on.bind(emitter),
297
+ off: emitter.off.bind(emitter),
298
+ once: emitter.once.bind(emitter),
299
+ events: emitter.events.bind(emitter)
300
+ };
301
+ }
302
+
303
+ // src/tts/websocket.ts
304
+ var _isConnected, _sampleRate2, _generateId, generateId_fn;
305
+ var WebSocket = class extends Client {
306
+ /**
307
+ * Create a new WebSocket client.
308
+ *
309
+ * @param args - Arguments to pass to the Client constructor.
310
+ */
311
+ constructor({ sampleRate }, ...args) {
312
+ super(...args);
313
+ /**
314
+ * Generate a unique ID suitable for a streaming context.
315
+ *
316
+ * Not suitable for security purposes or as a primary key, since
317
+ * it lacks the amount of entropy required for those use cases.
318
+ *
319
+ * @returns A unique ID.
320
+ */
321
+ __privateAdd(this, _generateId);
322
+ __privateAdd(this, _isConnected, false);
323
+ __privateAdd(this, _sampleRate2, void 0);
324
+ __privateSet(this, _sampleRate2, sampleRate);
325
+ }
326
+ /**
327
+ * Send a message over the WebSocket in order to start a stream.
328
+ *
329
+ * @param inputs - Stream options.
330
+ * @param options - Options for the stream.
331
+ * @param options.timeout - The maximum time to wait for a chunk before cancelling the stream.
332
+ * If `0`, the stream will not time out.
333
+ * @returns A Source object that can be passed to a Player to play the audio.
334
+ */
335
+ send(inputs, { timeout = 0 } = {}) {
336
+ var _a, _b, _c, _d;
337
+ if (!__privateGet(this, _isConnected)) {
338
+ throw new Error("Not connected to WebSocket. Call .connect() first.");
339
+ }
340
+ const contextId = __privateMethod(this, _generateId, generateId_fn).call(this);
341
+ (_a = this.socket) == null ? void 0 : _a.send(
342
+ JSON.stringify(__spreadProps(__spreadValues({
343
+ context_id: contextId
344
+ }, inputs), {
345
+ output_format: {
346
+ container: "raw",
347
+ encoding: "pcm_f32le",
348
+ sample_rate: __privateGet(this, _sampleRate2)
349
+ }
350
+ }))
351
+ );
352
+ const emitter = new import_emittery2.default();
353
+ const source = new Source({
354
+ sampleRate: __privateGet(this, _sampleRate2)
355
+ });
356
+ const streamCompleteController = new AbortController();
357
+ let timeoutId = null;
358
+ if (timeout > 0) {
359
+ timeoutId = setTimeout(streamCompleteController.abort, timeout);
360
+ }
361
+ const handleMessage = createMessageHandlerForContextId(
362
+ contextId,
363
+ (_0) => __async(this, [_0], function* ({ chunk, message }) {
364
+ emitter.emit("message", message);
365
+ if (isSentinel(chunk)) {
366
+ yield source.close();
367
+ streamCompleteController.abort();
368
+ return;
369
+ }
370
+ yield source.enqueue(base64ToArray([chunk]));
371
+ if (timeoutId) {
372
+ clearTimeout(timeoutId);
373
+ timeoutId = setTimeout(streamCompleteController.abort, timeout);
374
+ }
375
+ })
376
+ );
377
+ (_b = this.socket) == null ? void 0 : _b.addEventListener("message", handleMessage, {
378
+ signal: streamCompleteController.signal
379
+ });
380
+ (_c = this.socket) == null ? void 0 : _c.addEventListener(
381
+ "close",
382
+ () => {
383
+ streamCompleteController.abort();
384
+ },
385
+ {
386
+ once: true
387
+ }
388
+ );
389
+ (_d = this.socket) == null ? void 0 : _d.addEventListener(
390
+ "error",
391
+ () => {
392
+ streamCompleteController.abort();
393
+ },
394
+ {
395
+ once: true
396
+ }
397
+ );
398
+ streamCompleteController.signal.addEventListener("abort", () => {
399
+ source.close();
400
+ if (timeoutId) {
401
+ clearTimeout(timeoutId);
402
+ }
403
+ });
404
+ return __spreadValues({ source }, getEmitteryCallbacks(emitter));
405
+ }
406
+ /**
407
+ * Authenticate and connect to a Cartesia streaming WebSocket.
408
+ *
409
+ * @returns A promise that resolves when the WebSocket is connected.
410
+ * @throws {Error} If the WebSocket fails to connect.
411
+ */
412
+ connect() {
413
+ const url = constructApiUrl(
414
+ this.baseUrl,
415
+ `/tts/websocket?cartesia_version=${CARTESIA_VERSION}`,
416
+ "ws"
417
+ );
418
+ url.searchParams.set("api_key", this.apiKey);
419
+ const emitter = new import_emittery2.default();
420
+ this.socket = new import_partysocket.WebSocket(url.toString());
421
+ this.socket.onopen = () => {
422
+ __privateSet(this, _isConnected, true);
423
+ emitter.emit("open");
424
+ };
425
+ this.socket.onclose = () => {
426
+ __privateSet(this, _isConnected, false);
427
+ emitter.emit("close");
428
+ };
429
+ return new Promise(
430
+ (resolve, reject) => {
431
+ var _a, _b, _c;
432
+ (_a = this.socket) == null ? void 0 : _a.addEventListener(
433
+ "open",
434
+ () => {
435
+ resolve(getEmitteryCallbacks(emitter));
436
+ },
437
+ {
438
+ once: true
439
+ }
440
+ );
441
+ const aborter = new AbortController();
442
+ (_b = this.socket) == null ? void 0 : _b.addEventListener(
443
+ "error",
444
+ () => {
445
+ aborter.abort();
446
+ reject(new Error("WebSocket failed to connect."));
447
+ },
448
+ {
449
+ signal: aborter.signal
450
+ }
451
+ );
452
+ (_c = this.socket) == null ? void 0 : _c.addEventListener(
453
+ "close",
454
+ () => {
455
+ aborter.abort();
456
+ reject(new Error("WebSocket closed before it could connect."));
457
+ },
458
+ {
459
+ signal: aborter.signal
460
+ }
461
+ );
462
+ }
463
+ );
464
+ }
465
+ /**
466
+ * Disconnect from the Cartesia streaming WebSocket.
467
+ */
468
+ disconnect() {
469
+ var _a;
470
+ (_a = this.socket) == null ? void 0 : _a.close();
471
+ }
472
+ };
473
+ _isConnected = new WeakMap();
474
+ _sampleRate2 = new WeakMap();
475
+ _generateId = new WeakSet();
476
+ generateId_fn = function() {
477
+ return (0, import_human_id.humanId)({
478
+ separator: "-",
479
+ capitalize: false
480
+ });
481
+ };
482
+
483
+ // src/tts/index.ts
484
+ var TTS = class extends Client {
485
+ /**
486
+ * Get a WebSocket client for streaming audio from the TTS API.
487
+ *
488
+ * @returns {WebSocket} A Cartesia WebSocket client.
489
+ */
490
+ websocket(options) {
491
+ return new WebSocket(options, {
492
+ apiKey: this.apiKey,
493
+ baseUrl: this.baseUrl
494
+ });
495
+ }
496
+ };
@@ -0,0 +1,17 @@
1
+ import { Client } from '../lib/client.cjs';
2
+ import { WebSocketOptions } from '../types/index.cjs';
3
+ import WebSocket from './websocket.cjs';
4
+ import 'emittery';
5
+ import 'partysocket';
6
+ import './source.cjs';
7
+
8
+ declare class TTS extends Client {
9
+ /**
10
+ * Get a WebSocket client for streaming audio from the TTS API.
11
+ *
12
+ * @returns {WebSocket} A Cartesia WebSocket client.
13
+ */
14
+ websocket(options: WebSocketOptions): WebSocket;
15
+ }
16
+
17
+ export { TTS as default };
@@ -0,0 +1,17 @@
1
+ import { Client } from '../lib/client.js';
2
+ import { WebSocketOptions } from '../types/index.js';
3
+ import WebSocket from './websocket.js';
4
+ import 'emittery';
5
+ import 'partysocket';
6
+ import './source.js';
7
+
8
+ declare class TTS extends Client {
9
+ /**
10
+ * Get a WebSocket client for streaming audio from the TTS API.
11
+ *
12
+ * @returns {WebSocket} A Cartesia WebSocket client.
13
+ */
14
+ websocket(options: WebSocketOptions): WebSocket;
15
+ }
16
+
17
+ export { TTS as default };
@@ -0,0 +1,12 @@
1
+ import {
2
+ TTS
3
+ } from "../chunk-KWBSQZTY.js";
4
+ import "../chunk-3F5E46FT.js";
5
+ import "../chunk-PQ6CIPFW.js";
6
+ import "../chunk-JGP5BIUV.js";
7
+ import "../chunk-XHTDPLFR.js";
8
+ import "../chunk-RO7TY474.js";
9
+ import "../chunk-WIFMLPT5.js";
10
+ export {
11
+ TTS as default
12
+ };