cartesia 1.4.0__py3-none-any.whl → 2.0.0a0__py3-none-any.whl

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 (174) hide show
  1. cartesia/__init__.py +288 -3
  2. cartesia/api_status/__init__.py +6 -0
  3. cartesia/api_status/client.py +104 -0
  4. cartesia/api_status/requests/__init__.py +5 -0
  5. cartesia/api_status/requests/api_info.py +8 -0
  6. cartesia/api_status/types/__init__.py +5 -0
  7. cartesia/api_status/types/api_info.py +20 -0
  8. cartesia/base_client.py +160 -0
  9. cartesia/client.py +163 -40
  10. cartesia/core/__init__.py +47 -0
  11. cartesia/core/api_error.py +15 -0
  12. cartesia/core/client_wrapper.py +55 -0
  13. cartesia/core/datetime_utils.py +28 -0
  14. cartesia/core/file.py +67 -0
  15. cartesia/core/http_client.py +499 -0
  16. cartesia/core/jsonable_encoder.py +101 -0
  17. cartesia/core/pydantic_utilities.py +296 -0
  18. cartesia/core/query_encoder.py +58 -0
  19. cartesia/core/remove_none_from_dict.py +11 -0
  20. cartesia/core/request_options.py +35 -0
  21. cartesia/core/serialization.py +272 -0
  22. cartesia/datasets/__init__.py +24 -0
  23. cartesia/datasets/client.py +422 -0
  24. cartesia/datasets/requests/__init__.py +15 -0
  25. cartesia/datasets/requests/create_dataset_request.py +7 -0
  26. cartesia/datasets/requests/dataset.py +9 -0
  27. cartesia/datasets/requests/dataset_file.py +9 -0
  28. cartesia/datasets/requests/paginated_dataset_files.py +10 -0
  29. cartesia/datasets/requests/paginated_datasets.py +10 -0
  30. cartesia/datasets/types/__init__.py +17 -0
  31. cartesia/datasets/types/create_dataset_request.py +19 -0
  32. cartesia/datasets/types/dataset.py +21 -0
  33. cartesia/datasets/types/dataset_file.py +21 -0
  34. cartesia/datasets/types/file_purpose.py +5 -0
  35. cartesia/datasets/types/paginated_dataset_files.py +21 -0
  36. cartesia/datasets/types/paginated_datasets.py +21 -0
  37. cartesia/embedding/__init__.py +5 -0
  38. cartesia/embedding/types/__init__.py +5 -0
  39. cartesia/embedding/types/embedding.py +201 -0
  40. cartesia/environment.py +7 -0
  41. cartesia/infill/__init__.py +2 -0
  42. cartesia/infill/client.py +294 -0
  43. cartesia/tts/__init__.py +167 -0
  44. cartesia/{_async_websocket.py → tts/_async_websocket.py} +159 -84
  45. cartesia/tts/_websocket.py +430 -0
  46. cartesia/tts/client.py +407 -0
  47. cartesia/tts/requests/__init__.py +76 -0
  48. cartesia/tts/requests/cancel_context_request.py +17 -0
  49. cartesia/tts/requests/controls.py +11 -0
  50. cartesia/tts/requests/generation_request.py +53 -0
  51. cartesia/tts/requests/mp_3_output_format.py +11 -0
  52. cartesia/tts/requests/output_format.py +30 -0
  53. cartesia/tts/requests/phoneme_timestamps.py +10 -0
  54. cartesia/tts/requests/raw_output_format.py +11 -0
  55. cartesia/tts/requests/speed.py +7 -0
  56. cartesia/tts/requests/tts_request.py +24 -0
  57. cartesia/tts/requests/tts_request_embedding_specifier.py +16 -0
  58. cartesia/tts/requests/tts_request_id_specifier.py +16 -0
  59. cartesia/tts/requests/tts_request_voice_specifier.py +7 -0
  60. cartesia/tts/requests/wav_output_format.py +7 -0
  61. cartesia/tts/requests/web_socket_base_response.py +11 -0
  62. cartesia/tts/requests/web_socket_chunk_response.py +8 -0
  63. cartesia/tts/requests/web_socket_done_response.py +7 -0
  64. cartesia/tts/requests/web_socket_error_response.py +7 -0
  65. cartesia/tts/requests/web_socket_flush_done_response.py +9 -0
  66. cartesia/tts/requests/web_socket_phoneme_timestamps_response.py +9 -0
  67. cartesia/tts/requests/web_socket_raw_output_format.py +11 -0
  68. cartesia/tts/requests/web_socket_request.py +7 -0
  69. cartesia/tts/requests/web_socket_response.py +69 -0
  70. cartesia/tts/requests/web_socket_stream_options.py +8 -0
  71. cartesia/tts/requests/web_socket_timestamps_response.py +9 -0
  72. cartesia/tts/requests/web_socket_tts_output.py +18 -0
  73. cartesia/tts/requests/web_socket_tts_request.py +24 -0
  74. cartesia/tts/requests/word_timestamps.py +10 -0
  75. cartesia/tts/socket_client.py +302 -0
  76. cartesia/tts/types/__init__.py +90 -0
  77. cartesia/tts/types/cancel_context_request.py +28 -0
  78. cartesia/tts/types/context_id.py +3 -0
  79. cartesia/tts/types/controls.py +22 -0
  80. cartesia/tts/types/emotion.py +29 -0
  81. cartesia/tts/types/flush_id.py +3 -0
  82. cartesia/tts/types/generation_request.py +66 -0
  83. cartesia/tts/types/mp_3_output_format.py +23 -0
  84. cartesia/tts/types/natural_specifier.py +5 -0
  85. cartesia/tts/types/numerical_specifier.py +3 -0
  86. cartesia/tts/types/output_format.py +58 -0
  87. cartesia/tts/types/phoneme_timestamps.py +21 -0
  88. cartesia/tts/types/raw_encoding.py +5 -0
  89. cartesia/tts/types/raw_output_format.py +22 -0
  90. cartesia/tts/types/speed.py +7 -0
  91. cartesia/tts/types/supported_language.py +7 -0
  92. cartesia/tts/types/tts_request.py +35 -0
  93. cartesia/tts/types/tts_request_embedding_specifier.py +27 -0
  94. cartesia/tts/types/tts_request_id_specifier.py +27 -0
  95. cartesia/tts/types/tts_request_voice_specifier.py +7 -0
  96. cartesia/tts/types/wav_output_format.py +17 -0
  97. cartesia/tts/types/web_socket_base_response.py +22 -0
  98. cartesia/tts/types/web_socket_chunk_response.py +20 -0
  99. cartesia/tts/types/web_socket_done_response.py +17 -0
  100. cartesia/tts/types/web_socket_error_response.py +19 -0
  101. cartesia/tts/types/web_socket_flush_done_response.py +21 -0
  102. cartesia/tts/types/web_socket_phoneme_timestamps_response.py +20 -0
  103. cartesia/tts/types/web_socket_raw_output_format.py +22 -0
  104. cartesia/tts/types/web_socket_request.py +7 -0
  105. cartesia/tts/types/web_socket_response.py +124 -0
  106. cartesia/tts/types/web_socket_stream_options.py +19 -0
  107. cartesia/tts/types/web_socket_timestamps_response.py +20 -0
  108. cartesia/tts/types/web_socket_tts_output.py +27 -0
  109. cartesia/tts/types/web_socket_tts_request.py +36 -0
  110. cartesia/tts/types/word_timestamps.py +21 -0
  111. cartesia/tts/utils/tts.py +64 -0
  112. cartesia/tts/utils/types.py +70 -0
  113. cartesia/version.py +3 -1
  114. cartesia/voice_changer/__init__.py +27 -0
  115. cartesia/voice_changer/client.py +395 -0
  116. cartesia/voice_changer/requests/__init__.py +15 -0
  117. cartesia/voice_changer/requests/streaming_response.py +36 -0
  118. cartesia/voice_changer/types/__init__.py +17 -0
  119. cartesia/voice_changer/types/output_format_container.py +5 -0
  120. cartesia/voice_changer/types/streaming_response.py +62 -0
  121. cartesia/voices/__init__.py +67 -0
  122. cartesia/voices/client.py +1812 -0
  123. cartesia/voices/requests/__init__.py +27 -0
  124. cartesia/voices/requests/create_voice_request.py +21 -0
  125. cartesia/voices/requests/embedding_response.py +8 -0
  126. cartesia/voices/requests/embedding_specifier.py +10 -0
  127. cartesia/voices/requests/id_specifier.py +10 -0
  128. cartesia/voices/requests/localize_dialect.py +6 -0
  129. cartesia/voices/requests/localize_voice_request.py +15 -0
  130. cartesia/voices/requests/mix_voice_specifier.py +7 -0
  131. cartesia/voices/requests/mix_voices_request.py +9 -0
  132. cartesia/voices/requests/update_voice_request.py +15 -0
  133. cartesia/voices/requests/voice.py +39 -0
  134. cartesia/voices/requests/voice_metadata.py +36 -0
  135. cartesia/voices/types/__init__.py +41 -0
  136. cartesia/voices/types/base_voice_id.py +5 -0
  137. cartesia/voices/types/clone_mode.py +5 -0
  138. cartesia/voices/types/create_voice_request.py +32 -0
  139. cartesia/voices/types/embedding_response.py +20 -0
  140. cartesia/voices/types/embedding_specifier.py +22 -0
  141. cartesia/voices/types/gender.py +5 -0
  142. cartesia/voices/types/id_specifier.py +22 -0
  143. cartesia/voices/types/localize_dialect.py +6 -0
  144. cartesia/voices/types/localize_english_dialect.py +5 -0
  145. cartesia/voices/types/localize_target_language.py +7 -0
  146. cartesia/voices/types/localize_voice_request.py +26 -0
  147. cartesia/voices/types/mix_voice_specifier.py +7 -0
  148. cartesia/voices/types/mix_voices_request.py +20 -0
  149. cartesia/voices/types/update_voice_request.py +27 -0
  150. cartesia/voices/types/voice.py +50 -0
  151. cartesia/voices/types/voice_id.py +3 -0
  152. cartesia/voices/types/voice_metadata.py +48 -0
  153. cartesia/voices/types/weight.py +3 -0
  154. cartesia-2.0.0a0.dist-info/METADATA +306 -0
  155. cartesia-2.0.0a0.dist-info/RECORD +158 -0
  156. {cartesia-1.4.0.dist-info → cartesia-2.0.0a0.dist-info}/WHEEL +1 -1
  157. cartesia/_async_sse.py +0 -95
  158. cartesia/_logger.py +0 -3
  159. cartesia/_sse.py +0 -143
  160. cartesia/_types.py +0 -70
  161. cartesia/_websocket.py +0 -358
  162. cartesia/async_client.py +0 -82
  163. cartesia/async_tts.py +0 -176
  164. cartesia/resource.py +0 -44
  165. cartesia/tts.py +0 -292
  166. cartesia/utils/deprecated.py +0 -55
  167. cartesia/utils/retry.py +0 -87
  168. cartesia/utils/tts.py +0 -78
  169. cartesia/voices.py +0 -204
  170. cartesia-1.4.0.dist-info/METADATA +0 -663
  171. cartesia-1.4.0.dist-info/RECORD +0 -23
  172. cartesia-1.4.0.dist-info/licenses/LICENSE.md +0 -21
  173. /cartesia/{utils/__init__.py → py.typed} +0 -0
  174. /cartesia/{_constants.py → tts/utils/constants.py} +0 -0
@@ -0,0 +1,201 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ """
6
+ [
7
+ 1.0,
8
+ 1.0,
9
+ 1.0,
10
+ 1.0,
11
+ 1.0,
12
+ 1.0,
13
+ 1.0,
14
+ 1.0,
15
+ 1.0,
16
+ 1.0,
17
+ 1.0,
18
+ 1.0,
19
+ 1.0,
20
+ 1.0,
21
+ 1.0,
22
+ 1.0,
23
+ 1.0,
24
+ 1.0,
25
+ 1.0,
26
+ 1.0,
27
+ 1.0,
28
+ 1.0,
29
+ 1.0,
30
+ 1.0,
31
+ 1.0,
32
+ 1.0,
33
+ 1.0,
34
+ 1.0,
35
+ 1.0,
36
+ 1.0,
37
+ 1.0,
38
+ 1.0,
39
+ 1.0,
40
+ 1.0,
41
+ 1.0,
42
+ 1.0,
43
+ 1.0,
44
+ 1.0,
45
+ 1.0,
46
+ 1.0,
47
+ 1.0,
48
+ 1.0,
49
+ 1.0,
50
+ 1.0,
51
+ 1.0,
52
+ 1.0,
53
+ 1.0,
54
+ 1.0,
55
+ 1.0,
56
+ 1.0,
57
+ 1.0,
58
+ 1.0,
59
+ 1.0,
60
+ 1.0,
61
+ 1.0,
62
+ 1.0,
63
+ 1.0,
64
+ 1.0,
65
+ 1.0,
66
+ 1.0,
67
+ 1.0,
68
+ 1.0,
69
+ 1.0,
70
+ 1.0,
71
+ 1.0,
72
+ 1.0,
73
+ 1.0,
74
+ 1.0,
75
+ 1.0,
76
+ 1.0,
77
+ 1.0,
78
+ 1.0,
79
+ 1.0,
80
+ 1.0,
81
+ 1.0,
82
+ 1.0,
83
+ 1.0,
84
+ 1.0,
85
+ 1.0,
86
+ 1.0,
87
+ 1.0,
88
+ 1.0,
89
+ 1.0,
90
+ 1.0,
91
+ 1.0,
92
+ 1.0,
93
+ 1.0,
94
+ 1.0,
95
+ 1.0,
96
+ 1.0,
97
+ 1.0,
98
+ 1.0,
99
+ 1.0,
100
+ 1.0,
101
+ 1.0,
102
+ 1.0,
103
+ 1.0,
104
+ 1.0,
105
+ 1.0,
106
+ 1.0,
107
+ 1.0,
108
+ 1.0,
109
+ 1.0,
110
+ 1.0,
111
+ 1.0,
112
+ 1.0,
113
+ 1.0,
114
+ 1.0,
115
+ 1.0,
116
+ 1.0,
117
+ 1.0,
118
+ 1.0,
119
+ 1.0,
120
+ 1.0,
121
+ 1.0,
122
+ 1.0,
123
+ 1.0,
124
+ 1.0,
125
+ 1.0,
126
+ 1.0,
127
+ 1.0,
128
+ 1.0,
129
+ 1.0,
130
+ 1.0,
131
+ 1.0,
132
+ 1.0,
133
+ 1.0,
134
+ 1.0,
135
+ 1.0,
136
+ 1.0,
137
+ 1.0,
138
+ 1.0,
139
+ 1.0,
140
+ 1.0,
141
+ 1.0,
142
+ 1.0,
143
+ 1.0,
144
+ 1.0,
145
+ 1.0,
146
+ 1.0,
147
+ 1.0,
148
+ 1.0,
149
+ 1.0,
150
+ 1.0,
151
+ 1.0,
152
+ 1.0,
153
+ 1.0,
154
+ 1.0,
155
+ 1.0,
156
+ 1.0,
157
+ 1.0,
158
+ 1.0,
159
+ 1.0,
160
+ 1.0,
161
+ 1.0,
162
+ 1.0,
163
+ 1.0,
164
+ 1.0,
165
+ 1.0,
166
+ 1.0,
167
+ 1.0,
168
+ 1.0,
169
+ 1.0,
170
+ 1.0,
171
+ 1.0,
172
+ 1.0,
173
+ 1.0,
174
+ 1.0,
175
+ 1.0,
176
+ 1.0,
177
+ 1.0,
178
+ 1.0,
179
+ 1.0,
180
+ 1.0,
181
+ 1.0,
182
+ 1.0,
183
+ 1.0,
184
+ 1.0,
185
+ 1.0,
186
+ 1.0,
187
+ 1.0,
188
+ 1.0,
189
+ 1.0,
190
+ 1.0,
191
+ 1.0,
192
+ 1.0,
193
+ 1.0,
194
+ 1.0,
195
+ 1.0,
196
+ 1.0,
197
+ 1.0,
198
+ 1.0,
199
+ ]
200
+ """
201
+ Embedding = typing.List[float]
@@ -0,0 +1,7 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import enum
4
+
5
+
6
+ class CartesiaEnvironment(enum.Enum):
7
+ PRODUCTION = "https://api.cartesia.ai"
@@ -0,0 +1,2 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
@@ -0,0 +1,294 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+ from ..core.client_wrapper import SyncClientWrapper
5
+ from .. import core
6
+ from ..voice_changer.types.output_format_container import OutputFormatContainer
7
+ from ..tts.types.raw_encoding import RawEncoding
8
+ from ..tts.types.speed import Speed
9
+ from ..tts.types.emotion import Emotion
10
+ from ..core.request_options import RequestOptions
11
+ from json.decoder import JSONDecodeError
12
+ from ..core.api_error import ApiError
13
+ from ..core.client_wrapper import AsyncClientWrapper
14
+
15
+ # this is used as the default value for optional parameters
16
+ OMIT = typing.cast(typing.Any, ...)
17
+
18
+
19
+ class InfillClient:
20
+ def __init__(self, *, client_wrapper: SyncClientWrapper):
21
+ self._client_wrapper = client_wrapper
22
+
23
+ def bytes(
24
+ self,
25
+ *,
26
+ left_audio: core.File,
27
+ right_audio: core.File,
28
+ model_id: str,
29
+ language: str,
30
+ transcript: str,
31
+ voice_id: str,
32
+ output_format_container: OutputFormatContainer,
33
+ output_format_sample_rate: int,
34
+ output_format_encoding: typing.Optional[RawEncoding] = OMIT,
35
+ output_format_bit_rate: typing.Optional[int] = OMIT,
36
+ voice_experimental_controls_speed: typing.Optional[Speed] = OMIT,
37
+ voice_experimental_controls_emotion: typing.Optional[Emotion] = OMIT,
38
+ request_options: typing.Optional[RequestOptions] = None,
39
+ ) -> typing.Iterator[bytes]:
40
+ """
41
+ Generate audio that smoothly connects two existing audio segments. This is useful for inserting new speech between existing speech segments while maintaining natural transitions.
42
+
43
+ Only the `sonic-preview` model is supported for infill at this time.
44
+
45
+ At least one of `left_audio` or `right_audio` must be provided.
46
+
47
+ Parameters
48
+ ----------
49
+ left_audio : core.File
50
+ See core.File for more documentation
51
+
52
+ right_audio : core.File
53
+ See core.File for more documentation
54
+
55
+ model_id : str
56
+ The ID of the model to use for generating audio
57
+
58
+ language : str
59
+ The language of the transcript
60
+
61
+ transcript : str
62
+ The infill text to generate
63
+
64
+ voice_id : str
65
+ The ID of the voice to use for generating audio
66
+
67
+ output_format_container : OutputFormatContainer
68
+ The format of the output audio
69
+
70
+ output_format_sample_rate : int
71
+ The sample rate of the output audio
72
+
73
+ output_format_encoding : typing.Optional[RawEncoding]
74
+ Required for `raw` and `wav` containers.
75
+
76
+
77
+ output_format_bit_rate : typing.Optional[int]
78
+ Required for `mp3` containers.
79
+
80
+
81
+ voice_experimental_controls_speed : typing.Optional[Speed]
82
+ Either a number between -1.0 and 1.0 or a natural language description of speed.
83
+
84
+ If you specify a number, 0.0 is the default speed, -1.0 is the slowest speed, and 1.0 is the fastest speed.
85
+
86
+
87
+ voice_experimental_controls_emotion : typing.Optional[Emotion]
88
+ An array of emotion:level tags.
89
+
90
+ Supported emotions are: anger, positivity, surprise, sadness, and curiosity.
91
+
92
+ Supported levels are: lowest, low, (omit), high, highest.
93
+
94
+
95
+ request_options : typing.Optional[RequestOptions]
96
+ Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.
97
+
98
+ Yields
99
+ ------
100
+ typing.Iterator[bytes]
101
+
102
+ Examples
103
+ --------
104
+ from cartesia import Cartesia
105
+
106
+ client = Cartesia(
107
+ api_key="YOUR_API_KEY",
108
+ )
109
+ client.infill.bytes(
110
+ model_id="sonic-preview",
111
+ language="en",
112
+ transcript="middle segment",
113
+ voice_id="694f9389-aac1-45b6-b726-9d9369183238",
114
+ output_format_container="mp3",
115
+ output_format_sample_rate=44100,
116
+ output_format_bit_rate=128000,
117
+ )
118
+ """
119
+ with self._client_wrapper.httpx_client.stream(
120
+ "infill/bytes",
121
+ method="POST",
122
+ data={
123
+ "model_id[]": model_id,
124
+ "language[]": language,
125
+ "transcript[]": transcript,
126
+ "voice[id]": voice_id,
127
+ "output_format[container]": output_format_container,
128
+ "output_format[sample_rate]": output_format_sample_rate,
129
+ "output_format[encoding]": output_format_encoding,
130
+ "output_format[bit_rate]": output_format_bit_rate,
131
+ "voice[__experimental_controls][speed]": voice_experimental_controls_speed,
132
+ "voice[__experimental_controls][emotion][]": voice_experimental_controls_emotion,
133
+ },
134
+ files={
135
+ "left_audio": left_audio,
136
+ "right_audio": right_audio,
137
+ },
138
+ request_options=request_options,
139
+ omit=OMIT,
140
+ ) as _response:
141
+ try:
142
+ if 200 <= _response.status_code < 300:
143
+ _chunk_size = request_options.get("chunk_size", None) if request_options is not None else None
144
+ for _chunk in _response.iter_bytes(chunk_size=_chunk_size):
145
+ yield _chunk
146
+ return
147
+ _response.read()
148
+ _response_json = _response.json()
149
+ except JSONDecodeError:
150
+ raise ApiError(status_code=_response.status_code, body=_response.text)
151
+ raise ApiError(status_code=_response.status_code, body=_response_json)
152
+
153
+
154
+ class AsyncInfillClient:
155
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
156
+ self._client_wrapper = client_wrapper
157
+
158
+ async def bytes(
159
+ self,
160
+ *,
161
+ left_audio: core.File,
162
+ right_audio: core.File,
163
+ model_id: str,
164
+ language: str,
165
+ transcript: str,
166
+ voice_id: str,
167
+ output_format_container: OutputFormatContainer,
168
+ output_format_sample_rate: int,
169
+ output_format_encoding: typing.Optional[RawEncoding] = OMIT,
170
+ output_format_bit_rate: typing.Optional[int] = OMIT,
171
+ voice_experimental_controls_speed: typing.Optional[Speed] = OMIT,
172
+ voice_experimental_controls_emotion: typing.Optional[Emotion] = OMIT,
173
+ request_options: typing.Optional[RequestOptions] = None,
174
+ ) -> typing.AsyncIterator[bytes]:
175
+ """
176
+ Generate audio that smoothly connects two existing audio segments. This is useful for inserting new speech between existing speech segments while maintaining natural transitions.
177
+
178
+ Only the `sonic-preview` model is supported for infill at this time.
179
+
180
+ At least one of `left_audio` or `right_audio` must be provided.
181
+
182
+ Parameters
183
+ ----------
184
+ left_audio : core.File
185
+ See core.File for more documentation
186
+
187
+ right_audio : core.File
188
+ See core.File for more documentation
189
+
190
+ model_id : str
191
+ The ID of the model to use for generating audio
192
+
193
+ language : str
194
+ The language of the transcript
195
+
196
+ transcript : str
197
+ The infill text to generate
198
+
199
+ voice_id : str
200
+ The ID of the voice to use for generating audio
201
+
202
+ output_format_container : OutputFormatContainer
203
+ The format of the output audio
204
+
205
+ output_format_sample_rate : int
206
+ The sample rate of the output audio
207
+
208
+ output_format_encoding : typing.Optional[RawEncoding]
209
+ Required for `raw` and `wav` containers.
210
+
211
+
212
+ output_format_bit_rate : typing.Optional[int]
213
+ Required for `mp3` containers.
214
+
215
+
216
+ voice_experimental_controls_speed : typing.Optional[Speed]
217
+ Either a number between -1.0 and 1.0 or a natural language description of speed.
218
+
219
+ If you specify a number, 0.0 is the default speed, -1.0 is the slowest speed, and 1.0 is the fastest speed.
220
+
221
+
222
+ voice_experimental_controls_emotion : typing.Optional[Emotion]
223
+ An array of emotion:level tags.
224
+
225
+ Supported emotions are: anger, positivity, surprise, sadness, and curiosity.
226
+
227
+ Supported levels are: lowest, low, (omit), high, highest.
228
+
229
+
230
+ request_options : typing.Optional[RequestOptions]
231
+ Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.
232
+
233
+ Yields
234
+ ------
235
+ typing.AsyncIterator[bytes]
236
+
237
+ Examples
238
+ --------
239
+ import asyncio
240
+
241
+ from cartesia import AsyncCartesia
242
+
243
+ client = AsyncCartesia(
244
+ api_key="YOUR_API_KEY",
245
+ )
246
+
247
+
248
+ async def main() -> None:
249
+ await client.infill.bytes(
250
+ model_id="sonic-preview",
251
+ language="en",
252
+ transcript="middle segment",
253
+ voice_id="694f9389-aac1-45b6-b726-9d9369183238",
254
+ output_format_container="mp3",
255
+ output_format_sample_rate=44100,
256
+ output_format_bit_rate=128000,
257
+ )
258
+
259
+
260
+ asyncio.run(main())
261
+ """
262
+ async with self._client_wrapper.httpx_client.stream(
263
+ "infill/bytes",
264
+ method="POST",
265
+ data={
266
+ "model_id[]": model_id,
267
+ "language[]": language,
268
+ "transcript[]": transcript,
269
+ "voice[id]": voice_id,
270
+ "output_format[container]": output_format_container,
271
+ "output_format[sample_rate]": output_format_sample_rate,
272
+ "output_format[encoding]": output_format_encoding,
273
+ "output_format[bit_rate]": output_format_bit_rate,
274
+ "voice[__experimental_controls][speed]": voice_experimental_controls_speed,
275
+ "voice[__experimental_controls][emotion][]": voice_experimental_controls_emotion,
276
+ },
277
+ files={
278
+ "left_audio": left_audio,
279
+ "right_audio": right_audio,
280
+ },
281
+ request_options=request_options,
282
+ omit=OMIT,
283
+ ) as _response:
284
+ try:
285
+ if 200 <= _response.status_code < 300:
286
+ _chunk_size = request_options.get("chunk_size", None) if request_options is not None else None
287
+ async for _chunk in _response.aiter_bytes(chunk_size=_chunk_size):
288
+ yield _chunk
289
+ return
290
+ await _response.aread()
291
+ _response_json = _response.json()
292
+ except JSONDecodeError:
293
+ raise ApiError(status_code=_response.status_code, body=_response.text)
294
+ raise ApiError(status_code=_response.status_code, body=_response_json)
@@ -0,0 +1,167 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ from .types import (
4
+ CancelContextRequest,
5
+ ContextId,
6
+ Controls,
7
+ Emotion,
8
+ FlushId,
9
+ GenerationRequest,
10
+ Mp3OutputFormat,
11
+ NaturalSpecifier,
12
+ NumericalSpecifier,
13
+ OutputFormat,
14
+ OutputFormat_Mp3,
15
+ OutputFormat_Raw,
16
+ OutputFormat_Wav,
17
+ PhonemeTimestamps,
18
+ RawEncoding,
19
+ RawOutputFormat,
20
+ Speed,
21
+ SupportedLanguage,
22
+ TtsRequest,
23
+ TtsRequestEmbeddingSpecifier,
24
+ TtsRequestIdSpecifier,
25
+ TtsRequestVoiceSpecifier,
26
+ WavOutputFormat,
27
+ WebSocketBaseResponse,
28
+ WebSocketChunkResponse,
29
+ WebSocketDoneResponse,
30
+ WebSocketErrorResponse,
31
+ WebSocketFlushDoneResponse,
32
+ WebSocketPhonemeTimestampsResponse,
33
+ WebSocketRawOutputFormat,
34
+ WebSocketRequest,
35
+ WebSocketResponse,
36
+ WebSocketResponse_Chunk,
37
+ WebSocketResponse_Done,
38
+ WebSocketResponse_Error,
39
+ WebSocketResponse_FlushDone,
40
+ WebSocketResponse_PhonemeTimestamps,
41
+ WebSocketResponse_Timestamps,
42
+ WebSocketStreamOptions,
43
+ WebSocketTimestampsResponse,
44
+ WebSocketTtsOutput,
45
+ WebSocketTtsRequest,
46
+ WordTimestamps,
47
+ )
48
+ from .requests import (
49
+ CancelContextRequestParams,
50
+ ControlsParams,
51
+ GenerationRequestParams,
52
+ Mp3OutputFormatParams,
53
+ OutputFormatParams,
54
+ OutputFormat_Mp3Params,
55
+ OutputFormat_RawParams,
56
+ OutputFormat_WavParams,
57
+ PhonemeTimestampsParams,
58
+ RawOutputFormatParams,
59
+ SpeedParams,
60
+ TtsRequestEmbeddingSpecifierParams,
61
+ TtsRequestIdSpecifierParams,
62
+ TtsRequestParams,
63
+ TtsRequestVoiceSpecifierParams,
64
+ WavOutputFormatParams,
65
+ WebSocketBaseResponseParams,
66
+ WebSocketChunkResponseParams,
67
+ WebSocketDoneResponseParams,
68
+ WebSocketErrorResponseParams,
69
+ WebSocketFlushDoneResponseParams,
70
+ WebSocketPhonemeTimestampsResponseParams,
71
+ WebSocketRawOutputFormatParams,
72
+ WebSocketRequestParams,
73
+ WebSocketResponseParams,
74
+ WebSocketResponse_ChunkParams,
75
+ WebSocketResponse_DoneParams,
76
+ WebSocketResponse_ErrorParams,
77
+ WebSocketResponse_FlushDoneParams,
78
+ WebSocketResponse_PhonemeTimestampsParams,
79
+ WebSocketResponse_TimestampsParams,
80
+ WebSocketStreamOptionsParams,
81
+ WebSocketTimestampsResponseParams,
82
+ WebSocketTtsOutputParams,
83
+ WebSocketTtsRequestParams,
84
+ WordTimestampsParams,
85
+ )
86
+
87
+ __all__ = [
88
+ "CancelContextRequest",
89
+ "CancelContextRequestParams",
90
+ "ContextId",
91
+ "Controls",
92
+ "ControlsParams",
93
+ "Emotion",
94
+ "FlushId",
95
+ "GenerationRequest",
96
+ "GenerationRequestParams",
97
+ "Mp3OutputFormat",
98
+ "Mp3OutputFormatParams",
99
+ "NaturalSpecifier",
100
+ "NumericalSpecifier",
101
+ "OutputFormat",
102
+ "OutputFormatParams",
103
+ "OutputFormat_Mp3",
104
+ "OutputFormat_Mp3Params",
105
+ "OutputFormat_Raw",
106
+ "OutputFormat_RawParams",
107
+ "OutputFormat_Wav",
108
+ "OutputFormat_WavParams",
109
+ "PhonemeTimestamps",
110
+ "PhonemeTimestampsParams",
111
+ "RawEncoding",
112
+ "RawOutputFormat",
113
+ "RawOutputFormatParams",
114
+ "Speed",
115
+ "SpeedParams",
116
+ "SupportedLanguage",
117
+ "TtsRequest",
118
+ "TtsRequestEmbeddingSpecifier",
119
+ "TtsRequestEmbeddingSpecifierParams",
120
+ "TtsRequestIdSpecifier",
121
+ "TtsRequestIdSpecifierParams",
122
+ "TtsRequestParams",
123
+ "TtsRequestVoiceSpecifier",
124
+ "TtsRequestVoiceSpecifierParams",
125
+ "WavOutputFormat",
126
+ "WavOutputFormatParams",
127
+ "WebSocketBaseResponse",
128
+ "WebSocketBaseResponseParams",
129
+ "WebSocketChunkResponse",
130
+ "WebSocketChunkResponseParams",
131
+ "WebSocketDoneResponse",
132
+ "WebSocketDoneResponseParams",
133
+ "WebSocketErrorResponse",
134
+ "WebSocketErrorResponseParams",
135
+ "WebSocketFlushDoneResponse",
136
+ "WebSocketFlushDoneResponseParams",
137
+ "WebSocketPhonemeTimestampsResponse",
138
+ "WebSocketPhonemeTimestampsResponseParams",
139
+ "WebSocketRawOutputFormat",
140
+ "WebSocketRawOutputFormatParams",
141
+ "WebSocketRequest",
142
+ "WebSocketRequestParams",
143
+ "WebSocketResponse",
144
+ "WebSocketResponseParams",
145
+ "WebSocketResponse_Chunk",
146
+ "WebSocketResponse_ChunkParams",
147
+ "WebSocketResponse_Done",
148
+ "WebSocketResponse_DoneParams",
149
+ "WebSocketResponse_Error",
150
+ "WebSocketResponse_ErrorParams",
151
+ "WebSocketResponse_FlushDone",
152
+ "WebSocketResponse_FlushDoneParams",
153
+ "WebSocketResponse_PhonemeTimestamps",
154
+ "WebSocketResponse_PhonemeTimestampsParams",
155
+ "WebSocketResponse_Timestamps",
156
+ "WebSocketResponse_TimestampsParams",
157
+ "WebSocketStreamOptions",
158
+ "WebSocketStreamOptionsParams",
159
+ "WebSocketTimestampsResponse",
160
+ "WebSocketTimestampsResponseParams",
161
+ "WebSocketTtsOutput",
162
+ "WebSocketTtsOutputParams",
163
+ "WebSocketTtsRequest",
164
+ "WebSocketTtsRequestParams",
165
+ "WordTimestamps",
166
+ "WordTimestampsParams",
167
+ ]