camb-sdk 1.5.4__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 (167) hide show
  1. camb/__init__.py +335 -0
  2. camb/audio_separation/__init__.py +4 -0
  3. camb/audio_separation/client.py +406 -0
  4. camb/audio_separation/raw_client.py +534 -0
  5. camb/client.py +717 -0
  6. camb/core/__init__.py +105 -0
  7. camb/core/api_error.py +23 -0
  8. camb/core/client_wrapper.py +113 -0
  9. camb/core/datetime_utils.py +28 -0
  10. camb/core/file.py +67 -0
  11. camb/core/force_multipart.py +18 -0
  12. camb/core/http_client.py +663 -0
  13. camb/core/http_response.py +55 -0
  14. camb/core/http_sse/__init__.py +42 -0
  15. camb/core/http_sse/_api.py +112 -0
  16. camb/core/http_sse/_decoders.py +61 -0
  17. camb/core/http_sse/_exceptions.py +7 -0
  18. camb/core/http_sse/_models.py +17 -0
  19. camb/core/jsonable_encoder.py +100 -0
  20. camb/core/pydantic_utilities.py +260 -0
  21. camb/core/query_encoder.py +58 -0
  22. camb/core/remove_none_from_dict.py +11 -0
  23. camb/core/request_options.py +35 -0
  24. camb/core/serialization.py +276 -0
  25. camb/deprecated_streaming/__init__.py +4 -0
  26. camb/deprecated_streaming/client.py +532 -0
  27. camb/deprecated_streaming/raw_client.py +639 -0
  28. camb/dictionaries/__init__.py +4 -0
  29. camb/dictionaries/client.py +785 -0
  30. camb/dictionaries/raw_client.py +1048 -0
  31. camb/dub/__init__.py +49 -0
  32. camb/dub/client.py +846 -0
  33. camb/dub/raw_client.py +1194 -0
  34. camb/dub/types/__init__.py +53 -0
  35. camb/dub/types/dubbed_output_in_alt_format_request_payload_output_format.py +8 -0
  36. camb/dub/types/get_dubbed_output_in_alt_format_dub_alt_format_run_id_language_post_response.py +9 -0
  37. camb/dub/types/get_dubbed_run_info_dub_result_run_id_get_response.py +7 -0
  38. camb/dub/types/get_dubbing_runs_results_dubbing_results_post_response_value.py +7 -0
  39. camb/environment.py +7 -0
  40. camb/errors/__init__.py +34 -0
  41. camb/errors/unprocessable_entity_error.py +11 -0
  42. camb/folders/__init__.py +4 -0
  43. camb/folders/client.py +213 -0
  44. camb/folders/raw_client.py +278 -0
  45. camb/languages/__init__.py +4 -0
  46. camb/languages/client.py +168 -0
  47. camb/languages/raw_client.py +223 -0
  48. camb/project_setup/__init__.py +4 -0
  49. camb/project_setup/client.py +537 -0
  50. camb/project_setup/raw_client.py +655 -0
  51. camb/py.typed +0 -0
  52. camb/raw_client.py +236 -0
  53. camb/story/__init__.py +37 -0
  54. camb/story/client.py +579 -0
  55. camb/story/raw_client.py +743 -0
  56. camb/story/types/__init__.py +38 -0
  57. camb/story/types/create_story_story_post_response.py +8 -0
  58. camb/story/types/setup_story_story_setup_post_response.py +8 -0
  59. camb/streaming/__init__.py +4 -0
  60. camb/streaming/client.py +645 -0
  61. camb/streaming/raw_client.py +796 -0
  62. camb/text_to_audio/__init__.py +4 -0
  63. camb/text_to_audio/client.py +469 -0
  64. camb/text_to_audio/raw_client.py +610 -0
  65. camb/text_to_speech/__init__.py +49 -0
  66. camb/text_to_speech/baseten.py +214 -0
  67. camb/text_to_speech/client.py +742 -0
  68. camb/text_to_speech/raw_client.py +995 -0
  69. camb/text_to_speech/types/__init__.py +47 -0
  70. camb/text_to_speech/types/create_stream_tts_request_payload_language.py +71 -0
  71. camb/text_to_speech/types/create_stream_tts_request_payload_speech_model.py +7 -0
  72. camb/text_to_speech/types/get_tts_results_tts_results_post_response_value.py +7 -0
  73. camb/text_to_speech/types/get_tts_run_info_tts_result_run_id_get_response.py +7 -0
  74. camb/text_to_voice/__init__.py +4 -0
  75. camb/text_to_voice/client.py +329 -0
  76. camb/text_to_voice/raw_client.py +405 -0
  77. camb/transcription/__init__.py +4 -0
  78. camb/transcription/client.py +465 -0
  79. camb/transcription/raw_client.py +587 -0
  80. camb/translated_story/__init__.py +4 -0
  81. camb/translated_story/client.py +309 -0
  82. camb/translated_story/raw_client.py +381 -0
  83. camb/translated_tts/__init__.py +4 -0
  84. camb/translated_tts/client.py +313 -0
  85. camb/translated_tts/raw_client.py +357 -0
  86. camb/translation/__init__.py +4 -0
  87. camb/translation/client.py +631 -0
  88. camb/translation/raw_client.py +787 -0
  89. camb/types/__init__.py +236 -0
  90. camb/types/add_target_language_out.py +20 -0
  91. camb/types/audio_output_type.py +5 -0
  92. camb/types/audio_stream.py +31 -0
  93. camb/types/config_stream.py +22 -0
  94. camb/types/config_stream_pipeline.py +28 -0
  95. camb/types/create_custom_voice_out.py +19 -0
  96. camb/types/create_project_setup_out.py +19 -0
  97. camb/types/create_stream_out.py +22 -0
  98. camb/types/create_stream_request_payload.py +70 -0
  99. camb/types/create_translated_tts_out.py +19 -0
  100. camb/types/create_tts_out.py +19 -0
  101. camb/types/data_stream.py +24 -0
  102. camb/types/demixing_option.py +10 -0
  103. camb/types/dictionary_term.py +21 -0
  104. camb/types/dictionary_with_terms.py +28 -0
  105. camb/types/dubbing_result.py +22 -0
  106. camb/types/exception_reasons.py +30 -0
  107. camb/types/folder.py +20 -0
  108. camb/types/formalities.py +3 -0
  109. camb/types/gender.py +3 -0
  110. camb/types/get_audio_separation_result_out.py +20 -0
  111. camb/types/get_create_project_setup_response.py +21 -0
  112. camb/types/get_probe_stream_in.py +21 -0
  113. camb/types/get_probe_stream_out.py +24 -0
  114. camb/types/get_setup_story_result_response.py +21 -0
  115. camb/types/get_text_to_voice_result_out.py +19 -0
  116. camb/types/get_tts_result_out_file_url.py +19 -0
  117. camb/types/http_validation_error.py +20 -0
  118. camb/types/language_enums.py +154 -0
  119. camb/types/language_pydantic_model.py +21 -0
  120. camb/types/languages.py +3 -0
  121. camb/types/orchestrator_pipeline_call_result.py +19 -0
  122. camb/types/orchestrator_pipeline_result.py +25 -0
  123. camb/types/orchestrator_pipeline_result_exception_reason.py +7 -0
  124. camb/types/orchestrator_pipeline_result_message.py +5 -0
  125. camb/types/output_format.py +10 -0
  126. camb/types/overdub_config.py +37 -0
  127. camb/types/project_details.py +28 -0
  128. camb/types/revoicing_option.py +5 -0
  129. camb/types/run_i_ds_request_payload.py +19 -0
  130. camb/types/segmenting_option.py +5 -0
  131. camb/types/source_stream.py +30 -0
  132. camb/types/story_details.py +27 -0
  133. camb/types/stream_category.py +3 -0
  134. camb/types/stream_tts_inference_options.py +38 -0
  135. camb/types/stream_tts_output_configuration.py +33 -0
  136. camb/types/stream_tts_voice_settings.py +28 -0
  137. camb/types/stream_type.py +3 -0
  138. camb/types/stream_url_for_languages.py +21 -0
  139. camb/types/target_stream.py +34 -0
  140. camb/types/task_status.py +5 -0
  141. camb/types/term_translation_input.py +21 -0
  142. camb/types/term_translation_output.py +20 -0
  143. camb/types/text_to_audio_result.py +19 -0
  144. camb/types/text_to_audio_type.py +5 -0
  145. camb/types/transcribing_option.py +5 -0
  146. camb/types/transcript.py +22 -0
  147. camb/types/transcript_data_type.py +5 -0
  148. camb/types/transcript_file_format.py +5 -0
  149. camb/types/transcription_result.py +20 -0
  150. camb/types/translating_option.py +5 -0
  151. camb/types/translation_result.py +19 -0
  152. camb/types/tts_provider.py +3 -0
  153. camb/types/validation_error.py +22 -0
  154. camb/types/validation_error_loc_item.py +5 -0
  155. camb/types/video_output_type_without_avi.py +5 -0
  156. camb/types/video_stream.py +28 -0
  157. camb/types/voice.py +28 -0
  158. camb/voice_cloning/__init__.py +34 -0
  159. camb/voice_cloning/client.py +265 -0
  160. camb/voice_cloning/raw_client.py +320 -0
  161. camb/voice_cloning/types/__init__.py +36 -0
  162. camb/voice_cloning/types/list_voices_list_voices_get_response_item.py +7 -0
  163. camb_sdk-1.5.4.dist-info/METADATA +282 -0
  164. camb_sdk-1.5.4.dist-info/RECORD +167 -0
  165. camb_sdk-1.5.4.dist-info/WHEEL +5 -0
  166. camb_sdk-1.5.4.dist-info/licenses/LICENSE +21 -0
  167. camb_sdk-1.5.4.dist-info/top_level.txt +1 -0
@@ -0,0 +1,610 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import contextlib
4
+ import typing
5
+ from json.decoder import JSONDecodeError
6
+
7
+ from ..core.api_error import ApiError
8
+ from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
9
+ from ..core.http_response import AsyncHttpResponse, HttpResponse
10
+ from ..core.jsonable_encoder import jsonable_encoder
11
+ from ..core.pydantic_utilities import parse_obj_as
12
+ from ..core.request_options import RequestOptions
13
+ from ..errors.unprocessable_entity_error import UnprocessableEntityError
14
+ from ..types.http_validation_error import HttpValidationError
15
+ from ..types.orchestrator_pipeline_call_result import OrchestratorPipelineCallResult
16
+ from ..types.orchestrator_pipeline_result import OrchestratorPipelineResult
17
+ from ..types.text_to_audio_result import TextToAudioResult
18
+ from ..types.text_to_audio_type import TextToAudioType
19
+
20
+ # this is used as the default value for optional parameters
21
+ OMIT = typing.cast(typing.Any, ...)
22
+
23
+
24
+ class RawTextToAudioClient:
25
+ def __init__(self, *, client_wrapper: SyncClientWrapper):
26
+ self._client_wrapper = client_wrapper
27
+
28
+ def create_text_to_audio(
29
+ self,
30
+ *,
31
+ prompt: str,
32
+ run_id: typing.Optional[int] = None,
33
+ traceparent: typing.Optional[str] = None,
34
+ project_name: typing.Optional[str] = OMIT,
35
+ project_description: typing.Optional[str] = OMIT,
36
+ folder_id: typing.Optional[int] = OMIT,
37
+ duration: typing.Optional[float] = OMIT,
38
+ audio_type: typing.Optional[TextToAudioType] = OMIT,
39
+ request_options: typing.Optional[RequestOptions] = None,
40
+ ) -> HttpResponse[OrchestratorPipelineCallResult]:
41
+ """
42
+ Parameters
43
+ ----------
44
+ prompt : str
45
+ The text to be converted to audio.
46
+
47
+ run_id : typing.Optional[int]
48
+
49
+ traceparent : typing.Optional[str]
50
+
51
+ project_name : typing.Optional[str]
52
+
53
+ project_description : typing.Optional[str]
54
+
55
+ folder_id : typing.Optional[int]
56
+
57
+ duration : typing.Optional[float]
58
+ The desired duration of the audio.
59
+
60
+ audio_type : typing.Optional[TextToAudioType]
61
+ The audio type preference.
62
+
63
+ request_options : typing.Optional[RequestOptions]
64
+ Request-specific configuration.
65
+
66
+ Returns
67
+ -------
68
+ HttpResponse[OrchestratorPipelineCallResult]
69
+ Successful Response
70
+ """
71
+ _response = self._client_wrapper.httpx_client.request(
72
+ "text-to-sound",
73
+ method="POST",
74
+ params={
75
+ "run_id": run_id,
76
+ },
77
+ json={
78
+ "project_name": project_name,
79
+ "project_description": project_description,
80
+ "folder_id": folder_id,
81
+ "prompt": prompt,
82
+ "duration": duration,
83
+ "audio_type": audio_type,
84
+ },
85
+ headers={
86
+ "content-type": "application/json",
87
+ "traceparent": str(traceparent) if traceparent is not None else None,
88
+ },
89
+ request_options=request_options,
90
+ omit=OMIT,
91
+ )
92
+ try:
93
+ if 200 <= _response.status_code < 300:
94
+ _data = typing.cast(
95
+ OrchestratorPipelineCallResult,
96
+ parse_obj_as(
97
+ type_=OrchestratorPipelineCallResult, # type: ignore
98
+ object_=_response.json(),
99
+ ),
100
+ )
101
+ return HttpResponse(response=_response, data=_data)
102
+ if _response.status_code == 422:
103
+ raise UnprocessableEntityError(
104
+ headers=dict(_response.headers),
105
+ body=typing.cast(
106
+ HttpValidationError,
107
+ parse_obj_as(
108
+ type_=HttpValidationError, # type: ignore
109
+ object_=_response.json(),
110
+ ),
111
+ ),
112
+ )
113
+ _response_json = _response.json()
114
+ except JSONDecodeError:
115
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
116
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
117
+
118
+ def get_text_to_audio_status(
119
+ self,
120
+ task_id: str,
121
+ *,
122
+ run_id: typing.Optional[int] = None,
123
+ request_options: typing.Optional[RequestOptions] = None,
124
+ ) -> HttpResponse[OrchestratorPipelineResult]:
125
+ """
126
+ Parameters
127
+ ----------
128
+ task_id : str
129
+
130
+ run_id : typing.Optional[int]
131
+
132
+ request_options : typing.Optional[RequestOptions]
133
+ Request-specific configuration.
134
+
135
+ Returns
136
+ -------
137
+ HttpResponse[OrchestratorPipelineResult]
138
+ Successful Response
139
+ """
140
+ _response = self._client_wrapper.httpx_client.request(
141
+ f"text-to-sound/{jsonable_encoder(task_id)}",
142
+ method="GET",
143
+ params={
144
+ "run_id": run_id,
145
+ },
146
+ request_options=request_options,
147
+ )
148
+ try:
149
+ if 200 <= _response.status_code < 300:
150
+ _data = typing.cast(
151
+ OrchestratorPipelineResult,
152
+ parse_obj_as(
153
+ type_=OrchestratorPipelineResult, # type: ignore
154
+ object_=_response.json(),
155
+ ),
156
+ )
157
+ return HttpResponse(response=_response, data=_data)
158
+ if _response.status_code == 422:
159
+ raise UnprocessableEntityError(
160
+ headers=dict(_response.headers),
161
+ body=typing.cast(
162
+ HttpValidationError,
163
+ parse_obj_as(
164
+ type_=HttpValidationError, # type: ignore
165
+ object_=_response.json(),
166
+ ),
167
+ ),
168
+ )
169
+ _response_json = _response.json()
170
+ except JSONDecodeError:
171
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
172
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
173
+
174
+ @contextlib.contextmanager
175
+ def get_text_to_audio_result(
176
+ self,
177
+ run_id: typing.Optional[int],
178
+ *,
179
+ output_type: typing.Optional[str] = None,
180
+ request_options: typing.Optional[RequestOptions] = None,
181
+ ) -> typing.Iterator[HttpResponse[typing.Iterator[bytes]]]:
182
+ """
183
+ Retrieve the Text-to-Audio (TTA) result for a given run.
184
+
185
+ This endpoint validates the provided run ID and retrieves the associated
186
+ Text-to-Audio output. It supports two output formats:
187
+ - RAW_BYTES: Streams the audio file in WAV format.
188
+ - FILE_URL: Returns a pre-signed URL for downloading the audio file.
189
+
190
+ The endpoint ensures that the run type is valid for Text-to-Audio processing
191
+ and that the storage preferences are applied accordingly.
192
+
193
+ Args:
194
+ run_id (int): Unique identifier for the TTA run.
195
+ traceparent (Optional[str]): Trace header for distributed tracing.
196
+ api_key_obj (dict): API key object containing authentication and storage preferences.
197
+ output_type (OutputType): Desired output format. Defaults to RAW_BYTES.
198
+
199
+ Returns:
200
+ StreamingResponse | GetTTAOut:
201
+ - StreamingResponse: If output_type is RAW_BYTES, a streaming response with the audio in WAV format.
202
+ - GetTTAOut: If output_type is FILE_URL, a pre-signed URL to access the audio file.
203
+
204
+ Raises:
205
+ HTTPException:
206
+ - 400 BAD REQUEST: If the run type is invalid for a TTA run.
207
+ - 500 INTERNAL SERVER ERROR: If the audio file cannot be fetched or streamed.
208
+
209
+ Parameters
210
+ ----------
211
+ run_id : typing.Optional[int]
212
+
213
+ output_type : typing.Optional[str]
214
+ Output format for the Text To Speech result
215
+
216
+ request_options : typing.Optional[RequestOptions]
217
+ Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.
218
+
219
+ Returns
220
+ -------
221
+ typing.Iterator[HttpResponse[typing.Iterator[bytes]]]
222
+ Successful Response
223
+ """
224
+ with self._client_wrapper.httpx_client.stream(
225
+ f"text-to-sound-result/{jsonable_encoder(run_id)}",
226
+ method="GET",
227
+ params={
228
+ "output_type": output_type,
229
+ },
230
+ request_options=request_options,
231
+ ) as _response:
232
+
233
+ def _stream() -> HttpResponse[typing.Iterator[bytes]]:
234
+ try:
235
+ if 200 <= _response.status_code < 300:
236
+ _chunk_size = request_options.get("chunk_size", None) if request_options is not None else None
237
+ return HttpResponse(
238
+ response=_response, data=(_chunk for _chunk in _response.iter_bytes(chunk_size=_chunk_size))
239
+ )
240
+ _response.read()
241
+ _response_json = _response.json()
242
+ except JSONDecodeError:
243
+ raise ApiError(
244
+ status_code=_response.status_code, headers=dict(_response.headers), body=_response.text
245
+ )
246
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
247
+
248
+ yield _stream()
249
+
250
+ def get_text_to_sound_results(
251
+ self,
252
+ *,
253
+ run_ids: typing.Sequence[int],
254
+ run_id: typing.Optional[int] = None,
255
+ traceparent: typing.Optional[str] = None,
256
+ request_options: typing.Optional[RequestOptions] = None,
257
+ ) -> HttpResponse[typing.Dict[str, TextToAudioResult]]:
258
+ """
259
+ Parameters
260
+ ----------
261
+ run_ids : typing.Sequence[int]
262
+
263
+ run_id : typing.Optional[int]
264
+
265
+ traceparent : typing.Optional[str]
266
+
267
+ request_options : typing.Optional[RequestOptions]
268
+ Request-specific configuration.
269
+
270
+ Returns
271
+ -------
272
+ HttpResponse[typing.Dict[str, TextToAudioResult]]
273
+ Successful Response
274
+ """
275
+ _response = self._client_wrapper.httpx_client.request(
276
+ "text-to-sound-results",
277
+ method="POST",
278
+ params={
279
+ "run_id": run_id,
280
+ },
281
+ json={
282
+ "run_ids": run_ids,
283
+ },
284
+ headers={
285
+ "content-type": "application/json",
286
+ "traceparent": str(traceparent) if traceparent is not None else None,
287
+ },
288
+ request_options=request_options,
289
+ omit=OMIT,
290
+ )
291
+ try:
292
+ if 200 <= _response.status_code < 300:
293
+ _data = typing.cast(
294
+ typing.Dict[str, TextToAudioResult],
295
+ parse_obj_as(
296
+ type_=typing.Dict[str, TextToAudioResult], # type: ignore
297
+ object_=_response.json(),
298
+ ),
299
+ )
300
+ return HttpResponse(response=_response, data=_data)
301
+ if _response.status_code == 422:
302
+ raise UnprocessableEntityError(
303
+ headers=dict(_response.headers),
304
+ body=typing.cast(
305
+ HttpValidationError,
306
+ parse_obj_as(
307
+ type_=HttpValidationError, # type: ignore
308
+ object_=_response.json(),
309
+ ),
310
+ ),
311
+ )
312
+ _response_json = _response.json()
313
+ except JSONDecodeError:
314
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
315
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
316
+
317
+
318
+ class AsyncRawTextToAudioClient:
319
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
320
+ self._client_wrapper = client_wrapper
321
+
322
+ async def create_text_to_audio(
323
+ self,
324
+ *,
325
+ prompt: str,
326
+ run_id: typing.Optional[int] = None,
327
+ traceparent: typing.Optional[str] = None,
328
+ project_name: typing.Optional[str] = OMIT,
329
+ project_description: typing.Optional[str] = OMIT,
330
+ folder_id: typing.Optional[int] = OMIT,
331
+ duration: typing.Optional[float] = OMIT,
332
+ audio_type: typing.Optional[TextToAudioType] = OMIT,
333
+ request_options: typing.Optional[RequestOptions] = None,
334
+ ) -> AsyncHttpResponse[OrchestratorPipelineCallResult]:
335
+ """
336
+ Parameters
337
+ ----------
338
+ prompt : str
339
+ The text to be converted to audio.
340
+
341
+ run_id : typing.Optional[int]
342
+
343
+ traceparent : typing.Optional[str]
344
+
345
+ project_name : typing.Optional[str]
346
+
347
+ project_description : typing.Optional[str]
348
+
349
+ folder_id : typing.Optional[int]
350
+
351
+ duration : typing.Optional[float]
352
+ The desired duration of the audio.
353
+
354
+ audio_type : typing.Optional[TextToAudioType]
355
+ The audio type preference.
356
+
357
+ request_options : typing.Optional[RequestOptions]
358
+ Request-specific configuration.
359
+
360
+ Returns
361
+ -------
362
+ AsyncHttpResponse[OrchestratorPipelineCallResult]
363
+ Successful Response
364
+ """
365
+ _response = await self._client_wrapper.httpx_client.request(
366
+ "text-to-sound",
367
+ method="POST",
368
+ params={
369
+ "run_id": run_id,
370
+ },
371
+ json={
372
+ "project_name": project_name,
373
+ "project_description": project_description,
374
+ "folder_id": folder_id,
375
+ "prompt": prompt,
376
+ "duration": duration,
377
+ "audio_type": audio_type,
378
+ },
379
+ headers={
380
+ "content-type": "application/json",
381
+ "traceparent": str(traceparent) if traceparent is not None else None,
382
+ },
383
+ request_options=request_options,
384
+ omit=OMIT,
385
+ )
386
+ try:
387
+ if 200 <= _response.status_code < 300:
388
+ _data = typing.cast(
389
+ OrchestratorPipelineCallResult,
390
+ parse_obj_as(
391
+ type_=OrchestratorPipelineCallResult, # type: ignore
392
+ object_=_response.json(),
393
+ ),
394
+ )
395
+ return AsyncHttpResponse(response=_response, data=_data)
396
+ if _response.status_code == 422:
397
+ raise UnprocessableEntityError(
398
+ headers=dict(_response.headers),
399
+ body=typing.cast(
400
+ HttpValidationError,
401
+ parse_obj_as(
402
+ type_=HttpValidationError, # type: ignore
403
+ object_=_response.json(),
404
+ ),
405
+ ),
406
+ )
407
+ _response_json = _response.json()
408
+ except JSONDecodeError:
409
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
410
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
411
+
412
+ async def get_text_to_audio_status(
413
+ self,
414
+ task_id: str,
415
+ *,
416
+ run_id: typing.Optional[int] = None,
417
+ request_options: typing.Optional[RequestOptions] = None,
418
+ ) -> AsyncHttpResponse[OrchestratorPipelineResult]:
419
+ """
420
+ Parameters
421
+ ----------
422
+ task_id : str
423
+
424
+ run_id : typing.Optional[int]
425
+
426
+ request_options : typing.Optional[RequestOptions]
427
+ Request-specific configuration.
428
+
429
+ Returns
430
+ -------
431
+ AsyncHttpResponse[OrchestratorPipelineResult]
432
+ Successful Response
433
+ """
434
+ _response = await self._client_wrapper.httpx_client.request(
435
+ f"text-to-sound/{jsonable_encoder(task_id)}",
436
+ method="GET",
437
+ params={
438
+ "run_id": run_id,
439
+ },
440
+ request_options=request_options,
441
+ )
442
+ try:
443
+ if 200 <= _response.status_code < 300:
444
+ _data = typing.cast(
445
+ OrchestratorPipelineResult,
446
+ parse_obj_as(
447
+ type_=OrchestratorPipelineResult, # type: ignore
448
+ object_=_response.json(),
449
+ ),
450
+ )
451
+ return AsyncHttpResponse(response=_response, data=_data)
452
+ if _response.status_code == 422:
453
+ raise UnprocessableEntityError(
454
+ headers=dict(_response.headers),
455
+ body=typing.cast(
456
+ HttpValidationError,
457
+ parse_obj_as(
458
+ type_=HttpValidationError, # type: ignore
459
+ object_=_response.json(),
460
+ ),
461
+ ),
462
+ )
463
+ _response_json = _response.json()
464
+ except JSONDecodeError:
465
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
466
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
467
+
468
+ @contextlib.asynccontextmanager
469
+ async def get_text_to_audio_result(
470
+ self,
471
+ run_id: typing.Optional[int],
472
+ *,
473
+ output_type: typing.Optional[str] = None,
474
+ request_options: typing.Optional[RequestOptions] = None,
475
+ ) -> typing.AsyncIterator[AsyncHttpResponse[typing.AsyncIterator[bytes]]]:
476
+ """
477
+ Retrieve the Text-to-Audio (TTA) result for a given run.
478
+
479
+ This endpoint validates the provided run ID and retrieves the associated
480
+ Text-to-Audio output. It supports two output formats:
481
+ - RAW_BYTES: Streams the audio file in WAV format.
482
+ - FILE_URL: Returns a pre-signed URL for downloading the audio file.
483
+
484
+ The endpoint ensures that the run type is valid for Text-to-Audio processing
485
+ and that the storage preferences are applied accordingly.
486
+
487
+ Args:
488
+ run_id (int): Unique identifier for the TTA run.
489
+ traceparent (Optional[str]): Trace header for distributed tracing.
490
+ api_key_obj (dict): API key object containing authentication and storage preferences.
491
+ output_type (OutputType): Desired output format. Defaults to RAW_BYTES.
492
+
493
+ Returns:
494
+ StreamingResponse | GetTTAOut:
495
+ - StreamingResponse: If output_type is RAW_BYTES, a streaming response with the audio in WAV format.
496
+ - GetTTAOut: If output_type is FILE_URL, a pre-signed URL to access the audio file.
497
+
498
+ Raises:
499
+ HTTPException:
500
+ - 400 BAD REQUEST: If the run type is invalid for a TTA run.
501
+ - 500 INTERNAL SERVER ERROR: If the audio file cannot be fetched or streamed.
502
+
503
+ Parameters
504
+ ----------
505
+ run_id : typing.Optional[int]
506
+
507
+ output_type : typing.Optional[str]
508
+ Output format for the Text To Speech result
509
+
510
+ request_options : typing.Optional[RequestOptions]
511
+ Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.
512
+
513
+ Returns
514
+ -------
515
+ typing.AsyncIterator[AsyncHttpResponse[typing.AsyncIterator[bytes]]]
516
+ Successful Response
517
+ """
518
+ async with self._client_wrapper.httpx_client.stream(
519
+ f"text-to-sound-result/{jsonable_encoder(run_id)}",
520
+ method="GET",
521
+ params={
522
+ "output_type": output_type,
523
+ },
524
+ request_options=request_options,
525
+ ) as _response:
526
+
527
+ async def _stream() -> AsyncHttpResponse[typing.AsyncIterator[bytes]]:
528
+ try:
529
+ if 200 <= _response.status_code < 300:
530
+ _chunk_size = request_options.get("chunk_size", None) if request_options is not None else None
531
+ return AsyncHttpResponse(
532
+ response=_response,
533
+ data=(_chunk async for _chunk in _response.aiter_bytes(chunk_size=_chunk_size)),
534
+ )
535
+ await _response.aread()
536
+ _response_json = _response.json()
537
+ except JSONDecodeError:
538
+ raise ApiError(
539
+ status_code=_response.status_code, headers=dict(_response.headers), body=_response.text
540
+ )
541
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
542
+
543
+ yield await _stream()
544
+
545
+ async def get_text_to_sound_results(
546
+ self,
547
+ *,
548
+ run_ids: typing.Sequence[int],
549
+ run_id: typing.Optional[int] = None,
550
+ traceparent: typing.Optional[str] = None,
551
+ request_options: typing.Optional[RequestOptions] = None,
552
+ ) -> AsyncHttpResponse[typing.Dict[str, TextToAudioResult]]:
553
+ """
554
+ Parameters
555
+ ----------
556
+ run_ids : typing.Sequence[int]
557
+
558
+ run_id : typing.Optional[int]
559
+
560
+ traceparent : typing.Optional[str]
561
+
562
+ request_options : typing.Optional[RequestOptions]
563
+ Request-specific configuration.
564
+
565
+ Returns
566
+ -------
567
+ AsyncHttpResponse[typing.Dict[str, TextToAudioResult]]
568
+ Successful Response
569
+ """
570
+ _response = await self._client_wrapper.httpx_client.request(
571
+ "text-to-sound-results",
572
+ method="POST",
573
+ params={
574
+ "run_id": run_id,
575
+ },
576
+ json={
577
+ "run_ids": run_ids,
578
+ },
579
+ headers={
580
+ "content-type": "application/json",
581
+ "traceparent": str(traceparent) if traceparent is not None else None,
582
+ },
583
+ request_options=request_options,
584
+ omit=OMIT,
585
+ )
586
+ try:
587
+ if 200 <= _response.status_code < 300:
588
+ _data = typing.cast(
589
+ typing.Dict[str, TextToAudioResult],
590
+ parse_obj_as(
591
+ type_=typing.Dict[str, TextToAudioResult], # type: ignore
592
+ object_=_response.json(),
593
+ ),
594
+ )
595
+ return AsyncHttpResponse(response=_response, data=_data)
596
+ if _response.status_code == 422:
597
+ raise UnprocessableEntityError(
598
+ headers=dict(_response.headers),
599
+ body=typing.cast(
600
+ HttpValidationError,
601
+ parse_obj_as(
602
+ type_=HttpValidationError, # type: ignore
603
+ object_=_response.json(),
604
+ ),
605
+ ),
606
+ )
607
+ _response_json = _response.json()
608
+ except JSONDecodeError:
609
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
610
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
@@ -0,0 +1,49 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ # isort: skip_file
4
+
5
+ import typing
6
+ from importlib import import_module
7
+
8
+ if typing.TYPE_CHECKING:
9
+ from .types import (
10
+ CreateStreamTtsRequestPayloadLanguage,
11
+ CreateStreamTtsRequestPayloadSpeechModel,
12
+ GetTtsResultsTtsResultsPostResponseValue,
13
+ GetTtsRunInfoTtsResultRunIdGetResponse,
14
+ )
15
+ _dynamic_imports: typing.Dict[str, str] = {
16
+ "CreateStreamTtsRequestPayloadLanguage": ".types",
17
+ "CreateStreamTtsRequestPayloadSpeechModel": ".types",
18
+ "GetTtsResultsTtsResultsPostResponseValue": ".types",
19
+ "GetTtsRunInfoTtsResultRunIdGetResponse": ".types",
20
+ }
21
+
22
+
23
+ def __getattr__(attr_name: str) -> typing.Any:
24
+ module_name = _dynamic_imports.get(attr_name)
25
+ if module_name is None:
26
+ raise AttributeError(f"No {attr_name} found in _dynamic_imports for module name -> {__name__}")
27
+ try:
28
+ module = import_module(module_name, __package__)
29
+ if module_name == f".{attr_name}":
30
+ return module
31
+ else:
32
+ return getattr(module, attr_name)
33
+ except ImportError as e:
34
+ raise ImportError(f"Failed to import {attr_name} from {module_name}: {e}") from e
35
+ except AttributeError as e:
36
+ raise AttributeError(f"Failed to get {attr_name} from {module_name}: {e}") from e
37
+
38
+
39
+ def __dir__():
40
+ lazy_attrs = list(_dynamic_imports.keys())
41
+ return sorted(lazy_attrs)
42
+
43
+
44
+ __all__ = [
45
+ "CreateStreamTtsRequestPayloadLanguage",
46
+ "CreateStreamTtsRequestPayloadSpeechModel",
47
+ "GetTtsResultsTtsResultsPostResponseValue",
48
+ "GetTtsRunInfoTtsResultRunIdGetResponse",
49
+ ]