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
camb/client.py ADDED
@@ -0,0 +1,717 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ from __future__ import annotations
4
+
5
+ import typing
6
+
7
+ import httpx
8
+ from .core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
9
+ from .core.request_options import RequestOptions
10
+ from .environment import CambApiEnvironment
11
+ from .types.tts_provider import TtsProvider
12
+ from .raw_client import AsyncRawCambApi, RawCambApi
13
+
14
+ if typing.TYPE_CHECKING:
15
+ from .audio_separation.client import AsyncAudioSeparationClient, AudioSeparationClient
16
+ from .deprecated_streaming.client import AsyncDeprecatedStreamingClient, DeprecatedStreamingClient
17
+ from .dictionaries.client import AsyncDictionariesClient, DictionariesClient
18
+ from .dub.client import AsyncDubClient, DubClient
19
+ from .folders.client import AsyncFoldersClient, FoldersClient
20
+ from .languages.client import AsyncLanguagesClient, LanguagesClient
21
+ from .project_setup.client import AsyncProjectSetupClient, ProjectSetupClient
22
+ from .story.client import AsyncStoryClient, StoryClient
23
+ from .streaming.client import AsyncStreamingClient, StreamingClient
24
+ from .text_to_audio.client import AsyncTextToAudioClient, TextToAudioClient
25
+ from .text_to_speech.client import AsyncTextToSpeechClient, TextToSpeechClient
26
+ from .text_to_voice.client import AsyncTextToVoiceClient, TextToVoiceClient
27
+ from .transcription.client import AsyncTranscriptionClient, TranscriptionClient
28
+ from .translated_story.client import AsyncTranslatedStoryClient, TranslatedStoryClient
29
+ from .translated_tts.client import AsyncTranslatedTtsClient, TranslatedTtsClient
30
+ from .translation.client import AsyncTranslationClient, TranslationClient
31
+ from .voice_cloning.client import AsyncVoiceCloningClient, VoiceCloningClient
32
+
33
+ def save_stream_to_file(stream: typing.Iterable[bytes], filename: str) -> None:
34
+ """Saves a byte stream to a file.
35
+
36
+ Parameters
37
+ ----------
38
+ stream : typing.Iterable[bytes]
39
+ The byte stream to save.
40
+ filename : str
41
+ The name of the file to save the stream to.
42
+ """
43
+ with open(filename, "wb") as f:
44
+ for chunk in stream:
45
+ f.write(chunk)
46
+
47
+ async def save_async_stream_to_file(stream: typing.AsyncIterable[bytes], filename: str) -> None:
48
+ """Saves an async byte stream to a file.
49
+
50
+ Parameters
51
+ ----------
52
+ stream : typing.AsyncIterable[bytes]
53
+ The async byte stream to save.
54
+ filename : str
55
+ The name of the file to save the stream to.
56
+ """
57
+ with open(filename, "wb") as f:
58
+ async for chunk in stream:
59
+ f.write(chunk)
60
+
61
+ class CambAI:
62
+ """
63
+ Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propagate to these functions.
64
+
65
+ Parameters
66
+ ----------
67
+ base_url : typing.Optional[str]
68
+ The base url to use for requests from the client.
69
+
70
+ environment : CambApiEnvironment
71
+ The environment to use for requests from the client. from .environment import CambApiEnvironment
72
+
73
+
74
+
75
+ Defaults to CambApiEnvironment.DEFAULT
76
+
77
+
78
+
79
+ api_key : str
80
+ headers : typing.Optional[typing.Dict[str, str]]
81
+ Additional headers to send with every request.
82
+
83
+ timeout : typing.Optional[float]
84
+ The timeout to be used, in seconds, for requests. By default the timeout is 60 seconds, unless a custom httpx client is used, in which case this default is not enforced.
85
+
86
+ follow_redirects : typing.Optional[bool]
87
+ Whether the default httpx client follows redirects or not, this is irrelevant if a custom httpx client is passed in.
88
+
89
+ httpx_client : typing.Optional[httpx.Client]
90
+ The httpx client to use for making requests, a preconfigured client is used by default, however this is useful should you want to pass in any custom httpx configuration.
91
+
92
+ Examples
93
+ --------
94
+ from camb import CambApi
95
+
96
+ client = CambApi(
97
+ api_key="YOUR_API_KEY",
98
+ )
99
+ """
100
+
101
+ def __init__(
102
+ self,
103
+ *,
104
+ base_url: typing.Optional[str] = None,
105
+ environment: CambApiEnvironment = CambApiEnvironment.DEFAULT,
106
+ api_key: typing.Optional[str] = None,
107
+ headers: typing.Optional[typing.Dict[str, str]] = None,
108
+ timeout: typing.Optional[float] = None,
109
+ follow_redirects: typing.Optional[bool] = True,
110
+ httpx_client: typing.Optional[httpx.Client] = None,
111
+ tts_provider: typing.Optional[TtsProvider] = None,
112
+ provider_params: typing.Optional[typing.Dict[str, typing.Any]] = None,
113
+ ):
114
+ if api_key is None and (tts_provider is None or provider_params is None):
115
+ raise ValueError("Please provide either 'api_key' or both 'tts_provider' and 'provider_params'.")
116
+
117
+ _defaulted_timeout = (
118
+ timeout if timeout is not None else 60 if httpx_client is None else httpx_client.timeout.read
119
+ )
120
+ self._client_wrapper = SyncClientWrapper(
121
+ base_url=_get_base_url(base_url=base_url, environment=environment),
122
+ api_key=api_key,
123
+ headers=headers,
124
+ httpx_client=httpx_client
125
+ if httpx_client is not None
126
+ else httpx.Client(timeout=_defaulted_timeout, follow_redirects=follow_redirects)
127
+ if follow_redirects is not None
128
+ else httpx.Client(timeout=_defaulted_timeout),
129
+ timeout=_defaulted_timeout,
130
+ tts_provider=tts_provider,
131
+ provider_params=provider_params,
132
+ )
133
+ self._raw_client = RawCambApi(client_wrapper=self._client_wrapper)
134
+ self._audio_separation: typing.Optional[AudioSeparationClient] = None
135
+ self._dub: typing.Optional[DubClient] = None
136
+ self._folders: typing.Optional[FoldersClient] = None
137
+ self._languages: typing.Optional[LanguagesClient] = None
138
+ self._story: typing.Optional[StoryClient] = None
139
+ self._translated_story: typing.Optional[TranslatedStoryClient] = None
140
+ self._text_to_audio: typing.Optional[TextToAudioClient] = None
141
+ self._text_to_voice: typing.Optional[TextToVoiceClient] = None
142
+ self._text_to_speech: typing.Optional[TextToSpeechClient] = None
143
+ self._translation: typing.Optional[TranslationClient] = None
144
+ self._transcription: typing.Optional[TranscriptionClient] = None
145
+ self._translated_tts: typing.Optional[TranslatedTtsClient] = None
146
+ self._streaming: typing.Optional[StreamingClient] = None
147
+ self._voice_cloning: typing.Optional[VoiceCloningClient] = None
148
+ self._dictionaries: typing.Optional[DictionariesClient] = None
149
+ self._project_setup: typing.Optional[ProjectSetupClient] = None
150
+ self._deprecated_streaming: typing.Optional[DeprecatedStreamingClient] = None
151
+
152
+ @property
153
+ def with_raw_response(self) -> RawCambApi:
154
+ """
155
+ Retrieves a raw implementation of this client that returns raw responses.
156
+
157
+ Returns
158
+ -------
159
+ RawCambApi
160
+ """
161
+ return self._raw_client
162
+
163
+ def get_swagger_docs_docs_get(self, *, request_options: typing.Optional[RequestOptions] = None) -> typing.Any:
164
+ """
165
+ Parameters
166
+ ----------
167
+ request_options : typing.Optional[RequestOptions]
168
+ Request-specific configuration.
169
+
170
+ Returns
171
+ -------
172
+ typing.Any
173
+ Successful Response
174
+
175
+ Examples
176
+ --------
177
+ from camb import CambApi
178
+
179
+ client = CambApi(
180
+ api_key="YOUR_API_KEY",
181
+ )
182
+ client.get_swagger_docs_docs_get()
183
+ """
184
+ _response = self._raw_client.get_swagger_docs_docs_get(request_options=request_options)
185
+ return _response.data
186
+
187
+ def get_redoc_docs_redocs_get(self, *, request_options: typing.Optional[RequestOptions] = None) -> typing.Any:
188
+ """
189
+ Parameters
190
+ ----------
191
+ request_options : typing.Optional[RequestOptions]
192
+ Request-specific configuration.
193
+
194
+ Returns
195
+ -------
196
+ typing.Any
197
+ Successful Response
198
+
199
+ Examples
200
+ --------
201
+ from camb import CambApi
202
+
203
+ client = CambApi(
204
+ api_key="YOUR_API_KEY",
205
+ )
206
+ client.get_redoc_docs_redocs_get()
207
+ """
208
+ _response = self._raw_client.get_redoc_docs_redocs_get(request_options=request_options)
209
+ return _response.data
210
+
211
+ def get_openapi_schema_openapi_json_get(
212
+ self, *, request_options: typing.Optional[RequestOptions] = None
213
+ ) -> typing.Any:
214
+ """
215
+ Parameters
216
+ ----------
217
+ request_options : typing.Optional[RequestOptions]
218
+ Request-specific configuration.
219
+
220
+ Returns
221
+ -------
222
+ typing.Any
223
+ Successful Response
224
+
225
+ Examples
226
+ --------
227
+ from camb import CambApi
228
+
229
+ client = CambApi(
230
+ api_key="YOUR_API_KEY",
231
+ )
232
+ client.get_openapi_schema_openapi_json_get()
233
+ """
234
+ _response = self._raw_client.get_openapi_schema_openapi_json_get(request_options=request_options)
235
+ return _response.data
236
+
237
+ @property
238
+ def audio_separation(self):
239
+ if self._audio_separation is None:
240
+ from .audio_separation.client import AudioSeparationClient # noqa: E402
241
+
242
+ self._audio_separation = AudioSeparationClient(client_wrapper=self._client_wrapper)
243
+ return self._audio_separation
244
+
245
+ @property
246
+ def dub(self):
247
+ if self._dub is None:
248
+ from .dub.client import DubClient # noqa: E402
249
+
250
+ self._dub = DubClient(client_wrapper=self._client_wrapper)
251
+ return self._dub
252
+
253
+ @property
254
+ def folders(self):
255
+ if self._folders is None:
256
+ from .folders.client import FoldersClient # noqa: E402
257
+
258
+ self._folders = FoldersClient(client_wrapper=self._client_wrapper)
259
+ return self._folders
260
+
261
+ @property
262
+ def languages(self):
263
+ if self._languages is None:
264
+ from .languages.client import LanguagesClient # noqa: E402
265
+
266
+ self._languages = LanguagesClient(client_wrapper=self._client_wrapper)
267
+ return self._languages
268
+
269
+ @property
270
+ def story(self):
271
+ if self._story is None:
272
+ from .story.client import StoryClient # noqa: E402
273
+
274
+ self._story = StoryClient(client_wrapper=self._client_wrapper)
275
+ return self._story
276
+
277
+ @property
278
+ def translated_story(self):
279
+ if self._translated_story is None:
280
+ from .translated_story.client import TranslatedStoryClient # noqa: E402
281
+
282
+ self._translated_story = TranslatedStoryClient(client_wrapper=self._client_wrapper)
283
+ return self._translated_story
284
+
285
+ @property
286
+ def text_to_audio(self):
287
+ if self._text_to_audio is None:
288
+ from .text_to_audio.client import TextToAudioClient # noqa: E402
289
+
290
+ self._text_to_audio = TextToAudioClient(client_wrapper=self._client_wrapper)
291
+ return self._text_to_audio
292
+
293
+ @property
294
+ def text_to_voice(self):
295
+ if self._text_to_voice is None:
296
+ from .text_to_voice.client import TextToVoiceClient # noqa: E402
297
+
298
+ self._text_to_voice = TextToVoiceClient(client_wrapper=self._client_wrapper)
299
+ return self._text_to_voice
300
+
301
+ @property
302
+ def text_to_speech(self):
303
+ if self._text_to_speech is None:
304
+ from .text_to_speech.client import TextToSpeechClient # noqa: E402
305
+
306
+ self._text_to_speech = TextToSpeechClient(client_wrapper=self._client_wrapper)
307
+ return self._text_to_speech
308
+
309
+ @property
310
+ def translation(self):
311
+ if self._translation is None:
312
+ from .translation.client import TranslationClient # noqa: E402
313
+
314
+ self._translation = TranslationClient(client_wrapper=self._client_wrapper)
315
+ return self._translation
316
+
317
+ @property
318
+ def transcription(self):
319
+ if self._transcription is None:
320
+ from .transcription.client import TranscriptionClient # noqa: E402
321
+
322
+ self._transcription = TranscriptionClient(client_wrapper=self._client_wrapper)
323
+ return self._transcription
324
+
325
+ @property
326
+ def translated_tts(self):
327
+ if self._translated_tts is None:
328
+ from .translated_tts.client import TranslatedTtsClient # noqa: E402
329
+
330
+ self._translated_tts = TranslatedTtsClient(client_wrapper=self._client_wrapper)
331
+ return self._translated_tts
332
+
333
+ @property
334
+ def streaming(self):
335
+ if self._streaming is None:
336
+ from .streaming.client import StreamingClient # noqa: E402
337
+
338
+ self._streaming = StreamingClient(client_wrapper=self._client_wrapper)
339
+ return self._streaming
340
+
341
+ @property
342
+ def voice_cloning(self):
343
+ if self._voice_cloning is None:
344
+ from .voice_cloning.client import VoiceCloningClient # noqa: E402
345
+
346
+ self._voice_cloning = VoiceCloningClient(client_wrapper=self._client_wrapper)
347
+ return self._voice_cloning
348
+
349
+ @property
350
+ def dictionaries(self):
351
+ if self._dictionaries is None:
352
+ from .dictionaries.client import DictionariesClient # noqa: E402
353
+
354
+ self._dictionaries = DictionariesClient(client_wrapper=self._client_wrapper)
355
+ return self._dictionaries
356
+
357
+ @property
358
+ def project_setup(self):
359
+ if self._project_setup is None:
360
+ from .project_setup.client import ProjectSetupClient # noqa: E402
361
+
362
+ self._project_setup = ProjectSetupClient(client_wrapper=self._client_wrapper)
363
+ return self._project_setup
364
+
365
+ @property
366
+ def deprecated_streaming(self):
367
+ if self._deprecated_streaming is None:
368
+ from .deprecated_streaming.client import DeprecatedStreamingClient # noqa: E402
369
+
370
+ self._deprecated_streaming = DeprecatedStreamingClient(client_wrapper=self._client_wrapper)
371
+ return self._deprecated_streaming
372
+
373
+
374
+ class AsyncCambAI:
375
+ """
376
+ Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propagate to these functions.
377
+
378
+ Parameters
379
+ ----------
380
+ base_url : typing.Optional[str]
381
+ The base url to use for requests from the client.
382
+
383
+ environment : CambApiEnvironment
384
+ The environment to use for requests from the client. from .environment import CambApiEnvironment
385
+
386
+
387
+
388
+ Defaults to CambApiEnvironment.DEFAULT
389
+
390
+
391
+
392
+ api_key : str
393
+ headers : typing.Optional[typing.Dict[str, str]]
394
+ Additional headers to send with every request.
395
+
396
+ timeout : typing.Optional[float]
397
+ The timeout to be used, in seconds, for requests. By default the timeout is 60 seconds, unless a custom httpx client is used, in which case this default is not enforced.
398
+
399
+ follow_redirects : typing.Optional[bool]
400
+ Whether the default httpx client follows redirects or not, this is irrelevant if a custom httpx client is passed in.
401
+
402
+ httpx_client : typing.Optional[httpx.AsyncClient]
403
+ The httpx client to use for making requests, a preconfigured client is used by default, however this is useful should you want to pass in any custom httpx configuration.
404
+
405
+ Examples
406
+ --------
407
+ from camb import AsyncCambApi
408
+
409
+ client = AsyncCambApi(
410
+ api_key="YOUR_API_KEY",
411
+ )
412
+ """
413
+
414
+ def __init__(
415
+ self,
416
+ *,
417
+ base_url: typing.Optional[str] = None,
418
+ environment: CambApiEnvironment = CambApiEnvironment.DEFAULT,
419
+ api_key: typing.Optional[str] = None,
420
+ headers: typing.Optional[typing.Dict[str, str]] = None,
421
+ timeout: typing.Optional[float] = None,
422
+ follow_redirects: typing.Optional[bool] = True,
423
+ httpx_client: typing.Optional[httpx.AsyncClient] = None,
424
+ tts_provider: typing.Optional[TtsProvider] = None,
425
+ provider_params: typing.Optional[typing.Dict[str, typing.Any]] = None,
426
+ ):
427
+ if api_key is None and (tts_provider is None or provider_params is None):
428
+ raise ValueError("Please provide either 'api_key' or both 'tts_provider' and 'provider_params'.")
429
+
430
+ _defaulted_timeout = (
431
+ timeout if timeout is not None else 60 if httpx_client is None else httpx_client.timeout.read
432
+ )
433
+ self._client_wrapper = AsyncClientWrapper(
434
+ base_url=_get_base_url(base_url=base_url, environment=environment),
435
+ api_key=api_key,
436
+ headers=headers,
437
+ httpx_client=httpx_client
438
+ if httpx_client is not None
439
+ else httpx.AsyncClient(timeout=_defaulted_timeout, follow_redirects=follow_redirects)
440
+ if follow_redirects is not None
441
+ else httpx.AsyncClient(timeout=_defaulted_timeout),
442
+ timeout=_defaulted_timeout,
443
+ tts_provider=tts_provider,
444
+ provider_params=provider_params,
445
+ )
446
+ self._raw_client = AsyncRawCambApi(client_wrapper=self._client_wrapper)
447
+ self._audio_separation: typing.Optional[AsyncAudioSeparationClient] = None
448
+ self._dub: typing.Optional[AsyncDubClient] = None
449
+ self._folders: typing.Optional[AsyncFoldersClient] = None
450
+ self._languages: typing.Optional[AsyncLanguagesClient] = None
451
+ self._story: typing.Optional[AsyncStoryClient] = None
452
+ self._translated_story: typing.Optional[AsyncTranslatedStoryClient] = None
453
+ self._text_to_audio: typing.Optional[AsyncTextToAudioClient] = None
454
+ self._text_to_voice: typing.Optional[AsyncTextToVoiceClient] = None
455
+ self._text_to_speech: typing.Optional[AsyncTextToSpeechClient] = None
456
+ self._translation: typing.Optional[AsyncTranslationClient] = None
457
+ self._transcription: typing.Optional[AsyncTranscriptionClient] = None
458
+ self._translated_tts: typing.Optional[AsyncTranslatedTtsClient] = None
459
+ self._streaming: typing.Optional[AsyncStreamingClient] = None
460
+ self._voice_cloning: typing.Optional[AsyncVoiceCloningClient] = None
461
+ self._dictionaries: typing.Optional[AsyncDictionariesClient] = None
462
+ self._project_setup: typing.Optional[AsyncProjectSetupClient] = None
463
+ self._deprecated_streaming: typing.Optional[AsyncDeprecatedStreamingClient] = None
464
+
465
+ @property
466
+ def with_raw_response(self) -> AsyncRawCambApi:
467
+ """
468
+ Retrieves a raw implementation of this client that returns raw responses.
469
+
470
+ Returns
471
+ -------
472
+ AsyncRawCambApi
473
+ """
474
+ return self._raw_client
475
+
476
+ async def get_swagger_docs_docs_get(self, *, request_options: typing.Optional[RequestOptions] = None) -> typing.Any:
477
+ """
478
+ Parameters
479
+ ----------
480
+ request_options : typing.Optional[RequestOptions]
481
+ Request-specific configuration.
482
+
483
+ Returns
484
+ -------
485
+ typing.Any
486
+ Successful Response
487
+
488
+ Examples
489
+ --------
490
+ import asyncio
491
+
492
+ from camb import AsyncCambApi
493
+
494
+ client = AsyncCambApi(
495
+ api_key="YOUR_API_KEY",
496
+ )
497
+
498
+
499
+ async def main() -> None:
500
+ await client.get_swagger_docs_docs_get()
501
+
502
+
503
+ asyncio.run(main())
504
+ """
505
+ _response = await self._raw_client.get_swagger_docs_docs_get(request_options=request_options)
506
+ return _response.data
507
+
508
+ async def get_redoc_docs_redocs_get(self, *, request_options: typing.Optional[RequestOptions] = None) -> typing.Any:
509
+ """
510
+ Parameters
511
+ ----------
512
+ request_options : typing.Optional[RequestOptions]
513
+ Request-specific configuration.
514
+
515
+ Returns
516
+ -------
517
+ typing.Any
518
+ Successful Response
519
+
520
+ Examples
521
+ --------
522
+ import asyncio
523
+
524
+ from camb import AsyncCambApi
525
+
526
+ client = AsyncCambApi(
527
+ api_key="YOUR_API_KEY",
528
+ )
529
+
530
+
531
+ async def main() -> None:
532
+ await client.get_redoc_docs_redocs_get()
533
+
534
+
535
+ asyncio.run(main())
536
+ """
537
+ _response = await self._raw_client.get_redoc_docs_redocs_get(request_options=request_options)
538
+ return _response.data
539
+
540
+ async def get_openapi_schema_openapi_json_get(
541
+ self, *, request_options: typing.Optional[RequestOptions] = None
542
+ ) -> typing.Any:
543
+ """
544
+ Parameters
545
+ ----------
546
+ request_options : typing.Optional[RequestOptions]
547
+ Request-specific configuration.
548
+
549
+ Returns
550
+ -------
551
+ typing.Any
552
+ Successful Response
553
+
554
+ Examples
555
+ --------
556
+ import asyncio
557
+
558
+ from camb import AsyncCambApi
559
+
560
+ client = AsyncCambApi(
561
+ api_key="YOUR_API_KEY",
562
+ )
563
+
564
+
565
+ async def main() -> None:
566
+ await client.get_openapi_schema_openapi_json_get()
567
+
568
+
569
+ asyncio.run(main())
570
+ """
571
+ _response = await self._raw_client.get_openapi_schema_openapi_json_get(request_options=request_options)
572
+ return _response.data
573
+
574
+ @property
575
+ def audio_separation(self):
576
+ if self._audio_separation is None:
577
+ from .audio_separation.client import AsyncAudioSeparationClient # noqa: E402
578
+
579
+ self._audio_separation = AsyncAudioSeparationClient(client_wrapper=self._client_wrapper)
580
+ return self._audio_separation
581
+
582
+ @property
583
+ def dub(self):
584
+ if self._dub is None:
585
+ from .dub.client import AsyncDubClient # noqa: E402
586
+
587
+ self._dub = AsyncDubClient(client_wrapper=self._client_wrapper)
588
+ return self._dub
589
+
590
+ @property
591
+ def folders(self):
592
+ if self._folders is None:
593
+ from .folders.client import AsyncFoldersClient # noqa: E402
594
+
595
+ self._folders = AsyncFoldersClient(client_wrapper=self._client_wrapper)
596
+ return self._folders
597
+
598
+ @property
599
+ def languages(self):
600
+ if self._languages is None:
601
+ from .languages.client import AsyncLanguagesClient # noqa: E402
602
+
603
+ self._languages = AsyncLanguagesClient(client_wrapper=self._client_wrapper)
604
+ return self._languages
605
+
606
+ @property
607
+ def story(self):
608
+ if self._story is None:
609
+ from .story.client import AsyncStoryClient # noqa: E402
610
+
611
+ self._story = AsyncStoryClient(client_wrapper=self._client_wrapper)
612
+ return self._story
613
+
614
+ @property
615
+ def translated_story(self):
616
+ if self._translated_story is None:
617
+ from .translated_story.client import AsyncTranslatedStoryClient # noqa: E402
618
+
619
+ self._translated_story = AsyncTranslatedStoryClient(client_wrapper=self._client_wrapper)
620
+ return self._translated_story
621
+
622
+ @property
623
+ def text_to_audio(self):
624
+ if self._text_to_audio is None:
625
+ from .text_to_audio.client import AsyncTextToAudioClient # noqa: E402
626
+
627
+ self._text_to_audio = AsyncTextToAudioClient(client_wrapper=self._client_wrapper)
628
+ return self._text_to_audio
629
+
630
+ @property
631
+ def text_to_voice(self):
632
+ if self._text_to_voice is None:
633
+ from .text_to_voice.client import AsyncTextToVoiceClient # noqa: E402
634
+
635
+ self._text_to_voice = AsyncTextToVoiceClient(client_wrapper=self._client_wrapper)
636
+ return self._text_to_voice
637
+
638
+ @property
639
+ def text_to_speech(self):
640
+ if self._text_to_speech is None:
641
+ from .text_to_speech.client import AsyncTextToSpeechClient # noqa: E402
642
+
643
+ self._text_to_speech = AsyncTextToSpeechClient(client_wrapper=self._client_wrapper)
644
+ return self._text_to_speech
645
+
646
+ @property
647
+ def translation(self):
648
+ if self._translation is None:
649
+ from .translation.client import AsyncTranslationClient # noqa: E402
650
+
651
+ self._translation = AsyncTranslationClient(client_wrapper=self._client_wrapper)
652
+ return self._translation
653
+
654
+ @property
655
+ def transcription(self):
656
+ if self._transcription is None:
657
+ from .transcription.client import AsyncTranscriptionClient # noqa: E402
658
+
659
+ self._transcription = AsyncTranscriptionClient(client_wrapper=self._client_wrapper)
660
+ return self._transcription
661
+
662
+ @property
663
+ def translated_tts(self):
664
+ if self._translated_tts is None:
665
+ from .translated_tts.client import AsyncTranslatedTtsClient # noqa: E402
666
+
667
+ self._translated_tts = AsyncTranslatedTtsClient(client_wrapper=self._client_wrapper)
668
+ return self._translated_tts
669
+
670
+ @property
671
+ def streaming(self):
672
+ if self._streaming is None:
673
+ from .streaming.client import AsyncStreamingClient # noqa: E402
674
+
675
+ self._streaming = AsyncStreamingClient(client_wrapper=self._client_wrapper)
676
+ return self._streaming
677
+
678
+ @property
679
+ def voice_cloning(self):
680
+ if self._voice_cloning is None:
681
+ from .voice_cloning.client import AsyncVoiceCloningClient # noqa: E402
682
+
683
+ self._voice_cloning = AsyncVoiceCloningClient(client_wrapper=self._client_wrapper)
684
+ return self._voice_cloning
685
+
686
+ @property
687
+ def dictionaries(self):
688
+ if self._dictionaries is None:
689
+ from .dictionaries.client import AsyncDictionariesClient # noqa: E402
690
+
691
+ self._dictionaries = AsyncDictionariesClient(client_wrapper=self._client_wrapper)
692
+ return self._dictionaries
693
+
694
+ @property
695
+ def project_setup(self):
696
+ if self._project_setup is None:
697
+ from .project_setup.client import AsyncProjectSetupClient # noqa: E402
698
+
699
+ self._project_setup = AsyncProjectSetupClient(client_wrapper=self._client_wrapper)
700
+ return self._project_setup
701
+
702
+ @property
703
+ def deprecated_streaming(self):
704
+ if self._deprecated_streaming is None:
705
+ from .deprecated_streaming.client import AsyncDeprecatedStreamingClient # noqa: E402
706
+
707
+ self._deprecated_streaming = AsyncDeprecatedStreamingClient(client_wrapper=self._client_wrapper)
708
+ return self._deprecated_streaming
709
+
710
+
711
+ def _get_base_url(*, base_url: typing.Optional[str] = None, environment: CambApiEnvironment) -> str:
712
+ if base_url is not None:
713
+ return base_url
714
+ elif environment is not None:
715
+ return environment.value
716
+ else:
717
+ raise Exception("Please pass in either base_url or environment to construct the client")