@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.
Files changed (63) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +25 -21
  3. package/backcompat/index.d.mts +16 -0
  4. package/backcompat/index.d.mts.map +1 -0
  5. package/backcompat/index.d.ts +16 -0
  6. package/backcompat/index.d.ts.map +1 -0
  7. package/backcompat/index.js +36 -0
  8. package/backcompat/index.js.map +1 -0
  9. package/backcompat/index.mjs +31 -0
  10. package/backcompat/index.mjs.map +1 -0
  11. package/backcompat/tts-wrapper.d.mts +66 -0
  12. package/backcompat/tts-wrapper.d.mts.map +1 -0
  13. package/backcompat/tts-wrapper.d.ts +66 -0
  14. package/backcompat/tts-wrapper.d.ts.map +1 -0
  15. package/backcompat/tts-wrapper.js +260 -0
  16. package/backcompat/tts-wrapper.js.map +1 -0
  17. package/backcompat/tts-wrapper.mjs +254 -0
  18. package/backcompat/tts-wrapper.mjs.map +1 -0
  19. package/backcompat/types.d.mts +18 -0
  20. package/backcompat/types.d.mts.map +1 -0
  21. package/backcompat/types.d.ts +18 -0
  22. package/backcompat/types.d.ts.map +1 -0
  23. package/backcompat/types.js +3 -0
  24. package/backcompat/types.js.map +1 -0
  25. package/backcompat/types.mjs +2 -0
  26. package/backcompat/types.mjs.map +1 -0
  27. package/backcompat/voice-changer-wrapper.d.mts +17 -0
  28. package/backcompat/voice-changer-wrapper.d.mts.map +1 -0
  29. package/backcompat/voice-changer-wrapper.d.ts +17 -0
  30. package/backcompat/voice-changer-wrapper.d.ts.map +1 -0
  31. package/backcompat/voice-changer-wrapper.js +46 -0
  32. package/backcompat/voice-changer-wrapper.js.map +1 -0
  33. package/backcompat/voice-changer-wrapper.mjs +42 -0
  34. package/backcompat/voice-changer-wrapper.mjs.map +1 -0
  35. package/backcompat/voices-wrapper.d.mts +32 -0
  36. package/backcompat/voices-wrapper.d.mts.map +1 -0
  37. package/backcompat/voices-wrapper.d.ts +32 -0
  38. package/backcompat/voices-wrapper.d.ts.map +1 -0
  39. package/backcompat/voices-wrapper.js +77 -0
  40. package/backcompat/voices-wrapper.js.map +1 -0
  41. package/backcompat/voices-wrapper.mjs +73 -0
  42. package/backcompat/voices-wrapper.mjs.map +1 -0
  43. package/index.d.mts +1 -0
  44. package/index.d.mts.map +1 -1
  45. package/index.d.ts +1 -0
  46. package/index.d.ts.map +1 -1
  47. package/index.js +3 -1
  48. package/index.js.map +1 -1
  49. package/index.mjs +1 -0
  50. package/index.mjs.map +1 -1
  51. package/internal/tslib.js +4 -0
  52. package/package.json +11 -1
  53. package/src/backcompat/index.ts +40 -0
  54. package/src/backcompat/tts-wrapper.ts +324 -0
  55. package/src/backcompat/types.ts +19 -0
  56. package/src/backcompat/voice-changer-wrapper.ts +67 -0
  57. package/src/backcompat/voices-wrapper.ts +158 -0
  58. package/src/index.ts +1 -0
  59. package/src/version.ts +1 -1
  60. package/version.d.mts +1 -1
  61. package/version.d.ts +1 -1
  62. package/version.js +1 -1
  63. 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-b4'; // x-release-please-version
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-b4";
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-b4";
1
+ export declare const VERSION = "3.0.0-b6";
2
2
  //# sourceMappingURL=version.d.ts.map
package/version.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
- exports.VERSION = '3.0.0-b4'; // x-release-please-version
4
+ exports.VERSION = '3.0.0-b6'; // x-release-please-version
5
5
  //# sourceMappingURL=version.js.map
package/version.mjs CHANGED
@@ -1,2 +1,2 @@
1
- export const VERSION = '3.0.0-b4'; // x-release-please-version
1
+ export const VERSION = '3.0.0-b6'; // x-release-please-version
2
2
  //# sourceMappingURL=version.mjs.map