@cartesia/cartesia-js 3.0.0-b5 → 3.0.0-b7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/backcompat/errors.d.mts +16 -0
- package/backcompat/errors.d.mts.map +1 -0
- package/backcompat/errors.d.ts +16 -0
- package/backcompat/errors.d.ts.map +1 -0
- package/backcompat/errors.js +46 -0
- package/backcompat/errors.js.map +1 -0
- package/backcompat/errors.mjs +40 -0
- package/backcompat/errors.mjs.map +1 -0
- package/backcompat/index.d.mts +17 -31
- package/backcompat/index.d.mts.map +1 -1
- package/backcompat/index.d.ts +17 -31
- package/backcompat/index.d.ts.map +1 -1
- package/backcompat/index.js +26 -254
- package/backcompat/index.js.map +1 -1
- package/backcompat/index.mjs +25 -253
- package/backcompat/index.mjs.map +1 -1
- package/backcompat/tts-wrapper.d.mts +69 -0
- package/backcompat/tts-wrapper.d.mts.map +1 -0
- package/backcompat/tts-wrapper.d.ts +69 -0
- package/backcompat/tts-wrapper.d.ts.map +1 -0
- package/backcompat/tts-wrapper.js +264 -0
- package/backcompat/tts-wrapper.js.map +1 -0
- package/backcompat/tts-wrapper.mjs +258 -0
- package/backcompat/tts-wrapper.mjs.map +1 -0
- package/backcompat/types.d.mts +18 -0
- package/backcompat/types.d.mts.map +1 -0
- package/backcompat/types.d.ts +18 -0
- package/backcompat/types.d.ts.map +1 -0
- package/backcompat/types.js +3 -0
- package/backcompat/types.js.map +1 -0
- package/backcompat/types.mjs +2 -0
- package/backcompat/types.mjs.map +1 -0
- package/backcompat/voice-changer-wrapper.d.mts +19 -0
- package/backcompat/voice-changer-wrapper.d.mts.map +1 -0
- package/backcompat/voice-changer-wrapper.d.ts +19 -0
- package/backcompat/voice-changer-wrapper.d.ts.map +1 -0
- package/backcompat/voice-changer-wrapper.js +49 -0
- package/backcompat/voice-changer-wrapper.js.map +1 -0
- package/backcompat/voice-changer-wrapper.mjs +45 -0
- package/backcompat/voice-changer-wrapper.mjs.map +1 -0
- package/backcompat/voices-wrapper.d.mts +36 -0
- package/backcompat/voices-wrapper.d.mts.map +1 -0
- package/backcompat/voices-wrapper.d.ts +36 -0
- package/backcompat/voices-wrapper.d.ts.map +1 -0
- package/backcompat/voices-wrapper.js +82 -0
- package/backcompat/voices-wrapper.js.map +1 -0
- package/backcompat/voices-wrapper.mjs +78 -0
- package/backcompat/voices-wrapper.mjs.map +1 -0
- package/index.d.mts +1 -1
- package/index.d.mts.map +1 -1
- package/index.d.ts +1 -1
- package/index.d.ts.map +1 -1
- package/index.js +3 -3
- package/index.js.map +1 -1
- package/index.mjs +1 -1
- package/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/backcompat/errors.ts +52 -0
- package/src/backcompat/index.ts +31 -291
- package/src/backcompat/tts-wrapper.ts +328 -0
- package/src/backcompat/types.ts +19 -0
- package/src/backcompat/voice-changer-wrapper.ts +70 -0
- package/src/backcompat/voices-wrapper.ts +163 -0
- package/src/index.ts +1 -1
- package/src/version.ts +1 -1
- package/version.d.mts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import * as fs from "fs";
|
|
2
|
+
import { Cartesia } from "../client";
|
|
3
|
+
import { type Uploadable } from "../core/uploads";
|
|
4
|
+
import { type RequestOptions as InternalRequestOptions } from "../internal/request-options";
|
|
5
|
+
import { Readable } from "stream";
|
|
6
|
+
import { BackCompatRequestOptions } from "./types";
|
|
7
|
+
import { wrap } from "./errors";
|
|
8
|
+
|
|
9
|
+
export interface BackCompatVoiceChangerBytesRequest {
|
|
10
|
+
voiceId: string;
|
|
11
|
+
outputFormatContainer: "raw" | "wav" | "mp3";
|
|
12
|
+
outputFormatSampleRate: 8000 | 16000 | 22050 | 24000 | 44100 | 48000;
|
|
13
|
+
outputFormatEncoding?: "pcm_f32le" | "pcm_s16le" | "mulaw" | "alaw";
|
|
14
|
+
outputFormatBitRate?: 32000 | 64000 | 96000 | 128000 | 192000;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** @deprecated Use the new SDK's voice changer methods on the {@link Cartesia} instance instead. */
|
|
18
|
+
export class VoiceChangerWrapper {
|
|
19
|
+
private client: Cartesia;
|
|
20
|
+
|
|
21
|
+
constructor(client: Cartesia) {
|
|
22
|
+
this.client = client;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** @deprecated Use {@link Cartesia.voiceChanger.changeVoiceBytes} instead. */
|
|
26
|
+
async bytes(
|
|
27
|
+
clip: File | fs.ReadStream | Blob,
|
|
28
|
+
request: BackCompatVoiceChangerBytesRequest,
|
|
29
|
+
requestOptions?: BackCompatRequestOptions
|
|
30
|
+
) {
|
|
31
|
+
const params: any = {
|
|
32
|
+
clip: clip as Uploadable,
|
|
33
|
+
"voice[id]": request.voiceId,
|
|
34
|
+
"output_format[container]": request.outputFormatContainer,
|
|
35
|
+
"output_format[sample_rate]": request.outputFormatSampleRate,
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
if (request.outputFormatEncoding) {
|
|
39
|
+
params["output_format[encoding]"] = request.outputFormatEncoding;
|
|
40
|
+
}
|
|
41
|
+
if (request.outputFormatBitRate) {
|
|
42
|
+
params["output_format[bit_rate]"] = request.outputFormatBitRate;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const options: InternalRequestOptions = {};
|
|
46
|
+
if (requestOptions) {
|
|
47
|
+
if (requestOptions.timeoutInSeconds) {
|
|
48
|
+
options.timeout = requestOptions.timeoutInSeconds * 1000;
|
|
49
|
+
}
|
|
50
|
+
if (requestOptions.maxRetries !== undefined) {
|
|
51
|
+
options.maxRetries = requestOptions.maxRetries;
|
|
52
|
+
}
|
|
53
|
+
options.headers = requestOptions.headers;
|
|
54
|
+
options.signal = requestOptions.abortSignal;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const response = await wrap(this.client.voiceChanger.changeVoiceBytes(params, {
|
|
58
|
+
...options,
|
|
59
|
+
__binaryResponse: true,
|
|
60
|
+
} as any));
|
|
61
|
+
|
|
62
|
+
// @ts-ignore
|
|
63
|
+
if (response.body) {
|
|
64
|
+
// @ts-ignore
|
|
65
|
+
return Readable.fromWeb(response.body);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return response;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import * as fs from "fs";
|
|
2
|
+
import { Cartesia } from "../client";
|
|
3
|
+
import { type Uploadable } from "../core/uploads";
|
|
4
|
+
import {
|
|
5
|
+
type VoiceCloneParams,
|
|
6
|
+
type VoiceMetadata,
|
|
7
|
+
type SupportedLanguage,
|
|
8
|
+
type VoiceUpdateParams,
|
|
9
|
+
type Voice,
|
|
10
|
+
type VoiceLocalizeParams,
|
|
11
|
+
} from "../resources/voices";
|
|
12
|
+
import { type RequestOptions as InternalRequestOptions } from "../internal/request-options";
|
|
13
|
+
import { BackCompatRequestOptions } from "./types";
|
|
14
|
+
import { wrap } from "./errors";
|
|
15
|
+
|
|
16
|
+
export interface BackCompatCloneVoiceRequest {
|
|
17
|
+
name: string;
|
|
18
|
+
description?: string;
|
|
19
|
+
language: string;
|
|
20
|
+
mode: "similarity" | "stability";
|
|
21
|
+
enhance?: boolean;
|
|
22
|
+
baseVoiceId?: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface BackCompatUpdateVoiceRequest {
|
|
26
|
+
name: string;
|
|
27
|
+
description: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface BackCompatLocalizeVoiceRequest {
|
|
31
|
+
voiceId: string;
|
|
32
|
+
name: string;
|
|
33
|
+
description: string;
|
|
34
|
+
language:
|
|
35
|
+
| "en"
|
|
36
|
+
| "de"
|
|
37
|
+
| "es"
|
|
38
|
+
| "fr"
|
|
39
|
+
| "ja"
|
|
40
|
+
| "pt"
|
|
41
|
+
| "zh"
|
|
42
|
+
| "hi"
|
|
43
|
+
| "it"
|
|
44
|
+
| "ko"
|
|
45
|
+
| "nl"
|
|
46
|
+
| "pl"
|
|
47
|
+
| "ru"
|
|
48
|
+
| "sv"
|
|
49
|
+
| "tr";
|
|
50
|
+
originalSpeakerGender: "male" | "female";
|
|
51
|
+
dialect?:
|
|
52
|
+
| "au"
|
|
53
|
+
| "in"
|
|
54
|
+
| "so"
|
|
55
|
+
| "uk"
|
|
56
|
+
| "us"
|
|
57
|
+
| "mx"
|
|
58
|
+
| "pe"
|
|
59
|
+
| "br"
|
|
60
|
+
| "eu"
|
|
61
|
+
| "ca";
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** @deprecated Use the new SDK's voices methods on the {@link Cartesia} instance instead. */
|
|
65
|
+
export class VoicesWrapper {
|
|
66
|
+
private client: Cartesia;
|
|
67
|
+
|
|
68
|
+
constructor(client: Cartesia) {
|
|
69
|
+
this.client = client;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** @deprecated Use {@link Cartesia.voices.clone} instead. */
|
|
73
|
+
async clone(
|
|
74
|
+
clip: File | fs.ReadStream | Blob,
|
|
75
|
+
request: BackCompatCloneVoiceRequest,
|
|
76
|
+
requestOptions?: BackCompatRequestOptions
|
|
77
|
+
): Promise<VoiceMetadata> {
|
|
78
|
+
const params: VoiceCloneParams = {
|
|
79
|
+
clip: clip as Uploadable,
|
|
80
|
+
name: request.name,
|
|
81
|
+
language: request.language as SupportedLanguage,
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
if (request.description !== undefined) {
|
|
85
|
+
params.description = request.description;
|
|
86
|
+
}
|
|
87
|
+
if (request.baseVoiceId !== undefined) {
|
|
88
|
+
params.base_voice_id = request.baseVoiceId;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const options: InternalRequestOptions = {};
|
|
92
|
+
if (requestOptions) {
|
|
93
|
+
if (requestOptions.timeoutInSeconds) {
|
|
94
|
+
options.timeout = requestOptions.timeoutInSeconds * 1000;
|
|
95
|
+
}
|
|
96
|
+
if (requestOptions.maxRetries !== undefined) {
|
|
97
|
+
options.maxRetries = requestOptions.maxRetries;
|
|
98
|
+
}
|
|
99
|
+
options.headers = requestOptions.headers;
|
|
100
|
+
options.signal = requestOptions.abortSignal;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return wrap(this.client.voices.clone(params, options));
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/** @deprecated Use {@link Cartesia.voices.update} instead. */
|
|
107
|
+
async update(
|
|
108
|
+
id: string,
|
|
109
|
+
request: BackCompatUpdateVoiceRequest,
|
|
110
|
+
requestOptions?: BackCompatRequestOptions
|
|
111
|
+
): Promise<Voice> {
|
|
112
|
+
const params: VoiceUpdateParams = {
|
|
113
|
+
name: request.name,
|
|
114
|
+
description: request.description,
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
const options: InternalRequestOptions = {};
|
|
118
|
+
if (requestOptions) {
|
|
119
|
+
if (requestOptions.timeoutInSeconds) {
|
|
120
|
+
options.timeout = requestOptions.timeoutInSeconds * 1000;
|
|
121
|
+
}
|
|
122
|
+
if (requestOptions.maxRetries !== undefined) {
|
|
123
|
+
options.maxRetries = requestOptions.maxRetries;
|
|
124
|
+
}
|
|
125
|
+
options.headers = requestOptions.headers;
|
|
126
|
+
options.signal = requestOptions.abortSignal;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
return wrap(this.client.voices.update(id, params, options));
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/** @deprecated Use {@link Cartesia.voices.localize} instead. */
|
|
133
|
+
async localize(
|
|
134
|
+
request: BackCompatLocalizeVoiceRequest,
|
|
135
|
+
requestOptions?: BackCompatRequestOptions
|
|
136
|
+
): Promise<VoiceMetadata> {
|
|
137
|
+
const params: VoiceLocalizeParams = {
|
|
138
|
+
voice_id: request.voiceId,
|
|
139
|
+
name: request.name,
|
|
140
|
+
description: request.description,
|
|
141
|
+
language: request.language as any,
|
|
142
|
+
original_speaker_gender: request.originalSpeakerGender,
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
if (request.dialect) {
|
|
146
|
+
params.dialect = request.dialect as any; // Cast dialect as list might vary slightly or be strict
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
const options: InternalRequestOptions = {};
|
|
150
|
+
if (requestOptions) {
|
|
151
|
+
if (requestOptions.timeoutInSeconds) {
|
|
152
|
+
options.timeout = requestOptions.timeoutInSeconds * 1000;
|
|
153
|
+
}
|
|
154
|
+
if (requestOptions.maxRetries !== undefined) {
|
|
155
|
+
options.maxRetries = requestOptions.maxRetries;
|
|
156
|
+
}
|
|
157
|
+
options.headers = requestOptions.headers;
|
|
158
|
+
options.signal = requestOptions.abortSignal;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
return wrap(this.client.voices.localize(params, options));
|
|
162
|
+
}
|
|
163
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -5,7 +5,7 @@ export { Cartesia as default } from './client';
|
|
|
5
5
|
export { type Uploadable, toFile } from './core/uploads';
|
|
6
6
|
export { APIPromise } from './core/api-promise';
|
|
7
7
|
export { Cartesia, type ClientOptions } from './client';
|
|
8
|
-
export
|
|
8
|
+
export * from './backcompat';
|
|
9
9
|
export { PagePromise } from './core/pagination';
|
|
10
10
|
export {
|
|
11
11
|
CartesiaError,
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = '3.0.0-
|
|
1
|
+
export const VERSION = '3.0.0-b7'; // x-release-please-version
|
package/version.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "3.0.0-
|
|
1
|
+
export declare const VERSION = "3.0.0-b7";
|
|
2
2
|
//# sourceMappingURL=version.d.mts.map
|
package/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "3.0.0-
|
|
1
|
+
export declare const VERSION = "3.0.0-b7";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/version.js
CHANGED
package/version.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const VERSION = '3.0.0-
|
|
1
|
+
export const VERSION = '3.0.0-b7'; // x-release-please-version
|
|
2
2
|
//# sourceMappingURL=version.mjs.map
|