@cartesia/cartesia-js 2.1.5 → 2.1.6

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 (30) hide show
  1. package/api/resources/apiStatus/client/Client.js +1 -1
  2. package/api/resources/datasets/client/Client.d.ts +2 -5
  3. package/api/resources/datasets/client/Client.js +6 -9
  4. package/api/resources/datasets/client/requests/UploadDatasetFileRequest.d.ts +0 -4
  5. package/api/resources/infill/client/Client.d.ts +9 -1
  6. package/api/resources/infill/client/Client.js +10 -2
  7. package/api/resources/voices/client/Client.d.ts +44 -38
  8. package/api/resources/voices/client/Client.js +77 -71
  9. package/api/resources/voices/types/BaseVoiceId.d.ts +1 -1
  10. package/api/resources/voices/types/CreateVoiceRequest.d.ts +1 -0
  11. package/dist/api/resources/apiStatus/client/Client.js +1 -1
  12. package/dist/api/resources/datasets/client/Client.d.ts +2 -5
  13. package/dist/api/resources/datasets/client/Client.js +6 -9
  14. package/dist/api/resources/datasets/client/requests/UploadDatasetFileRequest.d.ts +0 -4
  15. package/dist/api/resources/infill/client/Client.d.ts +9 -1
  16. package/dist/api/resources/infill/client/Client.js +10 -2
  17. package/dist/api/resources/voices/client/Client.d.ts +44 -38
  18. package/dist/api/resources/voices/client/Client.js +77 -71
  19. package/dist/api/resources/voices/types/BaseVoiceId.d.ts +1 -1
  20. package/dist/api/resources/voices/types/CreateVoiceRequest.d.ts +1 -0
  21. package/dist/serialization/resources/voices/types/CreateVoiceRequest.d.ts +2 -0
  22. package/dist/serialization/resources/voices/types/CreateVoiceRequest.js +2 -0
  23. package/dist/version.d.ts +1 -1
  24. package/dist/version.js +1 -1
  25. package/package.json +1 -1
  26. package/reference.md +69 -119
  27. package/serialization/resources/voices/types/CreateVoiceRequest.d.ts +2 -0
  28. package/serialization/resources/voices/types/CreateVoiceRequest.js +2 -0
  29. package/version.d.ts +1 -1
  30. package/version.js +1 -1
@@ -40,24 +40,42 @@ export declare class Voices {
40
40
  */
41
41
  list(requestOptions?: Voices.RequestOptions): Promise<Cartesia.Voice[]>;
42
42
  /**
43
- * @param {Cartesia.CreateVoiceRequest} request
43
+ * Clone a voice from an audio clip. This endpoint has two modes, stability and similarity.
44
+ *
45
+ * Similarity mode clones are more similar to the source clip, but may reproduce background noise. For these, use an audio clip about 5 seconds long.
46
+ *
47
+ * Stability mode clones are more stable, but may not sound as similar to the source clip. For these, use an audio clip 10-20 seconds long.
48
+ *
49
+ * @param {File | fs.ReadStream | Blob} clip
50
+ * @param {Cartesia.CloneVoiceRequest} request
44
51
  * @param {Voices.RequestOptions} requestOptions - Request-specific configuration.
45
52
  *
46
53
  * @example
47
- * await client.voices.create({
48
- * name: "string",
49
- * description: "string",
50
- * embedding: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
51
- * language: "en"
54
+ * await client.voices.clone(fs.createReadStream("/path/to/your/file"), {
55
+ * name: "A high-stability cloned voice",
56
+ * description: "Copied from Cartesia docs",
57
+ * mode: "stability",
58
+ * language: "en",
59
+ * enhance: true
60
+ * })
61
+ *
62
+ * @example
63
+ * await client.voices.clone(fs.createReadStream("/path/to/your/file"), {
64
+ * name: "A high-similarity cloned voice",
65
+ * description: "Copied from Cartesia docs",
66
+ * mode: "similarity",
67
+ * language: "en",
68
+ * transcript: "A transcript of the words spoken in the audio clip.",
69
+ * enhance: false
52
70
  * })
53
71
  */
54
- create(request: Cartesia.CreateVoiceRequest, requestOptions?: Voices.RequestOptions): Promise<Cartesia.Voice>;
72
+ clone(clip: File | fs.ReadStream | Blob, request: Cartesia.CloneVoiceRequest, requestOptions?: Voices.RequestOptions): Promise<Cartesia.VoiceMetadata>;
55
73
  /**
56
74
  * @param {Cartesia.VoiceId} id
57
75
  * @param {Voices.RequestOptions} requestOptions - Request-specific configuration.
58
76
  *
59
77
  * @example
60
- * await client.voices.delete("string")
78
+ * await client.voices.delete("id")
61
79
  */
62
80
  delete(id: Cartesia.VoiceId, requestOptions?: Voices.RequestOptions): Promise<void>;
63
81
  /**
@@ -66,9 +84,9 @@ export declare class Voices {
66
84
  * @param {Voices.RequestOptions} requestOptions - Request-specific configuration.
67
85
  *
68
86
  * @example
69
- * await client.voices.update("string", {
70
- * name: "string",
71
- * description: "string"
87
+ * await client.voices.update("id", {
88
+ * name: "name",
89
+ * description: "description"
72
90
  * })
73
91
  */
74
92
  update(id: Cartesia.VoiceId, request: Cartesia.UpdateVoiceRequest, requestOptions?: Voices.RequestOptions): Promise<Cartesia.Voice>;
@@ -77,7 +95,7 @@ export declare class Voices {
77
95
  * @param {Voices.RequestOptions} requestOptions - Request-specific configuration.
78
96
  *
79
97
  * @example
80
- * await client.voices.get("string")
98
+ * await client.voices.get("id")
81
99
  */
82
100
  get(id: Cartesia.VoiceId, requestOptions?: Voices.RequestOptions): Promise<Cartesia.Voice>;
83
101
  /**
@@ -86,10 +104,10 @@ export declare class Voices {
86
104
  *
87
105
  * @example
88
106
  * await client.voices.localize({
89
- * embedding: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
107
+ * embedding: [1.1, 1.1],
90
108
  * language: "en",
91
109
  * originalSpeakerGender: "male",
92
- * dialect: "au"
110
+ * dialect: undefined
93
111
  * })
94
112
  */
95
113
  localize(request: Cartesia.LocalizeVoiceRequest, requestOptions?: Voices.RequestOptions): Promise<Cartesia.EmbeddingResponse>;
@@ -100,43 +118,31 @@ export declare class Voices {
100
118
  * @example
101
119
  * await client.voices.mix({
102
120
  * voices: [{
103
- * id: "string",
121
+ * id: "id",
122
+ * weight: 1.1
123
+ * }, {
124
+ * id: "id",
104
125
  * weight: 1.1
105
126
  * }]
106
127
  * })
107
128
  */
108
129
  mix(request: Cartesia.MixVoicesRequest, requestOptions?: Voices.RequestOptions): Promise<Cartesia.EmbeddingResponse>;
109
130
  /**
110
- * Clone a voice from an audio clip. This endpoint has two modes, stability and similarity.
111
- *
112
- * Similarity mode clones are more similar to the source clip, but may reproduce background noise. For these, use an audio clip about 5 seconds long.
131
+ * Create voice from raw features. If you'd like to clone a voice from an audio file, please use Clone Voice instead.
113
132
  *
114
- * Stability mode clones are more stable, but may not sound as similar to the source clip. For these, use an audio clip 10-20 seconds long.
115
- *
116
- * @param {File | fs.ReadStream | Blob} clip
117
- * @param {Cartesia.CloneVoiceRequest} request
133
+ * @param {Cartesia.CreateVoiceRequest} request
118
134
  * @param {Voices.RequestOptions} requestOptions - Request-specific configuration.
119
135
  *
120
136
  * @example
121
- * await client.voices.clone(fs.createReadStream("/path/to/your/file"), {
122
- * name: "A high-stability cloned voice",
123
- * description: "Copied from Cartesia docs",
124
- * mode: "stability",
125
- * language: "en",
126
- * enhance: true
127
- * })
128
- *
129
- * @example
130
- * await client.voices.clone(fs.createReadStream("/path/to/your/file"), {
131
- * name: "A high-similarity cloned voice",
132
- * description: "Copied from Cartesia docs",
133
- * mode: "similarity",
137
+ * await client.voices.create({
138
+ * name: "My Custom Voice",
139
+ * description: "A custom voice created through the API",
140
+ * embedding: [],
134
141
  * language: "en",
135
- * transcript: "A transcript of the words spoken in the audio clip.",
136
- * enhance: false
142
+ * baseVoiceId: "123e4567-e89b-12d3-a456-426614174000"
137
143
  * })
138
144
  */
139
- clone(clip: File | fs.ReadStream | Blob, request: Cartesia.CloneVoiceRequest, requestOptions?: Voices.RequestOptions): Promise<Cartesia.VoiceMetadata>;
145
+ create(request: Cartesia.CreateVoiceRequest, requestOptions?: Voices.RequestOptions): Promise<Cartesia.Voice>;
140
146
  protected _getCustomAuthorizationHeaders(): Promise<{
141
147
  "X-API-Key": string | undefined;
142
148
  }>;
@@ -70,7 +70,7 @@ class Voices {
70
70
  const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
71
71
  url: (0, url_join_1.default)((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.CartesiaEnvironment.Production, "/voices/"),
72
72
  method: "GET",
73
- headers: Object.assign(Object.assign({ "Cartesia-Version": (_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.cartesiaVersion) !== null && _f !== void 0 ? _f : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.1.5", "User-Agent": "@cartesia/cartesia-js/2.1.5", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
73
+ headers: Object.assign(Object.assign({ "Cartesia-Version": (_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.cartesiaVersion) !== null && _f !== void 0 ? _f : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.1.6", "User-Agent": "@cartesia/cartesia-js/2.1.6", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
74
74
  contentType: "application/json",
75
75
  requestType: "json",
76
76
  timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
@@ -108,33 +108,64 @@ class Voices {
108
108
  });
109
109
  }
110
110
  /**
111
- * @param {Cartesia.CreateVoiceRequest} request
111
+ * Clone a voice from an audio clip. This endpoint has two modes, stability and similarity.
112
+ *
113
+ * Similarity mode clones are more similar to the source clip, but may reproduce background noise. For these, use an audio clip about 5 seconds long.
114
+ *
115
+ * Stability mode clones are more stable, but may not sound as similar to the source clip. For these, use an audio clip 10-20 seconds long.
116
+ *
117
+ * @param {File | fs.ReadStream | Blob} clip
118
+ * @param {Cartesia.CloneVoiceRequest} request
112
119
  * @param {Voices.RequestOptions} requestOptions - Request-specific configuration.
113
120
  *
114
121
  * @example
115
- * await client.voices.create({
116
- * name: "string",
117
- * description: "string",
118
- * embedding: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
119
- * language: "en"
122
+ * await client.voices.clone(fs.createReadStream("/path/to/your/file"), {
123
+ * name: "A high-stability cloned voice",
124
+ * description: "Copied from Cartesia docs",
125
+ * mode: "stability",
126
+ * language: "en",
127
+ * enhance: true
128
+ * })
129
+ *
130
+ * @example
131
+ * await client.voices.clone(fs.createReadStream("/path/to/your/file"), {
132
+ * name: "A high-similarity cloned voice",
133
+ * description: "Copied from Cartesia docs",
134
+ * mode: "similarity",
135
+ * language: "en",
136
+ * transcript: "A transcript of the words spoken in the audio clip.",
137
+ * enhance: false
120
138
  * })
121
139
  */
122
- create(request, requestOptions) {
140
+ clone(clip, request, requestOptions) {
123
141
  return __awaiter(this, void 0, void 0, function* () {
124
142
  var _a, _b, _c, _d, _e, _f;
143
+ const _request = yield core.newFormData();
144
+ yield _request.appendFile("clip", clip);
145
+ _request.append("name", request.name);
146
+ if (request.description != null) {
147
+ _request.append("description", request.description);
148
+ }
149
+ _request.append("language", serializers.SupportedLanguage.jsonOrThrow(request.language, { unrecognizedObjectKeys: "strip" }));
150
+ _request.append("mode", serializers.CloneMode.jsonOrThrow(request.mode, { unrecognizedObjectKeys: "strip" }));
151
+ _request.append("enhance", request.enhance.toString());
152
+ if (request.transcript != null) {
153
+ _request.append("transcript", request.transcript);
154
+ }
155
+ const _maybeEncodedRequest = yield _request.getRequest();
125
156
  const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
126
- url: (0, url_join_1.default)((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.CartesiaEnvironment.Production, "/voices/"),
157
+ url: (0, url_join_1.default)((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.CartesiaEnvironment.Production, "/voices/clone"),
127
158
  method: "POST",
128
- headers: Object.assign(Object.assign({ "Cartesia-Version": (_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.cartesiaVersion) !== null && _f !== void 0 ? _f : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.1.5", "User-Agent": "@cartesia/cartesia-js/2.1.5", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
129
- contentType: "application/json",
130
- requestType: "json",
131
- body: serializers.CreateVoiceRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
159
+ headers: Object.assign(Object.assign(Object.assign({ "Cartesia-Version": (_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.cartesiaVersion) !== null && _f !== void 0 ? _f : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.1.6", "User-Agent": "@cartesia/cartesia-js/2.1.6", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())), _maybeEncodedRequest.headers), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
160
+ requestType: "file",
161
+ duplex: _maybeEncodedRequest.duplex,
162
+ body: _maybeEncodedRequest.body,
132
163
  timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
133
164
  maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
134
165
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
135
166
  });
136
167
  if (_response.ok) {
137
- return serializers.Voice.parseOrThrow(_response.body, {
168
+ return serializers.VoiceMetadata.parseOrThrow(_response.body, {
138
169
  unrecognizedObjectKeys: "passthrough",
139
170
  allowUnrecognizedUnionMembers: true,
140
171
  allowUnrecognizedEnumValues: true,
@@ -155,7 +186,7 @@ class Voices {
155
186
  body: _response.error.rawBody,
156
187
  });
157
188
  case "timeout":
158
- throw new errors.CartesiaTimeoutError("Timeout exceeded when calling POST /voices/.");
189
+ throw new errors.CartesiaTimeoutError("Timeout exceeded when calling POST /voices/clone.");
159
190
  case "unknown":
160
191
  throw new errors.CartesiaError({
161
192
  message: _response.error.errorMessage,
@@ -168,7 +199,7 @@ class Voices {
168
199
  * @param {Voices.RequestOptions} requestOptions - Request-specific configuration.
169
200
  *
170
201
  * @example
171
- * await client.voices.delete("string")
202
+ * await client.voices.delete("id")
172
203
  */
173
204
  delete(id, requestOptions) {
174
205
  return __awaiter(this, void 0, void 0, function* () {
@@ -176,7 +207,7 @@ class Voices {
176
207
  const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
177
208
  url: (0, url_join_1.default)((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.CartesiaEnvironment.Production, `/voices/${encodeURIComponent(serializers.VoiceId.jsonOrThrow(id))}`),
178
209
  method: "DELETE",
179
- headers: Object.assign(Object.assign({ "Cartesia-Version": (_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.cartesiaVersion) !== null && _f !== void 0 ? _f : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.1.5", "User-Agent": "@cartesia/cartesia-js/2.1.5", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
210
+ headers: Object.assign(Object.assign({ "Cartesia-Version": (_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.cartesiaVersion) !== null && _f !== void 0 ? _f : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.1.6", "User-Agent": "@cartesia/cartesia-js/2.1.6", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
180
211
  contentType: "application/json",
181
212
  requestType: "json",
182
213
  timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
@@ -213,9 +244,9 @@ class Voices {
213
244
  * @param {Voices.RequestOptions} requestOptions - Request-specific configuration.
214
245
  *
215
246
  * @example
216
- * await client.voices.update("string", {
217
- * name: "string",
218
- * description: "string"
247
+ * await client.voices.update("id", {
248
+ * name: "name",
249
+ * description: "description"
219
250
  * })
220
251
  */
221
252
  update(id, request, requestOptions) {
@@ -224,7 +255,7 @@ class Voices {
224
255
  const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
225
256
  url: (0, url_join_1.default)((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.CartesiaEnvironment.Production, `/voices/${encodeURIComponent(serializers.VoiceId.jsonOrThrow(id))}`),
226
257
  method: "PATCH",
227
- headers: Object.assign(Object.assign({ "Cartesia-Version": (_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.cartesiaVersion) !== null && _f !== void 0 ? _f : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.1.5", "User-Agent": "@cartesia/cartesia-js/2.1.5", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
258
+ headers: Object.assign(Object.assign({ "Cartesia-Version": (_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.cartesiaVersion) !== null && _f !== void 0 ? _f : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.1.6", "User-Agent": "@cartesia/cartesia-js/2.1.6", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
228
259
  contentType: "application/json",
229
260
  requestType: "json",
230
261
  body: serializers.UpdateVoiceRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
@@ -267,7 +298,7 @@ class Voices {
267
298
  * @param {Voices.RequestOptions} requestOptions - Request-specific configuration.
268
299
  *
269
300
  * @example
270
- * await client.voices.get("string")
301
+ * await client.voices.get("id")
271
302
  */
272
303
  get(id, requestOptions) {
273
304
  return __awaiter(this, void 0, void 0, function* () {
@@ -275,7 +306,7 @@ class Voices {
275
306
  const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
276
307
  url: (0, url_join_1.default)((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.CartesiaEnvironment.Production, `/voices/${encodeURIComponent(serializers.VoiceId.jsonOrThrow(id))}`),
277
308
  method: "GET",
278
- headers: Object.assign(Object.assign({ "Cartesia-Version": (_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.cartesiaVersion) !== null && _f !== void 0 ? _f : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.1.5", "User-Agent": "@cartesia/cartesia-js/2.1.5", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
309
+ headers: Object.assign(Object.assign({ "Cartesia-Version": (_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.cartesiaVersion) !== null && _f !== void 0 ? _f : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.1.6", "User-Agent": "@cartesia/cartesia-js/2.1.6", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
279
310
  contentType: "application/json",
280
311
  requestType: "json",
281
312
  timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
@@ -318,10 +349,10 @@ class Voices {
318
349
  *
319
350
  * @example
320
351
  * await client.voices.localize({
321
- * embedding: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
352
+ * embedding: [1.1, 1.1],
322
353
  * language: "en",
323
354
  * originalSpeakerGender: "male",
324
- * dialect: "au"
355
+ * dialect: undefined
325
356
  * })
326
357
  */
327
358
  localize(request, requestOptions) {
@@ -330,7 +361,7 @@ class Voices {
330
361
  const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
331
362
  url: (0, url_join_1.default)((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.CartesiaEnvironment.Production, "/voices/localize"),
332
363
  method: "POST",
333
- headers: Object.assign(Object.assign({ "Cartesia-Version": (_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.cartesiaVersion) !== null && _f !== void 0 ? _f : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.1.5", "User-Agent": "@cartesia/cartesia-js/2.1.5", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
364
+ headers: Object.assign(Object.assign({ "Cartesia-Version": (_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.cartesiaVersion) !== null && _f !== void 0 ? _f : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.1.6", "User-Agent": "@cartesia/cartesia-js/2.1.6", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
334
365
  contentType: "application/json",
335
366
  requestType: "json",
336
367
  body: serializers.LocalizeVoiceRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
@@ -375,7 +406,10 @@ class Voices {
375
406
  * @example
376
407
  * await client.voices.mix({
377
408
  * voices: [{
378
- * id: "string",
409
+ * id: "id",
410
+ * weight: 1.1
411
+ * }, {
412
+ * id: "id",
379
413
  * weight: 1.1
380
414
  * }]
381
415
  * })
@@ -386,7 +420,7 @@ class Voices {
386
420
  const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
387
421
  url: (0, url_join_1.default)((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.CartesiaEnvironment.Production, "/voices/mix"),
388
422
  method: "POST",
389
- headers: Object.assign(Object.assign({ "Cartesia-Version": (_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.cartesiaVersion) !== null && _f !== void 0 ? _f : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.1.5", "User-Agent": "@cartesia/cartesia-js/2.1.5", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
423
+ headers: Object.assign(Object.assign({ "Cartesia-Version": (_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.cartesiaVersion) !== null && _f !== void 0 ? _f : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.1.6", "User-Agent": "@cartesia/cartesia-js/2.1.6", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
390
424
  contentType: "application/json",
391
425
  requestType: "json",
392
426
  body: serializers.MixVoicesRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
@@ -425,64 +459,36 @@ class Voices {
425
459
  });
426
460
  }
427
461
  /**
428
- * Clone a voice from an audio clip. This endpoint has two modes, stability and similarity.
429
- *
430
- * Similarity mode clones are more similar to the source clip, but may reproduce background noise. For these, use an audio clip about 5 seconds long.
462
+ * Create voice from raw features. If you'd like to clone a voice from an audio file, please use Clone Voice instead.
431
463
  *
432
- * Stability mode clones are more stable, but may not sound as similar to the source clip. For these, use an audio clip 10-20 seconds long.
433
- *
434
- * @param {File | fs.ReadStream | Blob} clip
435
- * @param {Cartesia.CloneVoiceRequest} request
464
+ * @param {Cartesia.CreateVoiceRequest} request
436
465
  * @param {Voices.RequestOptions} requestOptions - Request-specific configuration.
437
466
  *
438
467
  * @example
439
- * await client.voices.clone(fs.createReadStream("/path/to/your/file"), {
440
- * name: "A high-stability cloned voice",
441
- * description: "Copied from Cartesia docs",
442
- * mode: "stability",
443
- * language: "en",
444
- * enhance: true
445
- * })
446
- *
447
- * @example
448
- * await client.voices.clone(fs.createReadStream("/path/to/your/file"), {
449
- * name: "A high-similarity cloned voice",
450
- * description: "Copied from Cartesia docs",
451
- * mode: "similarity",
468
+ * await client.voices.create({
469
+ * name: "My Custom Voice",
470
+ * description: "A custom voice created through the API",
471
+ * embedding: [],
452
472
  * language: "en",
453
- * transcript: "A transcript of the words spoken in the audio clip.",
454
- * enhance: false
473
+ * baseVoiceId: "123e4567-e89b-12d3-a456-426614174000"
455
474
  * })
456
475
  */
457
- clone(clip, request, requestOptions) {
476
+ create(request, requestOptions) {
458
477
  return __awaiter(this, void 0, void 0, function* () {
459
478
  var _a, _b, _c, _d, _e, _f;
460
- const _request = yield core.newFormData();
461
- yield _request.appendFile("clip", clip);
462
- _request.append("name", request.name);
463
- if (request.description != null) {
464
- _request.append("description", request.description);
465
- }
466
- _request.append("language", serializers.SupportedLanguage.jsonOrThrow(request.language, { unrecognizedObjectKeys: "strip" }));
467
- _request.append("mode", serializers.CloneMode.jsonOrThrow(request.mode, { unrecognizedObjectKeys: "strip" }));
468
- _request.append("enhance", request.enhance.toString());
469
- if (request.transcript != null) {
470
- _request.append("transcript", request.transcript);
471
- }
472
- const _maybeEncodedRequest = yield _request.getRequest();
473
479
  const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
474
- url: (0, url_join_1.default)((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.CartesiaEnvironment.Production, "/voices/clone"),
480
+ url: (0, url_join_1.default)((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.CartesiaEnvironment.Production, "/voices/"),
475
481
  method: "POST",
476
- headers: Object.assign(Object.assign(Object.assign({ "Cartesia-Version": (_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.cartesiaVersion) !== null && _f !== void 0 ? _f : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.1.5", "User-Agent": "@cartesia/cartesia-js/2.1.5", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())), _maybeEncodedRequest.headers), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
477
- requestType: "file",
478
- duplex: _maybeEncodedRequest.duplex,
479
- body: _maybeEncodedRequest.body,
482
+ headers: Object.assign(Object.assign({ "Cartesia-Version": (_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.cartesiaVersion) !== null && _f !== void 0 ? _f : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.1.6", "User-Agent": "@cartesia/cartesia-js/2.1.6", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
483
+ contentType: "application/json",
484
+ requestType: "json",
485
+ body: serializers.CreateVoiceRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
480
486
  timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
481
487
  maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
482
488
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
483
489
  });
484
490
  if (_response.ok) {
485
- return serializers.VoiceMetadata.parseOrThrow(_response.body, {
491
+ return serializers.Voice.parseOrThrow(_response.body, {
486
492
  unrecognizedObjectKeys: "passthrough",
487
493
  allowUnrecognizedUnionMembers: true,
488
494
  allowUnrecognizedEnumValues: true,
@@ -503,7 +509,7 @@ class Voices {
503
509
  body: _response.error.rawBody,
504
510
  });
505
511
  case "timeout":
506
- throw new errors.CartesiaTimeoutError("Timeout exceeded when calling POST /voices/clone.");
512
+ throw new errors.CartesiaTimeoutError("Timeout exceeded when calling POST /voices/.");
507
513
  case "unknown":
508
514
  throw new errors.CartesiaError({
509
515
  message: _response.error.errorMessage,
@@ -3,6 +3,6 @@
3
3
  */
4
4
  import * as Cartesia from "../../../index";
5
5
  /**
6
- * The ID of the base voice associated with the voice, used for features like voice mixing.
6
+ * Pull in features from a base voice, used for features like voice mixing.
7
7
  */
8
8
  export type BaseVoiceId = Cartesia.VoiceId;
@@ -9,4 +9,5 @@ export interface CreateVoiceRequest {
9
9
  description: string;
10
10
  embedding: Cartesia.Embedding;
11
11
  language?: Cartesia.SupportedLanguage;
12
+ baseVoiceId?: Cartesia.BaseVoiceId;
12
13
  }
@@ -6,6 +6,7 @@ import * as Cartesia from "../../../../api/index";
6
6
  import * as core from "../../../../core";
7
7
  import { Embedding } from "../../embedding/types/Embedding";
8
8
  import { SupportedLanguage } from "../../tts/types/SupportedLanguage";
9
+ import { BaseVoiceId } from "./BaseVoiceId";
9
10
  export declare const CreateVoiceRequest: core.serialization.ObjectSchema<serializers.CreateVoiceRequest.Raw, Cartesia.CreateVoiceRequest>;
10
11
  export declare namespace CreateVoiceRequest {
11
12
  interface Raw {
@@ -13,5 +14,6 @@ export declare namespace CreateVoiceRequest {
13
14
  description: string;
14
15
  embedding: Embedding.Raw;
15
16
  language?: SupportedLanguage.Raw | null;
17
+ base_voice_id?: BaseVoiceId.Raw | null;
16
18
  }
17
19
  }
@@ -40,9 +40,11 @@ exports.CreateVoiceRequest = void 0;
40
40
  const core = __importStar(require("../../../../core"));
41
41
  const Embedding_1 = require("../../embedding/types/Embedding");
42
42
  const SupportedLanguage_1 = require("../../tts/types/SupportedLanguage");
43
+ const BaseVoiceId_1 = require("./BaseVoiceId");
43
44
  exports.CreateVoiceRequest = core.serialization.object({
44
45
  name: core.serialization.string(),
45
46
  description: core.serialization.string(),
46
47
  embedding: Embedding_1.Embedding,
47
48
  language: SupportedLanguage_1.SupportedLanguage.optional(),
49
+ baseVoiceId: core.serialization.property("base_voice_id", BaseVoiceId_1.BaseVoiceId.optional()),
48
50
  });
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "2.1.5";
1
+ export declare const SDK_VERSION = "2.1.6";
package/dist/version.js CHANGED
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SDK_VERSION = void 0;
4
- exports.SDK_VERSION = "2.1.5";
4
+ exports.SDK_VERSION = "2.1.6";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cartesia/cartesia-js",
3
- "version": "2.1.5",
3
+ "version": "2.1.6",
4
4
  "private": false,
5
5
  "repository": "https://github.com/cartesia-ai/cartesia-js",
6
6
  "main": "./index.js",