@cartesia/cartesia-js 1.0.2 → 1.0.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.
@@ -5,32 +5,19 @@ $ tsup src/ --format cjs,esm --dts
5
5
  CLI Target: es6
6
6
  CJS Build start
7
7
  ESM Build start
8
- CJS dist/types/index.cjs 764.00 B
9
- CJS dist/voices/index.cjs 5.36 KB
10
- CJS dist/index.cjs 24.67 KB
11
- CJS dist/lib/client.cjs 4.07 KB
12
- CJS dist/lib/constants.cjs 1.43 KB
13
- CJS dist/lib/index.cjs 20.57 KB
14
- CJS dist/react/index.cjs 32.23 KB
15
- CJS dist/react/utils.cjs 1.80 KB
16
- CJS dist/tts/index.cjs 18.92 KB
17
- CJS dist/tts/player.cjs 6.96 KB
18
- CJS dist/tts/source.cjs 8.15 KB
19
- CJS dist/tts/utils.cjs 4.33 KB
20
- CJS dist/tts/websocket.cjs 18.61 KB
21
- CJS ⚡️ Build success in 75ms
22
- ESM dist/index.js 499.00 B
23
- ESM dist/lib/constants.js 183.00 B
24
8
  ESM dist/chunk-FXPGR372.js 0 B
9
+ ESM dist/index.js 499.00 B
10
+ ESM dist/lib/client.js 132.00 B
25
11
  ESM dist/react/index.js 7.62 KB
26
12
  ESM dist/tts/index.js 261.00 B
13
+ ESM dist/lib/constants.js 183.00 B
27
14
  ESM dist/lib/index.js 322.00 B
28
- ESM dist/chunk-NVOCUUOF.js 353.00 B
29
- ESM dist/chunk-UCYL2SOX.js 1.48 KB
15
+ ESM dist/chunk-ZF6HASZT.js 353.00 B
16
+ ESM dist/chunk-YFN6TFR4.js 1.74 KB
30
17
  ESM dist/react/utils.js 109.00 B
31
18
  ESM dist/chunk-NQVZNVOU.js 337.00 B
32
- ESM dist/chunk-EDAAHENY.js 439.00 B
33
- ESM dist/chunk-IZBPLCGW.js 7.13 KB
19
+ ESM dist/chunk-NWCW6C7H.js 439.00 B
20
+ ESM dist/chunk-EUW2435M.js 7.17 KB
34
21
  ESM dist/chunk-PISCPZK4.js 1.02 KB
35
22
  ESM dist/chunk-2BFEKY3F.js 366.00 B
36
23
  ESM dist/tts/player.js 174.00 B
@@ -38,16 +25,29 @@ $ tsup src/ --format cjs,esm --dts
38
25
  ESM dist/chunk-BHY7MNGT.js 2.11 KB
39
26
  ESM dist/chunk-6YQ6KDIQ.js 5.32 KB
40
27
  ESM dist/chunk-GHY2WEOK.js 2.70 KB
28
+ ESM dist/voices/index.js 174.00 B
29
+ ESM dist/types/index.js 31.00 B
41
30
  ESM dist/tts/source.js 144.00 B
42
31
  ESM dist/tts/utils.js 426.00 B
43
32
  ESM dist/tts/websocket.js 242.00 B
44
- ESM dist/types/index.js 31.00 B
45
- ESM dist/voices/index.js 174.00 B
46
- ESM dist/lib/client.js 132.00 B
47
- ESM ⚡️ Build success in 77ms
33
+ ESM ⚡️ Build success in 72ms
34
+ CJS dist/index.cjs 24.98 KB
35
+ CJS dist/lib/client.cjs 4.07 KB
36
+ CJS dist/lib/constants.cjs 1.43 KB
37
+ CJS dist/lib/index.cjs 20.87 KB
38
+ CJS dist/react/index.cjs 32.54 KB
39
+ CJS dist/react/utils.cjs 1.80 KB
40
+ CJS dist/tts/index.cjs 18.96 KB
41
+ CJS dist/tts/player.cjs 6.96 KB
42
+ CJS dist/tts/utils.cjs 4.33 KB
43
+ CJS dist/tts/source.cjs 8.15 KB
44
+ CJS dist/types/index.cjs 764.00 B
45
+ CJS dist/tts/websocket.cjs 18.65 KB
46
+ CJS dist/voices/index.cjs 5.62 KB
47
+ CJS ⚡️ Build success in 73ms
48
48
  DTS Build start
49
- DTS ⚡️ Build success in 8516ms
50
- DTS dist/index.d.cts 817.00 B
49
+ DTS ⚡️ Build success in 8468ms
50
+ DTS dist/index.d.cts 866.00 B
51
51
  DTS dist/lib/constants.d.cts 564.00 B
52
52
  DTS dist/lib/index.d.cts 410.00 B
53
53
  DTS dist/react/index.d.cts 1.09 KB
@@ -57,10 +57,10 @@ $ tsup src/ --format cjs,esm --dts
57
57
  DTS dist/tts/utils.d.cts 2.68 KB
58
58
  DTS dist/tts/websocket.d.cts 2.94 KB
59
59
  DTS dist/tts/source.d.cts 2.55 KB
60
- DTS dist/voices/index.d.cts 472.00 B
60
+ DTS dist/voices/index.d.cts 573.00 B
61
61
  DTS dist/lib/client.d.cts 293.00 B
62
- DTS dist/types/index.d.cts 3.25 KB
63
- DTS dist/index.d.ts 809.00 B
62
+ DTS dist/types/index.d.cts 3.50 KB
63
+ DTS dist/index.d.ts 858.00 B
64
64
  DTS dist/lib/constants.d.ts 564.00 B
65
65
  DTS dist/lib/index.d.ts 404.00 B
66
66
  DTS dist/react/index.d.ts 1.09 KB
@@ -70,6 +70,6 @@ $ tsup src/ --format cjs,esm --dts
70
70
  DTS dist/tts/utils.d.ts 2.68 KB
71
71
  DTS dist/tts/websocket.d.ts 2.94 KB
72
72
  DTS dist/tts/source.d.ts 2.55 KB
73
- DTS dist/voices/index.d.ts 470.00 B
73
+ DTS dist/voices/index.d.ts 571.00 B
74
74
  DTS dist/lib/client.d.ts 292.00 B
75
- DTS dist/types/index.d.ts 3.25 KB
75
+ DTS dist/types/index.d.ts 3.50 KB
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @cartesia/cartesia-js
2
2
 
3
+ ## 1.0.3
4
+
5
+ ### Patch Changes
6
+
7
+ - 9b157d6: Support Bun by adding socket binaryType
8
+
3
9
  ## 1.0.2
4
10
 
5
11
  ### Patch Changes
package/README.md CHANGED
@@ -52,6 +52,17 @@ console.log(voices);
52
52
  const voice = await cartesia.voices.get("<voice-id>");
53
53
  console.log(voice);
54
54
 
55
+ // Clone a voice from a file.
56
+ const clonedVoiceEmbedding = await cartesia.voices.clone({
57
+ mode: "clip",
58
+ clip: myFile, // Pass a File object or a Blob.
59
+ });
60
+
61
+ // Mix voices together.
62
+ const mixedVoiceEmbedding = await cartesia.voices.mix({
63
+ voices: [{ id: "<voice-id-1>", weight: 0.6 }, { id: "<voice-id-2>", weight: 0.4 }],
64
+ });
65
+
55
66
  // Create a voice.
56
67
  const newVoice = await cartesia.voices.create({
57
68
  name: "Tim",
@@ -59,12 +70,6 @@ const newVoice = await cartesia.voices.create({
59
70
  embedding: Array(192).fill(1.0),
60
71
  });
61
72
  console.log(newVoice);
62
-
63
- // Clone a voice from a file.
64
- const clonedVoice = await cartesia.voices.clone({
65
- mode: "clip",
66
- clip: myFile, // Pass a File object or a Blob.
67
- });
68
73
  ```
69
74
 
70
75
  ### TTS over WebSocket
@@ -169,6 +169,7 @@ var WebSocket = class extends Client {
169
169
  url.searchParams.set("cartesia_version", CARTESIA_VERSION);
170
170
  return url.toString();
171
171
  }));
172
+ this.socket.binaryType = "arraybuffer";
172
173
  this.socket.onopen = () => {
173
174
  __privateSet(this, _isConnected, true);
174
175
  emitter.emit("open");
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  WebSocket
3
- } from "./chunk-IZBPLCGW.js";
3
+ } from "./chunk-EUW2435M.js";
4
4
  import {
5
5
  Client
6
6
  } from "./chunk-PISCPZK4.js";
@@ -54,6 +54,16 @@ var Voices = class extends Client {
54
54
  throw new Error("Invalid mode for clone()");
55
55
  });
56
56
  }
57
+ mix(options) {
58
+ return __async(this, null, function* () {
59
+ const request = options;
60
+ const response = yield this._fetch("/voices/mix", {
61
+ method: "POST",
62
+ body: JSON.stringify(request)
63
+ });
64
+ return response.json();
65
+ });
66
+ }
57
67
  };
58
68
 
59
69
  export {
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  Voices
3
- } from "./chunk-UCYL2SOX.js";
3
+ } from "./chunk-YFN6TFR4.js";
4
4
  import {
5
5
  TTS
6
- } from "./chunk-EDAAHENY.js";
6
+ } from "./chunk-NWCW6C7H.js";
7
7
  import {
8
8
  Client
9
9
  } from "./chunk-PISCPZK4.js";
package/dist/index.cjs CHANGED
@@ -510,6 +510,7 @@ var WebSocket = class extends Client {
510
510
  url.searchParams.set("cartesia_version", CARTESIA_VERSION);
511
511
  return url.toString();
512
512
  }));
513
+ this.socket.binaryType = "arraybuffer";
513
514
  this.socket.onopen = () => {
514
515
  __privateSet(this, _isConnected, true);
515
516
  emitter.emit("open");
@@ -639,6 +640,16 @@ var Voices = class extends Client {
639
640
  throw new Error("Invalid mode for clone()");
640
641
  });
641
642
  }
643
+ mix(options) {
644
+ return __async(this, null, function* () {
645
+ const request = options;
646
+ const response = yield this._fetch("/voices/mix", {
647
+ method: "POST",
648
+ body: JSON.stringify(request)
649
+ });
650
+ return response.json();
651
+ });
652
+ }
642
653
  };
643
654
 
644
655
  // src/lib/index.ts
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { Cartesia, Cartesia as default } from './lib/index.cjs';
2
- export { Chunk, ClientOptions, CloneOptions, CloneResponse, ConnectionEventData, CreateVoice, EmitteryCallbacks, Emotion, EmotionControl, Encoding, Intensity, Sentinel, SourceEventData, StreamOptions, StreamRequest, TypedArray, UpdateVoice, Voice, VoiceOptions, VoiceSpecifier, WebSocketBaseResponse, WebSocketChunkResponse, WebSocketErrorResponse, WebSocketOptions, WebSocketResponse, WebSocketTimestampsResponse, WordTimestamps } from './types/index.cjs';
2
+ export { Chunk, ClientOptions, CloneOptions, CloneResponse, ConnectionEventData, CreateVoice, EmitteryCallbacks, Emotion, EmotionControl, Encoding, Intensity, MixVoicesOptions, MixVoicesResponse, Sentinel, SourceEventData, StreamOptions, StreamRequest, TypedArray, UpdateVoice, Voice, VoiceOptions, VoiceSpecifier, VoiceToMix, WebSocketBaseResponse, WebSocketChunkResponse, WebSocketErrorResponse, WebSocketOptions, WebSocketResponse, WebSocketTimestampsResponse, WordTimestamps } from './types/index.cjs';
3
3
  export { default as WebPlayer } from './tts/player.cjs';
4
4
  export { default as Source } from './tts/source.cjs';
5
5
  export { default as WebSocket } from './tts/websocket.cjs';
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { Cartesia, Cartesia as default } from './lib/index.js';
2
- export { Chunk, ClientOptions, CloneOptions, CloneResponse, ConnectionEventData, CreateVoice, EmitteryCallbacks, Emotion, EmotionControl, Encoding, Intensity, Sentinel, SourceEventData, StreamOptions, StreamRequest, TypedArray, UpdateVoice, Voice, VoiceOptions, VoiceSpecifier, WebSocketBaseResponse, WebSocketChunkResponse, WebSocketErrorResponse, WebSocketOptions, WebSocketResponse, WebSocketTimestampsResponse, WordTimestamps } from './types/index.js';
2
+ export { Chunk, ClientOptions, CloneOptions, CloneResponse, ConnectionEventData, CreateVoice, EmitteryCallbacks, Emotion, EmotionControl, Encoding, Intensity, MixVoicesOptions, MixVoicesResponse, Sentinel, SourceEventData, StreamOptions, StreamRequest, TypedArray, UpdateVoice, Voice, VoiceOptions, VoiceSpecifier, VoiceToMix, WebSocketBaseResponse, WebSocketChunkResponse, WebSocketErrorResponse, WebSocketOptions, WebSocketResponse, WebSocketTimestampsResponse, WordTimestamps } from './types/index.js';
3
3
  export { default as WebPlayer } from './tts/player.js';
4
4
  export { default as Source } from './tts/source.js';
5
5
  export { default as WebSocket } from './tts/websocket.js';
package/dist/index.js CHANGED
@@ -1,12 +1,12 @@
1
1
  import "./chunk-FXPGR372.js";
2
2
  import {
3
3
  Cartesia
4
- } from "./chunk-NVOCUUOF.js";
5
- import "./chunk-UCYL2SOX.js";
6
- import "./chunk-EDAAHENY.js";
4
+ } from "./chunk-ZF6HASZT.js";
5
+ import "./chunk-YFN6TFR4.js";
6
+ import "./chunk-NWCW6C7H.js";
7
7
  import {
8
8
  WebSocket
9
- } from "./chunk-IZBPLCGW.js";
9
+ } from "./chunk-EUW2435M.js";
10
10
  import "./chunk-PISCPZK4.js";
11
11
  import "./chunk-2BFEKY3F.js";
12
12
  import {
@@ -493,6 +493,7 @@ var WebSocket = class extends Client {
493
493
  url.searchParams.set("cartesia_version", CARTESIA_VERSION);
494
494
  return url.toString();
495
495
  }));
496
+ this.socket.binaryType = "arraybuffer";
496
497
  this.socket.onopen = () => {
497
498
  __privateSet(this, _isConnected, true);
498
499
  emitter.emit("open");
@@ -622,6 +623,16 @@ var Voices = class extends Client {
622
623
  throw new Error("Invalid mode for clone()");
623
624
  });
624
625
  }
626
+ mix(options) {
627
+ return __async(this, null, function* () {
628
+ const request = options;
629
+ const response = yield this._fetch("/voices/mix", {
630
+ method: "POST",
631
+ body: JSON.stringify(request)
632
+ });
633
+ return response.json();
634
+ });
635
+ }
625
636
  };
626
637
 
627
638
  // src/lib/index.ts
package/dist/lib/index.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  Cartesia
3
- } from "../chunk-NVOCUUOF.js";
4
- import "../chunk-UCYL2SOX.js";
5
- import "../chunk-EDAAHENY.js";
6
- import "../chunk-IZBPLCGW.js";
3
+ } from "../chunk-ZF6HASZT.js";
4
+ import "../chunk-YFN6TFR4.js";
5
+ import "../chunk-NWCW6C7H.js";
6
+ import "../chunk-EUW2435M.js";
7
7
  import "../chunk-PISCPZK4.js";
8
8
  import "../chunk-2BFEKY3F.js";
9
9
  import "../chunk-BHY7MNGT.js";
@@ -507,6 +507,7 @@ var WebSocket = class extends Client {
507
507
  url.searchParams.set("cartesia_version", CARTESIA_VERSION);
508
508
  return url.toString();
509
509
  }));
510
+ this.socket.binaryType = "arraybuffer";
510
511
  this.socket.onopen = () => {
511
512
  __privateSet(this, _isConnected, true);
512
513
  emitter.emit("open");
@@ -636,6 +637,16 @@ var Voices = class extends Client {
636
637
  throw new Error("Invalid mode for clone()");
637
638
  });
638
639
  }
640
+ mix(options) {
641
+ return __async(this, null, function* () {
642
+ const request = options;
643
+ const response = yield this._fetch("/voices/mix", {
644
+ method: "POST",
645
+ body: JSON.stringify(request)
646
+ });
647
+ return response.json();
648
+ });
649
+ }
639
650
  };
640
651
 
641
652
  // src/lib/index.ts
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  Cartesia
3
- } from "../chunk-NVOCUUOF.js";
4
- import "../chunk-UCYL2SOX.js";
3
+ } from "../chunk-ZF6HASZT.js";
4
+ import "../chunk-YFN6TFR4.js";
5
5
  import {
6
6
  pingServer
7
7
  } from "../chunk-NQVZNVOU.js";
8
- import "../chunk-EDAAHENY.js";
9
- import "../chunk-IZBPLCGW.js";
8
+ import "../chunk-NWCW6C7H.js";
9
+ import "../chunk-EUW2435M.js";
10
10
  import "../chunk-PISCPZK4.js";
11
11
  import "../chunk-2BFEKY3F.js";
12
12
  import {
@@ -493,6 +493,7 @@ var WebSocket = class extends Client {
493
493
  url.searchParams.set("cartesia_version", CARTESIA_VERSION);
494
494
  return url.toString();
495
495
  }));
496
+ this.socket.binaryType = "arraybuffer";
496
497
  this.socket.onopen = () => {
497
498
  __privateSet(this, _isConnected, true);
498
499
  emitter.emit("open");
package/dist/tts/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  TTS
3
- } from "../chunk-EDAAHENY.js";
4
- import "../chunk-IZBPLCGW.js";
3
+ } from "../chunk-NWCW6C7H.js";
4
+ import "../chunk-EUW2435M.js";
5
5
  import "../chunk-PISCPZK4.js";
6
6
  import "../chunk-2BFEKY3F.js";
7
7
  import "../chunk-BHY7MNGT.js";
@@ -491,6 +491,7 @@ var WebSocket = class extends Client {
491
491
  url.searchParams.set("cartesia_version", CARTESIA_VERSION);
492
492
  return url.toString();
493
493
  }));
494
+ this.socket.binaryType = "arraybuffer";
494
495
  this.socket.onopen = () => {
495
496
  __privateSet(this, _isConnected, true);
496
497
  emitter.emit("open");
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  WebSocket
3
- } from "../chunk-IZBPLCGW.js";
3
+ } from "../chunk-EUW2435M.js";
4
4
  import "../chunk-PISCPZK4.js";
5
5
  import "../chunk-2BFEKY3F.js";
6
6
  import "../chunk-BHY7MNGT.js";
@@ -11,10 +11,10 @@ type ConnectionEventData = {
11
11
  close: never;
12
12
  };
13
13
  type VoiceSpecifier = {
14
- mode: "id";
14
+ mode?: "id";
15
15
  id: string;
16
16
  } | {
17
- mode: "embedding";
17
+ mode?: "embedding";
18
18
  embedding: number[];
19
19
  };
20
20
  type Emotion = "anger" | "sadness" | "positivity" | "curiosity" | "surprise";
@@ -22,7 +22,7 @@ type Intensity = "lowest" | "low" | "high" | "highest";
22
22
  type EmotionControl = Emotion | `${Emotion}:${Intensity}`;
23
23
  type VoiceOptions = VoiceSpecifier & {
24
24
  __experimental_controls?: {
25
- speed?: "slowest" | "slow" | "normal" | "fast" | "fastest";
25
+ speed?: "slowest" | "slow" | "normal" | "fast" | "fastest" | number;
26
26
  emotion?: EmotionControl[];
27
27
  };
28
28
  };
@@ -83,6 +83,14 @@ type CloneOptions = {
83
83
  clip: Blob;
84
84
  enhance?: boolean;
85
85
  };
86
+ interface VoiceToMix {
87
+ id?: string;
88
+ embedding?: number[];
89
+ weight: number;
90
+ }
91
+ interface MixVoicesOptions {
92
+ voices: VoiceToMix[];
93
+ }
86
94
  type Voice = {
87
95
  id: string;
88
96
  name: string;
@@ -98,6 +106,9 @@ type UpdateVoice = Partial<Pick<Voice, "name" | "description" | "embedding">>;
98
106
  type CloneResponse = {
99
107
  embedding: number[];
100
108
  };
109
+ type MixVoicesResponse = {
110
+ embedding: number[];
111
+ };
101
112
  type WebSocketOptions = {
102
113
  container?: string;
103
114
  encoding?: string;
@@ -112,4 +123,4 @@ type SourceEventData = {
112
123
  type TypedArray = Float32Array | Int16Array | Uint8Array;
113
124
  type Encoding = "pcm_f32le" | "pcm_s16le" | "pcm_alaw" | "pcm_mulaw";
114
125
 
115
- export type { Chunk, ClientOptions, CloneOptions, CloneResponse, ConnectionEventData, CreateVoice, EmitteryCallbacks, Emotion, EmotionControl, Encoding, Intensity, Sentinel, SourceEventData, StreamOptions, StreamRequest, TypedArray, UpdateVoice, Voice, VoiceOptions, VoiceSpecifier, WebSocketBaseResponse, WebSocketChunkResponse, WebSocketErrorResponse, WebSocketOptions, WebSocketResponse, WebSocketTimestampsResponse, WordTimestamps };
126
+ export type { Chunk, ClientOptions, CloneOptions, CloneResponse, ConnectionEventData, CreateVoice, EmitteryCallbacks, Emotion, EmotionControl, Encoding, Intensity, MixVoicesOptions, MixVoicesResponse, Sentinel, SourceEventData, StreamOptions, StreamRequest, TypedArray, UpdateVoice, Voice, VoiceOptions, VoiceSpecifier, VoiceToMix, WebSocketBaseResponse, WebSocketChunkResponse, WebSocketErrorResponse, WebSocketOptions, WebSocketResponse, WebSocketTimestampsResponse, WordTimestamps };
@@ -11,10 +11,10 @@ type ConnectionEventData = {
11
11
  close: never;
12
12
  };
13
13
  type VoiceSpecifier = {
14
- mode: "id";
14
+ mode?: "id";
15
15
  id: string;
16
16
  } | {
17
- mode: "embedding";
17
+ mode?: "embedding";
18
18
  embedding: number[];
19
19
  };
20
20
  type Emotion = "anger" | "sadness" | "positivity" | "curiosity" | "surprise";
@@ -22,7 +22,7 @@ type Intensity = "lowest" | "low" | "high" | "highest";
22
22
  type EmotionControl = Emotion | `${Emotion}:${Intensity}`;
23
23
  type VoiceOptions = VoiceSpecifier & {
24
24
  __experimental_controls?: {
25
- speed?: "slowest" | "slow" | "normal" | "fast" | "fastest";
25
+ speed?: "slowest" | "slow" | "normal" | "fast" | "fastest" | number;
26
26
  emotion?: EmotionControl[];
27
27
  };
28
28
  };
@@ -83,6 +83,14 @@ type CloneOptions = {
83
83
  clip: Blob;
84
84
  enhance?: boolean;
85
85
  };
86
+ interface VoiceToMix {
87
+ id?: string;
88
+ embedding?: number[];
89
+ weight: number;
90
+ }
91
+ interface MixVoicesOptions {
92
+ voices: VoiceToMix[];
93
+ }
86
94
  type Voice = {
87
95
  id: string;
88
96
  name: string;
@@ -98,6 +106,9 @@ type UpdateVoice = Partial<Pick<Voice, "name" | "description" | "embedding">>;
98
106
  type CloneResponse = {
99
107
  embedding: number[];
100
108
  };
109
+ type MixVoicesResponse = {
110
+ embedding: number[];
111
+ };
101
112
  type WebSocketOptions = {
102
113
  container?: string;
103
114
  encoding?: string;
@@ -112,4 +123,4 @@ type SourceEventData = {
112
123
  type TypedArray = Float32Array | Int16Array | Uint8Array;
113
124
  type Encoding = "pcm_f32le" | "pcm_s16le" | "pcm_alaw" | "pcm_mulaw";
114
125
 
115
- export type { Chunk, ClientOptions, CloneOptions, CloneResponse, ConnectionEventData, CreateVoice, EmitteryCallbacks, Emotion, EmotionControl, Encoding, Intensity, Sentinel, SourceEventData, StreamOptions, StreamRequest, TypedArray, UpdateVoice, Voice, VoiceOptions, VoiceSpecifier, WebSocketBaseResponse, WebSocketChunkResponse, WebSocketErrorResponse, WebSocketOptions, WebSocketResponse, WebSocketTimestampsResponse, WordTimestamps };
126
+ export type { Chunk, ClientOptions, CloneOptions, CloneResponse, ConnectionEventData, CreateVoice, EmitteryCallbacks, Emotion, EmotionControl, Encoding, Intensity, MixVoicesOptions, MixVoicesResponse, Sentinel, SourceEventData, StreamOptions, StreamRequest, TypedArray, UpdateVoice, Voice, VoiceOptions, VoiceSpecifier, VoiceToMix, WebSocketBaseResponse, WebSocketChunkResponse, WebSocketErrorResponse, WebSocketOptions, WebSocketResponse, WebSocketTimestampsResponse, WordTimestamps };
@@ -159,4 +159,14 @@ var Voices = class extends Client {
159
159
  throw new Error("Invalid mode for clone()");
160
160
  });
161
161
  }
162
+ mix(options) {
163
+ return __async(this, null, function* () {
164
+ const request = options;
165
+ const response = yield this._fetch("/voices/mix", {
166
+ method: "POST",
167
+ body: JSON.stringify(request)
168
+ });
169
+ return response.json();
170
+ });
171
+ }
162
172
  };
@@ -1,5 +1,5 @@
1
1
  import { Client } from '../lib/client.cjs';
2
- import { Voice, CreateVoice, UpdateVoice, CloneOptions, CloneResponse } from '../types/index.cjs';
2
+ import { Voice, CreateVoice, UpdateVoice, CloneOptions, CloneResponse, MixVoicesOptions, MixVoicesResponse } from '../types/index.cjs';
3
3
  import 'emittery';
4
4
 
5
5
  declare class Voices extends Client {
@@ -8,6 +8,7 @@ declare class Voices extends Client {
8
8
  create(voice: CreateVoice): Promise<Voice>;
9
9
  update(id: string, voice: UpdateVoice): Promise<Voice>;
10
10
  clone(options: CloneOptions): Promise<CloneResponse>;
11
+ mix(options: MixVoicesOptions): Promise<MixVoicesResponse>;
11
12
  }
12
13
 
13
14
  export { Voices as default };
@@ -1,5 +1,5 @@
1
1
  import { Client } from '../lib/client.js';
2
- import { Voice, CreateVoice, UpdateVoice, CloneOptions, CloneResponse } from '../types/index.js';
2
+ import { Voice, CreateVoice, UpdateVoice, CloneOptions, CloneResponse, MixVoicesOptions, MixVoicesResponse } from '../types/index.js';
3
3
  import 'emittery';
4
4
 
5
5
  declare class Voices extends Client {
@@ -8,6 +8,7 @@ declare class Voices extends Client {
8
8
  create(voice: CreateVoice): Promise<Voice>;
9
9
  update(id: string, voice: UpdateVoice): Promise<Voice>;
10
10
  clone(options: CloneOptions): Promise<CloneResponse>;
11
+ mix(options: MixVoicesOptions): Promise<MixVoicesResponse>;
11
12
  }
12
13
 
13
14
  export { Voices as default };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  Voices
3
- } from "../chunk-UCYL2SOX.js";
3
+ } from "../chunk-YFN6TFR4.js";
4
4
  import "../chunk-PISCPZK4.js";
5
5
  import "../chunk-2BFEKY3F.js";
6
6
  import "../chunk-GHY2WEOK.js";
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "name": "Cartesia",
5
5
  "url": "https://cartesia.ai"
6
6
  },
7
- "version": "1.0.2",
7
+ "version": "1.0.3",
8
8
  "description": "Client for the Cartesia API.",
9
9
  "type": "module",
10
10
  "module": "./dist/index.js",
@@ -182,6 +182,8 @@ export default class WebSocket extends Client {
182
182
  url.searchParams.set("cartesia_version", CARTESIA_VERSION);
183
183
  return url.toString();
184
184
  });
185
+ this.socket.binaryType = "arraybuffer";
186
+
185
187
  this.socket.onopen = () => {
186
188
  this.#isConnected = true;
187
189
  emitter.emit("open");
@@ -16,11 +16,11 @@ export type ConnectionEventData = {
16
16
 
17
17
  export type VoiceSpecifier =
18
18
  | {
19
- mode: "id";
19
+ mode?: "id";
20
20
  id: string;
21
21
  }
22
22
  | {
23
- mode: "embedding";
23
+ mode?: "embedding";
24
24
  embedding: number[];
25
25
  };
26
26
 
@@ -35,7 +35,7 @@ export type EmotionControl = Emotion | `${Emotion}:${Intensity}`;
35
35
 
36
36
  export type VoiceOptions = VoiceSpecifier & {
37
37
  __experimental_controls?: {
38
- speed?: "slowest" | "slow" | "normal" | "fast" | "fastest";
38
+ speed?: "slowest" | "slow" | "normal" | "fast" | "fastest" | number;
39
39
  emotion?: EmotionControl[];
40
40
  };
41
41
  };
@@ -112,6 +112,16 @@ export type CloneOptions =
112
112
  enhance?: boolean;
113
113
  };
114
114
 
115
+ export interface VoiceToMix {
116
+ id?: string;
117
+ embedding?: number[];
118
+ weight: number;
119
+ }
120
+
121
+ export interface MixVoicesOptions {
122
+ voices: VoiceToMix[];
123
+ }
124
+
115
125
  export type Voice = {
116
126
  id: string;
117
127
  name: string;
@@ -134,6 +144,10 @@ export type CloneResponse = {
134
144
  embedding: number[];
135
145
  };
136
146
 
147
+ export type MixVoicesResponse = {
148
+ embedding: number[];
149
+ };
150
+
137
151
  export type WebSocketOptions = {
138
152
  container?: string;
139
153
  encoding?: string;
@@ -3,6 +3,8 @@ import type {
3
3
  CloneOptions,
4
4
  CloneResponse,
5
5
  CreateVoice,
6
+ MixVoicesOptions,
7
+ MixVoicesResponse,
6
8
  UpdateVoice,
7
9
  Voice,
8
10
  } from "../types";
@@ -51,4 +53,15 @@ export default class Voices extends Client {
51
53
 
52
54
  throw new Error("Invalid mode for clone()");
53
55
  }
56
+
57
+ async mix(options: MixVoicesOptions): Promise<MixVoicesResponse> {
58
+ const request: MixVoicesOptions = options;
59
+
60
+ const response = await this._fetch("/voices/mix", {
61
+ method: "POST",
62
+ body: JSON.stringify(request),
63
+ });
64
+
65
+ return response.json() as Promise<MixVoicesResponse>;
66
+ }
54
67
  }