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.
- camb/__init__.py +335 -0
- camb/audio_separation/__init__.py +4 -0
- camb/audio_separation/client.py +406 -0
- camb/audio_separation/raw_client.py +534 -0
- camb/client.py +717 -0
- camb/core/__init__.py +105 -0
- camb/core/api_error.py +23 -0
- camb/core/client_wrapper.py +113 -0
- camb/core/datetime_utils.py +28 -0
- camb/core/file.py +67 -0
- camb/core/force_multipart.py +18 -0
- camb/core/http_client.py +663 -0
- camb/core/http_response.py +55 -0
- camb/core/http_sse/__init__.py +42 -0
- camb/core/http_sse/_api.py +112 -0
- camb/core/http_sse/_decoders.py +61 -0
- camb/core/http_sse/_exceptions.py +7 -0
- camb/core/http_sse/_models.py +17 -0
- camb/core/jsonable_encoder.py +100 -0
- camb/core/pydantic_utilities.py +260 -0
- camb/core/query_encoder.py +58 -0
- camb/core/remove_none_from_dict.py +11 -0
- camb/core/request_options.py +35 -0
- camb/core/serialization.py +276 -0
- camb/deprecated_streaming/__init__.py +4 -0
- camb/deprecated_streaming/client.py +532 -0
- camb/deprecated_streaming/raw_client.py +639 -0
- camb/dictionaries/__init__.py +4 -0
- camb/dictionaries/client.py +785 -0
- camb/dictionaries/raw_client.py +1048 -0
- camb/dub/__init__.py +49 -0
- camb/dub/client.py +846 -0
- camb/dub/raw_client.py +1194 -0
- camb/dub/types/__init__.py +53 -0
- camb/dub/types/dubbed_output_in_alt_format_request_payload_output_format.py +8 -0
- camb/dub/types/get_dubbed_output_in_alt_format_dub_alt_format_run_id_language_post_response.py +9 -0
- camb/dub/types/get_dubbed_run_info_dub_result_run_id_get_response.py +7 -0
- camb/dub/types/get_dubbing_runs_results_dubbing_results_post_response_value.py +7 -0
- camb/environment.py +7 -0
- camb/errors/__init__.py +34 -0
- camb/errors/unprocessable_entity_error.py +11 -0
- camb/folders/__init__.py +4 -0
- camb/folders/client.py +213 -0
- camb/folders/raw_client.py +278 -0
- camb/languages/__init__.py +4 -0
- camb/languages/client.py +168 -0
- camb/languages/raw_client.py +223 -0
- camb/project_setup/__init__.py +4 -0
- camb/project_setup/client.py +537 -0
- camb/project_setup/raw_client.py +655 -0
- camb/py.typed +0 -0
- camb/raw_client.py +236 -0
- camb/story/__init__.py +37 -0
- camb/story/client.py +579 -0
- camb/story/raw_client.py +743 -0
- camb/story/types/__init__.py +38 -0
- camb/story/types/create_story_story_post_response.py +8 -0
- camb/story/types/setup_story_story_setup_post_response.py +8 -0
- camb/streaming/__init__.py +4 -0
- camb/streaming/client.py +645 -0
- camb/streaming/raw_client.py +796 -0
- camb/text_to_audio/__init__.py +4 -0
- camb/text_to_audio/client.py +469 -0
- camb/text_to_audio/raw_client.py +610 -0
- camb/text_to_speech/__init__.py +49 -0
- camb/text_to_speech/baseten.py +214 -0
- camb/text_to_speech/client.py +742 -0
- camb/text_to_speech/raw_client.py +995 -0
- camb/text_to_speech/types/__init__.py +47 -0
- camb/text_to_speech/types/create_stream_tts_request_payload_language.py +71 -0
- camb/text_to_speech/types/create_stream_tts_request_payload_speech_model.py +7 -0
- camb/text_to_speech/types/get_tts_results_tts_results_post_response_value.py +7 -0
- camb/text_to_speech/types/get_tts_run_info_tts_result_run_id_get_response.py +7 -0
- camb/text_to_voice/__init__.py +4 -0
- camb/text_to_voice/client.py +329 -0
- camb/text_to_voice/raw_client.py +405 -0
- camb/transcription/__init__.py +4 -0
- camb/transcription/client.py +465 -0
- camb/transcription/raw_client.py +587 -0
- camb/translated_story/__init__.py +4 -0
- camb/translated_story/client.py +309 -0
- camb/translated_story/raw_client.py +381 -0
- camb/translated_tts/__init__.py +4 -0
- camb/translated_tts/client.py +313 -0
- camb/translated_tts/raw_client.py +357 -0
- camb/translation/__init__.py +4 -0
- camb/translation/client.py +631 -0
- camb/translation/raw_client.py +787 -0
- camb/types/__init__.py +236 -0
- camb/types/add_target_language_out.py +20 -0
- camb/types/audio_output_type.py +5 -0
- camb/types/audio_stream.py +31 -0
- camb/types/config_stream.py +22 -0
- camb/types/config_stream_pipeline.py +28 -0
- camb/types/create_custom_voice_out.py +19 -0
- camb/types/create_project_setup_out.py +19 -0
- camb/types/create_stream_out.py +22 -0
- camb/types/create_stream_request_payload.py +70 -0
- camb/types/create_translated_tts_out.py +19 -0
- camb/types/create_tts_out.py +19 -0
- camb/types/data_stream.py +24 -0
- camb/types/demixing_option.py +10 -0
- camb/types/dictionary_term.py +21 -0
- camb/types/dictionary_with_terms.py +28 -0
- camb/types/dubbing_result.py +22 -0
- camb/types/exception_reasons.py +30 -0
- camb/types/folder.py +20 -0
- camb/types/formalities.py +3 -0
- camb/types/gender.py +3 -0
- camb/types/get_audio_separation_result_out.py +20 -0
- camb/types/get_create_project_setup_response.py +21 -0
- camb/types/get_probe_stream_in.py +21 -0
- camb/types/get_probe_stream_out.py +24 -0
- camb/types/get_setup_story_result_response.py +21 -0
- camb/types/get_text_to_voice_result_out.py +19 -0
- camb/types/get_tts_result_out_file_url.py +19 -0
- camb/types/http_validation_error.py +20 -0
- camb/types/language_enums.py +154 -0
- camb/types/language_pydantic_model.py +21 -0
- camb/types/languages.py +3 -0
- camb/types/orchestrator_pipeline_call_result.py +19 -0
- camb/types/orchestrator_pipeline_result.py +25 -0
- camb/types/orchestrator_pipeline_result_exception_reason.py +7 -0
- camb/types/orchestrator_pipeline_result_message.py +5 -0
- camb/types/output_format.py +10 -0
- camb/types/overdub_config.py +37 -0
- camb/types/project_details.py +28 -0
- camb/types/revoicing_option.py +5 -0
- camb/types/run_i_ds_request_payload.py +19 -0
- camb/types/segmenting_option.py +5 -0
- camb/types/source_stream.py +30 -0
- camb/types/story_details.py +27 -0
- camb/types/stream_category.py +3 -0
- camb/types/stream_tts_inference_options.py +38 -0
- camb/types/stream_tts_output_configuration.py +33 -0
- camb/types/stream_tts_voice_settings.py +28 -0
- camb/types/stream_type.py +3 -0
- camb/types/stream_url_for_languages.py +21 -0
- camb/types/target_stream.py +34 -0
- camb/types/task_status.py +5 -0
- camb/types/term_translation_input.py +21 -0
- camb/types/term_translation_output.py +20 -0
- camb/types/text_to_audio_result.py +19 -0
- camb/types/text_to_audio_type.py +5 -0
- camb/types/transcribing_option.py +5 -0
- camb/types/transcript.py +22 -0
- camb/types/transcript_data_type.py +5 -0
- camb/types/transcript_file_format.py +5 -0
- camb/types/transcription_result.py +20 -0
- camb/types/translating_option.py +5 -0
- camb/types/translation_result.py +19 -0
- camb/types/tts_provider.py +3 -0
- camb/types/validation_error.py +22 -0
- camb/types/validation_error_loc_item.py +5 -0
- camb/types/video_output_type_without_avi.py +5 -0
- camb/types/video_stream.py +28 -0
- camb/types/voice.py +28 -0
- camb/voice_cloning/__init__.py +34 -0
- camb/voice_cloning/client.py +265 -0
- camb/voice_cloning/raw_client.py +320 -0
- camb/voice_cloning/types/__init__.py +36 -0
- camb/voice_cloning/types/list_voices_list_voices_get_response_item.py +7 -0
- camb_sdk-1.5.4.dist-info/METADATA +282 -0
- camb_sdk-1.5.4.dist-info/RECORD +167 -0
- camb_sdk-1.5.4.dist-info/WHEEL +5 -0
- camb_sdk-1.5.4.dist-info/licenses/LICENSE +21 -0
- camb_sdk-1.5.4.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,742 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
|
|
5
|
+
from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
|
|
6
|
+
from ..core.request_options import RequestOptions
|
|
7
|
+
from ..types.create_tts_out import CreateTtsOut
|
|
8
|
+
from ..types.gender import Gender
|
|
9
|
+
from ..types.languages import Languages
|
|
10
|
+
from ..types.orchestrator_pipeline_result import OrchestratorPipelineResult
|
|
11
|
+
from ..types.stream_tts_inference_options import StreamTtsInferenceOptions
|
|
12
|
+
from ..types.stream_tts_output_configuration import StreamTtsOutputConfiguration
|
|
13
|
+
from ..types.stream_tts_voice_settings import StreamTtsVoiceSettings
|
|
14
|
+
from .raw_client import AsyncRawTextToSpeechClient, RawTextToSpeechClient
|
|
15
|
+
from .types.create_stream_tts_request_payload_language import CreateStreamTtsRequestPayloadLanguage
|
|
16
|
+
from .types.create_stream_tts_request_payload_speech_model import CreateStreamTtsRequestPayloadSpeechModel
|
|
17
|
+
from .types.get_tts_results_tts_results_post_response_value import GetTtsResultsTtsResultsPostResponseValue
|
|
18
|
+
from .types.get_tts_run_info_tts_result_run_id_get_response import GetTtsRunInfoTtsResultRunIdGetResponse
|
|
19
|
+
|
|
20
|
+
# this is used as the default value for optional parameters
|
|
21
|
+
OMIT = typing.cast(typing.Any, ...)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class TextToSpeechClient:
|
|
25
|
+
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
|
26
|
+
self._raw_client = RawTextToSpeechClient(client_wrapper=client_wrapper)
|
|
27
|
+
|
|
28
|
+
@property
|
|
29
|
+
def with_raw_response(self) -> RawTextToSpeechClient:
|
|
30
|
+
"""
|
|
31
|
+
Retrieves a raw implementation of this client that returns raw responses.
|
|
32
|
+
|
|
33
|
+
Returns
|
|
34
|
+
-------
|
|
35
|
+
RawTextToSpeechClient
|
|
36
|
+
"""
|
|
37
|
+
return self._raw_client
|
|
38
|
+
|
|
39
|
+
def tts(
|
|
40
|
+
self,
|
|
41
|
+
*,
|
|
42
|
+
text: str,
|
|
43
|
+
language: CreateStreamTtsRequestPayloadLanguage,
|
|
44
|
+
voice_id: typing.Optional[int] = OMIT,
|
|
45
|
+
speech_model: typing.Optional[CreateStreamTtsRequestPayloadSpeechModel] = OMIT,
|
|
46
|
+
user_instructions: typing.Optional[str] = OMIT,
|
|
47
|
+
enhance_named_entities_pronunciation: typing.Optional[bool] = OMIT,
|
|
48
|
+
output_configuration: typing.Optional[StreamTtsOutputConfiguration] = OMIT,
|
|
49
|
+
voice_settings: typing.Optional[StreamTtsVoiceSettings] = OMIT,
|
|
50
|
+
inference_options: typing.Optional[StreamTtsInferenceOptions] = OMIT,
|
|
51
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
52
|
+
) -> typing.Iterator[bytes]:
|
|
53
|
+
"""
|
|
54
|
+
Parameters
|
|
55
|
+
----------
|
|
56
|
+
text : str
|
|
57
|
+
|
|
58
|
+
language : CreateStreamTtsRequestPayloadLanguage
|
|
59
|
+
|
|
60
|
+
voice_id : int
|
|
61
|
+
|
|
62
|
+
speech_model : typing.Optional[CreateStreamTtsRequestPayloadSpeechModel]
|
|
63
|
+
|
|
64
|
+
user_instructions : typing.Optional[str]
|
|
65
|
+
|
|
66
|
+
enhance_named_entities_pronunciation : typing.Optional[bool]
|
|
67
|
+
|
|
68
|
+
output_configuration : typing.Optional[StreamTtsOutputConfiguration]
|
|
69
|
+
|
|
70
|
+
voice_settings : typing.Optional[StreamTtsVoiceSettings]
|
|
71
|
+
|
|
72
|
+
inference_options : typing.Optional[StreamTtsInferenceOptions]
|
|
73
|
+
|
|
74
|
+
request_options : typing.Optional[RequestOptions]
|
|
75
|
+
Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.
|
|
76
|
+
|
|
77
|
+
Returns
|
|
78
|
+
-------
|
|
79
|
+
typing.Iterator[bytes]
|
|
80
|
+
Streaming audio response
|
|
81
|
+
|
|
82
|
+
Examples
|
|
83
|
+
--------
|
|
84
|
+
from camb import CambApi
|
|
85
|
+
|
|
86
|
+
client = CambApi(
|
|
87
|
+
api_key="YOUR_API_KEY",
|
|
88
|
+
)
|
|
89
|
+
client.text_to_speech.tts(
|
|
90
|
+
text="foo",
|
|
91
|
+
language="ar-kw",
|
|
92
|
+
voice_id=1,
|
|
93
|
+
)
|
|
94
|
+
"""
|
|
95
|
+
with self._raw_client.tts(
|
|
96
|
+
text=text,
|
|
97
|
+
language=language,
|
|
98
|
+
voice_id=voice_id,
|
|
99
|
+
speech_model=speech_model,
|
|
100
|
+
user_instructions=user_instructions,
|
|
101
|
+
enhance_named_entities_pronunciation=enhance_named_entities_pronunciation,
|
|
102
|
+
output_configuration=output_configuration,
|
|
103
|
+
voice_settings=voice_settings,
|
|
104
|
+
inference_options=inference_options,
|
|
105
|
+
request_options=request_options,
|
|
106
|
+
) as r:
|
|
107
|
+
yield from r.data
|
|
108
|
+
|
|
109
|
+
def create_tts(
|
|
110
|
+
self,
|
|
111
|
+
*,
|
|
112
|
+
text: str,
|
|
113
|
+
voice_id: int,
|
|
114
|
+
language: Languages,
|
|
115
|
+
run_id: typing.Optional[int] = None,
|
|
116
|
+
project_name: typing.Optional[str] = OMIT,
|
|
117
|
+
project_description: typing.Optional[str] = OMIT,
|
|
118
|
+
folder_id: typing.Optional[int] = OMIT,
|
|
119
|
+
gender: typing.Optional[Gender] = OMIT,
|
|
120
|
+
age: typing.Optional[int] = OMIT,
|
|
121
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
122
|
+
) -> CreateTtsOut:
|
|
123
|
+
"""
|
|
124
|
+
Parameters
|
|
125
|
+
----------
|
|
126
|
+
text : str
|
|
127
|
+
|
|
128
|
+
voice_id : int
|
|
129
|
+
|
|
130
|
+
language : Languages
|
|
131
|
+
|
|
132
|
+
run_id : typing.Optional[int]
|
|
133
|
+
|
|
134
|
+
project_name : typing.Optional[str]
|
|
135
|
+
|
|
136
|
+
project_description : typing.Optional[str]
|
|
137
|
+
|
|
138
|
+
folder_id : typing.Optional[int]
|
|
139
|
+
|
|
140
|
+
gender : typing.Optional[Gender]
|
|
141
|
+
|
|
142
|
+
age : typing.Optional[int]
|
|
143
|
+
|
|
144
|
+
request_options : typing.Optional[RequestOptions]
|
|
145
|
+
Request-specific configuration.
|
|
146
|
+
|
|
147
|
+
Returns
|
|
148
|
+
-------
|
|
149
|
+
CreateTtsOut
|
|
150
|
+
Successful Response
|
|
151
|
+
|
|
152
|
+
Examples
|
|
153
|
+
--------
|
|
154
|
+
from camb import CambApi
|
|
155
|
+
|
|
156
|
+
client = CambApi(
|
|
157
|
+
api_key="YOUR_API_KEY",
|
|
158
|
+
)
|
|
159
|
+
client.text_to_speech.create_tts(
|
|
160
|
+
text="text",
|
|
161
|
+
voice_id=1,
|
|
162
|
+
language=1,
|
|
163
|
+
)
|
|
164
|
+
"""
|
|
165
|
+
_response = self._raw_client.create_tts(
|
|
166
|
+
text=text,
|
|
167
|
+
voice_id=voice_id,
|
|
168
|
+
language=language,
|
|
169
|
+
run_id=run_id,
|
|
170
|
+
project_name=project_name,
|
|
171
|
+
project_description=project_description,
|
|
172
|
+
folder_id=folder_id,
|
|
173
|
+
gender=gender,
|
|
174
|
+
age=age,
|
|
175
|
+
request_options=request_options,
|
|
176
|
+
)
|
|
177
|
+
return _response.data
|
|
178
|
+
|
|
179
|
+
def get_tts_result(
|
|
180
|
+
self,
|
|
181
|
+
task_id: str,
|
|
182
|
+
*,
|
|
183
|
+
run_id: typing.Optional[int] = None,
|
|
184
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
185
|
+
) -> OrchestratorPipelineResult:
|
|
186
|
+
"""
|
|
187
|
+
Parameters
|
|
188
|
+
----------
|
|
189
|
+
task_id : str
|
|
190
|
+
|
|
191
|
+
run_id : typing.Optional[int]
|
|
192
|
+
|
|
193
|
+
request_options : typing.Optional[RequestOptions]
|
|
194
|
+
Request-specific configuration.
|
|
195
|
+
|
|
196
|
+
Returns
|
|
197
|
+
-------
|
|
198
|
+
OrchestratorPipelineResult
|
|
199
|
+
Successful Response
|
|
200
|
+
|
|
201
|
+
Examples
|
|
202
|
+
--------
|
|
203
|
+
from camb import CambApi
|
|
204
|
+
|
|
205
|
+
client = CambApi(
|
|
206
|
+
api_key="YOUR_API_KEY",
|
|
207
|
+
)
|
|
208
|
+
client.text_to_speech.get_tts_result(
|
|
209
|
+
task_id="task_id",
|
|
210
|
+
)
|
|
211
|
+
"""
|
|
212
|
+
_response = self._raw_client.get_tts_result(task_id, run_id=run_id, request_options=request_options)
|
|
213
|
+
return _response.data
|
|
214
|
+
|
|
215
|
+
def get_tts_run_info(
|
|
216
|
+
self,
|
|
217
|
+
run_id: typing.Optional[int],
|
|
218
|
+
*,
|
|
219
|
+
output_type: typing.Optional[str] = None,
|
|
220
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
221
|
+
) -> GetTtsRunInfoTtsResultRunIdGetResponse:
|
|
222
|
+
"""
|
|
223
|
+
Retrieves the result of a Text To Speech (TTS) run.
|
|
224
|
+
|
|
225
|
+
This endpoint validates the provided `run_id` and fetches the corresponding TTS-generated audio.
|
|
226
|
+
The user must have valid access to the run. The function supports two output formats:
|
|
227
|
+
- `RAW_BYTES`: Streams the audio file directly.
|
|
228
|
+
- `FILE_URL`: Returns a pre-signed URL to download the audio file.
|
|
229
|
+
|
|
230
|
+
Args:
|
|
231
|
+
run_id (int): Unique identifier for the TTS run.
|
|
232
|
+
api_key_obj (dict): API key object used for authentication and storage preferences.
|
|
233
|
+
traceparent (Optional[str]): Traceparent header for distributed tracing.
|
|
234
|
+
output_type (OutputType, optional): Determines the output format. Defaults to `RAW_BYTES`.
|
|
235
|
+
|
|
236
|
+
Returns:
|
|
237
|
+
StreamingResponse | GetTTSOut:
|
|
238
|
+
- If `output_type = RAW_BYTES`: A streaming response containing the TTS-generated audio in FLAC format.
|
|
239
|
+
- If `output_type = FILE_URL`: A URL pointing to the stored TTS-generated audio file.
|
|
240
|
+
|
|
241
|
+
Raises:
|
|
242
|
+
HTTPException:
|
|
243
|
+
- 400 BAD REQUEST if the run ID is invalid or does not belong to a TTS process.
|
|
244
|
+
- 500 INTERNAL SERVER ERROR if fetching or streaming the audio fails.
|
|
245
|
+
|
|
246
|
+
Assumptions:
|
|
247
|
+
- The user has valid access to the `run_id`.
|
|
248
|
+
- The `run_id` corresponds to a valid TTS run.
|
|
249
|
+
- There is only **one** dialogue associated with the given `run_id`.
|
|
250
|
+
|
|
251
|
+
Parameters
|
|
252
|
+
----------
|
|
253
|
+
run_id : typing.Optional[int]
|
|
254
|
+
|
|
255
|
+
output_type : typing.Optional[str]
|
|
256
|
+
Output format for the Text To Speech result
|
|
257
|
+
|
|
258
|
+
request_options : typing.Optional[RequestOptions]
|
|
259
|
+
Request-specific configuration.
|
|
260
|
+
|
|
261
|
+
Returns
|
|
262
|
+
-------
|
|
263
|
+
GetTtsRunInfoTtsResultRunIdGetResponse
|
|
264
|
+
Successful Response
|
|
265
|
+
|
|
266
|
+
Examples
|
|
267
|
+
--------
|
|
268
|
+
from camb import CambApi
|
|
269
|
+
|
|
270
|
+
client = CambApi(
|
|
271
|
+
api_key="YOUR_API_KEY",
|
|
272
|
+
)
|
|
273
|
+
client.text_to_speech.get_tts_run_info(
|
|
274
|
+
run_id=1,
|
|
275
|
+
)
|
|
276
|
+
"""
|
|
277
|
+
_response = self._raw_client.get_tts_run_info(run_id, output_type=output_type, request_options=request_options)
|
|
278
|
+
return _response.data
|
|
279
|
+
|
|
280
|
+
def get_tts_results(
|
|
281
|
+
self,
|
|
282
|
+
*,
|
|
283
|
+
run_ids: typing.Sequence[int],
|
|
284
|
+
run_id: typing.Optional[int] = None,
|
|
285
|
+
traceparent: typing.Optional[str] = None,
|
|
286
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
287
|
+
) -> typing.Dict[str, GetTtsResultsTtsResultsPostResponseValue]:
|
|
288
|
+
"""
|
|
289
|
+
Parameters
|
|
290
|
+
----------
|
|
291
|
+
run_ids : typing.Sequence[int]
|
|
292
|
+
|
|
293
|
+
run_id : typing.Optional[int]
|
|
294
|
+
|
|
295
|
+
traceparent : typing.Optional[str]
|
|
296
|
+
|
|
297
|
+
request_options : typing.Optional[RequestOptions]
|
|
298
|
+
Request-specific configuration.
|
|
299
|
+
|
|
300
|
+
Returns
|
|
301
|
+
-------
|
|
302
|
+
typing.Dict[str, GetTtsResultsTtsResultsPostResponseValue]
|
|
303
|
+
Successful Response
|
|
304
|
+
|
|
305
|
+
Examples
|
|
306
|
+
--------
|
|
307
|
+
from camb import CambApi
|
|
308
|
+
|
|
309
|
+
client = CambApi(
|
|
310
|
+
api_key="YOUR_API_KEY",
|
|
311
|
+
)
|
|
312
|
+
client.text_to_speech.get_tts_results(
|
|
313
|
+
run_ids=[1],
|
|
314
|
+
)
|
|
315
|
+
"""
|
|
316
|
+
_response = self._raw_client.get_tts_results(
|
|
317
|
+
run_ids=run_ids, run_id=run_id, traceparent=traceparent, request_options=request_options
|
|
318
|
+
)
|
|
319
|
+
return _response.data
|
|
320
|
+
|
|
321
|
+
def get_tts_result_discord(
|
|
322
|
+
self,
|
|
323
|
+
task_id: str,
|
|
324
|
+
*,
|
|
325
|
+
run_id: typing.Optional[int] = None,
|
|
326
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
327
|
+
) -> OrchestratorPipelineResult:
|
|
328
|
+
"""
|
|
329
|
+
Parameters
|
|
330
|
+
----------
|
|
331
|
+
task_id : str
|
|
332
|
+
|
|
333
|
+
run_id : typing.Optional[int]
|
|
334
|
+
|
|
335
|
+
request_options : typing.Optional[RequestOptions]
|
|
336
|
+
Request-specific configuration.
|
|
337
|
+
|
|
338
|
+
Returns
|
|
339
|
+
-------
|
|
340
|
+
OrchestratorPipelineResult
|
|
341
|
+
Successful Response
|
|
342
|
+
|
|
343
|
+
Examples
|
|
344
|
+
--------
|
|
345
|
+
from camb import CambApi
|
|
346
|
+
|
|
347
|
+
client = CambApi(
|
|
348
|
+
api_key="YOUR_API_KEY",
|
|
349
|
+
)
|
|
350
|
+
client.text_to_speech.get_tts_result_discord(
|
|
351
|
+
task_id="task_id",
|
|
352
|
+
)
|
|
353
|
+
"""
|
|
354
|
+
_response = self._raw_client.get_tts_result_discord(task_id, run_id=run_id, request_options=request_options)
|
|
355
|
+
return _response.data
|
|
356
|
+
|
|
357
|
+
|
|
358
|
+
class AsyncTextToSpeechClient:
|
|
359
|
+
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
360
|
+
self._raw_client = AsyncRawTextToSpeechClient(client_wrapper=client_wrapper)
|
|
361
|
+
|
|
362
|
+
@property
|
|
363
|
+
def with_raw_response(self) -> AsyncRawTextToSpeechClient:
|
|
364
|
+
"""
|
|
365
|
+
Retrieves a raw implementation of this client that returns raw responses.
|
|
366
|
+
|
|
367
|
+
Returns
|
|
368
|
+
-------
|
|
369
|
+
AsyncRawTextToSpeechClient
|
|
370
|
+
"""
|
|
371
|
+
return self._raw_client
|
|
372
|
+
|
|
373
|
+
async def tts(
|
|
374
|
+
self,
|
|
375
|
+
*,
|
|
376
|
+
text: str,
|
|
377
|
+
language: CreateStreamTtsRequestPayloadLanguage,
|
|
378
|
+
voice_id: typing.Optional[int] = OMIT,
|
|
379
|
+
speech_model: typing.Optional[CreateStreamTtsRequestPayloadSpeechModel] = OMIT,
|
|
380
|
+
user_instructions: typing.Optional[str] = OMIT,
|
|
381
|
+
enhance_named_entities_pronunciation: typing.Optional[bool] = OMIT,
|
|
382
|
+
output_configuration: typing.Optional[StreamTtsOutputConfiguration] = OMIT,
|
|
383
|
+
voice_settings: typing.Optional[StreamTtsVoiceSettings] = OMIT,
|
|
384
|
+
inference_options: typing.Optional[StreamTtsInferenceOptions] = OMIT,
|
|
385
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
386
|
+
) -> typing.AsyncIterator[bytes]:
|
|
387
|
+
"""
|
|
388
|
+
Parameters
|
|
389
|
+
----------
|
|
390
|
+
text : str
|
|
391
|
+
|
|
392
|
+
language : CreateStreamTtsRequestPayloadLanguage
|
|
393
|
+
|
|
394
|
+
voice_id : int
|
|
395
|
+
|
|
396
|
+
speech_model : typing.Optional[CreateStreamTtsRequestPayloadSpeechModel]
|
|
397
|
+
|
|
398
|
+
user_instructions : typing.Optional[str]
|
|
399
|
+
|
|
400
|
+
enhance_named_entities_pronunciation : typing.Optional[bool]
|
|
401
|
+
|
|
402
|
+
output_configuration : typing.Optional[StreamTtsOutputConfiguration]
|
|
403
|
+
|
|
404
|
+
voice_settings : typing.Optional[StreamTtsVoiceSettings]
|
|
405
|
+
|
|
406
|
+
inference_options : typing.Optional[StreamTtsInferenceOptions]
|
|
407
|
+
|
|
408
|
+
request_options : typing.Optional[RequestOptions]
|
|
409
|
+
Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.
|
|
410
|
+
|
|
411
|
+
Returns
|
|
412
|
+
-------
|
|
413
|
+
typing.AsyncIterator[bytes]
|
|
414
|
+
Streaming audio response
|
|
415
|
+
|
|
416
|
+
Examples
|
|
417
|
+
--------
|
|
418
|
+
import asyncio
|
|
419
|
+
|
|
420
|
+
from camb import AsyncCambApi
|
|
421
|
+
|
|
422
|
+
client = AsyncCambApi(
|
|
423
|
+
api_key="YOUR_API_KEY",
|
|
424
|
+
)
|
|
425
|
+
|
|
426
|
+
|
|
427
|
+
async def main() -> None:
|
|
428
|
+
await client.text_to_speech.tts(
|
|
429
|
+
text="foo",
|
|
430
|
+
language="ar-kw",
|
|
431
|
+
voice_id=1,
|
|
432
|
+
)
|
|
433
|
+
|
|
434
|
+
|
|
435
|
+
asyncio.run(main())
|
|
436
|
+
"""
|
|
437
|
+
async with self._raw_client.tts(
|
|
438
|
+
text=text,
|
|
439
|
+
language=language,
|
|
440
|
+
voice_id=voice_id,
|
|
441
|
+
speech_model=speech_model,
|
|
442
|
+
user_instructions=user_instructions,
|
|
443
|
+
enhance_named_entities_pronunciation=enhance_named_entities_pronunciation,
|
|
444
|
+
output_configuration=output_configuration,
|
|
445
|
+
voice_settings=voice_settings,
|
|
446
|
+
inference_options=inference_options,
|
|
447
|
+
request_options=request_options,
|
|
448
|
+
) as r:
|
|
449
|
+
async for _chunk in r.data:
|
|
450
|
+
yield _chunk
|
|
451
|
+
|
|
452
|
+
async def create_tts(
|
|
453
|
+
self,
|
|
454
|
+
*,
|
|
455
|
+
text: str,
|
|
456
|
+
voice_id: int,
|
|
457
|
+
language: Languages,
|
|
458
|
+
run_id: typing.Optional[int] = None,
|
|
459
|
+
project_name: typing.Optional[str] = OMIT,
|
|
460
|
+
project_description: typing.Optional[str] = OMIT,
|
|
461
|
+
folder_id: typing.Optional[int] = OMIT,
|
|
462
|
+
gender: typing.Optional[Gender] = OMIT,
|
|
463
|
+
age: typing.Optional[int] = OMIT,
|
|
464
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
465
|
+
) -> CreateTtsOut:
|
|
466
|
+
"""
|
|
467
|
+
Parameters
|
|
468
|
+
----------
|
|
469
|
+
text : str
|
|
470
|
+
|
|
471
|
+
voice_id : int
|
|
472
|
+
|
|
473
|
+
language : Languages
|
|
474
|
+
|
|
475
|
+
run_id : typing.Optional[int]
|
|
476
|
+
|
|
477
|
+
project_name : typing.Optional[str]
|
|
478
|
+
|
|
479
|
+
project_description : typing.Optional[str]
|
|
480
|
+
|
|
481
|
+
folder_id : typing.Optional[int]
|
|
482
|
+
|
|
483
|
+
gender : typing.Optional[Gender]
|
|
484
|
+
|
|
485
|
+
age : typing.Optional[int]
|
|
486
|
+
|
|
487
|
+
request_options : typing.Optional[RequestOptions]
|
|
488
|
+
Request-specific configuration.
|
|
489
|
+
|
|
490
|
+
Returns
|
|
491
|
+
-------
|
|
492
|
+
CreateTtsOut
|
|
493
|
+
Successful Response
|
|
494
|
+
|
|
495
|
+
Examples
|
|
496
|
+
--------
|
|
497
|
+
import asyncio
|
|
498
|
+
|
|
499
|
+
from camb import AsyncCambApi
|
|
500
|
+
|
|
501
|
+
client = AsyncCambApi(
|
|
502
|
+
api_key="YOUR_API_KEY",
|
|
503
|
+
)
|
|
504
|
+
|
|
505
|
+
|
|
506
|
+
async def main() -> None:
|
|
507
|
+
await client.text_to_speech.create_tts(
|
|
508
|
+
text="text",
|
|
509
|
+
voice_id=1,
|
|
510
|
+
language=1,
|
|
511
|
+
)
|
|
512
|
+
|
|
513
|
+
|
|
514
|
+
asyncio.run(main())
|
|
515
|
+
"""
|
|
516
|
+
_response = await self._raw_client.create_tts(
|
|
517
|
+
text=text,
|
|
518
|
+
voice_id=voice_id,
|
|
519
|
+
language=language,
|
|
520
|
+
run_id=run_id,
|
|
521
|
+
project_name=project_name,
|
|
522
|
+
project_description=project_description,
|
|
523
|
+
folder_id=folder_id,
|
|
524
|
+
gender=gender,
|
|
525
|
+
age=age,
|
|
526
|
+
request_options=request_options,
|
|
527
|
+
)
|
|
528
|
+
return _response.data
|
|
529
|
+
|
|
530
|
+
async def get_tts_result(
|
|
531
|
+
self,
|
|
532
|
+
task_id: str,
|
|
533
|
+
*,
|
|
534
|
+
run_id: typing.Optional[int] = None,
|
|
535
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
536
|
+
) -> OrchestratorPipelineResult:
|
|
537
|
+
"""
|
|
538
|
+
Parameters
|
|
539
|
+
----------
|
|
540
|
+
task_id : str
|
|
541
|
+
|
|
542
|
+
run_id : typing.Optional[int]
|
|
543
|
+
|
|
544
|
+
request_options : typing.Optional[RequestOptions]
|
|
545
|
+
Request-specific configuration.
|
|
546
|
+
|
|
547
|
+
Returns
|
|
548
|
+
-------
|
|
549
|
+
OrchestratorPipelineResult
|
|
550
|
+
Successful Response
|
|
551
|
+
|
|
552
|
+
Examples
|
|
553
|
+
--------
|
|
554
|
+
import asyncio
|
|
555
|
+
|
|
556
|
+
from camb import AsyncCambApi
|
|
557
|
+
|
|
558
|
+
client = AsyncCambApi(
|
|
559
|
+
api_key="YOUR_API_KEY",
|
|
560
|
+
)
|
|
561
|
+
|
|
562
|
+
|
|
563
|
+
async def main() -> None:
|
|
564
|
+
await client.text_to_speech.get_tts_result(
|
|
565
|
+
task_id="task_id",
|
|
566
|
+
)
|
|
567
|
+
|
|
568
|
+
|
|
569
|
+
asyncio.run(main())
|
|
570
|
+
"""
|
|
571
|
+
_response = await self._raw_client.get_tts_result(task_id, run_id=run_id, request_options=request_options)
|
|
572
|
+
return _response.data
|
|
573
|
+
|
|
574
|
+
async def get_tts_run_info(
|
|
575
|
+
self,
|
|
576
|
+
run_id: typing.Optional[int],
|
|
577
|
+
*,
|
|
578
|
+
output_type: typing.Optional[str] = None,
|
|
579
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
580
|
+
) -> GetTtsRunInfoTtsResultRunIdGetResponse:
|
|
581
|
+
"""
|
|
582
|
+
Retrieves the result of a Text To Speech (TTS) run.
|
|
583
|
+
|
|
584
|
+
This endpoint validates the provided `run_id` and fetches the corresponding TTS-generated audio.
|
|
585
|
+
The user must have valid access to the run. The function supports two output formats:
|
|
586
|
+
- `RAW_BYTES`: Streams the audio file directly.
|
|
587
|
+
- `FILE_URL`: Returns a pre-signed URL to download the audio file.
|
|
588
|
+
|
|
589
|
+
Args:
|
|
590
|
+
run_id (int): Unique identifier for the TTS run.
|
|
591
|
+
api_key_obj (dict): API key object used for authentication and storage preferences.
|
|
592
|
+
traceparent (Optional[str]): Traceparent header for distributed tracing.
|
|
593
|
+
output_type (OutputType, optional): Determines the output format. Defaults to `RAW_BYTES`.
|
|
594
|
+
|
|
595
|
+
Returns:
|
|
596
|
+
StreamingResponse | GetTTSOut:
|
|
597
|
+
- If `output_type = RAW_BYTES`: A streaming response containing the TTS-generated audio in FLAC format.
|
|
598
|
+
- If `output_type = FILE_URL`: A URL pointing to the stored TTS-generated audio file.
|
|
599
|
+
|
|
600
|
+
Raises:
|
|
601
|
+
HTTPException:
|
|
602
|
+
- 400 BAD REQUEST if the run ID is invalid or does not belong to a TTS process.
|
|
603
|
+
- 500 INTERNAL SERVER ERROR if fetching or streaming the audio fails.
|
|
604
|
+
|
|
605
|
+
Assumptions:
|
|
606
|
+
- The user has valid access to the `run_id`.
|
|
607
|
+
- The `run_id` corresponds to a valid TTS run.
|
|
608
|
+
- There is only **one** dialogue associated with the given `run_id`.
|
|
609
|
+
|
|
610
|
+
Parameters
|
|
611
|
+
----------
|
|
612
|
+
run_id : typing.Optional[int]
|
|
613
|
+
|
|
614
|
+
output_type : typing.Optional[str]
|
|
615
|
+
Output format for the Text To Speech result
|
|
616
|
+
|
|
617
|
+
request_options : typing.Optional[RequestOptions]
|
|
618
|
+
Request-specific configuration.
|
|
619
|
+
|
|
620
|
+
Returns
|
|
621
|
+
-------
|
|
622
|
+
GetTtsRunInfoTtsResultRunIdGetResponse
|
|
623
|
+
Successful Response
|
|
624
|
+
|
|
625
|
+
Examples
|
|
626
|
+
--------
|
|
627
|
+
import asyncio
|
|
628
|
+
|
|
629
|
+
from camb import AsyncCambApi
|
|
630
|
+
|
|
631
|
+
client = AsyncCambApi(
|
|
632
|
+
api_key="YOUR_API_KEY",
|
|
633
|
+
)
|
|
634
|
+
|
|
635
|
+
|
|
636
|
+
async def main() -> None:
|
|
637
|
+
await client.text_to_speech.get_tts_run_info(
|
|
638
|
+
run_id=1,
|
|
639
|
+
)
|
|
640
|
+
|
|
641
|
+
|
|
642
|
+
asyncio.run(main())
|
|
643
|
+
"""
|
|
644
|
+
_response = await self._raw_client.get_tts_run_info(
|
|
645
|
+
run_id, output_type=output_type, request_options=request_options
|
|
646
|
+
)
|
|
647
|
+
return _response.data
|
|
648
|
+
|
|
649
|
+
async def get_tts_results(
|
|
650
|
+
self,
|
|
651
|
+
*,
|
|
652
|
+
run_ids: typing.Sequence[int],
|
|
653
|
+
run_id: typing.Optional[int] = None,
|
|
654
|
+
traceparent: typing.Optional[str] = None,
|
|
655
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
656
|
+
) -> typing.Dict[str, GetTtsResultsTtsResultsPostResponseValue]:
|
|
657
|
+
"""
|
|
658
|
+
Parameters
|
|
659
|
+
----------
|
|
660
|
+
run_ids : typing.Sequence[int]
|
|
661
|
+
|
|
662
|
+
run_id : typing.Optional[int]
|
|
663
|
+
|
|
664
|
+
traceparent : typing.Optional[str]
|
|
665
|
+
|
|
666
|
+
request_options : typing.Optional[RequestOptions]
|
|
667
|
+
Request-specific configuration.
|
|
668
|
+
|
|
669
|
+
Returns
|
|
670
|
+
-------
|
|
671
|
+
typing.Dict[str, GetTtsResultsTtsResultsPostResponseValue]
|
|
672
|
+
Successful Response
|
|
673
|
+
|
|
674
|
+
Examples
|
|
675
|
+
--------
|
|
676
|
+
import asyncio
|
|
677
|
+
|
|
678
|
+
from camb import AsyncCambApi
|
|
679
|
+
|
|
680
|
+
client = AsyncCambApi(
|
|
681
|
+
api_key="YOUR_API_KEY",
|
|
682
|
+
)
|
|
683
|
+
|
|
684
|
+
|
|
685
|
+
async def main() -> None:
|
|
686
|
+
await client.text_to_speech.get_tts_results(
|
|
687
|
+
run_ids=[1],
|
|
688
|
+
)
|
|
689
|
+
|
|
690
|
+
|
|
691
|
+
asyncio.run(main())
|
|
692
|
+
"""
|
|
693
|
+
_response = await self._raw_client.get_tts_results(
|
|
694
|
+
run_ids=run_ids, run_id=run_id, traceparent=traceparent, request_options=request_options
|
|
695
|
+
)
|
|
696
|
+
return _response.data
|
|
697
|
+
|
|
698
|
+
async def get_tts_result_discord(
|
|
699
|
+
self,
|
|
700
|
+
task_id: str,
|
|
701
|
+
*,
|
|
702
|
+
run_id: typing.Optional[int] = None,
|
|
703
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
704
|
+
) -> OrchestratorPipelineResult:
|
|
705
|
+
"""
|
|
706
|
+
Parameters
|
|
707
|
+
----------
|
|
708
|
+
task_id : str
|
|
709
|
+
|
|
710
|
+
run_id : typing.Optional[int]
|
|
711
|
+
|
|
712
|
+
request_options : typing.Optional[RequestOptions]
|
|
713
|
+
Request-specific configuration.
|
|
714
|
+
|
|
715
|
+
Returns
|
|
716
|
+
-------
|
|
717
|
+
OrchestratorPipelineResult
|
|
718
|
+
Successful Response
|
|
719
|
+
|
|
720
|
+
Examples
|
|
721
|
+
--------
|
|
722
|
+
import asyncio
|
|
723
|
+
|
|
724
|
+
from camb import AsyncCambApi
|
|
725
|
+
|
|
726
|
+
client = AsyncCambApi(
|
|
727
|
+
api_key="YOUR_API_KEY",
|
|
728
|
+
)
|
|
729
|
+
|
|
730
|
+
|
|
731
|
+
async def main() -> None:
|
|
732
|
+
await client.text_to_speech.get_tts_result_discord(
|
|
733
|
+
task_id="task_id",
|
|
734
|
+
)
|
|
735
|
+
|
|
736
|
+
|
|
737
|
+
asyncio.run(main())
|
|
738
|
+
"""
|
|
739
|
+
_response = await self._raw_client.get_tts_result_discord(
|
|
740
|
+
task_id, run_id=run_id, request_options=request_options
|
|
741
|
+
)
|
|
742
|
+
return _response.data
|