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