@cartesia/cartesia-js 1.2.2-alpha.0 → 2.0.0-alpha

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (1035) hide show
  1. package/Client.d.ts +40 -0
  2. package/Client.js +32 -0
  3. package/README.md +170 -193
  4. package/api/index.d.ts +1 -0
  5. package/api/index.js +17 -0
  6. package/api/resources/apiStatus/client/Client.d.ts +39 -0
  7. package/api/resources/apiStatus/client/Client.js +103 -0
  8. package/api/resources/apiStatus/client/index.d.ts +1 -0
  9. package/api/resources/apiStatus/client/index.js +2 -0
  10. package/api/resources/apiStatus/index.d.ts +2 -0
  11. package/api/resources/apiStatus/index.js +18 -0
  12. package/api/resources/apiStatus/types/ApiInfo.d.ts +7 -0
  13. package/api/resources/apiStatus/types/ApiInfo.js +5 -0
  14. package/api/resources/apiStatus/types/index.d.ts +1 -0
  15. package/api/resources/apiStatus/types/index.js +17 -0
  16. package/api/resources/embedding/index.d.ts +1 -0
  17. package/api/resources/embedding/index.js +17 -0
  18. package/api/resources/embedding/types/Embedding.d.ts +10 -0
  19. package/api/resources/embedding/types/Embedding.js +5 -0
  20. package/api/resources/embedding/types/index.d.ts +1 -0
  21. package/api/resources/embedding/types/index.js +17 -0
  22. package/api/resources/index.d.ts +12 -0
  23. package/api/resources/index.js +41 -0
  24. package/api/resources/tts/client/Client.d.ts +36 -0
  25. package/api/resources/tts/client/Client.js +152 -0
  26. package/api/resources/tts/client/index.d.ts +1 -0
  27. package/api/resources/tts/client/index.js +2 -0
  28. package/api/resources/tts/index.d.ts +2 -0
  29. package/api/resources/tts/index.js +18 -0
  30. package/api/resources/tts/types/CancelContextRequest.d.ts +10 -0
  31. package/api/resources/tts/types/CancelContextRequest.js +5 -0
  32. package/api/resources/tts/types/ContextId.d.ts +9 -0
  33. package/api/resources/tts/types/ContextId.js +5 -0
  34. package/api/resources/tts/types/Controls.d.ts +8 -0
  35. package/api/resources/tts/types/Controls.js +5 -0
  36. package/api/resources/tts/types/Emotion.d.ts +33 -0
  37. package/api/resources/tts/types/Emotion.js +28 -0
  38. package/api/resources/tts/types/GenerationRequest.d.ts +25 -0
  39. package/api/resources/tts/types/GenerationRequest.js +5 -0
  40. package/api/resources/tts/types/Mp3OutputFormat.d.ts +7 -0
  41. package/api/resources/tts/types/Mp3OutputFormat.js +5 -0
  42. package/api/resources/tts/types/NaturalSpecifier.d.ts +11 -0
  43. package/api/resources/tts/types/NaturalSpecifier.js +13 -0
  44. package/api/resources/tts/types/NumericalSpecifier.d.ts +4 -0
  45. package/api/resources/tts/types/NumericalSpecifier.js +5 -0
  46. package/api/resources/tts/types/OutputFormat.d.ts +16 -0
  47. package/api/resources/tts/types/OutputFormat.js +5 -0
  48. package/api/resources/tts/types/RawEncoding.d.ts +10 -0
  49. package/api/resources/tts/types/RawEncoding.js +12 -0
  50. package/api/resources/tts/types/RawOutputFormat.d.ts +8 -0
  51. package/api/resources/tts/types/RawOutputFormat.js +5 -0
  52. package/api/resources/tts/types/Speed.d.ts +10 -0
  53. package/api/resources/tts/types/Speed.js +5 -0
  54. package/api/resources/tts/types/SupportedLanguage.d.ts +26 -0
  55. package/api/resources/tts/types/SupportedLanguage.js +23 -0
  56. package/api/resources/tts/types/TtsRequest.d.ts +17 -0
  57. package/api/resources/tts/types/TtsRequest.js +5 -0
  58. package/api/resources/tts/types/TtsRequestEmbeddingSpecifier.d.ts +9 -0
  59. package/api/resources/tts/types/TtsRequestEmbeddingSpecifier.js +5 -0
  60. package/api/resources/tts/types/TtsRequestIdSpecifier.d.ts +9 -0
  61. package/api/resources/tts/types/TtsRequestIdSpecifier.js +5 -0
  62. package/api/resources/tts/types/TtsRequestVoiceSpecifier.d.ts +5 -0
  63. package/api/resources/tts/types/TtsRequestVoiceSpecifier.js +5 -0
  64. package/api/resources/tts/types/WavOutputFormat.d.ts +6 -0
  65. package/api/resources/tts/types/WavOutputFormat.js +5 -0
  66. package/api/resources/tts/types/WebSocketBaseResponse.d.ts +9 -0
  67. package/api/resources/tts/types/WebSocketBaseResponse.js +5 -0
  68. package/api/resources/tts/types/WebSocketChunkResponse.d.ts +8 -0
  69. package/api/resources/tts/types/WebSocketChunkResponse.js +5 -0
  70. package/api/resources/tts/types/WebSocketDoneResponse.d.ts +6 -0
  71. package/api/resources/tts/types/WebSocketDoneResponse.js +5 -0
  72. package/api/resources/tts/types/WebSocketErrorResponse.d.ts +7 -0
  73. package/api/resources/tts/types/WebSocketErrorResponse.js +5 -0
  74. package/api/resources/tts/types/WebSocketRawOutputFormat.d.ts +9 -0
  75. package/api/resources/tts/types/WebSocketRawOutputFormat.js +5 -0
  76. package/api/resources/tts/types/WebSocketRequest.d.ts +13 -0
  77. package/api/resources/tts/types/WebSocketRequest.js +5 -0
  78. package/api/resources/tts/types/WebSocketResponse.d.ts +19 -0
  79. package/api/resources/tts/types/WebSocketResponse.js +5 -0
  80. package/api/resources/tts/types/WebSocketStreamOptions.d.ts +6 -0
  81. package/api/resources/tts/types/WebSocketStreamOptions.js +5 -0
  82. package/api/resources/tts/types/WebSocketTimestampsResponse.d.ts +7 -0
  83. package/api/resources/tts/types/WebSocketTimestampsResponse.js +5 -0
  84. package/api/resources/tts/types/WebSocketTtsOutput.d.ts +9 -0
  85. package/api/resources/tts/types/WebSocketTtsOutput.js +5 -0
  86. package/api/resources/tts/types/WebSocketTtsRequest.d.ts +15 -0
  87. package/api/resources/tts/types/WebSocketTtsRequest.js +5 -0
  88. package/api/resources/tts/types/WordTimestamps.d.ts +8 -0
  89. package/api/resources/tts/types/WordTimestamps.js +5 -0
  90. package/api/resources/tts/types/index.d.ts +30 -0
  91. package/api/resources/tts/types/index.js +46 -0
  92. package/api/resources/voiceChanger/client/Client.d.ts +43 -0
  93. package/api/resources/voiceChanger/client/Client.js +181 -0
  94. package/api/resources/voiceChanger/client/index.d.ts +1 -0
  95. package/api/resources/voiceChanger/client/index.js +17 -0
  96. package/api/resources/voiceChanger/client/requests/VoiceChangerBytesRequest.d.ts +44 -0
  97. package/api/resources/voiceChanger/client/requests/VoiceChangerBytesRequest.js +5 -0
  98. package/api/resources/voiceChanger/client/requests/VoiceChangerSseRequest.d.ts +44 -0
  99. package/api/resources/voiceChanger/client/requests/VoiceChangerSseRequest.js +5 -0
  100. package/api/resources/voiceChanger/client/requests/index.d.ts +2 -0
  101. package/api/resources/voiceChanger/client/requests/index.js +2 -0
  102. package/api/resources/voiceChanger/index.d.ts +2 -0
  103. package/api/resources/voiceChanger/index.js +18 -0
  104. package/api/resources/voiceChanger/types/OutputFormatContainer.d.ts +9 -0
  105. package/api/resources/voiceChanger/types/OutputFormatContainer.js +11 -0
  106. package/api/resources/voiceChanger/types/StreamingResponse.d.ts +16 -0
  107. package/api/resources/voiceChanger/types/StreamingResponse.js +5 -0
  108. package/api/resources/voiceChanger/types/index.d.ts +2 -0
  109. package/api/resources/voiceChanger/types/index.js +18 -0
  110. package/api/resources/voices/client/Client.d.ts +141 -0
  111. package/api/resources/voices/client/Client.js +512 -0
  112. package/api/resources/voices/client/index.d.ts +1 -0
  113. package/api/resources/voices/client/index.js +17 -0
  114. package/api/resources/voices/client/requests/CloneVoiceRequest.d.ts +56 -0
  115. package/api/resources/voices/client/requests/CloneVoiceRequest.js +5 -0
  116. package/api/resources/voices/client/requests/index.d.ts +1 -0
  117. package/api/resources/voices/client/requests/index.js +2 -0
  118. package/api/resources/voices/index.d.ts +2 -0
  119. package/api/resources/voices/index.js +18 -0
  120. package/api/resources/voices/types/BaseVoiceId.d.ts +8 -0
  121. package/api/resources/voices/types/BaseVoiceId.js +5 -0
  122. package/api/resources/voices/types/CloneMode.d.ts +8 -0
  123. package/api/resources/voices/types/CloneMode.js +10 -0
  124. package/api/resources/voices/types/CreateVoiceRequest.d.ts +13 -0
  125. package/api/resources/voices/types/CreateVoiceRequest.js +5 -0
  126. package/api/resources/voices/types/EmbeddingResponse.d.ts +7 -0
  127. package/api/resources/voices/types/EmbeddingResponse.js +5 -0
  128. package/api/resources/voices/types/EmbeddingSpecifier.d.ts +8 -0
  129. package/api/resources/voices/types/EmbeddingSpecifier.js +5 -0
  130. package/api/resources/voices/types/Gender.d.ts +8 -0
  131. package/api/resources/voices/types/Gender.js +10 -0
  132. package/api/resources/voices/types/IdSpecifier.d.ts +8 -0
  133. package/api/resources/voices/types/IdSpecifier.js +5 -0
  134. package/api/resources/voices/types/LocalizeDialect.d.ts +16 -0
  135. package/api/resources/voices/types/LocalizeDialect.js +13 -0
  136. package/api/resources/voices/types/LocalizeTargetLanguage.d.ts +26 -0
  137. package/api/resources/voices/types/LocalizeTargetLanguage.js +23 -0
  138. package/api/resources/voices/types/LocalizeVoiceRequest.d.ts +10 -0
  139. package/api/resources/voices/types/LocalizeVoiceRequest.js +5 -0
  140. package/api/resources/voices/types/MixVoiceSpecifier.d.ts +5 -0
  141. package/api/resources/voices/types/MixVoiceSpecifier.js +5 -0
  142. package/api/resources/voices/types/MixVoicesRequest.d.ts +7 -0
  143. package/api/resources/voices/types/MixVoicesRequest.js +5 -0
  144. package/api/resources/voices/types/UpdateVoiceRequest.d.ts +9 -0
  145. package/api/resources/voices/types/UpdateVoiceRequest.js +5 -0
  146. package/api/resources/voices/types/Voice.d.ts +20 -0
  147. package/api/resources/voices/types/Voice.js +5 -0
  148. package/api/resources/voices/types/VoiceId.d.ts +7 -0
  149. package/api/resources/voices/types/VoiceId.js +5 -0
  150. package/api/resources/voices/types/VoiceMetadata.d.ts +18 -0
  151. package/api/resources/voices/types/VoiceMetadata.js +5 -0
  152. package/api/resources/voices/types/Weight.d.ts +7 -0
  153. package/api/resources/voices/types/Weight.js +5 -0
  154. package/api/resources/voices/types/index.d.ts +17 -0
  155. package/api/resources/voices/types/index.js +33 -0
  156. package/core/fetcher/APIResponse.d.ts +10 -0
  157. package/core/fetcher/APIResponse.js +2 -0
  158. package/core/fetcher/Fetcher.d.ts +39 -0
  159. package/core/fetcher/Fetcher.js +99 -0
  160. package/core/fetcher/Supplier.d.ts +4 -0
  161. package/core/fetcher/Supplier.js +22 -0
  162. package/core/fetcher/createRequestUrl.d.ts +1 -0
  163. package/core/fetcher/createRequestUrl.js +13 -0
  164. package/core/fetcher/getFetchFn.d.ts +4 -0
  165. package/core/fetcher/getFetchFn.js +59 -0
  166. package/core/fetcher/getHeader.d.ts +1 -0
  167. package/core/fetcher/getHeader.js +12 -0
  168. package/core/fetcher/getRequestBody.d.ts +7 -0
  169. package/core/fetcher/getRequestBody.js +23 -0
  170. package/core/fetcher/getResponseBody.d.ts +1 -0
  171. package/core/fetcher/getResponseBody.js +52 -0
  172. package/core/fetcher/index.d.ts +5 -0
  173. package/core/fetcher/index.js +9 -0
  174. package/core/fetcher/makeRequest.d.ts +1 -0
  175. package/core/fetcher/makeRequest.js +42 -0
  176. package/core/fetcher/requestWithRetries.d.ts +1 -0
  177. package/core/fetcher/requestWithRetries.js +41 -0
  178. package/core/fetcher/signals.d.ts +12 -0
  179. package/core/fetcher/signals.js +37 -0
  180. package/core/fetcher/stream-wrappers/Node18UniversalStreamWrapper.d.ts +30 -0
  181. package/core/fetcher/stream-wrappers/Node18UniversalStreamWrapper.js +247 -0
  182. package/core/fetcher/stream-wrappers/NodePre18StreamWrapper.d.ts +22 -0
  183. package/core/fetcher/stream-wrappers/NodePre18StreamWrapper.js +124 -0
  184. package/core/fetcher/stream-wrappers/UndiciStreamWrapper.d.ts +31 -0
  185. package/core/fetcher/stream-wrappers/UndiciStreamWrapper.js +229 -0
  186. package/core/fetcher/stream-wrappers/chooseStreamWrapper.d.ts +18 -0
  187. package/core/fetcher/stream-wrappers/chooseStreamWrapper.js +50 -0
  188. package/core/form-data-utils/FormDataWrapper.d.ts +60 -0
  189. package/core/form-data-utils/FormDataWrapper.js +174 -0
  190. package/core/form-data-utils/index.d.ts +1 -0
  191. package/core/form-data-utils/index.js +17 -0
  192. package/core/index.d.ts +5 -0
  193. package/core/index.js +34 -0
  194. package/core/runtime/index.d.ts +1 -0
  195. package/core/runtime/index.js +5 -0
  196. package/core/runtime/runtime.d.ts +9 -0
  197. package/core/runtime/runtime.js +93 -0
  198. package/core/schemas/Schema.d.ts +85 -0
  199. package/core/schemas/Schema.js +22 -0
  200. package/core/schemas/builders/bigint/bigint.d.ts +2 -0
  201. package/core/schemas/builders/bigint/bigint.js +50 -0
  202. package/core/schemas/builders/bigint/index.d.ts +1 -0
  203. package/core/schemas/builders/bigint/index.js +5 -0
  204. package/core/schemas/builders/date/date.d.ts +2 -0
  205. package/core/schemas/builders/date/date.js +63 -0
  206. package/core/schemas/builders/date/index.d.ts +1 -0
  207. package/core/schemas/builders/date/index.js +5 -0
  208. package/core/schemas/builders/enum/enum.d.ts +2 -0
  209. package/core/schemas/builders/enum/enum.js +39 -0
  210. package/core/schemas/builders/enum/index.d.ts +1 -0
  211. package/core/schemas/builders/enum/index.js +5 -0
  212. package/core/schemas/builders/index.d.ts +14 -0
  213. package/core/schemas/builders/index.js +30 -0
  214. package/core/schemas/builders/lazy/index.d.ts +3 -0
  215. package/core/schemas/builders/lazy/index.js +7 -0
  216. package/core/schemas/builders/lazy/lazy.d.ts +5 -0
  217. package/core/schemas/builders/lazy/lazy.js +25 -0
  218. package/core/schemas/builders/lazy/lazyObject.d.ts +3 -0
  219. package/core/schemas/builders/lazy/lazyObject.js +12 -0
  220. package/core/schemas/builders/list/index.d.ts +1 -0
  221. package/core/schemas/builders/list/index.js +5 -0
  222. package/core/schemas/builders/list/list.d.ts +2 -0
  223. package/core/schemas/builders/list/list.js +55 -0
  224. package/core/schemas/builders/literals/booleanLiteral.d.ts +2 -0
  225. package/core/schemas/builders/literals/booleanLiteral.js +29 -0
  226. package/core/schemas/builders/literals/index.d.ts +2 -0
  227. package/core/schemas/builders/literals/index.js +7 -0
  228. package/core/schemas/builders/literals/stringLiteral.d.ts +2 -0
  229. package/core/schemas/builders/literals/stringLiteral.js +29 -0
  230. package/core/schemas/builders/object/index.d.ts +6 -0
  231. package/core/schemas/builders/object/index.js +11 -0
  232. package/core/schemas/builders/object/object.d.ts +3 -0
  233. package/core/schemas/builders/object/object.js +233 -0
  234. package/core/schemas/builders/object/objectWithoutOptionalProperties.d.ts +6 -0
  235. package/core/schemas/builders/object/objectWithoutOptionalProperties.js +8 -0
  236. package/core/schemas/builders/object/property.d.ts +8 -0
  237. package/core/schemas/builders/object/property.js +16 -0
  238. package/core/schemas/builders/object/types.d.ts +26 -0
  239. package/core/schemas/builders/object/types.js +2 -0
  240. package/core/schemas/builders/object-like/getObjectLikeUtils.d.ts +9 -0
  241. package/core/schemas/builders/object-like/getObjectLikeUtils.js +54 -0
  242. package/core/schemas/builders/object-like/index.d.ts +2 -0
  243. package/core/schemas/builders/object-like/index.js +6 -0
  244. package/core/schemas/builders/object-like/types.d.ts +7 -0
  245. package/core/schemas/builders/object-like/types.js +2 -0
  246. package/core/schemas/builders/primitives/any.d.ts +1 -0
  247. package/core/schemas/builders/primitives/any.js +6 -0
  248. package/core/schemas/builders/primitives/boolean.d.ts +1 -0
  249. package/core/schemas/builders/primitives/boolean.js +25 -0
  250. package/core/schemas/builders/primitives/index.d.ts +5 -0
  251. package/core/schemas/builders/primitives/index.js +13 -0
  252. package/core/schemas/builders/primitives/number.d.ts +1 -0
  253. package/core/schemas/builders/primitives/number.js +25 -0
  254. package/core/schemas/builders/primitives/string.d.ts +1 -0
  255. package/core/schemas/builders/primitives/string.js +25 -0
  256. package/core/schemas/builders/primitives/unknown.d.ts +1 -0
  257. package/core/schemas/builders/primitives/unknown.js +6 -0
  258. package/core/schemas/builders/record/index.d.ts +2 -0
  259. package/core/schemas/builders/record/index.js +5 -0
  260. package/core/schemas/builders/record/record.d.ts +3 -0
  261. package/core/schemas/builders/record/record.js +95 -0
  262. package/core/schemas/builders/record/types.d.ts +4 -0
  263. package/core/schemas/builders/record/types.js +2 -0
  264. package/core/schemas/builders/schema-utils/JsonError.d.ts +5 -0
  265. package/core/schemas/builders/schema-utils/JsonError.js +12 -0
  266. package/core/schemas/builders/schema-utils/ParseError.d.ts +5 -0
  267. package/core/schemas/builders/schema-utils/ParseError.js +12 -0
  268. package/core/schemas/builders/schema-utils/getSchemaUtils.d.ts +17 -0
  269. package/core/schemas/builders/schema-utils/getSchemaUtils.js +82 -0
  270. package/core/schemas/builders/schema-utils/index.d.ts +4 -0
  271. package/core/schemas/builders/schema-utils/index.js +11 -0
  272. package/core/schemas/builders/schema-utils/stringifyValidationErrors.d.ts +2 -0
  273. package/core/schemas/builders/schema-utils/stringifyValidationErrors.js +10 -0
  274. package/core/schemas/builders/set/index.d.ts +1 -0
  275. package/core/schemas/builders/set/index.js +5 -0
  276. package/core/schemas/builders/set/set.d.ts +2 -0
  277. package/core/schemas/builders/set/set.js +44 -0
  278. package/core/schemas/builders/undiscriminated-union/index.d.ts +2 -0
  279. package/core/schemas/builders/undiscriminated-union/index.js +5 -0
  280. package/core/schemas/builders/undiscriminated-union/types.d.ts +4 -0
  281. package/core/schemas/builders/undiscriminated-union/types.js +2 -0
  282. package/core/schemas/builders/undiscriminated-union/undiscriminatedUnion.d.ts +3 -0
  283. package/core/schemas/builders/undiscriminated-union/undiscriminatedUnion.js +40 -0
  284. package/core/schemas/builders/union/discriminant.d.ts +5 -0
  285. package/core/schemas/builders/union/discriminant.js +10 -0
  286. package/core/schemas/builders/union/index.d.ts +4 -0
  287. package/core/schemas/builders/union/index.js +7 -0
  288. package/core/schemas/builders/union/types.d.ts +13 -0
  289. package/core/schemas/builders/union/types.js +2 -0
  290. package/core/schemas/builders/union/union.d.ts +4 -0
  291. package/core/schemas/builders/union/union.js +130 -0
  292. package/core/schemas/index.d.ts +2 -0
  293. package/core/schemas/index.js +17 -0
  294. package/core/schemas/utils/MaybePromise.d.ts +1 -0
  295. package/core/schemas/utils/MaybePromise.js +2 -0
  296. package/core/schemas/utils/addQuestionMarksToNullableProperties.d.ts +7 -0
  297. package/core/schemas/utils/addQuestionMarksToNullableProperties.js +2 -0
  298. package/core/schemas/utils/createIdentitySchemaCreator.d.ts +2 -0
  299. package/core/schemas/utils/createIdentitySchemaCreator.js +16 -0
  300. package/core/schemas/utils/entries.d.ts +1 -0
  301. package/core/schemas/utils/entries.js +7 -0
  302. package/core/schemas/utils/filterObject.d.ts +1 -0
  303. package/core/schemas/utils/filterObject.js +14 -0
  304. package/core/schemas/utils/getErrorMessageForIncorrectType.d.ts +1 -0
  305. package/core/schemas/utils/getErrorMessageForIncorrectType.js +28 -0
  306. package/core/schemas/utils/isPlainObject.d.ts +1 -0
  307. package/core/schemas/utils/isPlainObject.js +18 -0
  308. package/core/schemas/utils/keys.d.ts +1 -0
  309. package/core/schemas/utils/keys.js +7 -0
  310. package/core/schemas/utils/maybeSkipValidation.d.ts +2 -0
  311. package/core/schemas/utils/maybeSkipValidation.js +28 -0
  312. package/core/schemas/utils/partition.d.ts +1 -0
  313. package/core/schemas/utils/partition.js +16 -0
  314. package/core/streaming-fetcher/Stream.d.ts +48 -0
  315. package/core/streaming-fetcher/Stream.js +170 -0
  316. package/core/streaming-fetcher/index.d.ts +1 -0
  317. package/core/streaming-fetcher/index.js +5 -0
  318. package/core/websocket/events.d.ts +36 -0
  319. package/core/websocket/events.js +27 -0
  320. package/core/websocket/index.d.ts +1 -0
  321. package/core/websocket/index.js +17 -0
  322. package/core/websocket/ws.d.ts +136 -0
  323. package/core/websocket/ws.js +438 -0
  324. package/dist/Client.d.ts +40 -0
  325. package/dist/Client.js +32 -0
  326. package/dist/api/index.d.ts +1 -0
  327. package/dist/api/index.js +17 -0
  328. package/dist/api/resources/apiStatus/client/Client.d.ts +39 -0
  329. package/dist/api/resources/apiStatus/client/Client.js +103 -0
  330. package/dist/api/resources/apiStatus/client/index.d.ts +1 -0
  331. package/dist/api/resources/apiStatus/client/index.js +2 -0
  332. package/dist/api/resources/apiStatus/index.d.ts +2 -0
  333. package/dist/api/resources/apiStatus/index.js +18 -0
  334. package/dist/api/resources/apiStatus/types/ApiInfo.d.ts +7 -0
  335. package/dist/api/resources/apiStatus/types/ApiInfo.js +5 -0
  336. package/dist/api/resources/apiStatus/types/index.d.ts +1 -0
  337. package/dist/api/resources/apiStatus/types/index.js +17 -0
  338. package/dist/api/resources/embedding/index.d.ts +1 -0
  339. package/dist/api/resources/embedding/index.js +17 -0
  340. package/dist/api/resources/embedding/types/Embedding.d.ts +10 -0
  341. package/dist/api/resources/embedding/types/Embedding.js +5 -0
  342. package/dist/api/resources/embedding/types/index.d.ts +1 -0
  343. package/dist/api/resources/embedding/types/index.js +17 -0
  344. package/dist/api/resources/index.d.ts +12 -0
  345. package/dist/api/resources/index.js +41 -0
  346. package/dist/api/resources/tts/client/Client.d.ts +36 -0
  347. package/dist/api/resources/tts/client/Client.js +152 -0
  348. package/dist/api/resources/tts/client/index.d.ts +1 -0
  349. package/dist/api/resources/tts/client/index.js +2 -0
  350. package/dist/api/resources/tts/index.d.ts +2 -0
  351. package/dist/api/resources/tts/index.js +18 -0
  352. package/dist/api/resources/tts/types/CancelContextRequest.d.ts +10 -0
  353. package/dist/api/resources/tts/types/CancelContextRequest.js +5 -0
  354. package/dist/api/resources/tts/types/ContextId.d.ts +9 -0
  355. package/dist/api/resources/tts/types/ContextId.js +5 -0
  356. package/dist/api/resources/tts/types/Controls.d.ts +8 -0
  357. package/dist/api/resources/tts/types/Controls.js +5 -0
  358. package/dist/api/resources/tts/types/Emotion.d.ts +33 -0
  359. package/dist/api/resources/tts/types/Emotion.js +28 -0
  360. package/dist/api/resources/tts/types/GenerationRequest.d.ts +25 -0
  361. package/dist/api/resources/tts/types/GenerationRequest.js +5 -0
  362. package/dist/api/resources/tts/types/Mp3OutputFormat.d.ts +7 -0
  363. package/dist/api/resources/tts/types/Mp3OutputFormat.js +5 -0
  364. package/dist/api/resources/tts/types/NaturalSpecifier.d.ts +11 -0
  365. package/dist/api/resources/tts/types/NaturalSpecifier.js +13 -0
  366. package/dist/api/resources/tts/types/NumericalSpecifier.d.ts +4 -0
  367. package/dist/api/resources/tts/types/NumericalSpecifier.js +5 -0
  368. package/dist/api/resources/tts/types/OutputFormat.d.ts +16 -0
  369. package/dist/api/resources/tts/types/OutputFormat.js +5 -0
  370. package/dist/api/resources/tts/types/RawEncoding.d.ts +10 -0
  371. package/dist/api/resources/tts/types/RawEncoding.js +12 -0
  372. package/dist/api/resources/tts/types/RawOutputFormat.d.ts +8 -0
  373. package/dist/api/resources/tts/types/RawOutputFormat.js +5 -0
  374. package/dist/api/resources/tts/types/Speed.d.ts +10 -0
  375. package/dist/api/resources/tts/types/Speed.js +5 -0
  376. package/dist/api/resources/tts/types/SupportedLanguage.d.ts +26 -0
  377. package/dist/api/resources/tts/types/SupportedLanguage.js +23 -0
  378. package/dist/api/resources/tts/types/TtsRequest.d.ts +17 -0
  379. package/dist/api/resources/tts/types/TtsRequest.js +5 -0
  380. package/dist/api/resources/tts/types/TtsRequestEmbeddingSpecifier.d.ts +9 -0
  381. package/dist/api/resources/tts/types/TtsRequestEmbeddingSpecifier.js +5 -0
  382. package/dist/api/resources/tts/types/TtsRequestIdSpecifier.d.ts +9 -0
  383. package/dist/api/resources/tts/types/TtsRequestIdSpecifier.js +5 -0
  384. package/dist/api/resources/tts/types/TtsRequestVoiceSpecifier.d.ts +5 -0
  385. package/dist/api/resources/tts/types/TtsRequestVoiceSpecifier.js +5 -0
  386. package/dist/api/resources/tts/types/WavOutputFormat.d.ts +6 -0
  387. package/dist/api/resources/tts/types/WavOutputFormat.js +5 -0
  388. package/dist/api/resources/tts/types/WebSocketBaseResponse.d.ts +9 -0
  389. package/dist/api/resources/tts/types/WebSocketBaseResponse.js +5 -0
  390. package/dist/api/resources/tts/types/WebSocketChunkResponse.d.ts +8 -0
  391. package/dist/api/resources/tts/types/WebSocketChunkResponse.js +5 -0
  392. package/dist/api/resources/tts/types/WebSocketDoneResponse.d.ts +6 -0
  393. package/dist/api/resources/tts/types/WebSocketDoneResponse.js +5 -0
  394. package/dist/api/resources/tts/types/WebSocketErrorResponse.d.ts +7 -0
  395. package/dist/api/resources/tts/types/WebSocketErrorResponse.js +5 -0
  396. package/dist/api/resources/tts/types/WebSocketRawOutputFormat.d.ts +9 -0
  397. package/dist/api/resources/tts/types/WebSocketRawOutputFormat.js +5 -0
  398. package/dist/api/resources/tts/types/WebSocketRequest.d.ts +13 -0
  399. package/dist/api/resources/tts/types/WebSocketRequest.js +5 -0
  400. package/dist/api/resources/tts/types/WebSocketResponse.d.ts +19 -0
  401. package/dist/api/resources/tts/types/WebSocketResponse.js +5 -0
  402. package/dist/api/resources/tts/types/WebSocketStreamOptions.d.ts +6 -0
  403. package/dist/api/resources/tts/types/WebSocketStreamOptions.js +5 -0
  404. package/dist/api/resources/tts/types/WebSocketTimestampsResponse.d.ts +7 -0
  405. package/dist/api/resources/tts/types/WebSocketTimestampsResponse.js +5 -0
  406. package/dist/api/resources/tts/types/WebSocketTtsOutput.d.ts +9 -0
  407. package/dist/api/resources/tts/types/WebSocketTtsOutput.js +5 -0
  408. package/dist/api/resources/tts/types/WebSocketTtsRequest.d.ts +15 -0
  409. package/dist/api/resources/tts/types/WebSocketTtsRequest.js +5 -0
  410. package/dist/api/resources/tts/types/WordTimestamps.d.ts +8 -0
  411. package/dist/api/resources/tts/types/WordTimestamps.js +5 -0
  412. package/dist/api/resources/tts/types/index.d.ts +30 -0
  413. package/dist/api/resources/tts/types/index.js +46 -0
  414. package/dist/api/resources/voiceChanger/client/Client.d.ts +43 -0
  415. package/dist/api/resources/voiceChanger/client/Client.js +181 -0
  416. package/dist/api/resources/voiceChanger/client/index.d.ts +1 -0
  417. package/dist/api/resources/voiceChanger/client/index.js +17 -0
  418. package/dist/api/resources/voiceChanger/client/requests/VoiceChangerBytesRequest.d.ts +44 -0
  419. package/dist/api/resources/voiceChanger/client/requests/VoiceChangerBytesRequest.js +5 -0
  420. package/dist/api/resources/voiceChanger/client/requests/VoiceChangerSseRequest.d.ts +44 -0
  421. package/dist/api/resources/voiceChanger/client/requests/VoiceChangerSseRequest.js +5 -0
  422. package/dist/api/resources/voiceChanger/client/requests/index.d.ts +2 -0
  423. package/dist/api/resources/voiceChanger/client/requests/index.js +2 -0
  424. package/dist/api/resources/voiceChanger/index.d.ts +2 -0
  425. package/dist/api/resources/voiceChanger/index.js +18 -0
  426. package/dist/api/resources/voiceChanger/types/OutputFormatContainer.d.ts +9 -0
  427. package/dist/api/resources/voiceChanger/types/OutputFormatContainer.js +11 -0
  428. package/dist/api/resources/voiceChanger/types/StreamingResponse.d.ts +16 -0
  429. package/dist/api/resources/voiceChanger/types/StreamingResponse.js +5 -0
  430. package/dist/api/resources/voiceChanger/types/index.d.ts +2 -0
  431. package/dist/api/resources/voiceChanger/types/index.js +18 -0
  432. package/dist/api/resources/voices/client/Client.d.ts +141 -0
  433. package/dist/api/resources/voices/client/Client.js +512 -0
  434. package/dist/api/resources/voices/client/index.d.ts +1 -0
  435. package/dist/api/resources/voices/client/index.js +17 -0
  436. package/dist/api/resources/voices/client/requests/CloneVoiceRequest.d.ts +56 -0
  437. package/dist/api/resources/voices/client/requests/CloneVoiceRequest.js +5 -0
  438. package/dist/api/resources/voices/client/requests/index.d.ts +1 -0
  439. package/dist/api/resources/voices/client/requests/index.js +2 -0
  440. package/dist/api/resources/voices/index.d.ts +2 -0
  441. package/dist/api/resources/voices/index.js +18 -0
  442. package/dist/api/resources/voices/types/BaseVoiceId.d.ts +8 -0
  443. package/dist/api/resources/voices/types/BaseVoiceId.js +5 -0
  444. package/dist/api/resources/voices/types/CloneMode.d.ts +8 -0
  445. package/dist/api/resources/voices/types/CloneMode.js +10 -0
  446. package/dist/api/resources/voices/types/CreateVoiceRequest.d.ts +13 -0
  447. package/dist/api/resources/voices/types/CreateVoiceRequest.js +5 -0
  448. package/dist/api/resources/voices/types/EmbeddingResponse.d.ts +7 -0
  449. package/dist/api/resources/voices/types/EmbeddingResponse.js +5 -0
  450. package/dist/api/resources/voices/types/EmbeddingSpecifier.d.ts +8 -0
  451. package/dist/api/resources/voices/types/EmbeddingSpecifier.js +5 -0
  452. package/dist/api/resources/voices/types/Gender.d.ts +8 -0
  453. package/dist/api/resources/voices/types/Gender.js +10 -0
  454. package/dist/api/resources/voices/types/IdSpecifier.d.ts +8 -0
  455. package/dist/api/resources/voices/types/IdSpecifier.js +5 -0
  456. package/dist/api/resources/voices/types/LocalizeDialect.d.ts +16 -0
  457. package/dist/api/resources/voices/types/LocalizeDialect.js +13 -0
  458. package/dist/api/resources/voices/types/LocalizeTargetLanguage.d.ts +26 -0
  459. package/dist/api/resources/voices/types/LocalizeTargetLanguage.js +23 -0
  460. package/dist/api/resources/voices/types/LocalizeVoiceRequest.d.ts +10 -0
  461. package/dist/api/resources/voices/types/LocalizeVoiceRequest.js +5 -0
  462. package/dist/api/resources/voices/types/MixVoiceSpecifier.d.ts +5 -0
  463. package/dist/api/resources/voices/types/MixVoiceSpecifier.js +5 -0
  464. package/dist/api/resources/voices/types/MixVoicesRequest.d.ts +7 -0
  465. package/dist/api/resources/voices/types/MixVoicesRequest.js +5 -0
  466. package/dist/api/resources/voices/types/UpdateVoiceRequest.d.ts +9 -0
  467. package/dist/api/resources/voices/types/UpdateVoiceRequest.js +5 -0
  468. package/dist/api/resources/voices/types/Voice.d.ts +20 -0
  469. package/dist/api/resources/voices/types/Voice.js +5 -0
  470. package/dist/api/resources/voices/types/VoiceId.d.ts +7 -0
  471. package/dist/api/resources/voices/types/VoiceId.js +5 -0
  472. package/dist/api/resources/voices/types/VoiceMetadata.d.ts +18 -0
  473. package/dist/api/resources/voices/types/VoiceMetadata.js +5 -0
  474. package/dist/api/resources/voices/types/Weight.d.ts +7 -0
  475. package/dist/api/resources/voices/types/Weight.js +5 -0
  476. package/dist/api/resources/voices/types/index.d.ts +17 -0
  477. package/dist/api/resources/voices/types/index.js +33 -0
  478. package/dist/core/fetcher/APIResponse.d.ts +10 -0
  479. package/dist/core/fetcher/APIResponse.js +2 -0
  480. package/dist/core/fetcher/Fetcher.d.ts +39 -0
  481. package/dist/core/fetcher/Fetcher.js +99 -0
  482. package/dist/core/fetcher/Supplier.d.ts +4 -0
  483. package/dist/core/fetcher/Supplier.js +22 -0
  484. package/dist/core/fetcher/createRequestUrl.d.ts +1 -0
  485. package/dist/core/fetcher/createRequestUrl.js +13 -0
  486. package/dist/core/fetcher/getFetchFn.d.ts +4 -0
  487. package/dist/core/fetcher/getFetchFn.js +59 -0
  488. package/dist/core/fetcher/getHeader.d.ts +1 -0
  489. package/dist/core/fetcher/getHeader.js +12 -0
  490. package/dist/core/fetcher/getRequestBody.d.ts +7 -0
  491. package/dist/core/fetcher/getRequestBody.js +23 -0
  492. package/dist/core/fetcher/getResponseBody.d.ts +1 -0
  493. package/dist/core/fetcher/getResponseBody.js +52 -0
  494. package/dist/core/fetcher/index.d.ts +5 -0
  495. package/dist/core/fetcher/index.js +9 -0
  496. package/dist/core/fetcher/makeRequest.d.ts +1 -0
  497. package/dist/core/fetcher/makeRequest.js +42 -0
  498. package/dist/core/fetcher/requestWithRetries.d.ts +1 -0
  499. package/dist/core/fetcher/requestWithRetries.js +41 -0
  500. package/dist/core/fetcher/signals.d.ts +12 -0
  501. package/dist/core/fetcher/signals.js +37 -0
  502. package/dist/core/fetcher/stream-wrappers/Node18UniversalStreamWrapper.d.ts +30 -0
  503. package/dist/core/fetcher/stream-wrappers/Node18UniversalStreamWrapper.js +247 -0
  504. package/dist/core/fetcher/stream-wrappers/NodePre18StreamWrapper.d.ts +22 -0
  505. package/dist/core/fetcher/stream-wrappers/NodePre18StreamWrapper.js +124 -0
  506. package/dist/core/fetcher/stream-wrappers/UndiciStreamWrapper.d.ts +31 -0
  507. package/dist/core/fetcher/stream-wrappers/UndiciStreamWrapper.js +229 -0
  508. package/dist/core/fetcher/stream-wrappers/chooseStreamWrapper.d.ts +18 -0
  509. package/dist/core/fetcher/stream-wrappers/chooseStreamWrapper.js +50 -0
  510. package/dist/core/form-data-utils/FormDataWrapper.d.ts +60 -0
  511. package/dist/core/form-data-utils/FormDataWrapper.js +174 -0
  512. package/dist/core/form-data-utils/index.d.ts +1 -0
  513. package/dist/core/form-data-utils/index.js +17 -0
  514. package/dist/core/index.d.ts +5 -0
  515. package/dist/core/index.js +34 -0
  516. package/dist/core/runtime/index.d.ts +1 -0
  517. package/dist/core/runtime/index.js +5 -0
  518. package/dist/core/runtime/runtime.d.ts +9 -0
  519. package/dist/core/runtime/runtime.js +93 -0
  520. package/dist/core/schemas/Schema.d.ts +85 -0
  521. package/dist/core/schemas/Schema.js +22 -0
  522. package/dist/core/schemas/builders/bigint/bigint.d.ts +2 -0
  523. package/dist/core/schemas/builders/bigint/bigint.js +50 -0
  524. package/dist/core/schemas/builders/bigint/index.d.ts +1 -0
  525. package/dist/core/schemas/builders/bigint/index.js +5 -0
  526. package/dist/core/schemas/builders/date/date.d.ts +2 -0
  527. package/dist/core/schemas/builders/date/date.js +63 -0
  528. package/dist/core/schemas/builders/date/index.d.ts +1 -0
  529. package/dist/core/schemas/builders/date/index.js +5 -0
  530. package/dist/core/schemas/builders/enum/enum.d.ts +2 -0
  531. package/dist/core/schemas/builders/enum/enum.js +39 -0
  532. package/dist/core/schemas/builders/enum/index.d.ts +1 -0
  533. package/dist/core/schemas/builders/enum/index.js +5 -0
  534. package/dist/core/schemas/builders/index.d.ts +14 -0
  535. package/dist/core/schemas/builders/index.js +30 -0
  536. package/dist/core/schemas/builders/lazy/index.d.ts +3 -0
  537. package/dist/core/schemas/builders/lazy/index.js +7 -0
  538. package/dist/core/schemas/builders/lazy/lazy.d.ts +5 -0
  539. package/dist/core/schemas/builders/lazy/lazy.js +25 -0
  540. package/dist/core/schemas/builders/lazy/lazyObject.d.ts +3 -0
  541. package/dist/core/schemas/builders/lazy/lazyObject.js +12 -0
  542. package/dist/core/schemas/builders/list/index.d.ts +1 -0
  543. package/dist/core/schemas/builders/list/index.js +5 -0
  544. package/dist/core/schemas/builders/list/list.d.ts +2 -0
  545. package/dist/core/schemas/builders/list/list.js +55 -0
  546. package/dist/core/schemas/builders/literals/booleanLiteral.d.ts +2 -0
  547. package/dist/core/schemas/builders/literals/booleanLiteral.js +29 -0
  548. package/dist/core/schemas/builders/literals/index.d.ts +2 -0
  549. package/dist/core/schemas/builders/literals/index.js +7 -0
  550. package/dist/core/schemas/builders/literals/stringLiteral.d.ts +2 -0
  551. package/dist/core/schemas/builders/literals/stringLiteral.js +29 -0
  552. package/dist/core/schemas/builders/object/index.d.ts +6 -0
  553. package/dist/core/schemas/builders/object/index.js +11 -0
  554. package/dist/core/schemas/builders/object/object.d.ts +3 -0
  555. package/dist/core/schemas/builders/object/object.js +233 -0
  556. package/dist/core/schemas/builders/object/objectWithoutOptionalProperties.d.ts +6 -0
  557. package/dist/core/schemas/builders/object/objectWithoutOptionalProperties.js +8 -0
  558. package/dist/core/schemas/builders/object/property.d.ts +8 -0
  559. package/dist/core/schemas/builders/object/property.js +16 -0
  560. package/dist/core/schemas/builders/object/types.d.ts +26 -0
  561. package/dist/core/schemas/builders/object/types.js +2 -0
  562. package/dist/core/schemas/builders/object-like/getObjectLikeUtils.d.ts +9 -0
  563. package/dist/core/schemas/builders/object-like/getObjectLikeUtils.js +54 -0
  564. package/dist/core/schemas/builders/object-like/index.d.ts +2 -0
  565. package/dist/core/schemas/builders/object-like/index.js +6 -0
  566. package/dist/core/schemas/builders/object-like/types.d.ts +7 -0
  567. package/dist/core/schemas/builders/object-like/types.js +2 -0
  568. package/dist/core/schemas/builders/primitives/any.d.ts +1 -0
  569. package/dist/core/schemas/builders/primitives/any.js +6 -0
  570. package/dist/core/schemas/builders/primitives/boolean.d.ts +1 -0
  571. package/dist/core/schemas/builders/primitives/boolean.js +25 -0
  572. package/dist/core/schemas/builders/primitives/index.d.ts +5 -0
  573. package/dist/core/schemas/builders/primitives/index.js +13 -0
  574. package/dist/core/schemas/builders/primitives/number.d.ts +1 -0
  575. package/dist/core/schemas/builders/primitives/number.js +25 -0
  576. package/dist/core/schemas/builders/primitives/string.d.ts +1 -0
  577. package/dist/core/schemas/builders/primitives/string.js +25 -0
  578. package/dist/core/schemas/builders/primitives/unknown.d.ts +1 -0
  579. package/dist/core/schemas/builders/primitives/unknown.js +6 -0
  580. package/dist/core/schemas/builders/record/index.d.ts +2 -0
  581. package/dist/core/schemas/builders/record/index.js +5 -0
  582. package/dist/core/schemas/builders/record/record.d.ts +3 -0
  583. package/dist/core/schemas/builders/record/record.js +95 -0
  584. package/dist/core/schemas/builders/record/types.d.ts +4 -0
  585. package/dist/core/schemas/builders/record/types.js +2 -0
  586. package/dist/core/schemas/builders/schema-utils/JsonError.d.ts +5 -0
  587. package/dist/core/schemas/builders/schema-utils/JsonError.js +12 -0
  588. package/dist/core/schemas/builders/schema-utils/ParseError.d.ts +5 -0
  589. package/dist/core/schemas/builders/schema-utils/ParseError.js +12 -0
  590. package/dist/core/schemas/builders/schema-utils/getSchemaUtils.d.ts +17 -0
  591. package/dist/core/schemas/builders/schema-utils/getSchemaUtils.js +82 -0
  592. package/dist/core/schemas/builders/schema-utils/index.d.ts +4 -0
  593. package/dist/core/schemas/builders/schema-utils/index.js +11 -0
  594. package/dist/core/schemas/builders/schema-utils/stringifyValidationErrors.d.ts +2 -0
  595. package/dist/core/schemas/builders/schema-utils/stringifyValidationErrors.js +10 -0
  596. package/dist/core/schemas/builders/set/index.d.ts +1 -0
  597. package/dist/core/schemas/builders/set/index.js +5 -0
  598. package/dist/core/schemas/builders/set/set.d.ts +2 -0
  599. package/dist/core/schemas/builders/set/set.js +44 -0
  600. package/dist/core/schemas/builders/undiscriminated-union/index.d.ts +2 -0
  601. package/dist/core/schemas/builders/undiscriminated-union/index.js +5 -0
  602. package/dist/core/schemas/builders/undiscriminated-union/types.d.ts +4 -0
  603. package/dist/core/schemas/builders/undiscriminated-union/types.js +2 -0
  604. package/dist/core/schemas/builders/undiscriminated-union/undiscriminatedUnion.d.ts +3 -0
  605. package/dist/core/schemas/builders/undiscriminated-union/undiscriminatedUnion.js +40 -0
  606. package/dist/core/schemas/builders/union/discriminant.d.ts +5 -0
  607. package/dist/core/schemas/builders/union/discriminant.js +10 -0
  608. package/dist/core/schemas/builders/union/index.d.ts +4 -0
  609. package/dist/core/schemas/builders/union/index.js +7 -0
  610. package/dist/core/schemas/builders/union/types.d.ts +13 -0
  611. package/dist/core/schemas/builders/union/types.js +2 -0
  612. package/dist/core/schemas/builders/union/union.d.ts +4 -0
  613. package/dist/core/schemas/builders/union/union.js +130 -0
  614. package/dist/core/schemas/index.d.ts +2 -0
  615. package/dist/core/schemas/index.js +17 -0
  616. package/dist/core/schemas/utils/MaybePromise.d.ts +1 -0
  617. package/dist/core/schemas/utils/MaybePromise.js +2 -0
  618. package/dist/core/schemas/utils/addQuestionMarksToNullableProperties.d.ts +7 -0
  619. package/dist/core/schemas/utils/addQuestionMarksToNullableProperties.js +2 -0
  620. package/dist/core/schemas/utils/createIdentitySchemaCreator.d.ts +2 -0
  621. package/dist/core/schemas/utils/createIdentitySchemaCreator.js +16 -0
  622. package/dist/core/schemas/utils/entries.d.ts +1 -0
  623. package/dist/core/schemas/utils/entries.js +7 -0
  624. package/dist/core/schemas/utils/filterObject.d.ts +1 -0
  625. package/dist/core/schemas/utils/filterObject.js +14 -0
  626. package/dist/core/schemas/utils/getErrorMessageForIncorrectType.d.ts +1 -0
  627. package/dist/core/schemas/utils/getErrorMessageForIncorrectType.js +28 -0
  628. package/dist/core/schemas/utils/isPlainObject.d.ts +1 -0
  629. package/dist/core/schemas/utils/isPlainObject.js +18 -0
  630. package/dist/core/schemas/utils/keys.d.ts +1 -0
  631. package/dist/core/schemas/utils/keys.js +7 -0
  632. package/dist/core/schemas/utils/maybeSkipValidation.d.ts +2 -0
  633. package/dist/core/schemas/utils/maybeSkipValidation.js +28 -0
  634. package/dist/core/schemas/utils/partition.d.ts +1 -0
  635. package/dist/core/schemas/utils/partition.js +16 -0
  636. package/dist/core/streaming-fetcher/Stream.d.ts +48 -0
  637. package/dist/core/streaming-fetcher/Stream.js +170 -0
  638. package/dist/core/streaming-fetcher/index.d.ts +1 -0
  639. package/dist/core/streaming-fetcher/index.js +5 -0
  640. package/dist/core/websocket/events.d.ts +36 -0
  641. package/dist/core/websocket/events.js +27 -0
  642. package/dist/core/websocket/index.d.ts +1 -0
  643. package/dist/core/websocket/index.js +17 -0
  644. package/dist/core/websocket/ws.d.ts +136 -0
  645. package/dist/core/websocket/ws.js +438 -0
  646. package/dist/environments.d.ts +7 -0
  647. package/dist/environments.js +9 -0
  648. package/dist/errors/CartesiaError.d.ts +12 -0
  649. package/dist/errors/CartesiaError.js +32 -0
  650. package/dist/errors/CartesiaTimeoutError.d.ts +6 -0
  651. package/dist/errors/CartesiaTimeoutError.js +13 -0
  652. package/dist/errors/index.d.ts +2 -0
  653. package/dist/errors/index.js +7 -0
  654. package/dist/index.d.ts +4 -11
  655. package/dist/index.js +33 -26
  656. package/dist/serialization/index.d.ts +1 -0
  657. package/dist/serialization/index.js +17 -0
  658. package/dist/serialization/resources/apiStatus/index.d.ts +1 -0
  659. package/dist/serialization/resources/apiStatus/index.js +17 -0
  660. package/dist/serialization/resources/apiStatus/types/ApiInfo.d.ts +13 -0
  661. package/dist/serialization/resources/apiStatus/types/ApiInfo.js +34 -0
  662. package/dist/serialization/resources/apiStatus/types/index.d.ts +1 -0
  663. package/dist/serialization/resources/apiStatus/types/index.js +17 -0
  664. package/dist/serialization/resources/embedding/index.d.ts +1 -0
  665. package/dist/serialization/resources/embedding/index.js +17 -0
  666. package/dist/serialization/resources/embedding/types/Embedding.d.ts +10 -0
  667. package/dist/serialization/resources/embedding/types/Embedding.js +31 -0
  668. package/dist/serialization/resources/embedding/types/index.d.ts +1 -0
  669. package/dist/serialization/resources/embedding/types/index.js +17 -0
  670. package/dist/serialization/resources/index.d.ts +10 -0
  671. package/dist/serialization/resources/index.js +39 -0
  672. package/dist/serialization/resources/tts/index.d.ts +1 -0
  673. package/dist/serialization/resources/tts/index.js +17 -0
  674. package/dist/serialization/resources/tts/types/CancelContextRequest.d.ts +14 -0
  675. package/dist/serialization/resources/tts/types/CancelContextRequest.js +35 -0
  676. package/dist/serialization/resources/tts/types/ContextId.d.ts +10 -0
  677. package/dist/serialization/resources/tts/types/ContextId.js +31 -0
  678. package/dist/serialization/resources/tts/types/Controls.d.ts +15 -0
  679. package/dist/serialization/resources/tts/types/Controls.js +36 -0
  680. package/dist/serialization/resources/tts/types/Emotion.d.ts +10 -0
  681. package/dist/serialization/resources/tts/types/Emotion.js +52 -0
  682. package/dist/serialization/resources/tts/types/GenerationRequest.d.ts +24 -0
  683. package/dist/serialization/resources/tts/types/GenerationRequest.js +45 -0
  684. package/dist/serialization/resources/tts/types/Mp3OutputFormat.d.ts +13 -0
  685. package/dist/serialization/resources/tts/types/Mp3OutputFormat.js +34 -0
  686. package/dist/serialization/resources/tts/types/NaturalSpecifier.d.ts +10 -0
  687. package/dist/serialization/resources/tts/types/NaturalSpecifier.js +31 -0
  688. package/dist/serialization/resources/tts/types/NumericalSpecifier.d.ts +10 -0
  689. package/dist/serialization/resources/tts/types/NumericalSpecifier.js +31 -0
  690. package/dist/serialization/resources/tts/types/OutputFormat.d.ts +22 -0
  691. package/dist/serialization/resources/tts/types/OutputFormat.js +43 -0
  692. package/dist/serialization/resources/tts/types/RawEncoding.d.ts +10 -0
  693. package/dist/serialization/resources/tts/types/RawEncoding.js +31 -0
  694. package/dist/serialization/resources/tts/types/RawOutputFormat.d.ts +14 -0
  695. package/dist/serialization/resources/tts/types/RawOutputFormat.js +35 -0
  696. package/dist/serialization/resources/tts/types/Speed.d.ts +12 -0
  697. package/dist/serialization/resources/tts/types/Speed.js +33 -0
  698. package/dist/serialization/resources/tts/types/SupportedLanguage.d.ts +10 -0
  699. package/dist/serialization/resources/tts/types/SupportedLanguage.js +47 -0
  700. package/dist/serialization/resources/tts/types/TtsRequest.d.ts +20 -0
  701. package/dist/serialization/resources/tts/types/TtsRequest.js +41 -0
  702. package/dist/serialization/resources/tts/types/TtsRequestEmbeddingSpecifier.d.ts +16 -0
  703. package/dist/serialization/resources/tts/types/TtsRequestEmbeddingSpecifier.js +37 -0
  704. package/dist/serialization/resources/tts/types/TtsRequestIdSpecifier.d.ts +16 -0
  705. package/dist/serialization/resources/tts/types/TtsRequestIdSpecifier.js +37 -0
  706. package/dist/serialization/resources/tts/types/TtsRequestVoiceSpecifier.d.ts +12 -0
  707. package/dist/serialization/resources/tts/types/TtsRequestVoiceSpecifier.js +33 -0
  708. package/dist/serialization/resources/tts/types/WavOutputFormat.d.ts +12 -0
  709. package/dist/serialization/resources/tts/types/WavOutputFormat.js +32 -0
  710. package/dist/serialization/resources/tts/types/WebSocketBaseResponse.d.ts +15 -0
  711. package/dist/serialization/resources/tts/types/WebSocketBaseResponse.js +36 -0
  712. package/dist/serialization/resources/tts/types/WebSocketChunkResponse.d.ts +14 -0
  713. package/dist/serialization/resources/tts/types/WebSocketChunkResponse.js +37 -0
  714. package/dist/serialization/resources/tts/types/WebSocketDoneResponse.d.ts +12 -0
  715. package/dist/serialization/resources/tts/types/WebSocketDoneResponse.js +32 -0
  716. package/dist/serialization/resources/tts/types/WebSocketErrorResponse.d.ts +13 -0
  717. package/dist/serialization/resources/tts/types/WebSocketErrorResponse.js +36 -0
  718. package/dist/serialization/resources/tts/types/WebSocketRawOutputFormat.d.ts +15 -0
  719. package/dist/serialization/resources/tts/types/WebSocketRawOutputFormat.js +36 -0
  720. package/dist/serialization/resources/tts/types/WebSocketRequest.d.ts +12 -0
  721. package/dist/serialization/resources/tts/types/WebSocketRequest.js +33 -0
  722. package/dist/serialization/resources/tts/types/WebSocketResponse.d.ts +26 -0
  723. package/dist/serialization/resources/tts/types/WebSocketResponse.js +45 -0
  724. package/dist/serialization/resources/tts/types/WebSocketStreamOptions.d.ts +12 -0
  725. package/dist/serialization/resources/tts/types/WebSocketStreamOptions.js +33 -0
  726. package/dist/serialization/resources/tts/types/WebSocketTimestampsResponse.d.ts +14 -0
  727. package/dist/serialization/resources/tts/types/WebSocketTimestampsResponse.js +37 -0
  728. package/dist/serialization/resources/tts/types/WebSocketTtsOutput.d.ts +16 -0
  729. package/dist/serialization/resources/tts/types/WebSocketTtsOutput.js +37 -0
  730. package/dist/serialization/resources/tts/types/WebSocketTtsRequest.d.ts +21 -0
  731. package/dist/serialization/resources/tts/types/WebSocketTtsRequest.js +42 -0
  732. package/dist/serialization/resources/tts/types/WordTimestamps.d.ts +14 -0
  733. package/dist/serialization/resources/tts/types/WordTimestamps.js +35 -0
  734. package/dist/serialization/resources/tts/types/index.d.ts +30 -0
  735. package/dist/serialization/resources/tts/types/index.js +46 -0
  736. package/dist/serialization/resources/voiceChanger/index.d.ts +1 -0
  737. package/dist/serialization/resources/voiceChanger/index.js +17 -0
  738. package/dist/serialization/resources/voiceChanger/types/OutputFormatContainer.d.ts +10 -0
  739. package/dist/serialization/resources/voiceChanger/types/OutputFormatContainer.js +31 -0
  740. package/dist/serialization/resources/voiceChanger/types/StreamingResponse.d.ts +22 -0
  741. package/dist/serialization/resources/voiceChanger/types/StreamingResponse.js +43 -0
  742. package/dist/serialization/resources/voiceChanger/types/index.d.ts +2 -0
  743. package/dist/serialization/resources/voiceChanger/types/index.js +18 -0
  744. package/dist/serialization/resources/voices/client/index.d.ts +1 -0
  745. package/dist/serialization/resources/voices/client/index.js +27 -0
  746. package/dist/serialization/resources/voices/client/list.d.ts +11 -0
  747. package/dist/serialization/resources/voices/client/list.js +32 -0
  748. package/dist/serialization/resources/voices/index.d.ts +2 -0
  749. package/dist/serialization/resources/voices/index.js +18 -0
  750. package/dist/serialization/resources/voices/types/BaseVoiceId.d.ts +11 -0
  751. package/dist/serialization/resources/voices/types/BaseVoiceId.js +8 -0
  752. package/dist/serialization/resources/voices/types/CloneMode.d.ts +10 -0
  753. package/dist/serialization/resources/voices/types/CloneMode.js +31 -0
  754. package/dist/serialization/resources/voices/types/CreateVoiceRequest.d.ts +19 -0
  755. package/dist/serialization/resources/voices/types/CreateVoiceRequest.js +40 -0
  756. package/dist/serialization/resources/voices/types/EmbeddingResponse.d.ts +13 -0
  757. package/dist/serialization/resources/voices/types/EmbeddingResponse.js +34 -0
  758. package/dist/serialization/resources/voices/types/EmbeddingSpecifier.d.ts +15 -0
  759. package/dist/serialization/resources/voices/types/EmbeddingSpecifier.js +36 -0
  760. package/dist/serialization/resources/voices/types/Gender.d.ts +10 -0
  761. package/dist/serialization/resources/voices/types/Gender.js +34 -0
  762. package/dist/serialization/resources/voices/types/IdSpecifier.d.ts +15 -0
  763. package/dist/serialization/resources/voices/types/IdSpecifier.js +36 -0
  764. package/dist/serialization/resources/voices/types/LocalizeDialect.d.ts +10 -0
  765. package/dist/serialization/resources/voices/types/LocalizeDialect.js +31 -0
  766. package/dist/serialization/resources/voices/types/LocalizeTargetLanguage.d.ts +10 -0
  767. package/dist/serialization/resources/voices/types/LocalizeTargetLanguage.js +47 -0
  768. package/dist/serialization/resources/voices/types/LocalizeVoiceRequest.d.ts +19 -0
  769. package/dist/serialization/resources/voices/types/LocalizeVoiceRequest.js +40 -0
  770. package/dist/serialization/resources/voices/types/MixVoiceSpecifier.d.ts +12 -0
  771. package/dist/serialization/resources/voices/types/MixVoiceSpecifier.js +33 -0
  772. package/dist/serialization/resources/voices/types/MixVoicesRequest.d.ts +13 -0
  773. package/dist/serialization/resources/voices/types/MixVoicesRequest.js +34 -0
  774. package/dist/serialization/resources/voices/types/UpdateVoiceRequest.d.ts +13 -0
  775. package/dist/serialization/resources/voices/types/UpdateVoiceRequest.js +34 -0
  776. package/dist/serialization/resources/voices/types/Voice.d.ts +24 -0
  777. package/dist/serialization/resources/voices/types/Voice.js +45 -0
  778. package/dist/serialization/resources/voices/types/VoiceId.d.ts +10 -0
  779. package/dist/serialization/resources/voices/types/VoiceId.js +31 -0
  780. package/dist/serialization/resources/voices/types/VoiceMetadata.d.ts +20 -0
  781. package/dist/serialization/resources/voices/types/VoiceMetadata.js +41 -0
  782. package/dist/serialization/resources/voices/types/Weight.d.ts +10 -0
  783. package/dist/serialization/resources/voices/types/Weight.js +31 -0
  784. package/dist/serialization/resources/voices/types/index.d.ts +17 -0
  785. package/dist/serialization/resources/voices/types/index.js +33 -0
  786. package/dist/version.d.ts +1 -0
  787. package/dist/version.js +4 -0
  788. package/dist/wrapper/Client.d.ts +6 -0
  789. package/dist/wrapper/Client.js +12 -0
  790. package/dist/wrapper/StreamingTTSClient.d.ts +16 -0
  791. package/dist/wrapper/StreamingTTSClient.js +23 -0
  792. package/dist/{tts/player.d.ts → wrapper/WebPlayer.d.ts} +2 -7
  793. package/dist/wrapper/WebPlayer.js +141 -0
  794. package/dist/wrapper/Websocket.d.ts +57 -0
  795. package/dist/wrapper/Websocket.js +218 -0
  796. package/dist/{tts → wrapper}/source.d.ts +8 -16
  797. package/dist/wrapper/source.js +179 -0
  798. package/dist/wrapper/utils.d.ts +105 -0
  799. package/dist/wrapper/utils.js +173 -0
  800. package/environments.d.ts +7 -0
  801. package/environments.js +9 -0
  802. package/errors/CartesiaError.d.ts +12 -0
  803. package/errors/CartesiaError.js +32 -0
  804. package/errors/CartesiaTimeoutError.d.ts +6 -0
  805. package/errors/CartesiaTimeoutError.js +13 -0
  806. package/errors/index.d.ts +2 -0
  807. package/errors/index.js +7 -0
  808. package/index.d.ts +4 -0
  809. package/index.js +34 -0
  810. package/jest.config.js +5 -0
  811. package/package.json +45 -46
  812. package/reference.md +771 -0
  813. package/serialization/index.d.ts +1 -0
  814. package/serialization/index.js +17 -0
  815. package/serialization/resources/apiStatus/index.d.ts +1 -0
  816. package/serialization/resources/apiStatus/index.js +17 -0
  817. package/serialization/resources/apiStatus/types/ApiInfo.d.ts +13 -0
  818. package/serialization/resources/apiStatus/types/ApiInfo.js +34 -0
  819. package/serialization/resources/apiStatus/types/index.d.ts +1 -0
  820. package/serialization/resources/apiStatus/types/index.js +17 -0
  821. package/serialization/resources/embedding/index.d.ts +1 -0
  822. package/serialization/resources/embedding/index.js +17 -0
  823. package/serialization/resources/embedding/types/Embedding.d.ts +10 -0
  824. package/serialization/resources/embedding/types/Embedding.js +31 -0
  825. package/serialization/resources/embedding/types/index.d.ts +1 -0
  826. package/serialization/resources/embedding/types/index.js +17 -0
  827. package/serialization/resources/index.d.ts +10 -0
  828. package/serialization/resources/index.js +39 -0
  829. package/serialization/resources/tts/index.d.ts +1 -0
  830. package/serialization/resources/tts/index.js +17 -0
  831. package/serialization/resources/tts/types/CancelContextRequest.d.ts +14 -0
  832. package/serialization/resources/tts/types/CancelContextRequest.js +35 -0
  833. package/serialization/resources/tts/types/ContextId.d.ts +10 -0
  834. package/serialization/resources/tts/types/ContextId.js +31 -0
  835. package/serialization/resources/tts/types/Controls.d.ts +15 -0
  836. package/serialization/resources/tts/types/Controls.js +36 -0
  837. package/serialization/resources/tts/types/Emotion.d.ts +10 -0
  838. package/serialization/resources/tts/types/Emotion.js +52 -0
  839. package/serialization/resources/tts/types/GenerationRequest.d.ts +24 -0
  840. package/serialization/resources/tts/types/GenerationRequest.js +45 -0
  841. package/serialization/resources/tts/types/Mp3OutputFormat.d.ts +13 -0
  842. package/serialization/resources/tts/types/Mp3OutputFormat.js +34 -0
  843. package/serialization/resources/tts/types/NaturalSpecifier.d.ts +10 -0
  844. package/serialization/resources/tts/types/NaturalSpecifier.js +31 -0
  845. package/serialization/resources/tts/types/NumericalSpecifier.d.ts +10 -0
  846. package/serialization/resources/tts/types/NumericalSpecifier.js +31 -0
  847. package/serialization/resources/tts/types/OutputFormat.d.ts +22 -0
  848. package/serialization/resources/tts/types/OutputFormat.js +43 -0
  849. package/serialization/resources/tts/types/RawEncoding.d.ts +10 -0
  850. package/serialization/resources/tts/types/RawEncoding.js +31 -0
  851. package/serialization/resources/tts/types/RawOutputFormat.d.ts +14 -0
  852. package/serialization/resources/tts/types/RawOutputFormat.js +35 -0
  853. package/serialization/resources/tts/types/Speed.d.ts +12 -0
  854. package/serialization/resources/tts/types/Speed.js +33 -0
  855. package/serialization/resources/tts/types/SupportedLanguage.d.ts +10 -0
  856. package/serialization/resources/tts/types/SupportedLanguage.js +47 -0
  857. package/serialization/resources/tts/types/TtsRequest.d.ts +20 -0
  858. package/serialization/resources/tts/types/TtsRequest.js +41 -0
  859. package/serialization/resources/tts/types/TtsRequestEmbeddingSpecifier.d.ts +16 -0
  860. package/serialization/resources/tts/types/TtsRequestEmbeddingSpecifier.js +37 -0
  861. package/serialization/resources/tts/types/TtsRequestIdSpecifier.d.ts +16 -0
  862. package/serialization/resources/tts/types/TtsRequestIdSpecifier.js +37 -0
  863. package/serialization/resources/tts/types/TtsRequestVoiceSpecifier.d.ts +12 -0
  864. package/serialization/resources/tts/types/TtsRequestVoiceSpecifier.js +33 -0
  865. package/serialization/resources/tts/types/WavOutputFormat.d.ts +12 -0
  866. package/serialization/resources/tts/types/WavOutputFormat.js +32 -0
  867. package/serialization/resources/tts/types/WebSocketBaseResponse.d.ts +15 -0
  868. package/serialization/resources/tts/types/WebSocketBaseResponse.js +36 -0
  869. package/serialization/resources/tts/types/WebSocketChunkResponse.d.ts +14 -0
  870. package/serialization/resources/tts/types/WebSocketChunkResponse.js +37 -0
  871. package/serialization/resources/tts/types/WebSocketDoneResponse.d.ts +12 -0
  872. package/serialization/resources/tts/types/WebSocketDoneResponse.js +32 -0
  873. package/serialization/resources/tts/types/WebSocketErrorResponse.d.ts +13 -0
  874. package/serialization/resources/tts/types/WebSocketErrorResponse.js +36 -0
  875. package/serialization/resources/tts/types/WebSocketRawOutputFormat.d.ts +15 -0
  876. package/serialization/resources/tts/types/WebSocketRawOutputFormat.js +36 -0
  877. package/serialization/resources/tts/types/WebSocketRequest.d.ts +12 -0
  878. package/serialization/resources/tts/types/WebSocketRequest.js +33 -0
  879. package/serialization/resources/tts/types/WebSocketResponse.d.ts +26 -0
  880. package/serialization/resources/tts/types/WebSocketResponse.js +45 -0
  881. package/serialization/resources/tts/types/WebSocketStreamOptions.d.ts +12 -0
  882. package/serialization/resources/tts/types/WebSocketStreamOptions.js +33 -0
  883. package/serialization/resources/tts/types/WebSocketTimestampsResponse.d.ts +14 -0
  884. package/serialization/resources/tts/types/WebSocketTimestampsResponse.js +37 -0
  885. package/serialization/resources/tts/types/WebSocketTtsOutput.d.ts +16 -0
  886. package/serialization/resources/tts/types/WebSocketTtsOutput.js +37 -0
  887. package/serialization/resources/tts/types/WebSocketTtsRequest.d.ts +21 -0
  888. package/serialization/resources/tts/types/WebSocketTtsRequest.js +42 -0
  889. package/serialization/resources/tts/types/WordTimestamps.d.ts +14 -0
  890. package/serialization/resources/tts/types/WordTimestamps.js +35 -0
  891. package/serialization/resources/tts/types/index.d.ts +30 -0
  892. package/serialization/resources/tts/types/index.js +46 -0
  893. package/serialization/resources/voiceChanger/index.d.ts +1 -0
  894. package/serialization/resources/voiceChanger/index.js +17 -0
  895. package/serialization/resources/voiceChanger/types/OutputFormatContainer.d.ts +10 -0
  896. package/serialization/resources/voiceChanger/types/OutputFormatContainer.js +31 -0
  897. package/serialization/resources/voiceChanger/types/StreamingResponse.d.ts +22 -0
  898. package/serialization/resources/voiceChanger/types/StreamingResponse.js +43 -0
  899. package/serialization/resources/voiceChanger/types/index.d.ts +2 -0
  900. package/serialization/resources/voiceChanger/types/index.js +18 -0
  901. package/serialization/resources/voices/client/index.d.ts +1 -0
  902. package/serialization/resources/voices/client/index.js +27 -0
  903. package/serialization/resources/voices/client/list.d.ts +11 -0
  904. package/serialization/resources/voices/client/list.js +32 -0
  905. package/serialization/resources/voices/index.d.ts +2 -0
  906. package/serialization/resources/voices/index.js +18 -0
  907. package/serialization/resources/voices/types/BaseVoiceId.d.ts +11 -0
  908. package/serialization/resources/voices/types/BaseVoiceId.js +8 -0
  909. package/serialization/resources/voices/types/CloneMode.d.ts +10 -0
  910. package/serialization/resources/voices/types/CloneMode.js +31 -0
  911. package/serialization/resources/voices/types/CreateVoiceRequest.d.ts +19 -0
  912. package/serialization/resources/voices/types/CreateVoiceRequest.js +40 -0
  913. package/serialization/resources/voices/types/EmbeddingResponse.d.ts +13 -0
  914. package/serialization/resources/voices/types/EmbeddingResponse.js +34 -0
  915. package/serialization/resources/voices/types/EmbeddingSpecifier.d.ts +15 -0
  916. package/serialization/resources/voices/types/EmbeddingSpecifier.js +36 -0
  917. package/serialization/resources/voices/types/Gender.d.ts +10 -0
  918. package/serialization/resources/voices/types/Gender.js +34 -0
  919. package/serialization/resources/voices/types/IdSpecifier.d.ts +15 -0
  920. package/serialization/resources/voices/types/IdSpecifier.js +36 -0
  921. package/serialization/resources/voices/types/LocalizeDialect.d.ts +10 -0
  922. package/serialization/resources/voices/types/LocalizeDialect.js +31 -0
  923. package/serialization/resources/voices/types/LocalizeTargetLanguage.d.ts +10 -0
  924. package/serialization/resources/voices/types/LocalizeTargetLanguage.js +47 -0
  925. package/serialization/resources/voices/types/LocalizeVoiceRequest.d.ts +19 -0
  926. package/serialization/resources/voices/types/LocalizeVoiceRequest.js +40 -0
  927. package/serialization/resources/voices/types/MixVoiceSpecifier.d.ts +12 -0
  928. package/serialization/resources/voices/types/MixVoiceSpecifier.js +33 -0
  929. package/serialization/resources/voices/types/MixVoicesRequest.d.ts +13 -0
  930. package/serialization/resources/voices/types/MixVoicesRequest.js +34 -0
  931. package/serialization/resources/voices/types/UpdateVoiceRequest.d.ts +13 -0
  932. package/serialization/resources/voices/types/UpdateVoiceRequest.js +34 -0
  933. package/serialization/resources/voices/types/Voice.d.ts +24 -0
  934. package/serialization/resources/voices/types/Voice.js +45 -0
  935. package/serialization/resources/voices/types/VoiceId.d.ts +10 -0
  936. package/serialization/resources/voices/types/VoiceId.js +31 -0
  937. package/serialization/resources/voices/types/VoiceMetadata.d.ts +20 -0
  938. package/serialization/resources/voices/types/VoiceMetadata.js +41 -0
  939. package/serialization/resources/voices/types/Weight.d.ts +10 -0
  940. package/serialization/resources/voices/types/Weight.js +31 -0
  941. package/serialization/resources/voices/types/index.d.ts +17 -0
  942. package/serialization/resources/voices/types/index.js +33 -0
  943. package/version.d.ts +1 -0
  944. package/version.js +4 -0
  945. package/wrapper/Client.d.ts +6 -0
  946. package/wrapper/Client.js +12 -0
  947. package/wrapper/StreamingTTSClient.d.ts +16 -0
  948. package/wrapper/StreamingTTSClient.js +23 -0
  949. package/{dist/tts/player.d.cts → wrapper/WebPlayer.d.ts} +2 -7
  950. package/wrapper/WebPlayer.js +141 -0
  951. package/wrapper/Websocket.d.ts +57 -0
  952. package/wrapper/Websocket.js +218 -0
  953. package/{dist/tts/source.d.cts → wrapper/source.d.ts} +8 -16
  954. package/wrapper/source.js +179 -0
  955. package/wrapper/utils.d.ts +105 -0
  956. package/wrapper/utils.js +173 -0
  957. package/CHANGELOG.md +0 -90
  958. package/LICENSE.md +0 -21
  959. package/dist/chunk-2BFEKY3F.js +0 -16
  960. package/dist/chunk-5SBAQNWQ.js +0 -86
  961. package/dist/chunk-62LXGS65.js +0 -116
  962. package/dist/chunk-CSOXALSC.js +0 -132
  963. package/dist/chunk-EYRYHK3X.js +0 -43
  964. package/dist/chunk-FLWYXP5Z.js +0 -40
  965. package/dist/chunk-FXPGR372.js +0 -0
  966. package/dist/chunk-HQOC2S6C.js +0 -264
  967. package/dist/chunk-I5YVYTNK.js +0 -190
  968. package/dist/chunk-LKKWJLUG.js +0 -17
  969. package/dist/chunk-MGVQHO25.js +0 -26
  970. package/dist/chunk-NJDRWDQ3.js +0 -57
  971. package/dist/chunk-WLEVU3HN.js +0 -42
  972. package/dist/index.cjs +0 -910
  973. package/dist/index.d.cts +0 -11
  974. package/dist/lib/client.cjs +0 -113
  975. package/dist/lib/client.d.cts +0 -11
  976. package/dist/lib/client.d.ts +0 -11
  977. package/dist/lib/client.js +0 -8
  978. package/dist/lib/constants.cjs +0 -42
  979. package/dist/lib/constants.d.cts +0 -16
  980. package/dist/lib/constants.d.ts +0 -16
  981. package/dist/lib/constants.js +0 -11
  982. package/dist/lib/index.cjs +0 -772
  983. package/dist/lib/index.d.cts +0 -18
  984. package/dist/lib/index.d.ts +0 -18
  985. package/dist/lib/index.js +0 -15
  986. package/dist/react/index.cjs +0 -1164
  987. package/dist/react/index.d.cts +0 -34
  988. package/dist/react/index.d.ts +0 -34
  989. package/dist/react/index.js +0 -274
  990. package/dist/react/utils.cjs +0 -57
  991. package/dist/react/utils.d.cts +0 -7
  992. package/dist/react/utils.d.ts +0 -7
  993. package/dist/react/utils.js +0 -7
  994. package/dist/tts/index.cjs +0 -620
  995. package/dist/tts/index.d.cts +0 -24
  996. package/dist/tts/index.d.ts +0 -24
  997. package/dist/tts/index.js +0 -12
  998. package/dist/tts/player.cjs +0 -202
  999. package/dist/tts/player.js +0 -9
  1000. package/dist/tts/source.cjs +0 -244
  1001. package/dist/tts/source.js +0 -9
  1002. package/dist/tts/utils.cjs +0 -134
  1003. package/dist/tts/utils.d.cts +0 -69
  1004. package/dist/tts/utils.d.ts +0 -69
  1005. package/dist/tts/utils.js +0 -22
  1006. package/dist/tts/websocket.cjs +0 -588
  1007. package/dist/tts/websocket.d.cts +0 -69
  1008. package/dist/tts/websocket.d.ts +0 -69
  1009. package/dist/tts/websocket.js +0 -11
  1010. package/dist/types/index.cjs +0 -18
  1011. package/dist/types/index.d.cts +0 -173
  1012. package/dist/types/index.d.ts +0 -173
  1013. package/dist/types/index.js +0 -1
  1014. package/dist/voice-changer/index.cjs +0 -143
  1015. package/dist/voice-changer/index.d.cts +0 -9
  1016. package/dist/voice-changer/index.d.ts +0 -9
  1017. package/dist/voice-changer/index.js +0 -9
  1018. package/dist/voices/index.cjs +0 -217
  1019. package/dist/voices/index.d.cts +0 -16
  1020. package/dist/voices/index.d.ts +0 -16
  1021. package/dist/voices/index.js +0 -9
  1022. package/src/index.ts +0 -6
  1023. package/src/lib/client.ts +0 -31
  1024. package/src/lib/constants.ts +0 -25
  1025. package/src/lib/index.ts +0 -19
  1026. package/src/react/index.ts +0 -303
  1027. package/src/react/utils.ts +0 -11
  1028. package/src/tts/index.ts +0 -32
  1029. package/src/tts/player.ts +0 -117
  1030. package/src/tts/source.ts +0 -196
  1031. package/src/tts/utils.ts +0 -164
  1032. package/src/tts/websocket.ts +0 -271
  1033. package/src/types/index.ts +0 -233
  1034. package/src/voice-changer/index.ts +0 -37
  1035. package/src/voices/index.ts +0 -116
@@ -1,1164 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __defProps = Object.defineProperties;
5
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
7
- var __getOwnPropNames = Object.getOwnPropertyNames;
8
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
9
- var __getProtoOf = Object.getPrototypeOf;
10
- var __hasOwnProp = Object.prototype.hasOwnProperty;
11
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
12
- var __typeError = (msg) => {
13
- throw TypeError(msg);
14
- };
15
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
16
- var __spreadValues = (a, b) => {
17
- for (var prop in b || (b = {}))
18
- if (__hasOwnProp.call(b, prop))
19
- __defNormalProp(a, prop, b[prop]);
20
- if (__getOwnPropSymbols)
21
- for (var prop of __getOwnPropSymbols(b)) {
22
- if (__propIsEnum.call(b, prop))
23
- __defNormalProp(a, prop, b[prop]);
24
- }
25
- return a;
26
- };
27
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
28
- var __export = (target, all) => {
29
- for (var name in all)
30
- __defProp(target, name, { get: all[name], enumerable: true });
31
- };
32
- var __copyProps = (to, from, except, desc) => {
33
- if (from && typeof from === "object" || typeof from === "function") {
34
- for (let key of __getOwnPropNames(from))
35
- if (!__hasOwnProp.call(to, key) && key !== except)
36
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
37
- }
38
- return to;
39
- };
40
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
41
- // If the importer is in node compatibility mode or this is not an ESM
42
- // file that has been converted to a CommonJS file using a Babel-
43
- // compatible transform (i.e. "__esModule" has not been set), then set
44
- // "default" to the CommonJS "module.exports" for node compatibility.
45
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
46
- mod
47
- ));
48
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
49
- var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
50
- var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
51
- var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
52
- var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
53
- var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
54
- var __async = (__this, __arguments, generator) => {
55
- return new Promise((resolve, reject) => {
56
- var fulfilled = (value) => {
57
- try {
58
- step(generator.next(value));
59
- } catch (e) {
60
- reject(e);
61
- }
62
- };
63
- var rejected = (value) => {
64
- try {
65
- step(generator.throw(value));
66
- } catch (e) {
67
- reject(e);
68
- }
69
- };
70
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
71
- step((generator = generator.apply(__this, __arguments)).next());
72
- });
73
- };
74
-
75
- // src/react/index.ts
76
- var react_exports = {};
77
- __export(react_exports, {
78
- useTTS: () => useTTS
79
- });
80
- module.exports = __toCommonJS(react_exports);
81
- var import_react = require("react");
82
-
83
- // src/lib/client.ts
84
- var import_cross_fetch = __toESM(require("cross-fetch"), 1);
85
-
86
- // src/lib/constants.ts
87
- var BASE_URL = "https://api.cartesia.ai";
88
- var CARTESIA_VERSION = "2024-06-10";
89
- var constructApiUrl = (baseUrl, path, { websocket = false } = {}) => {
90
- const url = new URL(path, baseUrl);
91
- if (websocket) {
92
- url.protocol = baseUrl.replace(/^http/, "ws");
93
- }
94
- return url;
95
- };
96
-
97
- // src/lib/client.ts
98
- var Client = class {
99
- constructor(options = {}) {
100
- const apiKey = options.apiKey || process.env.CARTESIA_API_KEY;
101
- if (!apiKey) {
102
- throw new Error("Missing Cartesia API key.");
103
- }
104
- this.apiKey = typeof apiKey === "function" ? apiKey : () => __async(this, null, function* () {
105
- return apiKey;
106
- });
107
- this.baseUrl = options.baseUrl || BASE_URL;
108
- }
109
- _fetch(_0) {
110
- return __async(this, arguments, function* (path, options = {}) {
111
- const url = constructApiUrl(this.baseUrl, path);
112
- const headers = new Headers(options.headers);
113
- headers.set("X-API-Key", yield this.apiKey());
114
- headers.set("Cartesia-Version", CARTESIA_VERSION);
115
- return (0, import_cross_fetch.default)(url.toString(), __spreadProps(__spreadValues({}, options), {
116
- headers
117
- }));
118
- });
119
- }
120
- };
121
-
122
- // src/tts/websocket.ts
123
- var import_emittery2 = __toESM(require("emittery"), 1);
124
- var import_human_id = require("human-id");
125
- var import_partysocket = require("partysocket");
126
-
127
- // src/tts/source.ts
128
- var import_emittery = __toESM(require("emittery"), 1);
129
- var ENCODING_MAP = {
130
- pcm_f32le: { arrayType: Float32Array, bytesPerElement: 4 },
131
- pcm_s16le: { arrayType: Int16Array, bytesPerElement: 2 },
132
- pcm_alaw: { arrayType: Uint8Array, bytesPerElement: 1 },
133
- pcm_mulaw: { arrayType: Uint8Array, bytesPerElement: 1 }
134
- };
135
- var _emitter, _buffer, _readIndex, _writeIndex, _closed, _sampleRate, _encoding, _container, _Source_instances, createBuffer_fn;
136
- var Source = class {
137
- /**
138
- * Create a new Source.
139
- *
140
- * @param options - Options for the Source.
141
- * @param options.sampleRate - The sample rate of the audio.
142
- */
143
- constructor({
144
- sampleRate,
145
- encoding,
146
- container
147
- }) {
148
- __privateAdd(this, _Source_instances);
149
- __privateAdd(this, _emitter, new import_emittery.default());
150
- __privateAdd(this, _buffer);
151
- __privateAdd(this, _readIndex, 0);
152
- __privateAdd(this, _writeIndex, 0);
153
- __privateAdd(this, _closed, false);
154
- __privateAdd(this, _sampleRate);
155
- __privateAdd(this, _encoding);
156
- __privateAdd(this, _container);
157
- this.on = __privateGet(this, _emitter).on.bind(__privateGet(this, _emitter));
158
- this.once = __privateGet(this, _emitter).once.bind(__privateGet(this, _emitter));
159
- this.events = __privateGet(this, _emitter).events.bind(__privateGet(this, _emitter));
160
- this.off = __privateGet(this, _emitter).off.bind(__privateGet(this, _emitter));
161
- __privateSet(this, _sampleRate, sampleRate);
162
- __privateSet(this, _encoding, encoding);
163
- __privateSet(this, _container, container);
164
- __privateSet(this, _buffer, __privateMethod(this, _Source_instances, createBuffer_fn).call(this, 1024));
165
- }
166
- get sampleRate() {
167
- return __privateGet(this, _sampleRate);
168
- }
169
- get encoding() {
170
- return __privateGet(this, _encoding);
171
- }
172
- get container() {
173
- return __privateGet(this, _container);
174
- }
175
- /**
176
- * Append audio to the buffer.
177
- *
178
- * @param src The audio to append.
179
- */
180
- enqueue(src) {
181
- return __async(this, null, function* () {
182
- const requiredCapacity = __privateGet(this, _writeIndex) + src.length;
183
- if (requiredCapacity > __privateGet(this, _buffer).length) {
184
- let newCapacity = __privateGet(this, _buffer).length;
185
- while (newCapacity < requiredCapacity) {
186
- newCapacity *= 2;
187
- }
188
- const newBuffer = __privateMethod(this, _Source_instances, createBuffer_fn).call(this, newCapacity);
189
- newBuffer.set(__privateGet(this, _buffer));
190
- __privateSet(this, _buffer, newBuffer);
191
- }
192
- __privateGet(this, _buffer).set(src, __privateGet(this, _writeIndex));
193
- __privateSet(this, _writeIndex, __privateGet(this, _writeIndex) + src.length);
194
- yield __privateGet(this, _emitter).emit("enqueue");
195
- });
196
- }
197
- /**
198
- * Read audio from the buffer.
199
- *
200
- * @param dst The buffer to read the audio into.
201
- * @returns The number of samples read. If the source is closed, this will be
202
- * less than the length of the provided buffer.
203
- */
204
- read(dst) {
205
- return __async(this, null, function* () {
206
- const targetReadIndex = __privateGet(this, _readIndex) + dst.length;
207
- while (!__privateGet(this, _closed) && targetReadIndex > __privateGet(this, _writeIndex)) {
208
- yield __privateGet(this, _emitter).emit("wait");
209
- yield Promise.race([
210
- __privateGet(this, _emitter).once("enqueue"),
211
- __privateGet(this, _emitter).once("close")
212
- ]);
213
- yield __privateGet(this, _emitter).emit("read");
214
- }
215
- const read = Math.min(dst.length, __privateGet(this, _writeIndex) - __privateGet(this, _readIndex));
216
- dst.set(__privateGet(this, _buffer).subarray(__privateGet(this, _readIndex), __privateGet(this, _readIndex) + read));
217
- __privateSet(this, _readIndex, __privateGet(this, _readIndex) + read);
218
- return read;
219
- });
220
- }
221
- /**
222
- * Seek in the buffer.
223
- *
224
- * @param offset The offset to seek to.
225
- * @param whence The position to seek from.
226
- * @returns The new position in the buffer.
227
- * @throws {Error} If the seek is invalid.
228
- */
229
- seek(offset, whence) {
230
- return __async(this, null, function* () {
231
- let position = __privateGet(this, _readIndex);
232
- switch (whence) {
233
- case "start":
234
- position = offset;
235
- break;
236
- case "current":
237
- position += offset;
238
- break;
239
- case "end":
240
- position = __privateGet(this, _writeIndex) + offset;
241
- break;
242
- default:
243
- throw new Error(`Invalid seek mode: ${whence}`);
244
- }
245
- if (position < 0 || position > __privateGet(this, _writeIndex)) {
246
- throw new Error("Seek out of bounds");
247
- }
248
- __privateSet(this, _readIndex, position);
249
- return position;
250
- });
251
- }
252
- /**
253
- * Get the number of samples in a given duration.
254
- *
255
- * @param durationSecs The duration in seconds.
256
- * @returns The number of samples.
257
- */
258
- durationToSampleCount(durationSecs) {
259
- return Math.trunc(durationSecs * __privateGet(this, _sampleRate));
260
- }
261
- get buffer() {
262
- return __privateGet(this, _buffer);
263
- }
264
- get readIndex() {
265
- return __privateGet(this, _readIndex);
266
- }
267
- get writeIndex() {
268
- return __privateGet(this, _writeIndex);
269
- }
270
- /**
271
- * Close the source. This signals that no more audio will be enqueued.
272
- *
273
- * This will emit a "close" event.
274
- *
275
- * @returns A promise that resolves when the source is closed.
276
- */
277
- close() {
278
- return __async(this, null, function* () {
279
- __privateSet(this, _closed, true);
280
- yield __privateGet(this, _emitter).emit("close");
281
- __privateGet(this, _emitter).clearListeners();
282
- });
283
- }
284
- };
285
- _emitter = new WeakMap();
286
- _buffer = new WeakMap();
287
- _readIndex = new WeakMap();
288
- _writeIndex = new WeakMap();
289
- _closed = new WeakMap();
290
- _sampleRate = new WeakMap();
291
- _encoding = new WeakMap();
292
- _container = new WeakMap();
293
- _Source_instances = new WeakSet();
294
- /**
295
- * Create a new buffer for the source.
296
- *
297
- * @param size - The size of the buffer to create.
298
- * @returns The new buffer as a TypedArray based on the encoding.
299
- */
300
- createBuffer_fn = function(size) {
301
- const { arrayType: ArrayType } = ENCODING_MAP[__privateGet(this, _encoding)];
302
- return new ArrayType(size);
303
- };
304
-
305
- // src/tts/utils.ts
306
- var import_base64_js = __toESM(require("base64-js"), 1);
307
- function base64ToArray(b64, encoding) {
308
- const byteArrays = filterSentinel(b64).map((b) => import_base64_js.default.toByteArray(b));
309
- const { arrayType: ArrayType, bytesPerElement } = ENCODING_MAP[encoding];
310
- const totalLength = byteArrays.reduce(
311
- (acc, arr) => acc + arr.length / bytesPerElement,
312
- 0
313
- );
314
- const result = new ArrayType(totalLength);
315
- let offset = 0;
316
- for (const arr of byteArrays) {
317
- const floats = new ArrayType(arr.buffer);
318
- result.set(floats, offset);
319
- offset += floats.length;
320
- }
321
- return result;
322
- }
323
- function playAudioBuffer(floats, context, startAt, sampleRate) {
324
- const source = context.createBufferSource();
325
- const buffer = context.createBuffer(1, floats.length, sampleRate);
326
- buffer.getChannelData(0).set(floats);
327
- source.buffer = buffer;
328
- source.connect(context.destination);
329
- source.start(startAt);
330
- return new Promise((resolve) => {
331
- source.onended = () => {
332
- resolve();
333
- };
334
- });
335
- }
336
- function createMessageHandlerForContextId(contextId, handler) {
337
- return (event) => {
338
- if (typeof event.data !== "string") {
339
- return;
340
- }
341
- const message = JSON.parse(event.data);
342
- if (message.context_id !== contextId) {
343
- return;
344
- }
345
- let chunk;
346
- if (message.done) {
347
- chunk = getSentinel();
348
- } else if (message.type === "chunk") {
349
- chunk = message.data;
350
- }
351
- handler({ chunk, message: event.data, data: message });
352
- };
353
- }
354
- function getSentinel() {
355
- return null;
356
- }
357
- function isSentinel(x) {
358
- return x === getSentinel();
359
- }
360
- function filterSentinel(collection) {
361
- return collection.filter(
362
- (x) => !isSentinel(x)
363
- );
364
- }
365
- function getEmitteryCallbacks(emitter) {
366
- return {
367
- on: emitter.on.bind(emitter),
368
- off: emitter.off.bind(emitter),
369
- once: emitter.once.bind(emitter),
370
- events: emitter.events.bind(emitter)
371
- };
372
- }
373
-
374
- // src/tts/websocket.ts
375
- var _isConnected, _sampleRate2, _container2, _encoding2, _WebSocket_instances, generateId_fn;
376
- var WebSocket = class extends Client {
377
- /**
378
- * Create a new WebSocket client.
379
- *
380
- * @param args - Arguments to pass to the Client constructor.
381
- */
382
- constructor({ sampleRate, container, encoding }, ...args) {
383
- super(...args);
384
- __privateAdd(this, _WebSocket_instances);
385
- __privateAdd(this, _isConnected, false);
386
- __privateAdd(this, _sampleRate2);
387
- __privateAdd(this, _container2);
388
- __privateAdd(this, _encoding2);
389
- __privateSet(this, _sampleRate2, sampleRate);
390
- __privateSet(this, _container2, container != null ? container : "raw");
391
- __privateSet(this, _encoding2, encoding != null ? encoding : "pcm_f32le");
392
- }
393
- /**
394
- * Send a message over the WebSocket to start a stream.
395
- *
396
- * @param inputs - Generation parameters. Defined in the StreamRequest type.
397
- * @param options - Options for the stream.
398
- * @param options.timeout - The maximum time to wait for a chunk before cancelling the stream.
399
- * If set to `0`, the stream will not time out.
400
- * @returns A Source object that can be passed to a Player to play the audio.
401
- * @returns An Emittery instance that emits messages from the WebSocket.
402
- * @returns An abort function that can be called to cancel the stream.
403
- */
404
- send(inputs, { timeout = 0 } = {}) {
405
- var _a, _b, _c, _d;
406
- if (!__privateGet(this, _isConnected)) {
407
- throw new Error("Not connected to WebSocket. Call .connect() first.");
408
- }
409
- if (!inputs.context_id) {
410
- inputs.context_id = __privateMethod(this, _WebSocket_instances, generateId_fn).call(this);
411
- }
412
- if (!inputs.output_format) {
413
- inputs.output_format = {
414
- container: __privateGet(this, _container2),
415
- encoding: __privateGet(this, _encoding2),
416
- sample_rate: __privateGet(this, _sampleRate2)
417
- };
418
- }
419
- (_a = this.socket) == null ? void 0 : _a.send(
420
- JSON.stringify(__spreadValues({}, inputs))
421
- );
422
- const emitter = new import_emittery2.default();
423
- const source = new Source({
424
- sampleRate: __privateGet(this, _sampleRate2),
425
- encoding: __privateGet(this, _encoding2),
426
- container: __privateGet(this, _container2)
427
- });
428
- const streamCompleteController = new AbortController();
429
- let timeoutId = null;
430
- if (timeout > 0) {
431
- timeoutId = setTimeout(streamCompleteController.abort, timeout);
432
- }
433
- const handleMessage = createMessageHandlerForContextId(
434
- inputs.context_id,
435
- (_0) => __async(this, [_0], function* ({ chunk, message, data }) {
436
- emitter.emit("message", message);
437
- if (data.type === "timestamps") {
438
- emitter.emit("timestamps", data.word_timestamps);
439
- return;
440
- }
441
- if (isSentinel(chunk)) {
442
- yield source.close();
443
- streamCompleteController.abort();
444
- return;
445
- }
446
- if (timeoutId) {
447
- clearTimeout(timeoutId);
448
- timeoutId = setTimeout(streamCompleteController.abort, timeout);
449
- }
450
- if (!chunk) {
451
- return;
452
- }
453
- yield source.enqueue(base64ToArray([chunk], __privateGet(this, _encoding2)));
454
- })
455
- );
456
- (_b = this.socket) == null ? void 0 : _b.addEventListener("message", handleMessage, {
457
- signal: streamCompleteController.signal
458
- });
459
- (_c = this.socket) == null ? void 0 : _c.addEventListener(
460
- "close",
461
- () => {
462
- streamCompleteController.abort();
463
- },
464
- {
465
- once: true
466
- }
467
- );
468
- (_d = this.socket) == null ? void 0 : _d.addEventListener(
469
- "error",
470
- () => {
471
- streamCompleteController.abort();
472
- },
473
- {
474
- once: true
475
- }
476
- );
477
- streamCompleteController.signal.addEventListener("abort", () => {
478
- source.close();
479
- if (timeoutId) {
480
- clearTimeout(timeoutId);
481
- }
482
- });
483
- return __spreadProps(__spreadValues({
484
- source
485
- }, getEmitteryCallbacks(emitter)), {
486
- stop: streamCompleteController.abort.bind(streamCompleteController)
487
- });
488
- }
489
- /**
490
- * Continue a stream.
491
- *
492
- * @param inputs - Generation parameters. Defined in the StreamRequest type, but must include a `context_id` field. `continue` is set to true by default.
493
- */
494
- continue(inputs) {
495
- var _a;
496
- if (!__privateGet(this, _isConnected)) {
497
- throw new Error("Not connected to WebSocket. Call .connect() first.");
498
- }
499
- if (!inputs.context_id) {
500
- throw new Error("context_id is required to continue a context.");
501
- }
502
- if (!inputs.output_format) {
503
- inputs.output_format = {
504
- container: __privateGet(this, _container2),
505
- encoding: __privateGet(this, _encoding2),
506
- sample_rate: __privateGet(this, _sampleRate2)
507
- };
508
- }
509
- (_a = this.socket) == null ? void 0 : _a.send(
510
- JSON.stringify(__spreadValues({
511
- continue: true
512
- }, inputs))
513
- );
514
- }
515
- /**
516
- * Authenticate and connect to a Cartesia streaming WebSocket.
517
- *
518
- * @returns A promise that resolves when the WebSocket is connected.
519
- * @throws {Error} If the WebSocket fails to connect.
520
- */
521
- connect() {
522
- return __async(this, null, function* () {
523
- const emitter = new import_emittery2.default();
524
- this.socket = new import_partysocket.WebSocket(() => __async(this, null, function* () {
525
- const url = constructApiUrl(this.baseUrl, "/tts/websocket", {
526
- websocket: true
527
- });
528
- url.searchParams.set("api_key", yield this.apiKey());
529
- url.searchParams.set("cartesia_version", CARTESIA_VERSION);
530
- return url.toString();
531
- }));
532
- this.socket.binaryType = "arraybuffer";
533
- this.socket.onopen = () => {
534
- __privateSet(this, _isConnected, true);
535
- emitter.emit("open");
536
- };
537
- this.socket.onclose = () => {
538
- __privateSet(this, _isConnected, false);
539
- emitter.emit("close");
540
- };
541
- return new Promise(
542
- (resolve, reject) => {
543
- var _a, _b, _c;
544
- (_a = this.socket) == null ? void 0 : _a.addEventListener(
545
- "open",
546
- () => {
547
- resolve(getEmitteryCallbacks(emitter));
548
- },
549
- {
550
- once: true
551
- }
552
- );
553
- const aborter = new AbortController();
554
- (_b = this.socket) == null ? void 0 : _b.addEventListener(
555
- "error",
556
- () => {
557
- aborter.abort();
558
- reject(new Error("WebSocket failed to connect."));
559
- },
560
- {
561
- signal: aborter.signal
562
- }
563
- );
564
- (_c = this.socket) == null ? void 0 : _c.addEventListener(
565
- "close",
566
- () => {
567
- aborter.abort();
568
- reject(new Error("WebSocket closed before it could connect."));
569
- },
570
- {
571
- signal: aborter.signal
572
- }
573
- );
574
- }
575
- );
576
- });
577
- }
578
- /**
579
- * Disconnect from the Cartesia streaming WebSocket.
580
- */
581
- disconnect() {
582
- var _a;
583
- (_a = this.socket) == null ? void 0 : _a.close();
584
- }
585
- };
586
- _isConnected = new WeakMap();
587
- _sampleRate2 = new WeakMap();
588
- _container2 = new WeakMap();
589
- _encoding2 = new WeakMap();
590
- _WebSocket_instances = new WeakSet();
591
- /**
592
- * Generate a unique ID suitable for a streaming context.
593
- *
594
- * Not suitable for security purposes or as a primary key, since
595
- * it lacks the amount of entropy required for those use cases.
596
- *
597
- * @returns A unique ID.
598
- */
599
- generateId_fn = function() {
600
- return (0, import_human_id.humanId)({
601
- separator: "-",
602
- capitalize: false
603
- });
604
- };
605
-
606
- // src/tts/index.ts
607
- var TTS = class extends Client {
608
- /**
609
- * Get a WebSocket client for streaming audio from the TTS API.
610
- *
611
- * @returns {WebSocket} A Cartesia WebSocket client.
612
- */
613
- websocket(options) {
614
- return new WebSocket(options, {
615
- apiKey: this.apiKey,
616
- baseUrl: this.baseUrl
617
- });
618
- }
619
- /**
620
- * Generate audio bytes from text.
621
- *
622
- * @param options - The options for the request.
623
- * @returns {Promise<ArrayBuffer>} A promise that resolves to an ArrayBuffer containing the audio bytes.
624
- */
625
- bytes(options) {
626
- return __async(this, null, function* () {
627
- const response = yield this._fetch("/tts/bytes", {
628
- method: "POST",
629
- body: JSON.stringify(options)
630
- });
631
- return response.arrayBuffer();
632
- });
633
- }
634
- };
635
-
636
- // src/voice-changer/index.ts
637
- var VoiceChanger = class extends Client {
638
- bytes(options) {
639
- return __async(this, null, function* () {
640
- const formData = new FormData();
641
- formData.append("clip", options.clip);
642
- formData.append("voice[id]", options.voice.id);
643
- const fmt = options.output_format;
644
- formData.append("output_format[container]", fmt.container);
645
- if ("encoding" in fmt) {
646
- formData.append("output_format[encoding]", fmt.encoding);
647
- }
648
- if ("bit_rate" in fmt) {
649
- formData.append("output_format[bit_rate]", fmt.bit_rate.toString());
650
- }
651
- if ("sample_rate" in fmt) {
652
- formData.append("output_format[sample_rate]", fmt.sample_rate.toString());
653
- }
654
- const response = yield this._fetch("/voice-changer/bytes", {
655
- method: "POST",
656
- body: formData
657
- });
658
- if (!response.ok) {
659
- throw new Error(
660
- `Voice changer error! status: ${response.status}, message: ${yield response.text()}`
661
- );
662
- }
663
- return { buffer: yield response.arrayBuffer() };
664
- });
665
- }
666
- };
667
-
668
- // src/voices/index.ts
669
- var Voices = class extends Client {
670
- list() {
671
- return __async(this, null, function* () {
672
- const response = yield this._fetch("/voices");
673
- return response.json();
674
- });
675
- }
676
- get(voiceId) {
677
- return __async(this, null, function* () {
678
- const response = yield this._fetch(`/voices/${voiceId}`);
679
- return response.json();
680
- });
681
- }
682
- create(voice) {
683
- return __async(this, null, function* () {
684
- const response = yield this._fetch("/voices", {
685
- method: "POST",
686
- body: JSON.stringify(voice)
687
- });
688
- return response.json();
689
- });
690
- }
691
- update(id, voice) {
692
- return __async(this, null, function* () {
693
- const response = yield this._fetch(`/voices/${id}`, {
694
- method: "PATCH",
695
- body: JSON.stringify(voice)
696
- });
697
- return response.json();
698
- });
699
- }
700
- clone(options) {
701
- return __async(this, null, function* () {
702
- if (options.mode === "clip") {
703
- const formData = new FormData();
704
- formData.append("clip", options.clip);
705
- if (options.enhance !== void 0) {
706
- formData.append("enhance", options.enhance.toString());
707
- }
708
- const response = yield this._fetch("/voices/clone/clip", {
709
- method: "POST",
710
- body: formData
711
- });
712
- return response.json();
713
- }
714
- throw new Error("Invalid mode for clone()");
715
- });
716
- }
717
- hifiClone(options) {
718
- return __async(this, null, function* () {
719
- var _a;
720
- if (options.mode !== "clip") {
721
- throw new Error("Invalid mode for hifiClone()");
722
- }
723
- const formData = new FormData();
724
- formData.append("clip", options.clip);
725
- formData.append("name", options.name);
726
- formData.append("description", options.description);
727
- formData.append("language", options.language);
728
- formData.append("model_id", options.model_id);
729
- if (options.enhance !== void 0) {
730
- formData.append("enhance", options.enhance.toString());
731
- }
732
- if (options.transcript) {
733
- formData.append("transcript", options.transcript);
734
- }
735
- if (options.base_voice_id) {
736
- formData.append("base_voice_id", options.base_voice_id);
737
- }
738
- const response = yield this._fetch("/voices/clone/hifi", {
739
- method: "POST",
740
- body: formData
741
- });
742
- if (!response.ok) {
743
- if ((_a = response.headers.get("content-type")) == null ? void 0 : _a.includes("application/json")) {
744
- const errorData = yield response.json();
745
- throw new Error(errorData.message || "HiFi clone failed");
746
- }
747
- const errorText = yield response.text();
748
- throw new Error(errorText || "HiFi clone failed");
749
- }
750
- const data = yield response.json();
751
- return data;
752
- });
753
- }
754
- mix(options) {
755
- return __async(this, null, function* () {
756
- const response = yield this._fetch("/voices/mix", {
757
- method: "POST",
758
- body: JSON.stringify(options)
759
- });
760
- return response.json();
761
- });
762
- }
763
- localize(options) {
764
- return __async(this, null, function* () {
765
- const response = yield this._fetch("/voices/localize", {
766
- method: "POST",
767
- body: JSON.stringify(options)
768
- });
769
- return response.json();
770
- });
771
- }
772
- };
773
-
774
- // src/lib/index.ts
775
- var Cartesia = class extends Client {
776
- constructor(options = {}) {
777
- super(options);
778
- this.tts = new TTS(options);
779
- this.voices = new Voices(options);
780
- this.voiceChanger = new VoiceChanger(options);
781
- }
782
- };
783
-
784
- // src/tts/player.ts
785
- var _context, _startNextPlaybackAt, _bufferDuration, _Player_instances, playBuffer_fn;
786
- var Player = class {
787
- /**
788
- * Create a new Player.
789
- *
790
- * @param options - Options for the Player.
791
- * @param options.bufferDuration - The duration of the audio buffer to play.
792
- */
793
- constructor({ bufferDuration }) {
794
- __privateAdd(this, _Player_instances);
795
- __privateAdd(this, _context, null);
796
- __privateAdd(this, _startNextPlaybackAt, 0);
797
- __privateAdd(this, _bufferDuration);
798
- __privateSet(this, _bufferDuration, bufferDuration);
799
- }
800
- /**
801
- * Play audio from a source.
802
- *
803
- * @param source The source to play audio from.
804
- * @returns A promise that resolves when the audio has finished playing.
805
- */
806
- play(source) {
807
- return __async(this, null, function* () {
808
- __privateSet(this, _startNextPlaybackAt, 0);
809
- __privateSet(this, _context, new AudioContext({ sampleRate: source.sampleRate }));
810
- const buffer = new Float32Array(
811
- source.durationToSampleCount(__privateGet(this, _bufferDuration))
812
- );
813
- const plays = [];
814
- while (true) {
815
- const read = yield source.read(buffer);
816
- const playableAudio = buffer.subarray(0, read);
817
- plays.push(__privateMethod(this, _Player_instances, playBuffer_fn).call(this, playableAudio, source.sampleRate));
818
- if (read < buffer.length) {
819
- break;
820
- }
821
- }
822
- yield Promise.all(plays);
823
- });
824
- }
825
- /**
826
- * Pause the audio.
827
- *
828
- * @returns A promise that resolves when the audio has been paused.
829
- */
830
- pause() {
831
- return __async(this, null, function* () {
832
- if (!__privateGet(this, _context)) {
833
- throw new Error("AudioContext not initialized.");
834
- }
835
- yield __privateGet(this, _context).suspend();
836
- });
837
- }
838
- /**
839
- * Resume the audio.
840
- *
841
- * @returns A promise that resolves when the audio has been resumed.
842
- */
843
- resume() {
844
- return __async(this, null, function* () {
845
- if (!__privateGet(this, _context)) {
846
- throw new Error("AudioContext not initialized.");
847
- }
848
- yield __privateGet(this, _context).resume();
849
- });
850
- }
851
- /**
852
- * Toggle the audio.
853
- *
854
- * @returns A promise that resolves when the audio has been toggled.
855
- */
856
- toggle() {
857
- return __async(this, null, function* () {
858
- if (!__privateGet(this, _context)) {
859
- throw new Error("AudioContext not initialized.");
860
- }
861
- if (__privateGet(this, _context).state === "running") {
862
- yield this.pause();
863
- } else {
864
- yield this.resume();
865
- }
866
- });
867
- }
868
- /**
869
- * Stop the audio.
870
- *
871
- * @returns A promise that resolves when the audio has been stopped.
872
- */
873
- stop() {
874
- return __async(this, null, function* () {
875
- var _a;
876
- if (!__privateGet(this, _context)) {
877
- throw new Error("AudioContext not initialized.");
878
- }
879
- yield (_a = __privateGet(this, _context)) == null ? void 0 : _a.close();
880
- });
881
- }
882
- };
883
- _context = new WeakMap();
884
- _startNextPlaybackAt = new WeakMap();
885
- _bufferDuration = new WeakMap();
886
- _Player_instances = new WeakSet();
887
- playBuffer_fn = function(buf, sampleRate) {
888
- return __async(this, null, function* () {
889
- if (!__privateGet(this, _context)) {
890
- throw new Error("AudioContext not initialized.");
891
- }
892
- if (buf.length === 0) {
893
- return;
894
- }
895
- const startAt = __privateGet(this, _startNextPlaybackAt);
896
- const duration = buf.length / sampleRate;
897
- __privateSet(this, _startNextPlaybackAt, duration + Math.max(__privateGet(this, _context).currentTime, __privateGet(this, _startNextPlaybackAt)));
898
- yield playAudioBuffer(buf, __privateGet(this, _context), startAt, sampleRate);
899
- });
900
- };
901
-
902
- // src/react/utils.ts
903
- function pingServer(url) {
904
- return __async(this, null, function* () {
905
- const start = (/* @__PURE__ */ new Date()).getTime();
906
- yield fetch(url);
907
- const end = (/* @__PURE__ */ new Date()).getTime();
908
- return end - start;
909
- });
910
- }
911
-
912
- // src/react/index.ts
913
- var PING_INTERVAL = 5e3;
914
- var DEFAULT_BUFFER_DURATION = 0.01;
915
- function useTTS({
916
- apiKey,
917
- baseUrl,
918
- sampleRate,
919
- onError
920
- }) {
921
- var _a, _b;
922
- if (typeof window === "undefined") {
923
- return {
924
- buffer: () => __async(this, null, function* () {
925
- }),
926
- play: () => __async(this, null, function* () {
927
- }),
928
- pause: () => __async(this, null, function* () {
929
- }),
930
- resume: () => __async(this, null, function* () {
931
- }),
932
- toggle: () => __async(this, null, function* () {
933
- }),
934
- playbackStatus: "inactive",
935
- bufferStatus: "inactive",
936
- isWaiting: false,
937
- source: null,
938
- isConnected: false,
939
- metrics: {
940
- modelLatency: null
941
- }
942
- };
943
- }
944
- const websocket = (0, import_react.useMemo)(() => {
945
- if (!apiKey) {
946
- return null;
947
- }
948
- const cartesia = new Cartesia({ apiKey, baseUrl });
949
- baseUrl = baseUrl != null ? baseUrl : cartesia.baseUrl;
950
- return cartesia.tts.websocket({
951
- container: "raw",
952
- encoding: "pcm_f32le",
953
- sampleRate
954
- });
955
- }, [apiKey, baseUrl, sampleRate]);
956
- const websocketReturn = (0, import_react.useRef)(null);
957
- const player = (0, import_react.useRef)(null);
958
- const [playbackStatus, setPlaybackStatus] = (0, import_react.useState)("inactive");
959
- const [bufferStatus, setBufferStatus] = (0, import_react.useState)("inactive");
960
- const [isWaiting, setIsWaiting] = (0, import_react.useState)(false);
961
- const [isConnected, setIsConnected] = (0, import_react.useState)(false);
962
- const [bufferDuration, setBufferDuration] = (0, import_react.useState)(null);
963
- const [messages, setMessages] = (0, import_react.useState)([]);
964
- const buffer = (0, import_react.useCallback)(
965
- (options) => __async(this, null, function* () {
966
- var _a2, _b2;
967
- (_a2 = websocketReturn.current) == null ? void 0 : _a2.stop();
968
- try {
969
- setMessages([]);
970
- setBufferStatus("buffering");
971
- websocketReturn.current = (_b2 = websocket == null ? void 0 : websocket.send(options)) != null ? _b2 : null;
972
- if (!websocketReturn.current) {
973
- return;
974
- }
975
- const unsubscribe = websocketReturn.current.on("message", (message) => {
976
- const parsedMessage = JSON.parse(message);
977
- setMessages((messages2) => [...messages2, parsedMessage]);
978
- if (parsedMessage.error) {
979
- onError == null ? void 0 : onError(new Error(parsedMessage.error));
980
- }
981
- });
982
- yield websocketReturn.current.source.once("close");
983
- setBufferStatus("buffered");
984
- unsubscribe();
985
- } catch (error) {
986
- if (error instanceof Error) {
987
- onError == null ? void 0 : onError(error);
988
- } else {
989
- console.error(error);
990
- }
991
- }
992
- }),
993
- [websocket, onError]
994
- );
995
- const metrics = (0, import_react.useMemo)(() => {
996
- var _a2;
997
- if (messages.length === 0) {
998
- return {
999
- modelLatency: null
1000
- };
1001
- }
1002
- const modelLatency = (_a2 = messages[0].step_time) != null ? _a2 : null;
1003
- return {
1004
- modelLatency: Math.trunc(modelLatency)
1005
- };
1006
- }, [messages]);
1007
- (0, import_react.useEffect)(() => {
1008
- let cleanup = () => {
1009
- };
1010
- function setupConnection() {
1011
- return __async(this, null, function* () {
1012
- try {
1013
- const connection = yield websocket == null ? void 0 : websocket.connect();
1014
- if (!connection) {
1015
- return;
1016
- }
1017
- const unsubscribes = [];
1018
- setIsConnected(true);
1019
- unsubscribes.push(
1020
- connection.on("open", () => {
1021
- setIsConnected(true);
1022
- })
1023
- );
1024
- unsubscribes.push(
1025
- connection.on("close", () => {
1026
- setIsConnected(false);
1027
- })
1028
- );
1029
- const intervalId = setInterval(() => {
1030
- if (baseUrl) {
1031
- pingServer(new URL(baseUrl).origin).then((ping) => {
1032
- let bufferDuration2;
1033
- if (ping < 300) {
1034
- bufferDuration2 = 0.01;
1035
- } else if (ping > 1500) {
1036
- bufferDuration2 = 6;
1037
- } else {
1038
- bufferDuration2 = ping / 1e3 * 4;
1039
- }
1040
- setBufferDuration(bufferDuration2);
1041
- });
1042
- }
1043
- }, PING_INTERVAL);
1044
- return () => {
1045
- for (const unsubscribe of unsubscribes) {
1046
- unsubscribe();
1047
- }
1048
- clearInterval(intervalId);
1049
- websocket == null ? void 0 : websocket.disconnect();
1050
- };
1051
- } catch (e) {
1052
- console.error(e);
1053
- }
1054
- });
1055
- }
1056
- setupConnection().then((cleanupConnection) => {
1057
- cleanup = cleanupConnection;
1058
- });
1059
- return () => cleanup == null ? void 0 : cleanup();
1060
- }, [websocket, baseUrl]);
1061
- const play = (0, import_react.useCallback)(() => __async(this, null, function* () {
1062
- try {
1063
- if (playbackStatus === "playing" || !websocketReturn.current) {
1064
- return;
1065
- }
1066
- if (player.current) {
1067
- yield player.current.stop();
1068
- }
1069
- if (playbackStatus === "finished") {
1070
- websocketReturn.current.source.seek(0, "start");
1071
- }
1072
- setPlaybackStatus("playing");
1073
- const unsubscribes = [];
1074
- unsubscribes.push(
1075
- websocketReturn.current.source.on("wait", () => {
1076
- setIsWaiting(true);
1077
- })
1078
- );
1079
- unsubscribes.push(
1080
- websocketReturn.current.source.on("read", () => {
1081
- setIsWaiting(false);
1082
- })
1083
- );
1084
- player.current = new Player({
1085
- bufferDuration: bufferDuration != null ? bufferDuration : DEFAULT_BUFFER_DURATION
1086
- });
1087
- yield player.current.play(websocketReturn.current.source);
1088
- for (const unsubscribe of unsubscribes) {
1089
- unsubscribe();
1090
- }
1091
- setPlaybackStatus("finished");
1092
- } catch (error) {
1093
- if (error instanceof Error) {
1094
- onError == null ? void 0 : onError(error);
1095
- } else {
1096
- console.error(error);
1097
- }
1098
- }
1099
- }), [playbackStatus, bufferDuration, onError]);
1100
- const pause = (0, import_react.useCallback)(() => __async(this, null, function* () {
1101
- var _a2;
1102
- try {
1103
- yield (_a2 = player.current) == null ? void 0 : _a2.pause();
1104
- setPlaybackStatus("paused");
1105
- } catch (error) {
1106
- if (error instanceof Error) {
1107
- onError == null ? void 0 : onError(error);
1108
- } else {
1109
- console.error(error);
1110
- }
1111
- }
1112
- }), [onError]);
1113
- const resume = (0, import_react.useCallback)(() => __async(this, null, function* () {
1114
- var _a2;
1115
- try {
1116
- yield (_a2 = player.current) == null ? void 0 : _a2.resume();
1117
- setPlaybackStatus("playing");
1118
- } catch (error) {
1119
- if (error instanceof Error) {
1120
- onError == null ? void 0 : onError(error);
1121
- } else {
1122
- console.error(error);
1123
- }
1124
- }
1125
- }), [onError]);
1126
- const toggle = (0, import_react.useCallback)(() => __async(this, null, function* () {
1127
- var _a2;
1128
- try {
1129
- yield (_a2 = player.current) == null ? void 0 : _a2.toggle();
1130
- setPlaybackStatus((status) => {
1131
- if (status === "playing") {
1132
- return "paused";
1133
- }
1134
- if (status === "paused") {
1135
- return "playing";
1136
- }
1137
- return status;
1138
- });
1139
- } catch (error) {
1140
- if (error instanceof Error) {
1141
- onError == null ? void 0 : onError(error);
1142
- } else {
1143
- console.error(error);
1144
- }
1145
- }
1146
- }), [onError]);
1147
- return {
1148
- buffer,
1149
- play,
1150
- pause,
1151
- source: (_b = (_a = websocketReturn.current) == null ? void 0 : _a.source) != null ? _b : null,
1152
- resume,
1153
- toggle,
1154
- playbackStatus,
1155
- bufferStatus,
1156
- isWaiting,
1157
- isConnected,
1158
- metrics
1159
- };
1160
- }
1161
- // Annotate the CommonJS export names for ESM import in node:
1162
- 0 && (module.exports = {
1163
- useTTS
1164
- });