@cartesia/cartesia-js 1.0.2 → 1.1.0

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 (48) hide show
  1. package/.turbo/turbo-build.log +41 -41
  2. package/CHANGELOG.md +12 -0
  3. package/README.md +43 -9
  4. package/dist/{chunk-NQVZNVOU.js → chunk-3FL2SNIR.js} +1 -1
  5. package/dist/{chunk-NVOCUUOF.js → chunk-4GEDAGVY.js} +3 -3
  6. package/dist/{chunk-PISCPZK4.js → chunk-6PWLZAMS.js} +1 -1
  7. package/dist/{chunk-UCYL2SOX.js → chunk-CWIJUBG6.js} +20 -2
  8. package/dist/{chunk-IZBPLCGW.js → chunk-L3OMQKWL.js} +35 -10
  9. package/dist/{chunk-LZO6K34D.js → chunk-MNOPO7G6.js} +2 -2
  10. package/dist/{chunk-EDAAHENY.js → chunk-MUPVAEL7.js} +2 -2
  11. package/dist/{chunk-BHY7MNGT.js → chunk-VCZESWYA.js} +1 -1
  12. package/dist/{chunk-6YQ6KDIQ.js → chunk-VVDJR3OA.js} +32 -1
  13. package/dist/{chunk-GHY2WEOK.js → chunk-WIFMLPT5.js} +0 -13
  14. package/dist/index.cjs +80 -17
  15. package/dist/index.d.cts +1 -1
  16. package/dist/index.d.ts +1 -1
  17. package/dist/index.js +9 -9
  18. package/dist/lib/client.js +2 -2
  19. package/dist/lib/constants.js +1 -1
  20. package/dist/lib/index.cjs +80 -17
  21. package/dist/lib/index.js +8 -8
  22. package/dist/react/index.cjs +83 -17
  23. package/dist/react/index.js +13 -10
  24. package/dist/react/utils.js +2 -2
  25. package/dist/tts/index.cjs +62 -17
  26. package/dist/tts/index.js +6 -6
  27. package/dist/tts/player.js +4 -4
  28. package/dist/tts/source.cjs +31 -0
  29. package/dist/tts/source.d.cts +9 -0
  30. package/dist/tts/source.d.ts +9 -0
  31. package/dist/tts/source.js +2 -2
  32. package/dist/tts/utils.js +3 -3
  33. package/dist/tts/websocket.cjs +62 -17
  34. package/dist/tts/websocket.d.cts +9 -3
  35. package/dist/tts/websocket.d.ts +9 -3
  36. package/dist/tts/websocket.js +5 -5
  37. package/dist/types/index.d.cts +32 -6
  38. package/dist/types/index.d.ts +32 -6
  39. package/dist/voices/index.cjs +18 -0
  40. package/dist/voices/index.d.cts +3 -1
  41. package/dist/voices/index.d.ts +3 -1
  42. package/dist/voices/index.js +3 -3
  43. package/package.json +1 -1
  44. package/src/react/index.ts +4 -0
  45. package/src/tts/source.ts +35 -0
  46. package/src/tts/websocket.ts +35 -2
  47. package/src/types/index.ts +46 -5
  48. package/src/voices/index.ts +22 -0
@@ -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
  };
@@ -52,10 +52,24 @@ export type StreamRequest = {
52
52
  context_id?: string;
53
53
  continue?: boolean;
54
54
  duration?: number;
55
- language?: string;
55
+ language?: Language;
56
56
  add_timestamps?: boolean;
57
57
  };
58
58
 
59
+ export type ContinueRequest = StreamRequest & {
60
+ context_id: string;
61
+ };
62
+
63
+ export type Language =
64
+ | "en"
65
+ | "es"
66
+ | "fr"
67
+ | "de"
68
+ | "ja"
69
+ | "zh"
70
+ | "pt"
71
+ | (string & {});
72
+
59
73
  export type StreamOptions = {
60
74
  timeout?: number;
61
75
  };
@@ -112,6 +126,25 @@ export type CloneOptions =
112
126
  enhance?: boolean;
113
127
  };
114
128
 
129
+ export type LocalizeOptions = {
130
+ mode: "embedding";
131
+ embedding: number[];
132
+ } & {
133
+ language: Language;
134
+ dialect: string & {};
135
+ original_speaker_gender: "male" | "female" | (string & {});
136
+ };
137
+
138
+ export interface VoiceToMix {
139
+ id?: string;
140
+ embedding?: number[];
141
+ weight: number;
142
+ }
143
+
144
+ export interface MixVoicesOptions {
145
+ voices: VoiceToMix[];
146
+ }
147
+
115
148
  export type Voice = {
116
149
  id: string;
117
150
  name: string;
@@ -120,7 +153,7 @@ export type Voice = {
120
153
  is_public: boolean;
121
154
  user_id: string;
122
155
  created_at: string;
123
- language: string;
156
+ language: Language;
124
157
  };
125
158
 
126
159
  export type CreateVoice = Pick<Voice, "name" | "description" | "embedding"> &
@@ -134,6 +167,14 @@ export type CloneResponse = {
134
167
  embedding: number[];
135
168
  };
136
169
 
170
+ export type LocalizeResponse = {
171
+ embedding: number[];
172
+ };
173
+
174
+ export type MixVoicesResponse = {
175
+ embedding: number[];
176
+ };
177
+
137
178
  export type WebSocketOptions = {
138
179
  container?: string;
139
180
  encoding?: string;
@@ -3,6 +3,10 @@ import type {
3
3
  CloneOptions,
4
4
  CloneResponse,
5
5
  CreateVoice,
6
+ LocalizeOptions,
7
+ LocalizeResponse,
8
+ MixVoicesOptions,
9
+ MixVoicesResponse,
6
10
  UpdateVoice,
7
11
  Voice,
8
12
  } from "../types";
@@ -51,4 +55,22 @@ export default class Voices extends Client {
51
55
 
52
56
  throw new Error("Invalid mode for clone()");
53
57
  }
58
+
59
+ async mix(options: MixVoicesOptions): Promise<MixVoicesResponse> {
60
+ const response = await this._fetch("/voices/mix", {
61
+ method: "POST",
62
+ body: JSON.stringify(options),
63
+ });
64
+
65
+ return response.json() as Promise<MixVoicesResponse>;
66
+ }
67
+
68
+ async localize(options: LocalizeOptions): Promise<LocalizeResponse> {
69
+ const response = await this._fetch("/voices/localize", {
70
+ method: "POST",
71
+ body: JSON.stringify(options),
72
+ });
73
+
74
+ return response.json() as Promise<LocalizeResponse>;
75
+ }
54
76
  }