@cartesia/cartesia-js 3.0.0-b9 → 3.0.0
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 +126 -0
- package/README.md +18 -7
- package/backcompat/errors.d.mts +1 -2
- package/backcompat/errors.d.mts.map +1 -1
- package/backcompat/errors.d.ts +1 -2
- package/backcompat/errors.d.ts.map +1 -1
- package/backcompat/errors.js +1 -21
- package/backcompat/errors.js.map +1 -1
- package/backcompat/errors.mjs +1 -20
- package/backcompat/errors.mjs.map +1 -1
- package/backcompat/index.d.mts +1 -0
- package/backcompat/index.d.mts.map +1 -1
- package/backcompat/index.d.ts +1 -0
- package/backcompat/index.d.ts.map +1 -1
- package/backcompat/index.js +17 -17
- package/backcompat/index.js.map +1 -1
- package/backcompat/index.mjs +17 -17
- package/backcompat/index.mjs.map +1 -1
- package/backcompat/tts-wrapper.d.mts +33 -10
- package/backcompat/tts-wrapper.d.mts.map +1 -1
- package/backcompat/tts-wrapper.d.ts +33 -10
- package/backcompat/tts-wrapper.d.ts.map +1 -1
- package/backcompat/tts-wrapper.js +85 -28
- package/backcompat/tts-wrapper.js.map +1 -1
- package/backcompat/tts-wrapper.mjs +86 -29
- package/backcompat/tts-wrapper.mjs.map +1 -1
- package/backcompat/types.d.mts +1 -1
- package/backcompat/types.d.mts.map +1 -1
- package/backcompat/types.d.ts +1 -1
- package/backcompat/types.d.ts.map +1 -1
- package/backcompat/utils.d.mts +4 -0
- package/backcompat/utils.d.mts.map +1 -0
- package/backcompat/utils.d.ts +4 -0
- package/backcompat/utils.d.ts.map +1 -0
- package/backcompat/utils.js +39 -0
- package/backcompat/utils.js.map +1 -0
- package/backcompat/utils.mjs +35 -0
- package/backcompat/utils.mjs.map +1 -0
- package/backcompat/voice-changer-wrapper.d.mts +4 -4
- package/backcompat/voice-changer-wrapper.d.mts.map +1 -1
- package/backcompat/voice-changer-wrapper.d.ts +4 -4
- package/backcompat/voice-changer-wrapper.d.ts.map +1 -1
- package/backcompat/voice-changer-wrapper.js +8 -8
- package/backcompat/voice-changer-wrapper.js.map +1 -1
- package/backcompat/voice-changer-wrapper.mjs +8 -8
- package/backcompat/voice-changer-wrapper.mjs.map +1 -1
- package/backcompat/voices-wrapper.d.mts +42 -9
- package/backcompat/voices-wrapper.d.mts.map +1 -1
- package/backcompat/voices-wrapper.d.ts +42 -9
- package/backcompat/voices-wrapper.d.ts.map +1 -1
- package/backcompat/voices-wrapper.js +67 -4
- package/backcompat/voices-wrapper.js.map +1 -1
- package/backcompat/voices-wrapper.mjs +64 -1
- package/backcompat/voices-wrapper.mjs.map +1 -1
- package/client.d.mts +10 -12
- package/client.d.mts.map +1 -1
- package/client.d.ts +10 -12
- package/client.d.ts.map +1 -1
- package/client.js +26 -14
- package/client.js.map +1 -1
- package/client.mjs +26 -14
- package/client.mjs.map +1 -1
- package/internal/parse.d.mts.map +1 -1
- package/internal/parse.d.ts.map +1 -1
- package/internal/parse.js +5 -0
- package/internal/parse.js.map +1 -1
- package/internal/parse.mjs +5 -0
- package/internal/parse.mjs.map +1 -1
- package/internal/tslib.js +17 -17
- package/internal/utils/query.d.mts +2 -0
- package/internal/utils/query.d.mts.map +1 -0
- package/internal/utils/query.d.ts +2 -0
- package/internal/utils/query.d.ts.map +1 -0
- package/internal/utils/query.js +10 -0
- package/internal/utils/query.js.map +1 -0
- package/internal/utils/query.mjs +6 -0
- package/internal/utils/query.mjs.map +1 -0
- package/internal/utils.d.mts +1 -0
- package/internal/utils.d.ts +1 -0
- package/internal/utils.js +1 -0
- package/internal/utils.js.map +1 -1
- package/internal/utils.mjs +1 -0
- package/package.json +10 -11
- package/resources/index.d.mts +1 -2
- package/resources/index.d.mts.map +1 -1
- package/resources/index.d.ts +1 -2
- package/resources/index.d.ts.map +1 -1
- package/resources/index.js +1 -3
- package/resources/index.js.map +1 -1
- package/resources/index.mjs +0 -1
- package/resources/index.mjs.map +1 -1
- package/resources/tts/index.d.mts +3 -1
- package/resources/tts/index.d.mts.map +1 -1
- package/resources/tts/index.d.ts +3 -1
- package/resources/tts/index.d.ts.map +1 -1
- package/resources/tts/index.js +6 -1
- package/resources/tts/index.js.map +1 -1
- package/resources/tts/index.mjs +2 -0
- package/resources/tts/index.mjs.map +1 -1
- package/resources/tts/internal-base.d.mts +6 -1
- package/resources/tts/internal-base.d.mts.map +1 -1
- package/resources/tts/internal-base.d.ts +6 -1
- package/resources/tts/internal-base.d.ts.map +1 -1
- package/resources/tts/internal-base.js +9 -1
- package/resources/tts/internal-base.js.map +1 -1
- package/resources/tts/internal-base.mjs +7 -0
- package/resources/tts/internal-base.mjs.map +1 -1
- package/resources/tts/tts.d.mts +129 -11
- package/resources/tts/tts.d.mts.map +1 -1
- package/resources/tts/tts.d.ts +129 -11
- package/resources/tts/tts.d.ts.map +1 -1
- package/resources/tts/tts.js +39 -0
- package/resources/tts/tts.js.map +1 -1
- package/resources/tts/tts.mjs +39 -0
- package/resources/tts/tts.mjs.map +1 -1
- package/resources/tts/ws.d.mts +123 -4
- package/resources/tts/ws.d.mts.map +1 -1
- package/resources/tts/ws.d.ts +123 -4
- package/resources/tts/ws.d.ts.map +1 -1
- package/resources/tts/ws.js +360 -15
- package/resources/tts/ws.js.map +1 -1
- package/resources/tts/ws.mjs +359 -14
- package/resources/tts/ws.mjs.map +1 -1
- package/resources/voice-changer.d.mts +6 -6
- package/resources/voice-changer.d.mts.map +1 -1
- package/resources/voice-changer.d.ts +6 -6
- package/resources/voice-changer.d.ts.map +1 -1
- package/resources/voice-changer.js +6 -1
- package/resources/voice-changer.js.map +1 -1
- package/resources/voice-changer.mjs +6 -1
- package/resources/voice-changer.mjs.map +1 -1
- package/resources/voices.d.mts +1 -1
- package/resources/voices.d.mts.map +1 -1
- package/resources/voices.d.ts +1 -1
- package/resources/voices.d.ts.map +1 -1
- package/src/backcompat/errors.ts +16 -44
- package/src/backcompat/index.ts +64 -67
- package/src/backcompat/tts-wrapper.ts +405 -322
- package/src/backcompat/types.ts +13 -13
- package/src/backcompat/utils.ts +34 -0
- package/src/backcompat/voice-changer-wrapper.ts +58 -56
- package/src/backcompat/voices-wrapper.ts +238 -150
- package/src/client.ts +45 -29
- package/src/internal/parse.ts +6 -0
- package/src/internal/utils/query.ts +7 -0
- package/src/internal/utils.ts +1 -0
- package/src/resources/index.ts +3 -1
- package/src/resources/tts/index.ts +6 -0
- package/src/resources/tts/internal-base.ts +12 -1
- package/src/resources/tts/tts.ts +187 -13
- package/src/resources/tts/ws.ts +428 -16
- package/src/resources/voice-changer.ts +12 -7
- package/src/resources/voices.ts +2 -1
- package/src/version.ts +1 -1
- package/version.d.mts +1 -1
- package/version.d.mts.map +1 -1
- package/version.d.ts +1 -1
- package/version.d.ts.map +1 -1
- package/version.js +1 -1
- package/version.js.map +1 -1
- package/version.mjs +1 -1
- package/version.mjs.map +1 -1
- package/resources/infill.d.mts +0 -71
- package/resources/infill.d.mts.map +0 -1
- package/resources/infill.d.ts +0 -71
- package/resources/infill.d.ts.map +0 -1
- package/resources/infill.js +0 -35
- package/resources/infill.js.map +0 -1
- package/resources/infill.mjs +0 -31
- package/resources/infill.mjs.map +0 -1
- package/src/resources/infill.ts +0 -100
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,131 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 3.0.0 (2026-03-02)
|
|
4
|
+
|
|
5
|
+
Full Changelog: [v3.0.0-b17...v3.0.0](https://github.com/cartesia-ai/cartesia-js/compare/v3.0.0-b17...v3.0.0)
|
|
6
|
+
|
|
7
|
+
### Features
|
|
8
|
+
|
|
9
|
+
* **api:** add flush_id to chunks response and binary response to voice changer ([1d98580](https://github.com/cartesia-ai/cartesia-js/commit/1d98580ffe61be7a86d28bdf1ee5bb1d50df7382))
|
|
10
|
+
* **api:** group infill output_format ([ac4ded7](https://github.com/cartesia-ai/cartesia-js/commit/ac4ded743720fedbc4517c9c94ed75e79bb2f18b))
|
|
11
|
+
* **api:** infill output_format ([c3d3dac](https://github.com/cartesia-ai/cartesia-js/commit/c3d3dac2d3756038b2d199a75c204413c23a19d1))
|
|
12
|
+
* **api:** infill response ([b9cbaa2](https://github.com/cartesia-ai/cartesia-js/commit/b9cbaa27c220db26462aee7c80692df89edeb8fe))
|
|
13
|
+
* **api:** inline websocketresponse type definitions ([c5cbfbf](https://github.com/cartesia-ai/cartesia-js/commit/c5cbfbfeca17b0f799d791a9ba32c8d2fd18cda8))
|
|
14
|
+
* **api:** move infill and websocket_connect ([a987ebd](https://github.com/cartesia-ai/cartesia-js/commit/a987ebdddc35712a26bbad443672ee45a78b4afc))
|
|
15
|
+
* **api:** update headline example ([715db7e](https://github.com/cartesia-ai/cartesia-js/commit/715db7e02534a0e2254da61fc7342b240e7f251e))
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
* **client:** avoid memory leak with abort signals ([fb63460](https://github.com/cartesia-ai/cartesia-js/commit/fb63460d3701ac1684f5385f7d882f5e71747f14))
|
|
21
|
+
* **client:** avoid removing abort listener too early ([b89ee81](https://github.com/cartesia-ai/cartesia-js/commit/b89ee81caf0ae443eeac9898fb807c34545eb70b))
|
|
22
|
+
* **docs/contributing:** correct pnpm link command ([d5830ae](https://github.com/cartesia-ai/cartesia-js/commit/d5830aed6fd927265bfdbbe875aed7093e0f24cc))
|
|
23
|
+
* **internal:** skip tests that depend on mock server ([e55b44f](https://github.com/cartesia-ai/cartesia-js/commit/e55b44f8402a4f59f59e4780e06300260c9b8170))
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
### Chores
|
|
27
|
+
|
|
28
|
+
* **client:** do not parse responses with empty content-length ([ed0b69e](https://github.com/cartesia-ai/cartesia-js/commit/ed0b69e1c1d6d7854bccfb2d65ef273cc9564d93))
|
|
29
|
+
* **client:** restructure abort controller binding ([e969433](https://github.com/cartesia-ai/cartesia-js/commit/e9694332f28915c81908a09bffc1d877befb848f))
|
|
30
|
+
* **internal/client:** fix form-urlencoded requests ([80aceb7](https://github.com/cartesia-ai/cartesia-js/commit/80aceb72e17b1c6989e2ea9e53b83d29cdfe766e))
|
|
31
|
+
* **internal:** avoid type checking errors with ts-reset ([3eb6f15](https://github.com/cartesia-ai/cartesia-js/commit/3eb6f15cb8faa30ab5b759599a0bf74243851a5b))
|
|
32
|
+
* **internal:** fix pagination internals not accepting option promises ([822f34f](https://github.com/cartesia-ai/cartesia-js/commit/822f34fab79bd7274e15fe383798696e9ae3930b))
|
|
33
|
+
* **internal:** move stringifyQuery implementation to internal function ([ec23288](https://github.com/cartesia-ai/cartesia-js/commit/ec23288564c1586c22e64581ff4d77763a00a268))
|
|
34
|
+
* **internal:** remove mock server code ([2fe0e85](https://github.com/cartesia-ai/cartesia-js/commit/2fe0e85f5884a797b9bbbe80013e30f17f6ca5cb))
|
|
35
|
+
* **internal:** upgrade pnpm ([948fa2d](https://github.com/cartesia-ai/cartesia-js/commit/948fa2dbdc13671eda76493bbac27976fb70649b))
|
|
36
|
+
* **internal:** upgrade pnpm version ([9cc6aa2](https://github.com/cartesia-ai/cartesia-js/commit/9cc6aa2b033369cea8ade26c92bca06c3f6d4a79))
|
|
37
|
+
* update mock server docs ([4f1e1c6](https://github.com/cartesia-ai/cartesia-js/commit/4f1e1c6f34149aa4a65d4d562e32d19f8c247ce9))
|
|
38
|
+
|
|
39
|
+
## 3.0.0-b17 (2026-01-30)
|
|
40
|
+
|
|
41
|
+
Full Changelog: [v3.0.0-b16...v3.0.0-b17](https://github.com/cartesia-ai/cartesia-js/compare/v3.0.0-b16...v3.0.0-b17)
|
|
42
|
+
|
|
43
|
+
### Features
|
|
44
|
+
|
|
45
|
+
* **api:** update api version ([e98298c](https://github.com/cartesia-ai/cartesia-js/commit/e98298c56b49f1bf1a8e494edfaafd78cc5ebd4c))
|
|
46
|
+
|
|
47
|
+
## 3.0.0-b16 (2026-01-29)
|
|
48
|
+
|
|
49
|
+
Full Changelog: [v3.0.0-b15...v3.0.0-b16](https://github.com/cartesia-ai/cartesia-js/compare/v3.0.0-b15...v3.0.0-b16)
|
|
50
|
+
|
|
51
|
+
### Features
|
|
52
|
+
|
|
53
|
+
* **api:** add jsr key to npm target ([5afbf2e](https://github.com/cartesia-ai/cartesia-js/commit/5afbf2e0bad2551e2dbaa0be31553f98fdeb9724))
|
|
54
|
+
* **api:** update js target ([a39e957](https://github.com/cartesia-ai/cartesia-js/commit/a39e9571aa58fb6e1bbddeb523ce83527293a58b))
|
|
55
|
+
|
|
56
|
+
## 3.0.0-b15 (2026-01-29)
|
|
57
|
+
|
|
58
|
+
Full Changelog: [v3.0.0-b14...v3.0.0-b15](https://github.com/cartesia-ai/cartesia-js/compare/v3.0.0-b14...v3.0.0-b15)
|
|
59
|
+
|
|
60
|
+
### Features
|
|
61
|
+
|
|
62
|
+
* **api:** add release environment ([501864c](https://github.com/cartesia-ai/cartesia-js/commit/501864ca051ad7197b54bbb8c08039bb883ff4fd))
|
|
63
|
+
* **api:** update release environment ([c148860](https://github.com/cartesia-ai/cartesia-js/commit/c148860eea503d0720b08e7d187272625491d918))
|
|
64
|
+
* ws context helpers ([d1898fb](https://github.com/cartesia-ai/cartesia-js/commit/d1898fbe768daeb527282a4e7bcc53d4e4f7af51))
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
### Bug Fixes
|
|
68
|
+
|
|
69
|
+
* bytes returns arraybuffer ([#26](https://github.com/cartesia-ai/cartesia-js/issues/26)) ([229ea0f](https://github.com/cartesia-ai/cartesia-js/commit/229ea0f08c21d9a5fb56be8fac2a044368a33c34))
|
|
70
|
+
* export correct client ([#21](https://github.com/cartesia-ai/cartesia-js/issues/21)) ([e8456dd](https://github.com/cartesia-ai/cartesia-js/commit/e8456dd39a91f55cb27cd038cef0dbcd1b1acf3e))
|
|
71
|
+
* include message in `TimeoutError` for `.fernignore` clients. ([#41](https://github.com/cartesia-ai/cartesia-js/issues/41)) ([d50a5b9](https://github.com/cartesia-ai/cartesia-js/commit/d50a5b9a30a3c7001572d60314a6a3bb752ac28f))
|
|
72
|
+
* upgrade qs from 6.11.2 to 6.13.0 ([#24](https://github.com/cartesia-ai/cartesia-js/issues/24)) ([fddd4ac](https://github.com/cartesia-ai/cartesia-js/commit/fddd4acef6bd20d3859712b25f8774c6d04c2031))
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
### Chores
|
|
76
|
+
|
|
77
|
+
* downgrade emittery for cjs compatiblity ([#23](https://github.com/cartesia-ai/cartesia-js/issues/23)) ([015d941](https://github.com/cartesia-ai/cartesia-js/commit/015d9414cff876e44adf776cecca73bc081c2b48))
|
|
78
|
+
* export `WebPlayer` ([#31](https://github.com/cartesia-ai/cartesia-js/issues/31)) ([e31186e](https://github.com/cartesia-ai/cartesia-js/commit/e31186e75fbb22c5a79d82ddea5b160f3dd05e04))
|
|
79
|
+
* fix compile ([#64](https://github.com/cartesia-ai/cartesia-js/issues/64)) ([1de7fd0](https://github.com/cartesia-ai/cartesia-js/commit/1de7fd0b7891e54a13a78699516e610886578681))
|
|
80
|
+
* **internal:** codegen related update ([e44abc2](https://github.com/cartesia-ai/cartesia-js/commit/e44abc24b5c18735c74f1a9345b6f9d312aad338))
|
|
81
|
+
* remove `ci.yml` branch ([#22](https://github.com/cartesia-ai/cartesia-js/issues/22)) ([6d2201a](https://github.com/cartesia-ai/cartesia-js/commit/6d2201a7d13172768b5d17c2e8dc5ebfd3d9bcd2))
|
|
82
|
+
* remove fernignore on ArrayBuffer ([#55](https://github.com/cartesia-ai/cartesia-js/issues/55)) ([b10bbc7](https://github.com/cartesia-ai/cartesia-js/commit/b10bbc75335089004b38f4b547d92d789f15275c))
|
|
83
|
+
* remove ignored `README.md` ([#56](https://github.com/cartesia-ai/cartesia-js/issues/56)) ([ee6d2dd](https://github.com/cartesia-ai/cartesia-js/commit/ee6d2dd17b0e392189e553affdc411fcde42d5ed))
|
|
84
|
+
* remove STT .fernignore ([#65](https://github.com/cartesia-ai/cartesia-js/issues/65)) ([3c0ce3e](https://github.com/cartesia-ai/cartesia-js/commit/3c0ce3e0449166e3e7dc766eeeb90a991e12e401))
|
|
85
|
+
* sync repo ([1ad7016](https://github.com/cartesia-ai/cartesia-js/commit/1ad7016dc4222eb858389a0eed7dcd0558713346))
|
|
86
|
+
* update `apiKeyHeader` to `apiKey` ([#20](https://github.com/cartesia-ai/cartesia-js/issues/20)) ([0f54d2e](https://github.com/cartesia-ai/cartesia-js/commit/0f54d2ee812cd080c8722a55a157b63a37f885d5))
|
|
87
|
+
* update README ([#58](https://github.com/cartesia-ai/cartesia-js/issues/58)) ([c24f0a6](https://github.com/cartesia-ai/cartesia-js/commit/c24f0a6bfb43647723e322215ffc59f3b307b700))
|
|
88
|
+
* Update README.md ([#32](https://github.com/cartesia-ai/cartesia-js/issues/32)) ([8d36b88](https://github.com/cartesia-ai/cartesia-js/commit/8d36b88f76a56b470e57d16190f127d915e934e9))
|
|
89
|
+
* update SDK settings ([e2be8ea](https://github.com/cartesia-ai/cartesia-js/commit/e2be8ea4b2dbc3891029efa3f40bec512622f78d))
|
|
90
|
+
|
|
91
|
+
## 3.0.0-b14 (2026-01-23)
|
|
92
|
+
|
|
93
|
+
Full Changelog: [v3.0.0-b13...v3.0.0-b14](https://github.com/cartesia-ai/cartesia-js-internal/compare/v3.0.0-b13...v3.0.0-b14)
|
|
94
|
+
|
|
95
|
+
## 3.0.0-b13 (2026-01-21)
|
|
96
|
+
|
|
97
|
+
Full Changelog: [v3.0.0-b12...v3.0.0-b13](https://github.com/cartesia-ai/cartesia-js-internal/compare/v3.0.0-b12...v3.0.0-b13)
|
|
98
|
+
|
|
99
|
+
### Features
|
|
100
|
+
|
|
101
|
+
* **api:** remove -> delete ([04c4d03](https://github.com/cartesia-ai/cartesia-js-internal/commit/04c4d03a3e3525ad0e8c72a6372602319cdedb56))
|
|
102
|
+
* wrapper remove -> delete ([e856bda](https://github.com/cartesia-ai/cartesia-js-internal/commit/e856bda9d6bfb07c6df08839087de24380b336be))
|
|
103
|
+
|
|
104
|
+
## 3.0.0-b12 (2026-01-21)
|
|
105
|
+
|
|
106
|
+
Full Changelog: [v3.0.0-b11...v3.0.0-b12](https://github.com/cartesia-ai/cartesia-js-internal/compare/v3.0.0-b11...v3.0.0-b12)
|
|
107
|
+
|
|
108
|
+
### Features
|
|
109
|
+
|
|
110
|
+
* **api:** delete -> remove ([d51a281](https://github.com/cartesia-ai/cartesia-js-internal/commit/d51a2812bb7e5be98d1aa4248e90acc3a4aae0d2))
|
|
111
|
+
* update backcompat voices helpers ([ca4cc6a](https://github.com/cartesia-ai/cartesia-js-internal/commit/ca4cc6a98c2f9165689916e22afd784f56671948))
|
|
112
|
+
|
|
113
|
+
## 3.0.0-b11 (2026-01-20)
|
|
114
|
+
|
|
115
|
+
Full Changelog: [v3.0.0-b10...v3.0.0-b11](https://github.com/cartesia-ai/cartesia-js-internal/compare/v3.0.0-b10...v3.0.0-b11)
|
|
116
|
+
|
|
117
|
+
### Features
|
|
118
|
+
|
|
119
|
+
* **api:** binary response types ([5bdf3e3](https://github.com/cartesia-ai/cartesia-js-internal/commit/5bdf3e3be2867099b8187c186745a509991df91e))
|
|
120
|
+
|
|
121
|
+
## 3.0.0-b10 (2026-01-20)
|
|
122
|
+
|
|
123
|
+
Full Changelog: [v3.0.0-b9...v3.0.0-b10](https://github.com/cartesia-ai/cartesia-js-internal/compare/v3.0.0-b9...v3.0.0-b10)
|
|
124
|
+
|
|
125
|
+
### Features
|
|
126
|
+
|
|
127
|
+
* **api:** voice changer response ([5ca129b](https://github.com/cartesia-ai/cartesia-js-internal/commit/5ca129b1dfa59043560c7866a2cdd87fb03b42bf))
|
|
128
|
+
|
|
3
129
|
## 3.0.0-b9 (2026-01-16)
|
|
4
130
|
|
|
5
131
|
Full Changelog: [v3.0.0-b8...v3.0.0-b9](https://github.com/cartesia-ai/cartesia-js-internal/compare/v3.0.0-b8...v3.0.0-b9)
|
package/README.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
[>)](https://npmjs.org/package/@cartesia/cartesia-js) 
|
|
4
4
|
|
|
5
|
+
> **Note:** This README is for the 3.x beta. For the stable 2.x series, see the [`branch-2.x`](https://github.com/cartesia-ai/cartesia-js/tree/branch-2.x) branch.
|
|
6
|
+
|
|
5
7
|
This library provides convenient access to the Cartesia REST API from server-side TypeScript or JavaScript.
|
|
6
8
|
|
|
7
9
|
The full API of this library can be found in [api.md](api.md).
|
|
@@ -23,13 +25,22 @@ The full API of this library can be found in [api.md](api.md).
|
|
|
23
25
|
import Cartesia from '@cartesia/cartesia-js';
|
|
24
26
|
|
|
25
27
|
const client = new Cartesia({
|
|
26
|
-
|
|
28
|
+
token: 'My Token',
|
|
27
29
|
});
|
|
28
30
|
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
+
const response = await client.tts.generate({
|
|
32
|
+
model_id: 'sonic-3',
|
|
33
|
+
output_format: {
|
|
34
|
+
container: 'wav',
|
|
35
|
+
encoding: 'pcm_f32le',
|
|
36
|
+
sample_rate: 44100,
|
|
37
|
+
},
|
|
38
|
+
transcript: "I have to say that I'd rather stay awake when I'm asleep.",
|
|
39
|
+
voice: { mode: 'id', id: 'e07c00bc-4134-4eae-9ea4-1a55fb45746b' },
|
|
40
|
+
});
|
|
31
41
|
|
|
32
|
-
|
|
42
|
+
const content = await response.blob();
|
|
43
|
+
console.log(content);
|
|
33
44
|
```
|
|
34
45
|
|
|
35
46
|
### Request & Response types
|
|
@@ -185,7 +196,7 @@ while (page.hasNextPage()) {
|
|
|
185
196
|
|
|
186
197
|
## Default Headers
|
|
187
198
|
|
|
188
|
-
We automatically send the `cartesia-version` header set to `2025-04
|
|
199
|
+
We automatically send the `cartesia-version` header set to `2025-11-04`.
|
|
189
200
|
|
|
190
201
|
If you need to, you can override it by setting default headers on a per-request basis.
|
|
191
202
|
|
|
@@ -300,7 +311,7 @@ parameter. This library doesn't validate at runtime that the request matches the
|
|
|
300
311
|
send will be sent as-is.
|
|
301
312
|
|
|
302
313
|
```ts
|
|
303
|
-
client.
|
|
314
|
+
client.tts.generate({
|
|
304
315
|
// ...
|
|
305
316
|
// @ts-expect-error baz is not yet public
|
|
306
317
|
baz: 'undocumented option',
|
|
@@ -410,7 +421,7 @@ This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) con
|
|
|
410
421
|
|
|
411
422
|
We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.
|
|
412
423
|
|
|
413
|
-
We are keen for your feedback; please open an [issue](https://www.github.com/cartesia-ai/cartesia-js
|
|
424
|
+
We are keen for your feedback; please open an [issue](https://www.github.com/cartesia-ai/cartesia-js/issues) with questions, bugs, or suggestions.
|
|
414
425
|
|
|
415
426
|
## Requirements
|
|
416
427
|
|
package/backcompat/errors.d.mts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
export declare class CartesiaClientError extends Error {
|
|
3
3
|
readonly statusCode?: number;
|
|
4
4
|
readonly body?: unknown;
|
|
5
|
-
constructor({ message, statusCode, body
|
|
5
|
+
constructor({ message, statusCode, body }: {
|
|
6
6
|
message?: string;
|
|
7
7
|
statusCode?: number;
|
|
8
8
|
body?: unknown;
|
|
@@ -12,5 +12,4 @@ export declare class CartesiaClientError extends Error {
|
|
|
12
12
|
export declare class CartesiaTimeoutError extends Error {
|
|
13
13
|
constructor(message: string);
|
|
14
14
|
}
|
|
15
|
-
export declare function wrap<T>(promise: Promise<T>): Promise<T>;
|
|
16
15
|
//# sourceMappingURL=errors.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.mts","sourceRoot":"","sources":["../src/backcompat/errors.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"errors.d.mts","sourceRoot":"","sources":["../src/backcompat/errors.ts"],"names":[],"mappings":"AAAA,kGAAkG;AAClG,qBAAa,mBAAoB,SAAQ,KAAK;IAC5C,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC;gBAEZ,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,OAAO,CAAA;KAAE;CAUrG;AAED,iEAAiE;AACjE,qBAAa,oBAAqB,SAAQ,KAAK;gBACjC,OAAO,EAAE,MAAM;CAI5B"}
|
package/backcompat/errors.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
export declare class CartesiaClientError extends Error {
|
|
3
3
|
readonly statusCode?: number;
|
|
4
4
|
readonly body?: unknown;
|
|
5
|
-
constructor({ message, statusCode, body
|
|
5
|
+
constructor({ message, statusCode, body }: {
|
|
6
6
|
message?: string;
|
|
7
7
|
statusCode?: number;
|
|
8
8
|
body?: unknown;
|
|
@@ -12,5 +12,4 @@ export declare class CartesiaClientError extends Error {
|
|
|
12
12
|
export declare class CartesiaTimeoutError extends Error {
|
|
13
13
|
constructor(message: string);
|
|
14
14
|
}
|
|
15
|
-
export declare function wrap<T>(promise: Promise<T>): Promise<T>;
|
|
16
15
|
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/backcompat/errors.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/backcompat/errors.ts"],"names":[],"mappings":"AAAA,kGAAkG;AAClG,qBAAa,mBAAoB,SAAQ,KAAK;IAC5C,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC;gBAEZ,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,OAAO,CAAA;KAAE;CAUrG;AAED,iEAAiE;AACjE,qBAAa,oBAAqB,SAAQ,KAAK;gBACjC,OAAO,EAAE,MAAM;CAI5B"}
|
package/backcompat/errors.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CartesiaTimeoutError = exports.CartesiaClientError = void 0;
|
|
4
|
-
exports.wrap = wrap;
|
|
5
|
-
const error_1 = require("../core/error.js");
|
|
6
4
|
/** @deprecated Use {@link CartesiaError} or specialized error classes from core/error instead. */
|
|
7
5
|
class CartesiaClientError extends Error {
|
|
8
|
-
constructor({ message, statusCode, body
|
|
6
|
+
constructor({ message, statusCode, body }) {
|
|
9
7
|
super(message);
|
|
10
8
|
Object.setPrototypeOf(this, CartesiaClientError.prototype);
|
|
11
9
|
if (statusCode != null) {
|
|
@@ -25,22 +23,4 @@ class CartesiaTimeoutError extends Error {
|
|
|
25
23
|
}
|
|
26
24
|
}
|
|
27
25
|
exports.CartesiaTimeoutError = CartesiaTimeoutError;
|
|
28
|
-
async function wrap(promise) {
|
|
29
|
-
try {
|
|
30
|
-
return await promise;
|
|
31
|
-
}
|
|
32
|
-
catch (e) {
|
|
33
|
-
if (e instanceof error_1.APIConnectionTimeoutError) {
|
|
34
|
-
throw new CartesiaTimeoutError(e.message);
|
|
35
|
-
}
|
|
36
|
-
if (e instanceof error_1.APIError) {
|
|
37
|
-
throw new CartesiaClientError({
|
|
38
|
-
message: e.message,
|
|
39
|
-
statusCode: e.status,
|
|
40
|
-
body: e.error,
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
throw e;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
26
|
//# sourceMappingURL=errors.js.map
|
package/backcompat/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/backcompat/errors.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/backcompat/errors.ts"],"names":[],"mappings":";;;AAAA,kGAAkG;AAClG,MAAa,mBAAoB,SAAQ,KAAK;IAI5C,YAAY,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAA6D;QAClG,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,mBAAmB,CAAC,SAAS,CAAC,CAAC;QAC3D,IAAI,UAAU,IAAI,IAAI,EAAE,CAAC;YACvB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC/B,CAAC;QACD,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;YACvB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACnB,CAAC;IACH,CAAC;CACF;AAdD,kDAcC;AAED,iEAAiE;AACjE,MAAa,oBAAqB,SAAQ,KAAK;IAC7C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,oBAAoB,CAAC,SAAS,CAAC,CAAC;IAC9D,CAAC;CACF;AALD,oDAKC"}
|
package/backcompat/errors.mjs
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { APIConnectionTimeoutError, APIError } from "../core/error.mjs";
|
|
2
1
|
/** @deprecated Use {@link CartesiaError} or specialized error classes from core/error instead. */
|
|
3
2
|
export class CartesiaClientError extends Error {
|
|
4
|
-
constructor({ message, statusCode, body
|
|
3
|
+
constructor({ message, statusCode, body }) {
|
|
5
4
|
super(message);
|
|
6
5
|
Object.setPrototypeOf(this, CartesiaClientError.prototype);
|
|
7
6
|
if (statusCode != null) {
|
|
@@ -19,22 +18,4 @@ export class CartesiaTimeoutError extends Error {
|
|
|
19
18
|
Object.setPrototypeOf(this, CartesiaTimeoutError.prototype);
|
|
20
19
|
}
|
|
21
20
|
}
|
|
22
|
-
export async function wrap(promise) {
|
|
23
|
-
try {
|
|
24
|
-
return await promise;
|
|
25
|
-
}
|
|
26
|
-
catch (e) {
|
|
27
|
-
if (e instanceof APIConnectionTimeoutError) {
|
|
28
|
-
throw new CartesiaTimeoutError(e.message);
|
|
29
|
-
}
|
|
30
|
-
if (e instanceof APIError) {
|
|
31
|
-
throw new CartesiaClientError({
|
|
32
|
-
message: e.message,
|
|
33
|
-
statusCode: e.status,
|
|
34
|
-
body: e.error,
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
throw e;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
21
|
//# sourceMappingURL=errors.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.mjs","sourceRoot":"","sources":["../src/backcompat/errors.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"errors.mjs","sourceRoot":"","sources":["../src/backcompat/errors.ts"],"names":[],"mappings":"AAAA,kGAAkG;AAClG,MAAM,OAAO,mBAAoB,SAAQ,KAAK;IAI5C,YAAY,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAA6D;QAClG,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,mBAAmB,CAAC,SAAS,CAAC,CAAC;QAC3D,IAAI,UAAU,IAAI,IAAI,EAAE,CAAC;YACvB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC/B,CAAC;QACD,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;YACvB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACnB,CAAC;IACH,CAAC;CACF;AAED,iEAAiE;AACjE,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IAC7C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,oBAAoB,CAAC,SAAS,CAAC,CAAC;IAC9D,CAAC;CACF"}
|
package/backcompat/index.d.mts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/backcompat/index.ts"],"names":[],"mappings":"OACO,EAAE,UAAU,EAAE;OACd,EAAE,aAAa,EAAE;OACjB,EAAE,mBAAmB,EAAE;
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/backcompat/index.ts"],"names":[],"mappings":"OACO,EAAE,UAAU,EAAE;OACd,EAAE,aAAa,EAAE;OACjB,EAAE,mBAAmB,EAAE;OAEvB,KAAK,EAAE,qBAAqB,EAAY;AAuC/C;;;;GAIG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,MAAM,CAAW;IAClB,GAAG,EAAE,UAAU,CAAC;IAChB,MAAM,EAAE,aAAa,CAAC;IACtB,YAAY,EAAE,mBAAmB,CAAC;gBAE7B,OAAO,GAAE,qBAA0B;CAuBhD"}
|
package/backcompat/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/backcompat/index.ts"],"names":[],"mappings":"OACO,EAAE,UAAU,EAAE;OACd,EAAE,aAAa,EAAE;OACjB,EAAE,mBAAmB,EAAE;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/backcompat/index.ts"],"names":[],"mappings":"OACO,EAAE,UAAU,EAAE;OACd,EAAE,aAAa,EAAE;OACjB,EAAE,mBAAmB,EAAE;OAEvB,KAAK,EAAE,qBAAqB,EAAY;AAuC/C;;;;GAIG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,MAAM,CAAW;IAClB,GAAG,EAAE,UAAU,CAAC;IAChB,MAAM,EAAE,aAAa,CAAC;IACtB,YAAY,EAAE,mBAAmB,CAAC;gBAE7B,OAAO,GAAE,qBAA0B;CAuBhD"}
|
package/backcompat/index.js
CHANGED
|
@@ -6,8 +6,9 @@ const client_1 = require("../client.js");
|
|
|
6
6
|
const tts_wrapper_1 = require("./tts-wrapper.js");
|
|
7
7
|
const voices_wrapper_1 = require("./voices-wrapper.js");
|
|
8
8
|
const voice_changer_wrapper_1 = require("./voice-changer-wrapper.js");
|
|
9
|
+
const headers_1 = require("../internal/headers.js");
|
|
9
10
|
async function resolveSupplier(supplier) {
|
|
10
|
-
if (typeof supplier ===
|
|
11
|
+
if (typeof supplier === 'function') {
|
|
11
12
|
return supplier();
|
|
12
13
|
}
|
|
13
14
|
return supplier;
|
|
@@ -17,26 +18,24 @@ class DynamicCartesia extends client_1.Cartesia {
|
|
|
17
18
|
super(options);
|
|
18
19
|
this.apiKeySupplier = options.apiKeySupplier;
|
|
19
20
|
}
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
validateHeaders(_headers) {
|
|
22
|
+
// Skip validation if we have a dynamic API key supplier
|
|
23
|
+
// The key will be resolved and added in authHeaders
|
|
24
|
+
if (this.apiKeySupplier) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
super.validateHeaders(_headers);
|
|
28
|
+
}
|
|
29
|
+
async authHeaders(opts) {
|
|
30
|
+
// If we have a dynamic supplier, resolve it and return the auth header
|
|
22
31
|
if (this.apiKeySupplier) {
|
|
23
32
|
const key = await resolveSupplier(this.apiKeySupplier);
|
|
24
33
|
if (key) {
|
|
25
|
-
|
|
26
|
-
if (!request.headers) {
|
|
27
|
-
request.headers = { Authorization: authHeader };
|
|
28
|
-
}
|
|
29
|
-
else if (request.headers instanceof Headers) {
|
|
30
|
-
request.headers.set("Authorization", authHeader);
|
|
31
|
-
}
|
|
32
|
-
else if (Array.isArray(request.headers)) {
|
|
33
|
-
request.headers.push(["Authorization", authHeader]);
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
request.headers["Authorization"] = authHeader;
|
|
37
|
-
}
|
|
34
|
+
return (0, headers_1.buildHeaders)([{ Authorization: `Bearer ${key}` }]);
|
|
38
35
|
}
|
|
39
36
|
}
|
|
37
|
+
// Otherwise, fall back to default behavior
|
|
38
|
+
return super.authHeaders(opts);
|
|
40
39
|
}
|
|
41
40
|
}
|
|
42
41
|
/**
|
|
@@ -49,7 +48,7 @@ class CartesiaClient {
|
|
|
49
48
|
const newOptions = {};
|
|
50
49
|
let apiKeySupplier;
|
|
51
50
|
if (options.apiKey) {
|
|
52
|
-
if (typeof options.apiKey ===
|
|
51
|
+
if (typeof options.apiKey === 'function') {
|
|
53
52
|
apiKeySupplier = options.apiKey;
|
|
54
53
|
}
|
|
55
54
|
else {
|
|
@@ -74,4 +73,5 @@ tslib_1.__exportStar(require("./voices-wrapper.js"), exports);
|
|
|
74
73
|
tslib_1.__exportStar(require("./voice-changer-wrapper.js"), exports);
|
|
75
74
|
tslib_1.__exportStar(require("./types.js"), exports);
|
|
76
75
|
tslib_1.__exportStar(require("./errors.js"), exports);
|
|
76
|
+
tslib_1.__exportStar(require("./utils.js"), exports);
|
|
77
77
|
//# sourceMappingURL=index.js.map
|
package/backcompat/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/backcompat/index.ts"],"names":[],"mappings":";;;;AAAA,yCAAyD;AACzD,kDAA2C;AAC3C,wDAAiD;AACjD,sEAA8D;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/backcompat/index.ts"],"names":[],"mappings":";;;;AAAA,yCAAyD;AACzD,kDAA2C;AAC3C,wDAAiD;AACjD,sEAA8D;AAC9D,oDAAyE;AAGzE,KAAK,UAAU,eAAe,CAAI,QAAqB;IACrD,IAAI,OAAO,QAAQ,KAAK,UAAU,EAAE,CAAC;QACnC,OAAQ,QAAiC,EAAE,CAAC;IAC9C,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,MAAM,eAAgB,SAAQ,iBAAQ;IAGpC,YAAY,OAA0E;QACpF,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC;IAC/C,CAAC;IAEkB,eAAe,CAAC,QAAyB;QAC1D,wDAAwD;Q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rE,IAAI,CAAC,GAAG,GAAG,IAAI,wBAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACvC,IAAI,CAAC,MAAM,GAAG,IAAI,8BAAa,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC7C,IAAI,CAAC,YAAY,GAAG,IAAI,2CAAmB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC3D,CAAC;CACF;AA7BD,wCA6BC;AAED,2DAA8B;AAC9B,8DAAiC;AACjC,qEAAwC;AACxC,qDAAwB;AACxB,sDAAyB;AACzB,qDAAwB"}
|
package/backcompat/index.mjs
CHANGED
|
@@ -2,8 +2,9 @@ import { Cartesia } from "../client.mjs";
|
|
|
2
2
|
import { TTSWrapper } from "./tts-wrapper.mjs";
|
|
3
3
|
import { VoicesWrapper } from "./voices-wrapper.mjs";
|
|
4
4
|
import { VoiceChangerWrapper } from "./voice-changer-wrapper.mjs";
|
|
5
|
+
import { buildHeaders } from "../internal/headers.mjs";
|
|
5
6
|
async function resolveSupplier(supplier) {
|
|
6
|
-
if (typeof supplier ===
|
|
7
|
+
if (typeof supplier === 'function') {
|
|
7
8
|
return supplier();
|
|
8
9
|
}
|
|
9
10
|
return supplier;
|
|
@@ -13,26 +14,24 @@ class DynamicCartesia extends Cartesia {
|
|
|
13
14
|
super(options);
|
|
14
15
|
this.apiKeySupplier = options.apiKeySupplier;
|
|
15
16
|
}
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
validateHeaders(_headers) {
|
|
18
|
+
// Skip validation if we have a dynamic API key supplier
|
|
19
|
+
// The key will be resolved and added in authHeaders
|
|
20
|
+
if (this.apiKeySupplier) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
super.validateHeaders(_headers);
|
|
24
|
+
}
|
|
25
|
+
async authHeaders(opts) {
|
|
26
|
+
// If we have a dynamic supplier, resolve it and return the auth header
|
|
18
27
|
if (this.apiKeySupplier) {
|
|
19
28
|
const key = await resolveSupplier(this.apiKeySupplier);
|
|
20
29
|
if (key) {
|
|
21
|
-
|
|
22
|
-
if (!request.headers) {
|
|
23
|
-
request.headers = { Authorization: authHeader };
|
|
24
|
-
}
|
|
25
|
-
else if (request.headers instanceof Headers) {
|
|
26
|
-
request.headers.set("Authorization", authHeader);
|
|
27
|
-
}
|
|
28
|
-
else if (Array.isArray(request.headers)) {
|
|
29
|
-
request.headers.push(["Authorization", authHeader]);
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
request.headers["Authorization"] = authHeader;
|
|
33
|
-
}
|
|
30
|
+
return buildHeaders([{ Authorization: `Bearer ${key}` }]);
|
|
34
31
|
}
|
|
35
32
|
}
|
|
33
|
+
// Otherwise, fall back to default behavior
|
|
34
|
+
return super.authHeaders(opts);
|
|
36
35
|
}
|
|
37
36
|
}
|
|
38
37
|
/**
|
|
@@ -45,7 +44,7 @@ export class CartesiaClient {
|
|
|
45
44
|
const newOptions = {};
|
|
46
45
|
let apiKeySupplier;
|
|
47
46
|
if (options.apiKey) {
|
|
48
|
-
if (typeof options.apiKey ===
|
|
47
|
+
if (typeof options.apiKey === 'function') {
|
|
49
48
|
apiKeySupplier = options.apiKey;
|
|
50
49
|
}
|
|
51
50
|
else {
|
|
@@ -69,4 +68,5 @@ export * from "./voices-wrapper.mjs";
|
|
|
69
68
|
export * from "./voice-changer-wrapper.mjs";
|
|
70
69
|
export * from "./types.mjs";
|
|
71
70
|
export * from "./errors.mjs";
|
|
71
|
+
export * from "./utils.mjs";
|
|
72
72
|
//# sourceMappingURL=index.mjs.map
|
package/backcompat/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/backcompat/index.ts"],"names":[],"mappings":"OAAO,EAAE,QAAQ,EAAsB;OAChC,EAAE,UAAU,EAAE;OACd,EAAE,aAAa,EAAE;OACjB,EAAE,mBAAmB,EAAE;
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/backcompat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,OAAO,OAAO,CAAC,MAAM,KAAK,UAAU,EAAE,CAAC;gBACzC,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC;YAClC,CAAC;iBAAM,CAAC;gBACN,UAAU,CAAC,MAAM,GAAG,OAAO,CAAC,MAAgB,CAAC;YAC/C,CAAC;QACH,CAAC;QAED,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;YACpB,UAAU,CAAC,OAAO,GAAG,OAAO,CAAC,OAAiB,CAAC;QACjD,CAAC;aAAM,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;YAC/B,UAAU,CAAC,OAAO,GAAG,OAAO,CAAC,WAAqB,CAAC;QACrD,CAAC;QAED,IAAI,CAAC,MAAM,GAAG,IAAI,eAAe,CAAC,EAAE,GAAG,UAAU,EAAE,cAAc,EAAE,CAAC,CAAC;QACrE,IAAI,CAAC,GAAG,GAAG,IAAI,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACvC,IAAI,CAAC,MAAM,GAAG,IAAI,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC7C,IAAI,CAAC,YAAY,GAAG,IAAI,mBAAmB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC3D,CAAC;CACF"}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { Cartesia } from "../client.mjs";
|
|
2
2
|
import { BackCompatRequestOptions } from "./types.mjs";
|
|
3
|
-
import { Readable } from
|
|
3
|
+
import { Readable } from 'stream';
|
|
4
4
|
export interface BackCompatWebSocketOptions {
|
|
5
|
-
container?:
|
|
6
|
-
encoding?:
|
|
5
|
+
container?: 'raw' | 'wav' | 'mp3';
|
|
6
|
+
encoding?: 'pcm_f32le' | 'pcm_s16le' | 'pcm_alaw' | 'pcm_mulaw';
|
|
7
7
|
sampleRate: number;
|
|
8
8
|
}
|
|
9
9
|
export type BackCompatTtsRequestVoiceSpecifier = {
|
|
10
|
-
mode:
|
|
10
|
+
mode: 'id';
|
|
11
11
|
id: string;
|
|
12
12
|
} | {
|
|
13
|
-
mode:
|
|
13
|
+
mode: 'embedding';
|
|
14
14
|
embedding: number[];
|
|
15
15
|
};
|
|
16
16
|
export interface BackCompatGenerationConfig {
|
|
@@ -24,8 +24,8 @@ export interface BackCompatWebSocketTtsRequest {
|
|
|
24
24
|
voice: BackCompatTtsRequestVoiceSpecifier;
|
|
25
25
|
generationConfig?: BackCompatGenerationConfig;
|
|
26
26
|
outputFormat?: {
|
|
27
|
-
container?:
|
|
28
|
-
encoding?:
|
|
27
|
+
container?: 'raw' | 'wav' | 'mp3';
|
|
28
|
+
encoding?: 'pcm_f32le' | 'pcm_s16le' | 'pcm_alaw' | 'pcm_mulaw';
|
|
29
29
|
sampleRate?: number;
|
|
30
30
|
bitRate?: number;
|
|
31
31
|
};
|
|
@@ -41,14 +41,14 @@ export interface BackCompatTtsRequest {
|
|
|
41
41
|
voice: BackCompatTtsRequestVoiceSpecifier;
|
|
42
42
|
language?: string;
|
|
43
43
|
outputFormat: {
|
|
44
|
-
container:
|
|
45
|
-
encoding?:
|
|
44
|
+
container: 'raw' | 'wav' | 'mp3';
|
|
45
|
+
encoding?: 'pcm_f32le' | 'pcm_s16le' | 'pcm_alaw' | 'pcm_mulaw';
|
|
46
46
|
sampleRate: number;
|
|
47
47
|
bitRate?: number;
|
|
48
48
|
};
|
|
49
49
|
generationConfig?: BackCompatGenerationConfig;
|
|
50
50
|
duration?: number;
|
|
51
|
-
speed?:
|
|
51
|
+
speed?: 'slow' | 'normal' | 'fast';
|
|
52
52
|
pronunciationDictId?: string;
|
|
53
53
|
}
|
|
54
54
|
declare class AudioSource {
|
|
@@ -73,12 +73,35 @@ export declare class WebSocketWrapper {
|
|
|
73
73
|
}>;
|
|
74
74
|
disconnect(): void;
|
|
75
75
|
}
|
|
76
|
+
export interface BackCompatTtsGenerateOptions {
|
|
77
|
+
modelId?: string;
|
|
78
|
+
outputFormat?: {
|
|
79
|
+
container: 'raw' | 'wav' | 'mp3';
|
|
80
|
+
encoding?: 'pcm_f32le' | 'pcm_s16le' | 'pcm_alaw' | 'pcm_mulaw';
|
|
81
|
+
sampleRate: number;
|
|
82
|
+
bitRate?: number;
|
|
83
|
+
};
|
|
84
|
+
language?: string;
|
|
85
|
+
generationConfig?: BackCompatGenerationConfig;
|
|
86
|
+
speed?: 'slow' | 'normal' | 'fast';
|
|
87
|
+
pronunciationDictId?: string;
|
|
88
|
+
}
|
|
76
89
|
/** @deprecated Use the new SDK's tts methods on the {@link Cartesia} instance instead. */
|
|
77
90
|
export declare class TTSWrapper {
|
|
78
91
|
private client;
|
|
79
92
|
constructor(client: Cartesia);
|
|
80
93
|
/** @deprecated Use {@link Cartesia.tts.websocket} instead. */
|
|
81
94
|
websocket(config: BackCompatWebSocketOptions): WebSocketWrapper;
|
|
95
|
+
/**
|
|
96
|
+
* Generate speech from text.
|
|
97
|
+
* @param transcript The text to convert to speech
|
|
98
|
+
* @param voiceId The voice ID to use
|
|
99
|
+
* @param options Generation options
|
|
100
|
+
* @param signal Optional abort signal
|
|
101
|
+
* @param _source Optional source identifier (e.g., "playground_tts") - for tracking purposes
|
|
102
|
+
* @deprecated Use {@link Cartesia.tts.generate} instead.
|
|
103
|
+
*/
|
|
104
|
+
generate(transcript: string, voiceId: string, options?: BackCompatTtsGenerateOptions, signal?: AbortSignal, _source?: string): Promise<Readable>;
|
|
82
105
|
/** @deprecated Use {@link Cartesia.tts.generate} instead. */
|
|
83
106
|
bytes(request: BackCompatTtsRequest, requestOptions?: BackCompatRequestOptions): Promise<Readable>;
|
|
84
107
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tts-wrapper.d.mts","sourceRoot":"","sources":["../src/backcompat/tts-wrapper.ts"],"names":[],"mappings":"OACO,EAAE,QAAQ,EAAE;
|
|
1
|
+
{"version":3,"file":"tts-wrapper.d.mts","sourceRoot":"","sources":["../src/backcompat/tts-wrapper.ts"],"names":[],"mappings":"OACO,EAAE,QAAQ,EAAE;OACZ,EAA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