@cartesia/cartesia-js 2.0.1 → 2.0.3
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/README.md +1 -5
- package/api/resources/apiStatus/client/Client.js +1 -1
- package/api/resources/tts/client/Client.js +2 -2
- package/api/resources/voiceChanger/client/Client.js +2 -2
- package/api/resources/voices/client/Client.js +8 -8
- package/dist/api/resources/apiStatus/client/Client.js +1 -1
- package/dist/api/resources/tts/client/Client.js +2 -2
- package/dist/api/resources/voiceChanger/client/Client.js +2 -2
- package/dist/api/resources/voices/client/Client.js +8 -8
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/wrapper/Websocket.d.ts +7 -24
- package/dist/wrapper/Websocket.js +56 -55
- package/dist/wrapper/source.d.ts +5 -4
- package/dist/wrapper/source.js +1 -1
- package/package.json +2 -2
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/wrapper/Websocket.d.ts +7 -24
- package/wrapper/Websocket.js +56 -55
- package/wrapper/source.d.ts +5 -4
- package/wrapper/source.js +1 -1
package/README.md
CHANGED
|
@@ -58,11 +58,7 @@ const websocket = cartesia.tts.websocket({
|
|
|
58
58
|
});
|
|
59
59
|
|
|
60
60
|
try {
|
|
61
|
-
await websocket.connect(
|
|
62
|
-
// If using Node.js, you can pass a custom WebSocket constructor, such as from `ws`.
|
|
63
|
-
// This is not needed for browser usage, so you can call connect() without any arguments.
|
|
64
|
-
WebSocket: WS,
|
|
65
|
-
});
|
|
61
|
+
await websocket.connect();
|
|
66
62
|
} catch (error) {
|
|
67
63
|
console.error(`Failed to connect to Cartesia: ${error}`);
|
|
68
64
|
}
|
|
@@ -56,7 +56,7 @@ class ApiStatus {
|
|
|
56
56
|
const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
|
|
57
57
|
url: (_b = (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.CartesiaEnvironment.Production,
|
|
58
58
|
method: "GET",
|
|
59
|
-
headers: Object.assign({ "Cartesia-Version": (_e = (_c = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _c !== void 0 ? _c : (_d = this._options) === null || _d === void 0 ? void 0 : _d.cartesiaVersion) !== null && _e !== void 0 ? _e : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.0.
|
|
59
|
+
headers: Object.assign({ "Cartesia-Version": (_e = (_c = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _c !== void 0 ? _c : (_d = this._options) === null || _d === void 0 ? void 0 : _d.cartesiaVersion) !== null && _e !== void 0 ? _e : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.0.3", "User-Agent": "@cartesia/cartesia-js/2.0.3", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())),
|
|
60
60
|
contentType: "application/json",
|
|
61
61
|
requestType: "json",
|
|
62
62
|
timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
|
|
@@ -54,7 +54,7 @@ class Tts {
|
|
|
54
54
|
const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
|
|
55
55
|
url: (0, url_join_1.default)((_b = (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.CartesiaEnvironment.Production, "/tts/bytes"),
|
|
56
56
|
method: "POST",
|
|
57
|
-
headers: Object.assign({ "Cartesia-Version": (_e = (_c = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _c !== void 0 ? _c : (_d = this._options) === null || _d === void 0 ? void 0 : _d.cartesiaVersion) !== null && _e !== void 0 ? _e : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.0.
|
|
57
|
+
headers: Object.assign({ "Cartesia-Version": (_e = (_c = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _c !== void 0 ? _c : (_d = this._options) === null || _d === void 0 ? void 0 : _d.cartesiaVersion) !== null && _e !== void 0 ? _e : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.0.3", "User-Agent": "@cartesia/cartesia-js/2.0.3", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())),
|
|
58
58
|
contentType: "application/json",
|
|
59
59
|
requestType: "json",
|
|
60
60
|
body: serializers.TtsRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
|
|
@@ -93,7 +93,7 @@ class Tts {
|
|
|
93
93
|
const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
|
|
94
94
|
url: (0, url_join_1.default)((_b = (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.CartesiaEnvironment.Production, "/tts/sse"),
|
|
95
95
|
method: "POST",
|
|
96
|
-
headers: Object.assign({ "Cartesia-Version": (_e = (_c = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _c !== void 0 ? _c : (_d = this._options) === null || _d === void 0 ? void 0 : _d.cartesiaVersion) !== null && _e !== void 0 ? _e : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.0.
|
|
96
|
+
headers: Object.assign({ "Cartesia-Version": (_e = (_c = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _c !== void 0 ? _c : (_d = this._options) === null || _d === void 0 ? void 0 : _d.cartesiaVersion) !== null && _e !== void 0 ? _e : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.0.3", "User-Agent": "@cartesia/cartesia-js/2.0.3", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())),
|
|
97
97
|
contentType: "application/json",
|
|
98
98
|
requestType: "json",
|
|
99
99
|
body: serializers.TtsRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
|
|
@@ -71,7 +71,7 @@ class VoiceChanger {
|
|
|
71
71
|
const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
|
|
72
72
|
url: (0, url_join_1.default)((_b = (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.CartesiaEnvironment.Production, "/voice-changer/bytes"),
|
|
73
73
|
method: "POST",
|
|
74
|
-
headers: Object.assign(Object.assign({ "Cartesia-Version": (_e = (_c = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _c !== void 0 ? _c : (_d = this._options) === null || _d === void 0 ? void 0 : _d.cartesiaVersion) !== null && _e !== void 0 ? _e : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.0.
|
|
74
|
+
headers: Object.assign(Object.assign({ "Cartesia-Version": (_e = (_c = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _c !== void 0 ? _c : (_d = this._options) === null || _d === void 0 ? void 0 : _d.cartesiaVersion) !== null && _e !== void 0 ? _e : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.0.3", "User-Agent": "@cartesia/cartesia-js/2.0.3", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())), _maybeEncodedRequest.headers),
|
|
75
75
|
requestType: "file",
|
|
76
76
|
duplex: _maybeEncodedRequest.duplex,
|
|
77
77
|
body: _maybeEncodedRequest.body,
|
|
@@ -122,7 +122,7 @@ class VoiceChanger {
|
|
|
122
122
|
const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
|
|
123
123
|
url: (0, url_join_1.default)((_b = (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.CartesiaEnvironment.Production, "/voice-changer/sse"),
|
|
124
124
|
method: "POST",
|
|
125
|
-
headers: Object.assign(Object.assign({ "Cartesia-Version": (_e = (_c = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _c !== void 0 ? _c : (_d = this._options) === null || _d === void 0 ? void 0 : _d.cartesiaVersion) !== null && _e !== void 0 ? _e : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.0.
|
|
125
|
+
headers: Object.assign(Object.assign({ "Cartesia-Version": (_e = (_c = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _c !== void 0 ? _c : (_d = this._options) === null || _d === void 0 ? void 0 : _d.cartesiaVersion) !== null && _e !== void 0 ? _e : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.0.3", "User-Agent": "@cartesia/cartesia-js/2.0.3", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())), _maybeEncodedRequest.headers),
|
|
126
126
|
requestType: "file",
|
|
127
127
|
duplex: _maybeEncodedRequest.duplex,
|
|
128
128
|
body: _maybeEncodedRequest.body,
|
|
@@ -60,7 +60,7 @@ class Voices {
|
|
|
60
60
|
const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
|
|
61
61
|
url: (0, url_join_1.default)((_b = (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.CartesiaEnvironment.Production, "/voices/"),
|
|
62
62
|
method: "GET",
|
|
63
|
-
headers: Object.assign({ "Cartesia-Version": (_e = (_c = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _c !== void 0 ? _c : (_d = this._options) === null || _d === void 0 ? void 0 : _d.cartesiaVersion) !== null && _e !== void 0 ? _e : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.0.
|
|
63
|
+
headers: Object.assign({ "Cartesia-Version": (_e = (_c = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _c !== void 0 ? _c : (_d = this._options) === null || _d === void 0 ? void 0 : _d.cartesiaVersion) !== null && _e !== void 0 ? _e : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.0.3", "User-Agent": "@cartesia/cartesia-js/2.0.3", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())),
|
|
64
64
|
contentType: "application/json",
|
|
65
65
|
requestType: "json",
|
|
66
66
|
timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
|
|
@@ -116,7 +116,7 @@ class Voices {
|
|
|
116
116
|
const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
|
|
117
117
|
url: (0, url_join_1.default)((_b = (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.CartesiaEnvironment.Production, "/voices/"),
|
|
118
118
|
method: "POST",
|
|
119
|
-
headers: Object.assign({ "Cartesia-Version": (_e = (_c = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _c !== void 0 ? _c : (_d = this._options) === null || _d === void 0 ? void 0 : _d.cartesiaVersion) !== null && _e !== void 0 ? _e : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.0.
|
|
119
|
+
headers: Object.assign({ "Cartesia-Version": (_e = (_c = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _c !== void 0 ? _c : (_d = this._options) === null || _d === void 0 ? void 0 : _d.cartesiaVersion) !== null && _e !== void 0 ? _e : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.0.3", "User-Agent": "@cartesia/cartesia-js/2.0.3", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())),
|
|
120
120
|
contentType: "application/json",
|
|
121
121
|
requestType: "json",
|
|
122
122
|
body: serializers.CreateVoiceRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
|
|
@@ -167,7 +167,7 @@ class Voices {
|
|
|
167
167
|
const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
|
|
168
168
|
url: (0, url_join_1.default)((_b = (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.CartesiaEnvironment.Production, `/voices/${encodeURIComponent(serializers.VoiceId.jsonOrThrow(id))}`),
|
|
169
169
|
method: "DELETE",
|
|
170
|
-
headers: Object.assign({ "Cartesia-Version": (_e = (_c = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _c !== void 0 ? _c : (_d = this._options) === null || _d === void 0 ? void 0 : _d.cartesiaVersion) !== null && _e !== void 0 ? _e : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.0.
|
|
170
|
+
headers: Object.assign({ "Cartesia-Version": (_e = (_c = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _c !== void 0 ? _c : (_d = this._options) === null || _d === void 0 ? void 0 : _d.cartesiaVersion) !== null && _e !== void 0 ? _e : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.0.3", "User-Agent": "@cartesia/cartesia-js/2.0.3", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())),
|
|
171
171
|
contentType: "application/json",
|
|
172
172
|
requestType: "json",
|
|
173
173
|
timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
|
|
@@ -215,7 +215,7 @@ class Voices {
|
|
|
215
215
|
const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
|
|
216
216
|
url: (0, url_join_1.default)((_b = (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.CartesiaEnvironment.Production, `/voices/${encodeURIComponent(serializers.VoiceId.jsonOrThrow(id))}`),
|
|
217
217
|
method: "PATCH",
|
|
218
|
-
headers: Object.assign({ "Cartesia-Version": (_e = (_c = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _c !== void 0 ? _c : (_d = this._options) === null || _d === void 0 ? void 0 : _d.cartesiaVersion) !== null && _e !== void 0 ? _e : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.0.
|
|
218
|
+
headers: Object.assign({ "Cartesia-Version": (_e = (_c = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _c !== void 0 ? _c : (_d = this._options) === null || _d === void 0 ? void 0 : _d.cartesiaVersion) !== null && _e !== void 0 ? _e : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.0.3", "User-Agent": "@cartesia/cartesia-js/2.0.3", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())),
|
|
219
219
|
contentType: "application/json",
|
|
220
220
|
requestType: "json",
|
|
221
221
|
body: serializers.UpdateVoiceRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
|
|
@@ -266,7 +266,7 @@ class Voices {
|
|
|
266
266
|
const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
|
|
267
267
|
url: (0, url_join_1.default)((_b = (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.CartesiaEnvironment.Production, `/voices/${encodeURIComponent(serializers.VoiceId.jsonOrThrow(id))}`),
|
|
268
268
|
method: "GET",
|
|
269
|
-
headers: Object.assign({ "Cartesia-Version": (_e = (_c = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _c !== void 0 ? _c : (_d = this._options) === null || _d === void 0 ? void 0 : _d.cartesiaVersion) !== null && _e !== void 0 ? _e : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.0.
|
|
269
|
+
headers: Object.assign({ "Cartesia-Version": (_e = (_c = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _c !== void 0 ? _c : (_d = this._options) === null || _d === void 0 ? void 0 : _d.cartesiaVersion) !== null && _e !== void 0 ? _e : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.0.3", "User-Agent": "@cartesia/cartesia-js/2.0.3", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())),
|
|
270
270
|
contentType: "application/json",
|
|
271
271
|
requestType: "json",
|
|
272
272
|
timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
|
|
@@ -321,7 +321,7 @@ class Voices {
|
|
|
321
321
|
const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
|
|
322
322
|
url: (0, url_join_1.default)((_b = (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.CartesiaEnvironment.Production, "/voices/localize"),
|
|
323
323
|
method: "POST",
|
|
324
|
-
headers: Object.assign({ "Cartesia-Version": (_e = (_c = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _c !== void 0 ? _c : (_d = this._options) === null || _d === void 0 ? void 0 : _d.cartesiaVersion) !== null && _e !== void 0 ? _e : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.0.
|
|
324
|
+
headers: Object.assign({ "Cartesia-Version": (_e = (_c = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _c !== void 0 ? _c : (_d = this._options) === null || _d === void 0 ? void 0 : _d.cartesiaVersion) !== null && _e !== void 0 ? _e : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.0.3", "User-Agent": "@cartesia/cartesia-js/2.0.3", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())),
|
|
325
325
|
contentType: "application/json",
|
|
326
326
|
requestType: "json",
|
|
327
327
|
body: serializers.LocalizeVoiceRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
|
|
@@ -377,7 +377,7 @@ class Voices {
|
|
|
377
377
|
const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
|
|
378
378
|
url: (0, url_join_1.default)((_b = (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.CartesiaEnvironment.Production, "/voices/mix"),
|
|
379
379
|
method: "POST",
|
|
380
|
-
headers: Object.assign({ "Cartesia-Version": (_e = (_c = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _c !== void 0 ? _c : (_d = this._options) === null || _d === void 0 ? void 0 : _d.cartesiaVersion) !== null && _e !== void 0 ? _e : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.0.
|
|
380
|
+
headers: Object.assign({ "Cartesia-Version": (_e = (_c = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _c !== void 0 ? _c : (_d = this._options) === null || _d === void 0 ? void 0 : _d.cartesiaVersion) !== null && _e !== void 0 ? _e : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.0.3", "User-Agent": "@cartesia/cartesia-js/2.0.3", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())),
|
|
381
381
|
contentType: "application/json",
|
|
382
382
|
requestType: "json",
|
|
383
383
|
body: serializers.MixVoicesRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
|
|
@@ -464,7 +464,7 @@ class Voices {
|
|
|
464
464
|
const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
|
|
465
465
|
url: (0, url_join_1.default)((_b = (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.CartesiaEnvironment.Production, "/voices/clone"),
|
|
466
466
|
method: "POST",
|
|
467
|
-
headers: Object.assign(Object.assign({ "Cartesia-Version": (_e = (_c = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _c !== void 0 ? _c : (_d = this._options) === null || _d === void 0 ? void 0 : _d.cartesiaVersion) !== null && _e !== void 0 ? _e : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.0.
|
|
467
|
+
headers: Object.assign(Object.assign({ "Cartesia-Version": (_e = (_c = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _c !== void 0 ? _c : (_d = this._options) === null || _d === void 0 ? void 0 : _d.cartesiaVersion) !== null && _e !== void 0 ? _e : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.0.3", "User-Agent": "@cartesia/cartesia-js/2.0.3", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())), _maybeEncodedRequest.headers),
|
|
468
468
|
requestType: "file",
|
|
469
469
|
duplex: _maybeEncodedRequest.duplex,
|
|
470
470
|
body: _maybeEncodedRequest.body,
|
|
@@ -56,7 +56,7 @@ class ApiStatus {
|
|
|
56
56
|
const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
|
|
57
57
|
url: (_b = (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.CartesiaEnvironment.Production,
|
|
58
58
|
method: "GET",
|
|
59
|
-
headers: Object.assign({ "Cartesia-Version": (_e = (_c = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _c !== void 0 ? _c : (_d = this._options) === null || _d === void 0 ? void 0 : _d.cartesiaVersion) !== null && _e !== void 0 ? _e : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.0.
|
|
59
|
+
headers: Object.assign({ "Cartesia-Version": (_e = (_c = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _c !== void 0 ? _c : (_d = this._options) === null || _d === void 0 ? void 0 : _d.cartesiaVersion) !== null && _e !== void 0 ? _e : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.0.3", "User-Agent": "@cartesia/cartesia-js/2.0.3", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())),
|
|
60
60
|
contentType: "application/json",
|
|
61
61
|
requestType: "json",
|
|
62
62
|
timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
|
|
@@ -54,7 +54,7 @@ class Tts {
|
|
|
54
54
|
const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
|
|
55
55
|
url: (0, url_join_1.default)((_b = (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.CartesiaEnvironment.Production, "/tts/bytes"),
|
|
56
56
|
method: "POST",
|
|
57
|
-
headers: Object.assign({ "Cartesia-Version": (_e = (_c = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _c !== void 0 ? _c : (_d = this._options) === null || _d === void 0 ? void 0 : _d.cartesiaVersion) !== null && _e !== void 0 ? _e : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.0.
|
|
57
|
+
headers: Object.assign({ "Cartesia-Version": (_e = (_c = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _c !== void 0 ? _c : (_d = this._options) === null || _d === void 0 ? void 0 : _d.cartesiaVersion) !== null && _e !== void 0 ? _e : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.0.3", "User-Agent": "@cartesia/cartesia-js/2.0.3", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())),
|
|
58
58
|
contentType: "application/json",
|
|
59
59
|
requestType: "json",
|
|
60
60
|
body: serializers.TtsRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
|
|
@@ -93,7 +93,7 @@ class Tts {
|
|
|
93
93
|
const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
|
|
94
94
|
url: (0, url_join_1.default)((_b = (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.CartesiaEnvironment.Production, "/tts/sse"),
|
|
95
95
|
method: "POST",
|
|
96
|
-
headers: Object.assign({ "Cartesia-Version": (_e = (_c = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _c !== void 0 ? _c : (_d = this._options) === null || _d === void 0 ? void 0 : _d.cartesiaVersion) !== null && _e !== void 0 ? _e : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.0.
|
|
96
|
+
headers: Object.assign({ "Cartesia-Version": (_e = (_c = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _c !== void 0 ? _c : (_d = this._options) === null || _d === void 0 ? void 0 : _d.cartesiaVersion) !== null && _e !== void 0 ? _e : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.0.3", "User-Agent": "@cartesia/cartesia-js/2.0.3", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())),
|
|
97
97
|
contentType: "application/json",
|
|
98
98
|
requestType: "json",
|
|
99
99
|
body: serializers.TtsRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
|
|
@@ -71,7 +71,7 @@ class VoiceChanger {
|
|
|
71
71
|
const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
|
|
72
72
|
url: (0, url_join_1.default)((_b = (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.CartesiaEnvironment.Production, "/voice-changer/bytes"),
|
|
73
73
|
method: "POST",
|
|
74
|
-
headers: Object.assign(Object.assign({ "Cartesia-Version": (_e = (_c = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _c !== void 0 ? _c : (_d = this._options) === null || _d === void 0 ? void 0 : _d.cartesiaVersion) !== null && _e !== void 0 ? _e : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.0.
|
|
74
|
+
headers: Object.assign(Object.assign({ "Cartesia-Version": (_e = (_c = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _c !== void 0 ? _c : (_d = this._options) === null || _d === void 0 ? void 0 : _d.cartesiaVersion) !== null && _e !== void 0 ? _e : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.0.3", "User-Agent": "@cartesia/cartesia-js/2.0.3", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())), _maybeEncodedRequest.headers),
|
|
75
75
|
requestType: "file",
|
|
76
76
|
duplex: _maybeEncodedRequest.duplex,
|
|
77
77
|
body: _maybeEncodedRequest.body,
|
|
@@ -122,7 +122,7 @@ class VoiceChanger {
|
|
|
122
122
|
const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
|
|
123
123
|
url: (0, url_join_1.default)((_b = (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.CartesiaEnvironment.Production, "/voice-changer/sse"),
|
|
124
124
|
method: "POST",
|
|
125
|
-
headers: Object.assign(Object.assign({ "Cartesia-Version": (_e = (_c = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _c !== void 0 ? _c : (_d = this._options) === null || _d === void 0 ? void 0 : _d.cartesiaVersion) !== null && _e !== void 0 ? _e : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.0.
|
|
125
|
+
headers: Object.assign(Object.assign({ "Cartesia-Version": (_e = (_c = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _c !== void 0 ? _c : (_d = this._options) === null || _d === void 0 ? void 0 : _d.cartesiaVersion) !== null && _e !== void 0 ? _e : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.0.3", "User-Agent": "@cartesia/cartesia-js/2.0.3", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())), _maybeEncodedRequest.headers),
|
|
126
126
|
requestType: "file",
|
|
127
127
|
duplex: _maybeEncodedRequest.duplex,
|
|
128
128
|
body: _maybeEncodedRequest.body,
|
|
@@ -60,7 +60,7 @@ class Voices {
|
|
|
60
60
|
const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
|
|
61
61
|
url: (0, url_join_1.default)((_b = (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.CartesiaEnvironment.Production, "/voices/"),
|
|
62
62
|
method: "GET",
|
|
63
|
-
headers: Object.assign({ "Cartesia-Version": (_e = (_c = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _c !== void 0 ? _c : (_d = this._options) === null || _d === void 0 ? void 0 : _d.cartesiaVersion) !== null && _e !== void 0 ? _e : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.0.
|
|
63
|
+
headers: Object.assign({ "Cartesia-Version": (_e = (_c = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _c !== void 0 ? _c : (_d = this._options) === null || _d === void 0 ? void 0 : _d.cartesiaVersion) !== null && _e !== void 0 ? _e : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.0.3", "User-Agent": "@cartesia/cartesia-js/2.0.3", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())),
|
|
64
64
|
contentType: "application/json",
|
|
65
65
|
requestType: "json",
|
|
66
66
|
timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
|
|
@@ -116,7 +116,7 @@ class Voices {
|
|
|
116
116
|
const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
|
|
117
117
|
url: (0, url_join_1.default)((_b = (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.CartesiaEnvironment.Production, "/voices/"),
|
|
118
118
|
method: "POST",
|
|
119
|
-
headers: Object.assign({ "Cartesia-Version": (_e = (_c = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _c !== void 0 ? _c : (_d = this._options) === null || _d === void 0 ? void 0 : _d.cartesiaVersion) !== null && _e !== void 0 ? _e : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.0.
|
|
119
|
+
headers: Object.assign({ "Cartesia-Version": (_e = (_c = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _c !== void 0 ? _c : (_d = this._options) === null || _d === void 0 ? void 0 : _d.cartesiaVersion) !== null && _e !== void 0 ? _e : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.0.3", "User-Agent": "@cartesia/cartesia-js/2.0.3", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())),
|
|
120
120
|
contentType: "application/json",
|
|
121
121
|
requestType: "json",
|
|
122
122
|
body: serializers.CreateVoiceRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
|
|
@@ -167,7 +167,7 @@ class Voices {
|
|
|
167
167
|
const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
|
|
168
168
|
url: (0, url_join_1.default)((_b = (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.CartesiaEnvironment.Production, `/voices/${encodeURIComponent(serializers.VoiceId.jsonOrThrow(id))}`),
|
|
169
169
|
method: "DELETE",
|
|
170
|
-
headers: Object.assign({ "Cartesia-Version": (_e = (_c = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _c !== void 0 ? _c : (_d = this._options) === null || _d === void 0 ? void 0 : _d.cartesiaVersion) !== null && _e !== void 0 ? _e : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.0.
|
|
170
|
+
headers: Object.assign({ "Cartesia-Version": (_e = (_c = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _c !== void 0 ? _c : (_d = this._options) === null || _d === void 0 ? void 0 : _d.cartesiaVersion) !== null && _e !== void 0 ? _e : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.0.3", "User-Agent": "@cartesia/cartesia-js/2.0.3", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())),
|
|
171
171
|
contentType: "application/json",
|
|
172
172
|
requestType: "json",
|
|
173
173
|
timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
|
|
@@ -215,7 +215,7 @@ class Voices {
|
|
|
215
215
|
const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
|
|
216
216
|
url: (0, url_join_1.default)((_b = (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.CartesiaEnvironment.Production, `/voices/${encodeURIComponent(serializers.VoiceId.jsonOrThrow(id))}`),
|
|
217
217
|
method: "PATCH",
|
|
218
|
-
headers: Object.assign({ "Cartesia-Version": (_e = (_c = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _c !== void 0 ? _c : (_d = this._options) === null || _d === void 0 ? void 0 : _d.cartesiaVersion) !== null && _e !== void 0 ? _e : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.0.
|
|
218
|
+
headers: Object.assign({ "Cartesia-Version": (_e = (_c = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _c !== void 0 ? _c : (_d = this._options) === null || _d === void 0 ? void 0 : _d.cartesiaVersion) !== null && _e !== void 0 ? _e : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.0.3", "User-Agent": "@cartesia/cartesia-js/2.0.3", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())),
|
|
219
219
|
contentType: "application/json",
|
|
220
220
|
requestType: "json",
|
|
221
221
|
body: serializers.UpdateVoiceRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
|
|
@@ -266,7 +266,7 @@ class Voices {
|
|
|
266
266
|
const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
|
|
267
267
|
url: (0, url_join_1.default)((_b = (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.CartesiaEnvironment.Production, `/voices/${encodeURIComponent(serializers.VoiceId.jsonOrThrow(id))}`),
|
|
268
268
|
method: "GET",
|
|
269
|
-
headers: Object.assign({ "Cartesia-Version": (_e = (_c = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _c !== void 0 ? _c : (_d = this._options) === null || _d === void 0 ? void 0 : _d.cartesiaVersion) !== null && _e !== void 0 ? _e : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.0.
|
|
269
|
+
headers: Object.assign({ "Cartesia-Version": (_e = (_c = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _c !== void 0 ? _c : (_d = this._options) === null || _d === void 0 ? void 0 : _d.cartesiaVersion) !== null && _e !== void 0 ? _e : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.0.3", "User-Agent": "@cartesia/cartesia-js/2.0.3", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())),
|
|
270
270
|
contentType: "application/json",
|
|
271
271
|
requestType: "json",
|
|
272
272
|
timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
|
|
@@ -321,7 +321,7 @@ class Voices {
|
|
|
321
321
|
const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
|
|
322
322
|
url: (0, url_join_1.default)((_b = (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.CartesiaEnvironment.Production, "/voices/localize"),
|
|
323
323
|
method: "POST",
|
|
324
|
-
headers: Object.assign({ "Cartesia-Version": (_e = (_c = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _c !== void 0 ? _c : (_d = this._options) === null || _d === void 0 ? void 0 : _d.cartesiaVersion) !== null && _e !== void 0 ? _e : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.0.
|
|
324
|
+
headers: Object.assign({ "Cartesia-Version": (_e = (_c = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _c !== void 0 ? _c : (_d = this._options) === null || _d === void 0 ? void 0 : _d.cartesiaVersion) !== null && _e !== void 0 ? _e : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.0.3", "User-Agent": "@cartesia/cartesia-js/2.0.3", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())),
|
|
325
325
|
contentType: "application/json",
|
|
326
326
|
requestType: "json",
|
|
327
327
|
body: serializers.LocalizeVoiceRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
|
|
@@ -377,7 +377,7 @@ class Voices {
|
|
|
377
377
|
const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
|
|
378
378
|
url: (0, url_join_1.default)((_b = (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.CartesiaEnvironment.Production, "/voices/mix"),
|
|
379
379
|
method: "POST",
|
|
380
|
-
headers: Object.assign({ "Cartesia-Version": (_e = (_c = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _c !== void 0 ? _c : (_d = this._options) === null || _d === void 0 ? void 0 : _d.cartesiaVersion) !== null && _e !== void 0 ? _e : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.0.
|
|
380
|
+
headers: Object.assign({ "Cartesia-Version": (_e = (_c = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _c !== void 0 ? _c : (_d = this._options) === null || _d === void 0 ? void 0 : _d.cartesiaVersion) !== null && _e !== void 0 ? _e : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.0.3", "User-Agent": "@cartesia/cartesia-js/2.0.3", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())),
|
|
381
381
|
contentType: "application/json",
|
|
382
382
|
requestType: "json",
|
|
383
383
|
body: serializers.MixVoicesRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
|
|
@@ -464,7 +464,7 @@ class Voices {
|
|
|
464
464
|
const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
|
|
465
465
|
url: (0, url_join_1.default)((_b = (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.CartesiaEnvironment.Production, "/voices/clone"),
|
|
466
466
|
method: "POST",
|
|
467
|
-
headers: Object.assign(Object.assign({ "Cartesia-Version": (_e = (_c = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _c !== void 0 ? _c : (_d = this._options) === null || _d === void 0 ? void 0 : _d.cartesiaVersion) !== null && _e !== void 0 ? _e : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.0.
|
|
467
|
+
headers: Object.assign(Object.assign({ "Cartesia-Version": (_e = (_c = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _c !== void 0 ? _c : (_d = this._options) === null || _d === void 0 ? void 0 : _d.cartesiaVersion) !== null && _e !== void 0 ? _e : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.0.3", "User-Agent": "@cartesia/cartesia-js/2.0.3", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())), _maybeEncodedRequest.headers),
|
|
468
468
|
requestType: "file",
|
|
469
469
|
duplex: _maybeEncodedRequest.duplex,
|
|
470
470
|
body: _maybeEncodedRequest.body,
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "2.0.
|
|
1
|
+
export declare const SDK_VERSION = "2.0.3";
|
package/dist/version.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ReconnectingWebSocket, Options } from "../core/websocket";
|
|
2
2
|
import type { WebSocketStreamOptions, WebSocketTtsRequest, WordTimestamps } from "../api";
|
|
3
3
|
import { ConnectionEventData, WebSocketOptions, EmitteryCallbacks } from "./utils";
|
|
4
|
-
import { Tts } from "api/resources/tts/client/Client";
|
|
4
|
+
import { Tts } from "../api/resources/tts/client/Client";
|
|
5
5
|
import Source from "./source";
|
|
6
6
|
export default class Websocket {
|
|
7
7
|
#private;
|
|
@@ -17,31 +17,14 @@ export default class Websocket {
|
|
|
17
17
|
* If set to `0`, the stream will not time out.
|
|
18
18
|
* @returns A Source object that can be passed to a Player to play the audio.
|
|
19
19
|
* @returns An Emittery instance that emits messages from the WebSocket.
|
|
20
|
-
* @returns An abort function that can be called to cancel the stream.
|
|
21
20
|
*/
|
|
22
|
-
send(inputs: WebSocketTtsRequest, { timeout }?: WebSocketStreamOptions): {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
};
|
|
27
|
-
on: <Name extends "timestamps" | "message" | keyof import("emittery").OmnipresentEventData>(eventName: Name | readonly Name[], listener: (eventData: ({
|
|
28
|
-
message: string;
|
|
29
|
-
timestamps: WordTimestamps;
|
|
30
|
-
} & import("emittery").OmnipresentEventData)[Name]) => void | Promise<void>) => import("emittery").UnsubscribeFunction;
|
|
31
|
-
off: <Name_1 extends "timestamps" | "message" | keyof import("emittery").OmnipresentEventData>(eventName: Name_1 | readonly Name_1[], listener: (eventData: ({
|
|
32
|
-
message: string;
|
|
33
|
-
timestamps: WordTimestamps;
|
|
34
|
-
} & import("emittery").OmnipresentEventData)[Name_1]) => void | Promise<void>) => void;
|
|
35
|
-
once: <Name_2 extends "timestamps" | "message" | keyof import("emittery").OmnipresentEventData>(eventName: Name_2 | readonly Name_2[]) => import("emittery").EmitteryOncePromise<({
|
|
36
|
-
message: string;
|
|
37
|
-
timestamps: WordTimestamps;
|
|
38
|
-
} & import("emittery").OmnipresentEventData)[Name_2]>;
|
|
39
|
-
events: <Name_3 extends "timestamps" | "message">(eventName: Name_3 | readonly Name_3[]) => AsyncIterableIterator<{
|
|
40
|
-
message: string;
|
|
41
|
-
timestamps: WordTimestamps;
|
|
42
|
-
}[Name_3]>;
|
|
21
|
+
send(inputs: WebSocketTtsRequest, { timeout }?: WebSocketStreamOptions): Promise<EmitteryCallbacks<{
|
|
22
|
+
message: string;
|
|
23
|
+
timestamps: WordTimestamps;
|
|
24
|
+
}> & {
|
|
43
25
|
source: Source;
|
|
44
|
-
|
|
26
|
+
stop: unknown;
|
|
27
|
+
}>;
|
|
45
28
|
continue(inputs: WebSocketTtsRequest): void;
|
|
46
29
|
/**
|
|
47
30
|
* Authenticate and connect to a Cartesia streaming WebSocket.
|
|
@@ -77,69 +77,70 @@ class Websocket {
|
|
|
77
77
|
* If set to `0`, the stream will not time out.
|
|
78
78
|
* @returns A Source object that can be passed to a Player to play the audio.
|
|
79
79
|
* @returns An Emittery instance that emits messages from the WebSocket.
|
|
80
|
-
* @returns An abort function that can be called to cancel the stream.
|
|
81
80
|
*/
|
|
82
81
|
send(inputs, { timeout = 0 } = {}) {
|
|
83
82
|
var _a, _b, _c, _d;
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
if (!inputs.contextId) {
|
|
88
|
-
inputs.contextId = __classPrivateFieldGet(this, _Websocket_instances, "m", _Websocket_generateId).call(this);
|
|
89
|
-
}
|
|
90
|
-
if (!inputs.outputFormat) {
|
|
91
|
-
inputs.outputFormat = (0, utils_1.resolveOutputFormat)(__classPrivateFieldGet(this, _Websocket_container, "f"), __classPrivateFieldGet(this, _Websocket_encoding, "f"), __classPrivateFieldGet(this, _Websocket_sampleRate, "f"));
|
|
92
|
-
}
|
|
93
|
-
(_a = this.socket) === null || _a === void 0 ? void 0 : _a.send(JSON.stringify(serializers.WebSocketTtsRequest.jsonOrThrow(inputs, { unrecognizedObjectKeys: "strip" })));
|
|
94
|
-
const emitter = new emittery_1.default();
|
|
95
|
-
const source = new source_1.default({
|
|
96
|
-
sampleRate: __classPrivateFieldGet(this, _Websocket_sampleRate, "f"),
|
|
97
|
-
encoding: __classPrivateFieldGet(this, _Websocket_encoding, "f"),
|
|
98
|
-
container: __classPrivateFieldGet(this, _Websocket_container, "f"),
|
|
99
|
-
});
|
|
100
|
-
// Used to signal that the stream is complete, either because the
|
|
101
|
-
// WebSocket has closed, or because the stream has finished.
|
|
102
|
-
const streamCompleteController = new AbortController();
|
|
103
|
-
// Set a timeout.
|
|
104
|
-
let timeoutId = null;
|
|
105
|
-
if (timeout > 0) {
|
|
106
|
-
timeoutId = setTimeout(streamCompleteController.abort, timeout);
|
|
107
|
-
}
|
|
108
|
-
const handleMessage = (0, utils_1.createMessageHandlerForContextId)(inputs.contextId, ({ chunk, message, data }) => __awaiter(this, void 0, void 0, function* () {
|
|
109
|
-
emitter.emit("message", message);
|
|
110
|
-
if (data.type === "timestamps" && data.wordTimestamps) {
|
|
111
|
-
emitter.emit("timestamps", data.wordTimestamps);
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
if ((0, utils_1.isSentinel)(chunk)) {
|
|
115
|
-
yield source.close();
|
|
116
|
-
streamCompleteController.abort();
|
|
117
|
-
return;
|
|
83
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
84
|
+
if (!__classPrivateFieldGet(this, _Websocket_isConnected, "f")) {
|
|
85
|
+
throw new Error("Not connected to WebSocket. Call .connect() first.");
|
|
118
86
|
}
|
|
119
|
-
if (
|
|
120
|
-
|
|
121
|
-
timeoutId = setTimeout(streamCompleteController.abort, timeout);
|
|
87
|
+
if (!inputs.contextId) {
|
|
88
|
+
inputs.contextId = __classPrivateFieldGet(this, _Websocket_instances, "m", _Websocket_generateId).call(this);
|
|
122
89
|
}
|
|
123
|
-
if (!
|
|
124
|
-
|
|
90
|
+
if (!inputs.outputFormat) {
|
|
91
|
+
inputs.outputFormat = (0, utils_1.resolveOutputFormat)(__classPrivateFieldGet(this, _Websocket_container, "f"), __classPrivateFieldGet(this, _Websocket_encoding, "f"), __classPrivateFieldGet(this, _Websocket_sampleRate, "f"));
|
|
125
92
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
93
|
+
(_a = this.socket) === null || _a === void 0 ? void 0 : _a.send(JSON.stringify(serializers.WebSocketTtsRequest.jsonOrThrow(inputs, { unrecognizedObjectKeys: "strip" })));
|
|
94
|
+
const emitter = new emittery_1.default();
|
|
95
|
+
const source = new source_1.default({
|
|
96
|
+
sampleRate: __classPrivateFieldGet(this, _Websocket_sampleRate, "f"),
|
|
97
|
+
encoding: __classPrivateFieldGet(this, _Websocket_encoding, "f"),
|
|
98
|
+
container: __classPrivateFieldGet(this, _Websocket_container, "f"),
|
|
99
|
+
});
|
|
100
|
+
// Used to signal that the stream is complete, either because the
|
|
101
|
+
// WebSocket has closed, or because the stream has finished.
|
|
102
|
+
const streamCompleteController = new AbortController();
|
|
103
|
+
// Set a timeout.
|
|
104
|
+
let timeoutId = null;
|
|
105
|
+
if (timeout > 0) {
|
|
106
|
+
timeoutId = setTimeout(streamCompleteController.abort, timeout);
|
|
139
107
|
}
|
|
140
|
-
|
|
108
|
+
const handleMessage = (0, utils_1.createMessageHandlerForContextId)(inputs.contextId, ({ chunk, message, data }) => __awaiter(this, void 0, void 0, function* () {
|
|
109
|
+
emitter.emit("message", message);
|
|
110
|
+
if (data.type === "timestamps" && data.wordTimestamps) {
|
|
111
|
+
emitter.emit("timestamps", data.wordTimestamps);
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
if ((0, utils_1.isSentinel)(chunk)) {
|
|
115
|
+
yield source.close();
|
|
116
|
+
streamCompleteController.abort();
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
if (timeoutId) {
|
|
120
|
+
clearTimeout(timeoutId);
|
|
121
|
+
timeoutId = setTimeout(streamCompleteController.abort, timeout);
|
|
122
|
+
}
|
|
123
|
+
if (!chunk) {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
yield source.enqueue((0, utils_1.base64ToArray)([chunk], __classPrivateFieldGet(this, _Websocket_encoding, "f")));
|
|
127
|
+
}));
|
|
128
|
+
(_b = this.socket) === null || _b === void 0 ? void 0 : _b.addEventListener("message", handleMessage);
|
|
129
|
+
(_c = this.socket) === null || _c === void 0 ? void 0 : _c.addEventListener("close", () => {
|
|
130
|
+
streamCompleteController.abort();
|
|
131
|
+
});
|
|
132
|
+
(_d = this.socket) === null || _d === void 0 ? void 0 : _d.addEventListener("error", () => {
|
|
133
|
+
streamCompleteController.abort();
|
|
134
|
+
});
|
|
135
|
+
streamCompleteController.signal.addEventListener("abort", () => {
|
|
136
|
+
source.close();
|
|
137
|
+
if (timeoutId) {
|
|
138
|
+
clearTimeout(timeoutId);
|
|
139
|
+
}
|
|
140
|
+
emitter.clearListeners();
|
|
141
|
+
});
|
|
142
|
+
return Object.assign(Object.assign({ source }, (0, utils_1.getEmitteryCallbacks)(emitter)), { stop: streamCompleteController.abort.bind(streamCompleteController) });
|
|
141
143
|
});
|
|
142
|
-
return Object.assign(Object.assign({ source }, (0, utils_1.getEmitteryCallbacks)(emitter)), { stop: streamCompleteController.abort.bind(streamCompleteController) });
|
|
143
144
|
}
|
|
144
145
|
continue(inputs) {
|
|
145
146
|
var _a;
|
package/dist/wrapper/source.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
import Emittery from "emittery";
|
|
1
2
|
import { RawEncoding } from "../api";
|
|
2
3
|
import { SourceEventData, TypedArray } from "./utils";
|
|
3
4
|
export default class Source {
|
|
4
5
|
#private;
|
|
5
|
-
on: <
|
|
6
|
-
once: <
|
|
7
|
-
events: <
|
|
8
|
-
off: <
|
|
6
|
+
on: Emittery<SourceEventData>["on"];
|
|
7
|
+
once: Emittery<SourceEventData>["once"];
|
|
8
|
+
events: Emittery<SourceEventData>["events"];
|
|
9
|
+
off: Emittery<SourceEventData>["off"];
|
|
9
10
|
/**
|
|
10
11
|
* Create a new Source.
|
|
11
12
|
*
|
package/dist/wrapper/source.js
CHANGED
|
@@ -46,7 +46,7 @@ class Source {
|
|
|
46
46
|
this.on = __classPrivateFieldGet(this, _Source_emitter, "f").on.bind(__classPrivateFieldGet(this, _Source_emitter, "f"));
|
|
47
47
|
this.once = __classPrivateFieldGet(this, _Source_emitter, "f").once.bind(__classPrivateFieldGet(this, _Source_emitter, "f"));
|
|
48
48
|
this.events = __classPrivateFieldGet(this, _Source_emitter, "f").events.bind(__classPrivateFieldGet(this, _Source_emitter, "f"));
|
|
49
|
-
this.off = __classPrivateFieldGet(this, _Source_emitter, "f").off.bind(__classPrivateFieldGet(this, _Source_emitter, "f"));
|
|
49
|
+
this.off = __classPrivateFieldGet(this, _Source_emitter, "f").off.bind(__classPrivateFieldGet(this, _Source_emitter, "f").off);
|
|
50
50
|
__classPrivateFieldSet(this, _Source_sampleRate, sampleRate, "f");
|
|
51
51
|
__classPrivateFieldSet(this, _Source_encoding, encoding, "f");
|
|
52
52
|
__classPrivateFieldSet(this, _Source_container, container, "f");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cartesia/cartesia-js",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.3",
|
|
4
4
|
"private": false,
|
|
5
5
|
"repository": "https://github.com/cartesia-ai/cartesia-js",
|
|
6
6
|
"main": "./index.js",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"qs": "6.11.2",
|
|
20
20
|
"readable-stream": "^4.5.2",
|
|
21
21
|
"form-data-encoder": "^4.0.2",
|
|
22
|
-
"emittery": "^
|
|
22
|
+
"emittery": "^0.13.1",
|
|
23
23
|
"human-id": "^4.1.1",
|
|
24
24
|
"ws": "^8.15.13"
|
|
25
25
|
},
|
package/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "2.0.
|
|
1
|
+
export declare const SDK_VERSION = "2.0.3";
|
package/version.js
CHANGED
package/wrapper/Websocket.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ReconnectingWebSocket, Options } from "../core/websocket";
|
|
2
2
|
import type { WebSocketStreamOptions, WebSocketTtsRequest, WordTimestamps } from "../api";
|
|
3
3
|
import { ConnectionEventData, WebSocketOptions, EmitteryCallbacks } from "./utils";
|
|
4
|
-
import { Tts } from "api/resources/tts/client/Client";
|
|
4
|
+
import { Tts } from "../api/resources/tts/client/Client";
|
|
5
5
|
import Source from "./source";
|
|
6
6
|
export default class Websocket {
|
|
7
7
|
#private;
|
|
@@ -17,31 +17,14 @@ export default class Websocket {
|
|
|
17
17
|
* If set to `0`, the stream will not time out.
|
|
18
18
|
* @returns A Source object that can be passed to a Player to play the audio.
|
|
19
19
|
* @returns An Emittery instance that emits messages from the WebSocket.
|
|
20
|
-
* @returns An abort function that can be called to cancel the stream.
|
|
21
20
|
*/
|
|
22
|
-
send(inputs: WebSocketTtsRequest, { timeout }?: WebSocketStreamOptions): {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
};
|
|
27
|
-
on: <Name extends "timestamps" | "message" | keyof import("emittery").OmnipresentEventData>(eventName: Name | readonly Name[], listener: (eventData: ({
|
|
28
|
-
message: string;
|
|
29
|
-
timestamps: WordTimestamps;
|
|
30
|
-
} & import("emittery").OmnipresentEventData)[Name]) => void | Promise<void>) => import("emittery").UnsubscribeFunction;
|
|
31
|
-
off: <Name_1 extends "timestamps" | "message" | keyof import("emittery").OmnipresentEventData>(eventName: Name_1 | readonly Name_1[], listener: (eventData: ({
|
|
32
|
-
message: string;
|
|
33
|
-
timestamps: WordTimestamps;
|
|
34
|
-
} & import("emittery").OmnipresentEventData)[Name_1]) => void | Promise<void>) => void;
|
|
35
|
-
once: <Name_2 extends "timestamps" | "message" | keyof import("emittery").OmnipresentEventData>(eventName: Name_2 | readonly Name_2[]) => import("emittery").EmitteryOncePromise<({
|
|
36
|
-
message: string;
|
|
37
|
-
timestamps: WordTimestamps;
|
|
38
|
-
} & import("emittery").OmnipresentEventData)[Name_2]>;
|
|
39
|
-
events: <Name_3 extends "timestamps" | "message">(eventName: Name_3 | readonly Name_3[]) => AsyncIterableIterator<{
|
|
40
|
-
message: string;
|
|
41
|
-
timestamps: WordTimestamps;
|
|
42
|
-
}[Name_3]>;
|
|
21
|
+
send(inputs: WebSocketTtsRequest, { timeout }?: WebSocketStreamOptions): Promise<EmitteryCallbacks<{
|
|
22
|
+
message: string;
|
|
23
|
+
timestamps: WordTimestamps;
|
|
24
|
+
}> & {
|
|
43
25
|
source: Source;
|
|
44
|
-
|
|
26
|
+
stop: unknown;
|
|
27
|
+
}>;
|
|
45
28
|
continue(inputs: WebSocketTtsRequest): void;
|
|
46
29
|
/**
|
|
47
30
|
* Authenticate and connect to a Cartesia streaming WebSocket.
|
package/wrapper/Websocket.js
CHANGED
|
@@ -77,69 +77,70 @@ class Websocket {
|
|
|
77
77
|
* If set to `0`, the stream will not time out.
|
|
78
78
|
* @returns A Source object that can be passed to a Player to play the audio.
|
|
79
79
|
* @returns An Emittery instance that emits messages from the WebSocket.
|
|
80
|
-
* @returns An abort function that can be called to cancel the stream.
|
|
81
80
|
*/
|
|
82
81
|
send(inputs, { timeout = 0 } = {}) {
|
|
83
82
|
var _a, _b, _c, _d;
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
if (!inputs.contextId) {
|
|
88
|
-
inputs.contextId = __classPrivateFieldGet(this, _Websocket_instances, "m", _Websocket_generateId).call(this);
|
|
89
|
-
}
|
|
90
|
-
if (!inputs.outputFormat) {
|
|
91
|
-
inputs.outputFormat = (0, utils_1.resolveOutputFormat)(__classPrivateFieldGet(this, _Websocket_container, "f"), __classPrivateFieldGet(this, _Websocket_encoding, "f"), __classPrivateFieldGet(this, _Websocket_sampleRate, "f"));
|
|
92
|
-
}
|
|
93
|
-
(_a = this.socket) === null || _a === void 0 ? void 0 : _a.send(JSON.stringify(serializers.WebSocketTtsRequest.jsonOrThrow(inputs, { unrecognizedObjectKeys: "strip" })));
|
|
94
|
-
const emitter = new emittery_1.default();
|
|
95
|
-
const source = new source_1.default({
|
|
96
|
-
sampleRate: __classPrivateFieldGet(this, _Websocket_sampleRate, "f"),
|
|
97
|
-
encoding: __classPrivateFieldGet(this, _Websocket_encoding, "f"),
|
|
98
|
-
container: __classPrivateFieldGet(this, _Websocket_container, "f"),
|
|
99
|
-
});
|
|
100
|
-
// Used to signal that the stream is complete, either because the
|
|
101
|
-
// WebSocket has closed, or because the stream has finished.
|
|
102
|
-
const streamCompleteController = new AbortController();
|
|
103
|
-
// Set a timeout.
|
|
104
|
-
let timeoutId = null;
|
|
105
|
-
if (timeout > 0) {
|
|
106
|
-
timeoutId = setTimeout(streamCompleteController.abort, timeout);
|
|
107
|
-
}
|
|
108
|
-
const handleMessage = (0, utils_1.createMessageHandlerForContextId)(inputs.contextId, ({ chunk, message, data }) => __awaiter(this, void 0, void 0, function* () {
|
|
109
|
-
emitter.emit("message", message);
|
|
110
|
-
if (data.type === "timestamps" && data.wordTimestamps) {
|
|
111
|
-
emitter.emit("timestamps", data.wordTimestamps);
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
if ((0, utils_1.isSentinel)(chunk)) {
|
|
115
|
-
yield source.close();
|
|
116
|
-
streamCompleteController.abort();
|
|
117
|
-
return;
|
|
83
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
84
|
+
if (!__classPrivateFieldGet(this, _Websocket_isConnected, "f")) {
|
|
85
|
+
throw new Error("Not connected to WebSocket. Call .connect() first.");
|
|
118
86
|
}
|
|
119
|
-
if (
|
|
120
|
-
|
|
121
|
-
timeoutId = setTimeout(streamCompleteController.abort, timeout);
|
|
87
|
+
if (!inputs.contextId) {
|
|
88
|
+
inputs.contextId = __classPrivateFieldGet(this, _Websocket_instances, "m", _Websocket_generateId).call(this);
|
|
122
89
|
}
|
|
123
|
-
if (!
|
|
124
|
-
|
|
90
|
+
if (!inputs.outputFormat) {
|
|
91
|
+
inputs.outputFormat = (0, utils_1.resolveOutputFormat)(__classPrivateFieldGet(this, _Websocket_container, "f"), __classPrivateFieldGet(this, _Websocket_encoding, "f"), __classPrivateFieldGet(this, _Websocket_sampleRate, "f"));
|
|
125
92
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
93
|
+
(_a = this.socket) === null || _a === void 0 ? void 0 : _a.send(JSON.stringify(serializers.WebSocketTtsRequest.jsonOrThrow(inputs, { unrecognizedObjectKeys: "strip" })));
|
|
94
|
+
const emitter = new emittery_1.default();
|
|
95
|
+
const source = new source_1.default({
|
|
96
|
+
sampleRate: __classPrivateFieldGet(this, _Websocket_sampleRate, "f"),
|
|
97
|
+
encoding: __classPrivateFieldGet(this, _Websocket_encoding, "f"),
|
|
98
|
+
container: __classPrivateFieldGet(this, _Websocket_container, "f"),
|
|
99
|
+
});
|
|
100
|
+
// Used to signal that the stream is complete, either because the
|
|
101
|
+
// WebSocket has closed, or because the stream has finished.
|
|
102
|
+
const streamCompleteController = new AbortController();
|
|
103
|
+
// Set a timeout.
|
|
104
|
+
let timeoutId = null;
|
|
105
|
+
if (timeout > 0) {
|
|
106
|
+
timeoutId = setTimeout(streamCompleteController.abort, timeout);
|
|
139
107
|
}
|
|
140
|
-
|
|
108
|
+
const handleMessage = (0, utils_1.createMessageHandlerForContextId)(inputs.contextId, ({ chunk, message, data }) => __awaiter(this, void 0, void 0, function* () {
|
|
109
|
+
emitter.emit("message", message);
|
|
110
|
+
if (data.type === "timestamps" && data.wordTimestamps) {
|
|
111
|
+
emitter.emit("timestamps", data.wordTimestamps);
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
if ((0, utils_1.isSentinel)(chunk)) {
|
|
115
|
+
yield source.close();
|
|
116
|
+
streamCompleteController.abort();
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
if (timeoutId) {
|
|
120
|
+
clearTimeout(timeoutId);
|
|
121
|
+
timeoutId = setTimeout(streamCompleteController.abort, timeout);
|
|
122
|
+
}
|
|
123
|
+
if (!chunk) {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
yield source.enqueue((0, utils_1.base64ToArray)([chunk], __classPrivateFieldGet(this, _Websocket_encoding, "f")));
|
|
127
|
+
}));
|
|
128
|
+
(_b = this.socket) === null || _b === void 0 ? void 0 : _b.addEventListener("message", handleMessage);
|
|
129
|
+
(_c = this.socket) === null || _c === void 0 ? void 0 : _c.addEventListener("close", () => {
|
|
130
|
+
streamCompleteController.abort();
|
|
131
|
+
});
|
|
132
|
+
(_d = this.socket) === null || _d === void 0 ? void 0 : _d.addEventListener("error", () => {
|
|
133
|
+
streamCompleteController.abort();
|
|
134
|
+
});
|
|
135
|
+
streamCompleteController.signal.addEventListener("abort", () => {
|
|
136
|
+
source.close();
|
|
137
|
+
if (timeoutId) {
|
|
138
|
+
clearTimeout(timeoutId);
|
|
139
|
+
}
|
|
140
|
+
emitter.clearListeners();
|
|
141
|
+
});
|
|
142
|
+
return Object.assign(Object.assign({ source }, (0, utils_1.getEmitteryCallbacks)(emitter)), { stop: streamCompleteController.abort.bind(streamCompleteController) });
|
|
141
143
|
});
|
|
142
|
-
return Object.assign(Object.assign({ source }, (0, utils_1.getEmitteryCallbacks)(emitter)), { stop: streamCompleteController.abort.bind(streamCompleteController) });
|
|
143
144
|
}
|
|
144
145
|
continue(inputs) {
|
|
145
146
|
var _a;
|
package/wrapper/source.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
import Emittery from "emittery";
|
|
1
2
|
import { RawEncoding } from "../api";
|
|
2
3
|
import { SourceEventData, TypedArray } from "./utils";
|
|
3
4
|
export default class Source {
|
|
4
5
|
#private;
|
|
5
|
-
on: <
|
|
6
|
-
once: <
|
|
7
|
-
events: <
|
|
8
|
-
off: <
|
|
6
|
+
on: Emittery<SourceEventData>["on"];
|
|
7
|
+
once: Emittery<SourceEventData>["once"];
|
|
8
|
+
events: Emittery<SourceEventData>["events"];
|
|
9
|
+
off: Emittery<SourceEventData>["off"];
|
|
9
10
|
/**
|
|
10
11
|
* Create a new Source.
|
|
11
12
|
*
|
package/wrapper/source.js
CHANGED
|
@@ -46,7 +46,7 @@ class Source {
|
|
|
46
46
|
this.on = __classPrivateFieldGet(this, _Source_emitter, "f").on.bind(__classPrivateFieldGet(this, _Source_emitter, "f"));
|
|
47
47
|
this.once = __classPrivateFieldGet(this, _Source_emitter, "f").once.bind(__classPrivateFieldGet(this, _Source_emitter, "f"));
|
|
48
48
|
this.events = __classPrivateFieldGet(this, _Source_emitter, "f").events.bind(__classPrivateFieldGet(this, _Source_emitter, "f"));
|
|
49
|
-
this.off = __classPrivateFieldGet(this, _Source_emitter, "f").off.bind(__classPrivateFieldGet(this, _Source_emitter, "f"));
|
|
49
|
+
this.off = __classPrivateFieldGet(this, _Source_emitter, "f").off.bind(__classPrivateFieldGet(this, _Source_emitter, "f").off);
|
|
50
50
|
__classPrivateFieldSet(this, _Source_sampleRate, sampleRate, "f");
|
|
51
51
|
__classPrivateFieldSet(this, _Source_encoding, encoding, "f");
|
|
52
52
|
__classPrivateFieldSet(this, _Source_container, container, "f");
|