@cartesia/cartesia-js 2.2.5 → 2.2.7

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 (195) hide show
  1. package/Client.d.ts +3 -0
  2. package/Client.js +11 -6
  3. package/README.md +469 -144
  4. package/api/resources/apiStatus/client/Client.js +1 -1
  5. package/api/resources/auth/client/Client.d.ts +17 -0
  6. package/api/resources/auth/client/Client.js +18 -1
  7. package/api/resources/auth/types/TokenGrant.d.ts +3 -1
  8. package/api/resources/auth/types/TokenRequest.d.ts +2 -2
  9. package/api/resources/index.d.ts +1 -0
  10. package/api/resources/index.js +1 -0
  11. package/api/resources/infill/client/Client.js +1 -1
  12. package/api/resources/infill/client/requests/InfillBytesRequest.d.ts +3 -11
  13. package/api/resources/stt/client/Client.d.ts +43 -0
  14. package/api/resources/stt/client/Client.js +108 -0
  15. package/api/resources/stt/client/index.d.ts +1 -1
  16. package/api/resources/stt/client/index.js +15 -3
  17. package/api/resources/stt/client/requests/TranscriptionRequest.d.ts +147 -0
  18. package/api/resources/stt/client/requests/TranscriptionRequest.js +5 -0
  19. package/api/resources/stt/client/requests/index.d.ts +1 -0
  20. package/api/resources/stt/client/requests/index.js +2 -0
  21. package/api/resources/stt/index.d.ts +1 -0
  22. package/api/resources/stt/index.js +1 -0
  23. package/api/resources/stt/types/TimestampGranularity.d.ts +12 -0
  24. package/api/resources/stt/types/TimestampGranularity.js +9 -0
  25. package/api/resources/stt/types/TranscriptMessage.d.ts +1 -1
  26. package/api/resources/stt/types/TranscriptionResponse.d.ts +2 -2
  27. package/api/resources/stt/types/index.d.ts +1 -0
  28. package/api/resources/stt/types/index.js +1 -0
  29. package/api/resources/tts/client/Client.d.ts +7 -2
  30. package/api/resources/tts/client/Client.js +8 -8
  31. package/api/resources/tts/types/Controls.d.ts +1 -1
  32. package/api/resources/tts/types/Emotion.d.ts +2 -33
  33. package/api/resources/tts/types/Emotion.js +0 -28
  34. package/api/resources/tts/types/EmotionDeprecated.d.ts +38 -0
  35. package/api/resources/tts/types/EmotionDeprecated.js +33 -0
  36. package/api/resources/tts/types/GenerationConfig.d.ts +15 -0
  37. package/api/resources/tts/types/GenerationConfig.js +5 -0
  38. package/api/resources/tts/types/GenerationRequest.d.ts +5 -4
  39. package/api/resources/tts/types/Mp3OutputFormat.d.ts +1 -0
  40. package/api/resources/tts/types/RawOutputFormat.d.ts +1 -0
  41. package/api/resources/tts/types/SseOutputFormat.d.ts +10 -0
  42. package/api/resources/tts/types/SseOutputFormat.js +5 -0
  43. package/api/resources/tts/types/TtsRequest.d.ts +1 -0
  44. package/api/resources/tts/types/TtssseRequest.d.ts +27 -0
  45. package/api/resources/tts/types/TtssseRequest.js +5 -0
  46. package/api/resources/tts/types/WebSocketRawOutputFormat.d.ts +1 -0
  47. package/api/resources/tts/types/WebSocketRequest.d.ts +2 -4
  48. package/api/resources/tts/types/WebSocketTtsRequest.d.ts +4 -1
  49. package/api/resources/tts/types/index.d.ts +5 -1
  50. package/api/resources/tts/types/index.js +5 -1
  51. package/api/resources/voiceChanger/client/Client.d.ts +9 -4
  52. package/api/resources/voiceChanger/client/Client.js +24 -20
  53. package/api/resources/voiceChanger/client/requests/VoiceChangerBytesRequest.d.ts +3 -8
  54. package/api/resources/voiceChanger/client/requests/VoiceChangerSseRequest.d.ts +3 -8
  55. package/api/resources/voices/client/Client.js +8 -8
  56. package/api/resources/voices/client/requests/CloneVoiceRequest.d.ts +6 -24
  57. package/api/resources/voices/types/LocalizeDialect.d.ts +4 -8
  58. package/core/fetcher/Fetcher.d.ts +2 -2
  59. package/core/fetcher/Fetcher.js +4 -3
  60. package/core/fetcher/getResponseBody.js +3 -3
  61. package/dist/Client.d.ts +3 -0
  62. package/dist/Client.js +11 -6
  63. package/dist/api/resources/apiStatus/client/Client.js +1 -1
  64. package/dist/api/resources/auth/client/Client.d.ts +17 -0
  65. package/dist/api/resources/auth/client/Client.js +18 -1
  66. package/dist/api/resources/auth/types/TokenGrant.d.ts +3 -1
  67. package/dist/api/resources/auth/types/TokenRequest.d.ts +2 -2
  68. package/dist/api/resources/index.d.ts +1 -0
  69. package/dist/api/resources/index.js +1 -0
  70. package/dist/api/resources/infill/client/Client.js +1 -1
  71. package/dist/api/resources/infill/client/requests/InfillBytesRequest.d.ts +3 -11
  72. package/dist/api/resources/stt/client/Client.d.ts +43 -0
  73. package/dist/api/resources/stt/client/Client.js +108 -0
  74. package/dist/api/resources/stt/client/index.d.ts +1 -1
  75. package/dist/api/resources/stt/client/index.js +15 -3
  76. package/dist/api/resources/stt/client/requests/TranscriptionRequest.d.ts +147 -0
  77. package/dist/api/resources/stt/client/requests/TranscriptionRequest.js +5 -0
  78. package/dist/api/resources/stt/client/requests/index.d.ts +1 -0
  79. package/dist/api/resources/stt/client/requests/index.js +2 -0
  80. package/dist/api/resources/stt/index.d.ts +1 -0
  81. package/dist/api/resources/stt/index.js +1 -0
  82. package/dist/api/resources/stt/types/TimestampGranularity.d.ts +12 -0
  83. package/dist/api/resources/stt/types/TimestampGranularity.js +9 -0
  84. package/dist/api/resources/stt/types/TranscriptMessage.d.ts +1 -1
  85. package/dist/api/resources/stt/types/TranscriptionResponse.d.ts +2 -2
  86. package/dist/api/resources/stt/types/index.d.ts +1 -0
  87. package/dist/api/resources/stt/types/index.js +1 -0
  88. package/dist/api/resources/tts/client/Client.d.ts +7 -2
  89. package/dist/api/resources/tts/client/Client.js +8 -8
  90. package/dist/api/resources/tts/types/Controls.d.ts +1 -1
  91. package/dist/api/resources/tts/types/Emotion.d.ts +2 -33
  92. package/dist/api/resources/tts/types/Emotion.js +0 -28
  93. package/dist/api/resources/tts/types/EmotionDeprecated.d.ts +38 -0
  94. package/dist/api/resources/tts/types/EmotionDeprecated.js +33 -0
  95. package/dist/api/resources/tts/types/GenerationConfig.d.ts +15 -0
  96. package/dist/api/resources/tts/types/GenerationConfig.js +5 -0
  97. package/dist/api/resources/tts/types/GenerationRequest.d.ts +5 -4
  98. package/dist/api/resources/tts/types/Mp3OutputFormat.d.ts +1 -0
  99. package/dist/api/resources/tts/types/RawOutputFormat.d.ts +1 -0
  100. package/dist/api/resources/tts/types/SseOutputFormat.d.ts +10 -0
  101. package/dist/api/resources/tts/types/SseOutputFormat.js +5 -0
  102. package/dist/api/resources/tts/types/TtsRequest.d.ts +1 -0
  103. package/dist/api/resources/tts/types/TtssseRequest.d.ts +27 -0
  104. package/dist/api/resources/tts/types/TtssseRequest.js +5 -0
  105. package/dist/api/resources/tts/types/WebSocketRawOutputFormat.d.ts +1 -0
  106. package/dist/api/resources/tts/types/WebSocketRequest.d.ts +2 -4
  107. package/dist/api/resources/tts/types/WebSocketTtsRequest.d.ts +4 -1
  108. package/dist/api/resources/tts/types/index.d.ts +5 -1
  109. package/dist/api/resources/tts/types/index.js +5 -1
  110. package/dist/api/resources/voiceChanger/client/Client.d.ts +9 -4
  111. package/dist/api/resources/voiceChanger/client/Client.js +24 -20
  112. package/dist/api/resources/voiceChanger/client/requests/VoiceChangerBytesRequest.d.ts +3 -8
  113. package/dist/api/resources/voiceChanger/client/requests/VoiceChangerSseRequest.d.ts +3 -8
  114. package/dist/api/resources/voices/client/Client.js +8 -8
  115. package/dist/api/resources/voices/client/requests/CloneVoiceRequest.d.ts +6 -24
  116. package/dist/api/resources/voices/types/LocalizeDialect.d.ts +4 -8
  117. package/dist/core/fetcher/Fetcher.d.ts +2 -2
  118. package/dist/core/fetcher/Fetcher.js +4 -3
  119. package/dist/core/fetcher/getResponseBody.js +3 -3
  120. package/dist/index.d.ts +2 -0
  121. package/dist/index.js +8 -1
  122. package/dist/serialization/resources/auth/types/TokenGrant.d.ts +2 -1
  123. package/dist/serialization/resources/auth/types/TokenGrant.js +2 -1
  124. package/dist/serialization/resources/auth/types/TokenRequest.d.ts +1 -1
  125. package/dist/serialization/resources/auth/types/TokenRequest.js +1 -1
  126. package/dist/serialization/resources/stt/types/TimestampGranularity.d.ts +10 -0
  127. package/dist/serialization/resources/stt/types/TimestampGranularity.js +41 -0
  128. package/dist/serialization/resources/stt/types/index.d.ts +1 -0
  129. package/dist/serialization/resources/stt/types/index.js +1 -0
  130. package/dist/serialization/resources/tts/types/Controls.d.ts +2 -2
  131. package/dist/serialization/resources/tts/types/Controls.js +2 -2
  132. package/dist/serialization/resources/tts/types/Emotion.d.ts +1 -1
  133. package/dist/serialization/resources/tts/types/Emotion.js +1 -27
  134. package/dist/serialization/resources/tts/types/EmotionDeprecated.d.ts +10 -0
  135. package/dist/serialization/resources/tts/types/EmotionDeprecated.js +67 -0
  136. package/dist/serialization/resources/tts/types/GenerationConfig.d.ts +15 -0
  137. package/dist/serialization/resources/tts/types/GenerationConfig.js +46 -0
  138. package/dist/serialization/resources/tts/types/GenerationRequest.d.ts +3 -1
  139. package/dist/serialization/resources/tts/types/GenerationRequest.js +3 -1
  140. package/dist/serialization/resources/tts/types/SseOutputFormat.d.ts +15 -0
  141. package/dist/serialization/resources/tts/types/SseOutputFormat.js +46 -0
  142. package/dist/serialization/resources/tts/types/TtsRequest.d.ts +2 -0
  143. package/dist/serialization/resources/tts/types/TtsRequest.js +2 -0
  144. package/dist/serialization/resources/tts/types/TtssseRequest.d.ts +29 -0
  145. package/dist/serialization/resources/tts/types/TtssseRequest.js +60 -0
  146. package/dist/serialization/resources/tts/types/WebSocketTtsRequest.d.ts +3 -1
  147. package/dist/serialization/resources/tts/types/WebSocketTtsRequest.js +3 -1
  148. package/dist/serialization/resources/tts/types/index.d.ts +5 -1
  149. package/dist/serialization/resources/tts/types/index.js +5 -1
  150. package/dist/version.d.ts +1 -1
  151. package/dist/version.js +1 -1
  152. package/dist/wrapper/StreamingSTTClient.d.ts +22 -2
  153. package/dist/wrapper/StreamingSTTClient.js +124 -1
  154. package/dist/wrapper/SttWebsocket.d.ts +8 -3
  155. package/dist/wrapper/SttWebsocket.js +24 -3
  156. package/dist/wrapper/Websocket.js +1 -1
  157. package/index.d.ts +2 -0
  158. package/index.js +8 -1
  159. package/package.json +1 -1
  160. package/reference.md +89 -1
  161. package/serialization/resources/auth/types/TokenGrant.d.ts +2 -1
  162. package/serialization/resources/auth/types/TokenGrant.js +2 -1
  163. package/serialization/resources/auth/types/TokenRequest.d.ts +1 -1
  164. package/serialization/resources/auth/types/TokenRequest.js +1 -1
  165. package/serialization/resources/stt/types/TimestampGranularity.d.ts +10 -0
  166. package/serialization/resources/stt/types/TimestampGranularity.js +41 -0
  167. package/serialization/resources/stt/types/index.d.ts +1 -0
  168. package/serialization/resources/stt/types/index.js +1 -0
  169. package/serialization/resources/tts/types/Controls.d.ts +2 -2
  170. package/serialization/resources/tts/types/Controls.js +2 -2
  171. package/serialization/resources/tts/types/Emotion.d.ts +1 -1
  172. package/serialization/resources/tts/types/Emotion.js +1 -27
  173. package/serialization/resources/tts/types/EmotionDeprecated.d.ts +10 -0
  174. package/serialization/resources/tts/types/EmotionDeprecated.js +67 -0
  175. package/serialization/resources/tts/types/GenerationConfig.d.ts +15 -0
  176. package/serialization/resources/tts/types/GenerationConfig.js +46 -0
  177. package/serialization/resources/tts/types/GenerationRequest.d.ts +3 -1
  178. package/serialization/resources/tts/types/GenerationRequest.js +3 -1
  179. package/serialization/resources/tts/types/SseOutputFormat.d.ts +15 -0
  180. package/serialization/resources/tts/types/SseOutputFormat.js +46 -0
  181. package/serialization/resources/tts/types/TtsRequest.d.ts +2 -0
  182. package/serialization/resources/tts/types/TtsRequest.js +2 -0
  183. package/serialization/resources/tts/types/TtssseRequest.d.ts +29 -0
  184. package/serialization/resources/tts/types/TtssseRequest.js +60 -0
  185. package/serialization/resources/tts/types/WebSocketTtsRequest.d.ts +3 -1
  186. package/serialization/resources/tts/types/WebSocketTtsRequest.js +3 -1
  187. package/serialization/resources/tts/types/index.d.ts +5 -1
  188. package/serialization/resources/tts/types/index.js +5 -1
  189. package/version.d.ts +1 -1
  190. package/version.js +1 -1
  191. package/wrapper/StreamingSTTClient.d.ts +22 -2
  192. package/wrapper/StreamingSTTClient.js +124 -1
  193. package/wrapper/SttWebsocket.d.ts +8 -3
  194. package/wrapper/SttWebsocket.js +24 -3
  195. package/wrapper/Websocket.js +1 -1
@@ -10,6 +10,7 @@ export interface GenerationRequest {
10
10
  voice: Cartesia.TtsRequestVoiceSpecifier;
11
11
  language?: Cartesia.SupportedLanguage;
12
12
  outputFormat: Cartesia.WebSocketRawOutputFormat;
13
+ generationConfig?: Cartesia.GenerationConfig;
13
14
  /**
14
15
  * The maximum duration of the audio in seconds. You do not usually need to specify this.
15
16
  * If the duration is not appropriate for the length of the transcript, the output audio may be truncated.
@@ -32,10 +33,10 @@ export interface GenerationRequest {
32
33
  maxBufferDelayMs?: number;
33
34
  /** Whether to flush the context. */
34
35
  flush?: boolean;
35
- /** Whether to return word-level timestamps. */
36
+ /** Whether to return word-level timestamps. If `false` (default), no word timestamps will be produced at all. If `true`, the server will return timestamp events containing word-level timing information. */
36
37
  addTimestamps?: boolean;
37
- /** Whether to return phoneme-level timestamps. */
38
+ /** Whether to return phoneme-level timestamps. If `false` (default), no phoneme timestamps will be produced. If `true`, the server will return timestamp events containing phoneme-level timing information. */
38
39
  addPhonemeTimestamps?: boolean;
39
- /** Whether to use the original transcript for timestamps. */
40
- useOriginalTimestamps?: boolean;
40
+ /** Whether to use normalized timestamps (True) or original timestamps (False). */
41
+ useNormalizedTimestamps?: boolean;
41
42
  }
@@ -2,6 +2,7 @@
2
2
  * This file was auto-generated by Fern from our API Definition.
3
3
  */
4
4
  export interface Mp3OutputFormat {
5
+ /** The sample rate of the audio in Hz. Supported sample rates are 8000, 16000, 22050, 24000, 44100, 48000. */
5
6
  sampleRate: number;
6
7
  /** The bit rate of the audio in bits per second. Supported bit rates are 32000, 64000, 96000, 128000, 192000. */
7
8
  bitRate: number;
@@ -4,6 +4,7 @@
4
4
  import * as Cartesia from "../../../index";
5
5
  export interface RawOutputFormat {
6
6
  encoding: Cartesia.RawEncoding;
7
+ /** The sample rate of the audio in Hz. Supported sample rates are 8000, 16000, 22050, 24000, 44100, 48000. */
7
8
  sampleRate: number;
8
9
  bitRate?: number;
9
10
  }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ import * as Cartesia from "../../../index";
5
+ export interface SseOutputFormat {
6
+ container: "raw";
7
+ encoding: Cartesia.RawEncoding;
8
+ /** The sample rate of the audio in Hz. Supported sample rates are 8000, 16000, 22050, 24000, 44100, 48000. */
9
+ sampleRate: number;
10
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ /**
3
+ * This file was auto-generated by Fern from our API Definition.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -9,6 +9,7 @@ export interface TtsRequest {
9
9
  voice: Cartesia.TtsRequestVoiceSpecifier;
10
10
  language?: Cartesia.SupportedLanguage;
11
11
  outputFormat: Cartesia.OutputFormat;
12
+ generationConfig?: Cartesia.GenerationConfig;
12
13
  /**
13
14
  * The maximum duration of the audio in seconds. You do not usually need to specify this.
14
15
  * If the duration is not appropriate for the length of the transcript, the output audio may be truncated.
@@ -0,0 +1,27 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ import * as Cartesia from "../../../index";
5
+ export interface TtssseRequest {
6
+ /** The ID of the model to use for the generation. See [Models](/build-with-cartesia/models) for available models. */
7
+ modelId: string;
8
+ transcript: string;
9
+ voice: Cartesia.TtsRequestVoiceSpecifier;
10
+ language?: Cartesia.SupportedLanguage;
11
+ outputFormat: Cartesia.SseOutputFormat;
12
+ generationConfig?: Cartesia.GenerationConfig;
13
+ /**
14
+ * The maximum duration of the audio in seconds. You do not usually need to specify this.
15
+ * If the duration is not appropriate for the length of the transcript, the output audio may be truncated.
16
+ */
17
+ duration?: number;
18
+ speed?: Cartesia.ModelSpeed;
19
+ /** Whether to return word-level timestamps. If `false` (default), no word timestamps will be produced at all. If `true`, the server will return timestamp events containing word-level timing information. */
20
+ addTimestamps?: boolean;
21
+ /** Whether to return phoneme-level timestamps. If `false` (default), no phoneme timestamps will be produced - if `add_timestamps` is `true`, the produced timestamps will be word timestamps instead. If `true`, the server will return timestamp events containing phoneme-level timing information. */
22
+ addPhonemeTimestamps?: boolean;
23
+ /** Whether to use normalized timestamps (True) or original timestamps (False). */
24
+ useNormalizedTimestamps?: boolean;
25
+ /** Optional context ID for this request. */
26
+ contextId?: Cartesia.ContextId;
27
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ /**
3
+ * This file was auto-generated by Fern from our API Definition.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -5,5 +5,6 @@ import * as Cartesia from "../../../index";
5
5
  export interface WebSocketRawOutputFormat {
6
6
  container: "raw";
7
7
  encoding: Cartesia.RawEncoding;
8
+ /** The sample rate of the audio in Hz. Supported sample rates are 8000, 16000, 22050, 24000, 44100, 48000. */
8
9
  sampleRate: number;
9
10
  }
@@ -4,10 +4,8 @@
4
4
  import * as Cartesia from "../../../index";
5
5
  export type WebSocketRequest =
6
6
  /**
7
- * Use this to generate speech for a transcript.
8
- * */
7
+ * Use this to generate speech for a transcript. */
9
8
  Cartesia.GenerationRequest
10
9
  /**
11
- * Use this to cancel a context, so that no more messages are generated for that context.
12
- * */
10
+ * Use this to cancel a context, so that no more messages are generated for that context. */
13
11
  | Cartesia.CancelContextRequest;
@@ -6,13 +6,16 @@ export interface WebSocketTtsRequest {
6
6
  /** The ID of the model to use for the generation. See [Models](/build-with-cartesia/models) for available models. */
7
7
  modelId: string;
8
8
  outputFormat?: Cartesia.OutputFormat;
9
+ generationConfig?: Cartesia.GenerationConfig;
9
10
  transcript?: string;
10
11
  voice: Cartesia.TtsRequestVoiceSpecifier;
11
12
  duration?: number;
12
13
  language?: string;
14
+ /** Whether to return word-level timestamps. If `false` (default), no word timestamps will be produced at all. If `true`, the server will return timestamp events containing word-level timing information. */
13
15
  addTimestamps?: boolean;
16
+ /** Whether to return phoneme-level timestamps. If `false` (default), no phoneme timestamps will be produced - if `add_timestamps` is `true`, the produced timestamps will be word timestamps instead. If `true`, the server will return timestamp events containing phoneme-level timing information. */
14
17
  addPhonemeTimestamps?: boolean;
15
- useOriginalTimestamps?: boolean;
18
+ useNormalizedTimestamps?: boolean;
16
19
  continue?: boolean;
17
20
  contextId?: string;
18
21
  maxBufferDelayMs?: number;
@@ -19,9 +19,13 @@ export * from "./WebSocketRawOutputFormat";
19
19
  export * from "./WebSocketRequest";
20
20
  export * from "./WebSocketTtsRequest";
21
21
  export * from "./TtsRequest";
22
+ export * from "./TtssseRequest";
22
23
  export * from "./SupportedLanguage";
24
+ export * from "./GenerationConfig";
25
+ export * from "./Emotion";
23
26
  export * from "./OutputFormat";
24
27
  export * from "./RawOutputFormat";
28
+ export * from "./SseOutputFormat";
25
29
  export * from "./RawEncoding";
26
30
  export * from "./WavOutputFormat";
27
31
  export * from "./Mp3OutputFormat";
@@ -32,4 +36,4 @@ export * from "./Controls";
32
36
  export * from "./Speed";
33
37
  export * from "./NumericalSpecifier";
34
38
  export * from "./NaturalSpecifier";
35
- export * from "./Emotion";
39
+ export * from "./EmotionDeprecated";
@@ -35,9 +35,13 @@ __exportStar(require("./WebSocketRawOutputFormat"), exports);
35
35
  __exportStar(require("./WebSocketRequest"), exports);
36
36
  __exportStar(require("./WebSocketTtsRequest"), exports);
37
37
  __exportStar(require("./TtsRequest"), exports);
38
+ __exportStar(require("./TtssseRequest"), exports);
38
39
  __exportStar(require("./SupportedLanguage"), exports);
40
+ __exportStar(require("./GenerationConfig"), exports);
41
+ __exportStar(require("./Emotion"), exports);
39
42
  __exportStar(require("./OutputFormat"), exports);
40
43
  __exportStar(require("./RawOutputFormat"), exports);
44
+ __exportStar(require("./SseOutputFormat"), exports);
41
45
  __exportStar(require("./RawEncoding"), exports);
42
46
  __exportStar(require("./WavOutputFormat"), exports);
43
47
  __exportStar(require("./Mp3OutputFormat"), exports);
@@ -48,4 +52,4 @@ __exportStar(require("./Controls"), exports);
48
52
  __exportStar(require("./Speed"), exports);
49
53
  __exportStar(require("./NumericalSpecifier"), exports);
50
54
  __exportStar(require("./NaturalSpecifier"), exports);
51
- __exportStar(require("./Emotion"), exports);
55
+ __exportStar(require("./EmotionDeprecated"), exports);
@@ -1,14 +1,17 @@
1
1
  /**
2
2
  * This file was auto-generated by Fern from our API Definition.
3
3
  */
4
- import { Blob } from "buffer";
5
- import * as fs from "fs";
6
- import * as core from "../../../../core";
7
4
  import * as environments from "../../../../environments";
5
+ import * as core from "../../../../core";
6
+ import * as fs from "fs";
7
+ import { Blob } from "buffer";
8
8
  import * as Cartesia from "../../../index";
9
+ import * as stream from "stream";
9
10
  export declare namespace VoiceChanger {
10
11
  interface Options {
11
12
  environment?: core.Supplier<environments.CartesiaEnvironment | string>;
13
+ /** Specify a custom URL to connect the client to. */
14
+ baseUrl?: core.Supplier<string>;
12
15
  apiKey?: core.Supplier<string | undefined>;
13
16
  /** Override the Cartesia-Version header */
14
17
  cartesiaVersion?: "2024-06-10";
@@ -23,6 +26,8 @@ export declare namespace VoiceChanger {
23
26
  abortSignal?: AbortSignal;
24
27
  /** Override the Cartesia-Version header */
25
28
  cartesiaVersion?: "2024-06-10";
29
+ /** Additional headers to include in the request. */
30
+ headers?: Record<string, string>;
26
31
  }
27
32
  }
28
33
  export declare class VoiceChanger {
@@ -33,7 +38,7 @@ export declare class VoiceChanger {
33
38
  *
34
39
  * This endpoint is priced at 15 characters per second of input audio.
35
40
  */
36
- bytes(clip: File | fs.ReadStream | Blob, request: Cartesia.VoiceChangerBytesRequest, requestOptions?: VoiceChanger.RequestOptions): Promise<ArrayBuffer>;
41
+ bytes(clip: File | fs.ReadStream | Blob, request: Cartesia.VoiceChangerBytesRequest, requestOptions?: VoiceChanger.RequestOptions): Promise<stream.Readable>;
37
42
  sse(clip: File | fs.ReadStream | Blob, request: Cartesia.VoiceChangerSseRequest, requestOptions?: VoiceChanger.RequestOptions): Promise<core.Stream<Cartesia.StreamingResponse>>;
38
43
  protected _getCustomAuthorizationHeaders(): Promise<{
39
44
  "X-API-Key": string | undefined;
@@ -49,11 +49,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
49
49
  };
50
50
  Object.defineProperty(exports, "__esModule", { value: true });
51
51
  exports.VoiceChanger = void 0;
52
- const url_join_1 = __importDefault(require("url-join"));
53
- const core = __importStar(require("../../../../core"));
54
52
  const environments = __importStar(require("../../../../environments"));
55
- const errors = __importStar(require("../../../../errors/index"));
53
+ const core = __importStar(require("../../../../core"));
56
54
  const serializers = __importStar(require("../../../../serialization/index"));
55
+ const url_join_1 = __importDefault(require("url-join"));
56
+ const errors = __importStar(require("../../../../errors/index"));
57
57
  class VoiceChanger {
58
58
  constructor(_options = {}) {
59
59
  this._options = _options;
@@ -65,27 +65,29 @@ class VoiceChanger {
65
65
  */
66
66
  bytes(clip, request, requestOptions) {
67
67
  return __awaiter(this, void 0, void 0, function* () {
68
- var _a, _b, _c, _d, _e;
68
+ var _a, _b, _c, _d, _e, _f;
69
69
  const _request = yield core.newFormData();
70
70
  yield _request.appendFile("clip", clip);
71
- yield _request.append("voice[id]", request.voiceId);
72
- yield _request.append("output_format[container]", request.outputFormatContainer);
73
- yield _request.append("output_format[sample_rate]", request.outputFormatSampleRate.toString());
71
+ _request.append("voice[id]", request.voiceId);
72
+ _request.append("output_format[container]", serializers.OutputFormatContainer.jsonOrThrow(request.outputFormatContainer, {
73
+ unrecognizedObjectKeys: "strip",
74
+ }));
75
+ _request.append("output_format[sample_rate]", request.outputFormatSampleRate.toString());
74
76
  if (request.outputFormatEncoding != null) {
75
- yield _request.append("output_format[encoding]", request.outputFormatEncoding);
77
+ _request.append("output_format[encoding]", serializers.RawEncoding.jsonOrThrow(request.outputFormatEncoding, { unrecognizedObjectKeys: "strip" }));
76
78
  }
77
79
  if (request.outputFormatBitRate != null) {
78
- yield _request.append("output_format[bit_rate]", request.outputFormatBitRate.toString());
80
+ _request.append("output_format[bit_rate]", request.outputFormatBitRate.toString());
79
81
  }
80
82
  const _maybeEncodedRequest = yield _request.getRequest();
81
83
  const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
82
- url: (0, url_join_1.default)((_b = (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.CartesiaEnvironment.Production, "/voice-changer/bytes"),
84
+ url: (0, url_join_1.default)((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.CartesiaEnvironment.Production, "/voice-changer/bytes"),
83
85
  method: "POST",
84
- headers: Object.assign(Object.assign({ "Cartesia-Version": (_e = (_c = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _c !== void 0 ? _c : (_d = this._options) === null || _d === void 0 ? void 0 : _d.cartesiaVersion) !== null && _e !== void 0 ? _e : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.0.4-alpha0", "User-Agent": "@cartesia/cartesia-js/2.0.4-alpha0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())), _maybeEncodedRequest.headers),
86
+ headers: Object.assign(Object.assign(Object.assign({ "Cartesia-Version": (_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.cartesiaVersion) !== null && _f !== void 0 ? _f : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.2.7", "User-Agent": "@cartesia/cartesia-js/2.2.7", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())), _maybeEncodedRequest.headers), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
85
87
  requestType: "file",
86
88
  duplex: _maybeEncodedRequest.duplex,
87
89
  body: _maybeEncodedRequest.body,
88
- responseType: "arraybuffer",
90
+ responseType: "streaming",
89
91
  timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
90
92
  maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
91
93
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
@@ -116,23 +118,25 @@ class VoiceChanger {
116
118
  }
117
119
  sse(clip, request, requestOptions) {
118
120
  return __awaiter(this, void 0, void 0, function* () {
119
- var _a, _b, _c, _d, _e;
121
+ var _a, _b, _c, _d, _e, _f;
120
122
  const _request = yield core.newFormData();
121
123
  yield _request.appendFile("clip", clip);
122
- yield _request.append("voice[id]", request.voiceId);
123
- yield _request.append("output_format[container]", request.outputFormatContainer);
124
- yield _request.append("output_format[sample_rate]", request.outputFormatSampleRate.toString());
124
+ _request.append("voice[id]", request.voiceId);
125
+ _request.append("output_format[container]", serializers.OutputFormatContainer.jsonOrThrow(request.outputFormatContainer, {
126
+ unrecognizedObjectKeys: "strip",
127
+ }));
128
+ _request.append("output_format[sample_rate]", request.outputFormatSampleRate.toString());
125
129
  if (request.outputFormatEncoding != null) {
126
- yield _request.append("output_format[encoding]", request.outputFormatEncoding);
130
+ _request.append("output_format[encoding]", serializers.RawEncoding.jsonOrThrow(request.outputFormatEncoding, { unrecognizedObjectKeys: "strip" }));
127
131
  }
128
132
  if (request.outputFormatBitRate != null) {
129
- yield _request.append("output_format[bit_rate]", request.outputFormatBitRate.toString());
133
+ _request.append("output_format[bit_rate]", request.outputFormatBitRate.toString());
130
134
  }
131
135
  const _maybeEncodedRequest = yield _request.getRequest();
132
136
  const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
133
- url: (0, url_join_1.default)((_b = (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.CartesiaEnvironment.Production, "/voice-changer/sse"),
137
+ url: (0, url_join_1.default)((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.CartesiaEnvironment.Production, "/voice-changer/sse"),
134
138
  method: "POST",
135
- headers: Object.assign(Object.assign({ "Cartesia-Version": (_e = (_c = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _c !== void 0 ? _c : (_d = this._options) === null || _d === void 0 ? void 0 : _d.cartesiaVersion) !== null && _e !== void 0 ? _e : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.0.4-alpha0", "User-Agent": "@cartesia/cartesia-js/2.0.4-alpha0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())), _maybeEncodedRequest.headers),
139
+ headers: Object.assign(Object.assign(Object.assign({ "Cartesia-Version": (_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.cartesiaVersion) !== null && _f !== void 0 ? _f : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.2.7", "User-Agent": "@cartesia/cartesia-js/2.2.7", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())), _maybeEncodedRequest.headers), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
136
140
  requestType: "file",
137
141
  duplex: _maybeEncodedRequest.duplex,
138
142
  body: _maybeEncodedRequest.body,
@@ -30,15 +30,10 @@ import * as Cartesia from "../../../../index";
30
30
  export interface VoiceChangerBytesRequest {
31
31
  voiceId: string;
32
32
  outputFormatContainer: Cartesia.OutputFormatContainer;
33
+ /** The sample rate of the output audio in Hz. Supported sample rates are 8000, 16000, 22050, 24000, 44100, 48000. */
33
34
  outputFormatSampleRate: number;
34
- /**
35
- * Required for `raw` and `wav` containers.
36
- *
37
- */
35
+ /** Required for `raw` and `wav` containers. */
38
36
  outputFormatEncoding?: Cartesia.RawEncoding;
39
- /**
40
- * Required for `mp3` containers.
41
- *
42
- */
37
+ /** Required for `mp3` containers. */
43
38
  outputFormatBitRate?: number;
44
39
  }
@@ -30,15 +30,10 @@ import * as Cartesia from "../../../../index";
30
30
  export interface VoiceChangerSseRequest {
31
31
  voiceId: string;
32
32
  outputFormatContainer: Cartesia.OutputFormatContainer;
33
+ /** The sample rate of the audio in Hz. Supported sample rates are 8000, 16000, 22050, 24000, 44100, 48000. */
33
34
  outputFormatSampleRate: number;
34
- /**
35
- * Required for `raw` and `wav` containers.
36
- *
37
- */
35
+ /** Required for `raw` and `wav` containers. */
38
36
  outputFormatEncoding?: Cartesia.RawEncoding;
39
- /**
40
- * Required for `mp3` containers.
41
- *
42
- */
37
+ /** Required for `mp3` containers. */
43
38
  outputFormatBitRate?: number;
44
39
  }
@@ -70,7 +70,7 @@ class Voices {
70
70
  const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
71
71
  url: (0, url_join_1.default)((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.CartesiaEnvironment.Production, "/voices/"),
72
72
  method: "GET",
73
- headers: Object.assign(Object.assign({ "Cartesia-Version": (_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.cartesiaVersion) !== null && _f !== void 0 ? _f : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.2.5", "User-Agent": "@cartesia/cartesia-js/2.2.5", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
73
+ headers: Object.assign(Object.assign({ "Cartesia-Version": (_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.cartesiaVersion) !== null && _f !== void 0 ? _f : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.2.7", "User-Agent": "@cartesia/cartesia-js/2.2.7", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
74
74
  contentType: "application/json",
75
75
  requestType: "json",
76
76
  timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
@@ -155,7 +155,7 @@ class Voices {
155
155
  const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
156
156
  url: (0, url_join_1.default)((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.CartesiaEnvironment.Production, "/voices/clone"),
157
157
  method: "POST",
158
- headers: Object.assign(Object.assign(Object.assign({ "Cartesia-Version": (_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.cartesiaVersion) !== null && _f !== void 0 ? _f : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.2.5", "User-Agent": "@cartesia/cartesia-js/2.2.5", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())), _maybeEncodedRequest.headers), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
158
+ headers: Object.assign(Object.assign(Object.assign({ "Cartesia-Version": (_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.cartesiaVersion) !== null && _f !== void 0 ? _f : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.2.7", "User-Agent": "@cartesia/cartesia-js/2.2.7", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())), _maybeEncodedRequest.headers), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
159
159
  requestType: "file",
160
160
  duplex: _maybeEncodedRequest.duplex,
161
161
  body: _maybeEncodedRequest.body,
@@ -206,7 +206,7 @@ class Voices {
206
206
  const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
207
207
  url: (0, url_join_1.default)((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.CartesiaEnvironment.Production, `/voices/${encodeURIComponent(serializers.VoiceId.jsonOrThrow(id))}`),
208
208
  method: "DELETE",
209
- headers: Object.assign(Object.assign({ "Cartesia-Version": (_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.cartesiaVersion) !== null && _f !== void 0 ? _f : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.2.5", "User-Agent": "@cartesia/cartesia-js/2.2.5", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
209
+ headers: Object.assign(Object.assign({ "Cartesia-Version": (_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.cartesiaVersion) !== null && _f !== void 0 ? _f : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.2.7", "User-Agent": "@cartesia/cartesia-js/2.2.7", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
210
210
  contentType: "application/json",
211
211
  requestType: "json",
212
212
  timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
@@ -254,7 +254,7 @@ class Voices {
254
254
  const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
255
255
  url: (0, url_join_1.default)((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.CartesiaEnvironment.Production, `/voices/${encodeURIComponent(serializers.VoiceId.jsonOrThrow(id))}`),
256
256
  method: "PATCH",
257
- headers: Object.assign(Object.assign({ "Cartesia-Version": (_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.cartesiaVersion) !== null && _f !== void 0 ? _f : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.2.5", "User-Agent": "@cartesia/cartesia-js/2.2.5", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
257
+ headers: Object.assign(Object.assign({ "Cartesia-Version": (_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.cartesiaVersion) !== null && _f !== void 0 ? _f : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.2.7", "User-Agent": "@cartesia/cartesia-js/2.2.7", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
258
258
  contentType: "application/json",
259
259
  requestType: "json",
260
260
  body: serializers.UpdateVoiceRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
@@ -305,7 +305,7 @@ class Voices {
305
305
  const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
306
306
  url: (0, url_join_1.default)((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.CartesiaEnvironment.Production, `/voices/${encodeURIComponent(serializers.VoiceId.jsonOrThrow(id))}`),
307
307
  method: "GET",
308
- headers: Object.assign(Object.assign({ "Cartesia-Version": (_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.cartesiaVersion) !== null && _f !== void 0 ? _f : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.2.5", "User-Agent": "@cartesia/cartesia-js/2.2.5", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
308
+ headers: Object.assign(Object.assign({ "Cartesia-Version": (_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.cartesiaVersion) !== null && _f !== void 0 ? _f : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.2.7", "User-Agent": "@cartesia/cartesia-js/2.2.7", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
309
309
  contentType: "application/json",
310
310
  requestType: "json",
311
311
  timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
@@ -364,7 +364,7 @@ class Voices {
364
364
  const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
365
365
  url: (0, url_join_1.default)((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.CartesiaEnvironment.Production, "/voices/localize"),
366
366
  method: "POST",
367
- headers: Object.assign(Object.assign({ "Cartesia-Version": (_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.cartesiaVersion) !== null && _f !== void 0 ? _f : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.2.5", "User-Agent": "@cartesia/cartesia-js/2.2.5", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
367
+ headers: Object.assign(Object.assign({ "Cartesia-Version": (_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.cartesiaVersion) !== null && _f !== void 0 ? _f : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.2.7", "User-Agent": "@cartesia/cartesia-js/2.2.7", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
368
368
  contentType: "application/json",
369
369
  requestType: "json",
370
370
  body: serializers.LocalizeVoiceRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
@@ -423,7 +423,7 @@ class Voices {
423
423
  const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
424
424
  url: (0, url_join_1.default)((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.CartesiaEnvironment.Production, "/voices/mix"),
425
425
  method: "POST",
426
- headers: Object.assign(Object.assign({ "Cartesia-Version": (_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.cartesiaVersion) !== null && _f !== void 0 ? _f : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.2.5", "User-Agent": "@cartesia/cartesia-js/2.2.5", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
426
+ headers: Object.assign(Object.assign({ "Cartesia-Version": (_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.cartesiaVersion) !== null && _f !== void 0 ? _f : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.2.7", "User-Agent": "@cartesia/cartesia-js/2.2.7", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
427
427
  contentType: "application/json",
428
428
  requestType: "json",
429
429
  body: serializers.MixVoicesRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
@@ -482,7 +482,7 @@ class Voices {
482
482
  const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
483
483
  url: (0, url_join_1.default)((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.CartesiaEnvironment.Production, "/voices/"),
484
484
  method: "POST",
485
- headers: Object.assign(Object.assign({ "Cartesia-Version": (_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.cartesiaVersion) !== null && _f !== void 0 ? _f : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.2.5", "User-Agent": "@cartesia/cartesia-js/2.2.5", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
485
+ headers: Object.assign(Object.assign({ "Cartesia-Version": (_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.cartesiaVersion) !== null && _f !== void 0 ? _f : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.2.7", "User-Agent": "@cartesia/cartesia-js/2.2.7", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
486
486
  contentType: "application/json",
487
487
  requestType: "json",
488
488
  body: serializers.CreateVoiceRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
@@ -20,34 +20,16 @@ import * as Cartesia from "../../../../index";
20
20
  * }
21
21
  */
22
22
  export interface CloneVoiceRequest {
23
- /**
24
- * The name of the voice.
25
- *
26
- */
23
+ /** The name of the voice. */
27
24
  name: string;
28
- /**
29
- * A description for the voice.
30
- *
31
- */
25
+ /** A description for the voice. */
32
26
  description?: string;
33
- /**
34
- * The language of the voice.
35
- *
36
- */
27
+ /** The language of the voice. */
37
28
  language: Cartesia.SupportedLanguage;
38
- /**
39
- * Tradeoff between similarity and stability. Similarity clones sound more like the source clip, but may reproduce background noise. Stability clones always sound like a studio recording, but may not sound as similar to the source clip.
40
- *
41
- */
29
+ /** Tradeoff between similarity and stability. Similarity clones sound more like the source clip, but may reproduce background noise. Stability clones always sound like a studio recording, but may not sound as similar to the source clip. */
42
30
  mode: Cartesia.CloneMode;
43
- /**
44
- * Whether to apply AI enhancements to the clip to reduce background noise. This leads to cleaner generated speech at the cost of reduced similarity to the source clip.
45
- *
46
- */
31
+ /** Whether to apply AI enhancements to the clip to reduce background noise. This leads to cleaner generated speech at the cost of reduced similarity to the source clip. */
47
32
  enhance?: boolean;
48
- /**
49
- * Optional base voice ID that the cloned voice is derived from.
50
- *
51
- */
33
+ /** Optional base voice ID that the cloned voice is derived from. */
52
34
  baseVoiceId?: Cartesia.VoiceId;
53
35
  }
@@ -7,18 +7,14 @@ import * as Cartesia from "../../../index";
7
7
  */
8
8
  export type LocalizeDialect =
9
9
  /**
10
- * Only available when language is set to English (`en`). Options: Australian (`au`), Indian (`in`), Southern (`so`), British (`uk`), or American (`us`).
11
- * */
10
+ * Only available when language is set to English (`en`). Options: Australian (`au`), Indian (`in`), Southern (`so`), British (`uk`), or American (`us`). */
12
11
  Cartesia.LocalizeEnglishDialect
13
12
  /**
14
- * Only available when language is set to Spanish (`es`). Options: Latin American (`mx`) and Peninsular (`pe`).
15
- * */
13
+ * Only available when language is set to Spanish (`es`). Options: Latin American (`mx`) and Peninsular (`pe`). */
16
14
  | Cartesia.LocalizeSpanishDialect
17
15
  /**
18
- * Only available when language is set to Portuguese (`pt`). Options: Brazilian (`br`) and European Portuguese (`eu`).
19
- * */
16
+ * Only available when language is set to Portuguese (`pt`). Options: Brazilian (`br`) and European Portuguese (`eu`). */
20
17
  | Cartesia.LocalizePortugueseDialect
21
18
  /**
22
- * Only available when language is set to French (`fr`). Options: Standard Parisian/Metropolitan (`eu`) and Canadian (`ca`).
23
- * */
19
+ * Only available when language is set to French (`fr`). Options: Standard Parisian/Metropolitan (`eu`) and Canadian (`ca`). */
24
20
  | Cartesia.LocalizeFrenchDialect;
@@ -6,14 +6,14 @@ export declare namespace Fetcher {
6
6
  method: string;
7
7
  contentType?: string;
8
8
  headers?: Record<string, string | undefined>;
9
- queryParameters?: Record<string, string | string[] | object | object[]>;
9
+ queryParameters?: Record<string, string | string[] | object | object[] | null>;
10
10
  body?: unknown;
11
11
  timeoutMs?: number;
12
12
  maxRetries?: number;
13
13
  withCredentials?: boolean;
14
14
  abortSignal?: AbortSignal;
15
15
  requestType?: "json" | "file" | "bytes";
16
- responseType?: "json" | "blob" | "sse" | "streaming" | "text" | "arraybuffer";
16
+ responseType?: "json" | "blob" | "sse" | "streaming" | "text" | "arrayBuffer";
17
17
  duplex?: "half";
18
18
  }
19
19
  type Error = FailedStatusCodeError | NonJsonError | TimeoutError | UnknownError;
@@ -11,6 +11,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.fetcher = void 0;
13
13
  exports.fetcherImpl = fetcherImpl;
14
+ const json_1 = require("../json");
14
15
  const createRequestUrl_1 = require("./createRequestUrl");
15
16
  const getFetchFn_1 = require("./getFetchFn");
16
17
  const getRequestBody_1 = require("./getRequestBody");
@@ -31,7 +32,7 @@ function fetcherImpl(args) {
31
32
  }
32
33
  }
33
34
  const url = (0, createRequestUrl_1.createRequestUrl)(args.url, args.queryParameters);
34
- let requestBody = yield (0, getRequestBody_1.getRequestBody)({
35
+ const requestBody = yield (0, getRequestBody_1.getRequestBody)({
35
36
  body: args.body,
36
37
  type: args.requestType === "json" ? "json" : "other",
37
38
  });
@@ -40,7 +41,7 @@ function fetcherImpl(args) {
40
41
  const response = yield (0, requestWithRetries_1.requestWithRetries)(() => __awaiter(this, void 0, void 0, function* () {
41
42
  return (0, makeRequest_1.makeRequest)(fetchFn, url, args.method, headers, requestBody, args.timeoutMs, args.abortSignal, args.withCredentials, args.duplex);
42
43
  }), args.maxRetries);
43
- let responseBody = yield (0, getResponseBody_1.getResponseBody)(response, args.responseType);
44
+ const responseBody = yield (0, getResponseBody_1.getResponseBody)(response, args.responseType);
44
45
  if (response.status >= 200 && response.status < 400) {
45
46
  return {
46
47
  ok: true,
@@ -90,7 +91,7 @@ function fetcherImpl(args) {
90
91
  ok: false,
91
92
  error: {
92
93
  reason: "unknown",
93
- errorMessage: JSON.stringify(error),
94
+ errorMessage: (0, json_1.toJson)(error),
94
95
  },
95
96
  };
96
97
  }
@@ -16,15 +16,15 @@ function getResponseBody(response, responseType) {
16
16
  if (response.body != null && responseType === "blob") {
17
17
  return yield response.blob();
18
18
  }
19
+ else if (response.body != null && responseType === "arrayBuffer") {
20
+ return yield response.arrayBuffer();
21
+ }
19
22
  else if (response.body != null && responseType === "sse") {
20
23
  return response.body;
21
24
  }
22
25
  else if (response.body != null && responseType === "streaming") {
23
26
  return (0, chooseStreamWrapper_1.chooseStreamWrapper)(response.body);
24
27
  }
25
- else if (response.body != null && responseType === "arraybuffer") {
26
- return yield response.arrayBuffer();
27
- }
28
28
  else if (response.body != null && responseType === "text") {
29
29
  return yield response.text();
30
30
  }
package/dist/index.d.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  export * as Cartesia from "./api";
2
2
  export { CartesiaClient } from "./wrapper/Client";
3
3
  export { WebPlayer } from "./wrapper/WebPlayer";
4
+ export { default as SttWebsocket } from "./wrapper/SttWebsocket";
5
+ export { StreamingSTTClient } from "./wrapper/StreamingSTTClient";
4
6
  export { CartesiaEnvironment } from "./environments";
5
7
  export { CartesiaError, CartesiaTimeoutError } from "./errors";