camb-sdk 1.0.0__tar.gz

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.

Potentially problematic release.


This version of camb-sdk might be problematic. Click here for more details.

Files changed (119) hide show
  1. camb_sdk-1.0.0/LICENSE +21 -0
  2. camb_sdk-1.0.0/PKG-INFO +266 -0
  3. camb_sdk-1.0.0/README.md +248 -0
  4. camb_sdk-1.0.0/camb_sdk.egg-info/PKG-INFO +266 -0
  5. camb_sdk-1.0.0/camb_sdk.egg-info/SOURCES.txt +117 -0
  6. camb_sdk-1.0.0/camb_sdk.egg-info/dependency_links.txt +1 -0
  7. camb_sdk-1.0.0/camb_sdk.egg-info/requires.txt +4 -0
  8. camb_sdk-1.0.0/camb_sdk.egg-info/top_level.txt +1 -0
  9. camb_sdk-1.0.0/cambai/__init__.py +145 -0
  10. camb_sdk-1.0.0/cambai/api/__init__.py +12 -0
  11. camb_sdk-1.0.0/cambai/api/apis_api.py +10291 -0
  12. camb_sdk-1.0.0/cambai/api/audio_separation_api.py +837 -0
  13. camb_sdk-1.0.0/cambai/api/dictionaries_api.py +286 -0
  14. camb_sdk-1.0.0/cambai/api/dub_api.py +906 -0
  15. camb_sdk-1.0.0/cambai/api/stories_api.py +1511 -0
  16. camb_sdk-1.0.0/cambai/api/text_to_audio_api.py +835 -0
  17. camb_sdk-1.0.0/cambai/api/text_to_speech_api.py +574 -0
  18. camb_sdk-1.0.0/cambai/api/text_to_voice_api.py +840 -0
  19. camb_sdk-1.0.0/cambai/api_client.py +801 -0
  20. camb_sdk-1.0.0/cambai/api_response.py +21 -0
  21. camb_sdk-1.0.0/cambai/configuration.py +603 -0
  22. camb_sdk-1.0.0/cambai/exceptions.py +216 -0
  23. camb_sdk-1.0.0/cambai/models/__init__.py +58 -0
  24. camb_sdk-1.0.0/cambai/models/audio_output_file_url_response.py +87 -0
  25. camb_sdk-1.0.0/cambai/models/audio_output_type.py +39 -0
  26. camb_sdk-1.0.0/cambai/models/audio_separation_run_info_response.py +89 -0
  27. camb_sdk-1.0.0/cambai/models/body_translate_translate_post.py +103 -0
  28. camb_sdk-1.0.0/cambai/models/create_api_key_request_payload.py +89 -0
  29. camb_sdk-1.0.0/cambai/models/create_custom_voice_out.py +87 -0
  30. camb_sdk-1.0.0/cambai/models/create_text_to_audio_request_payload.py +89 -0
  31. camb_sdk-1.0.0/cambai/models/create_text_to_voice_request_payload.py +89 -0
  32. camb_sdk-1.0.0/cambai/models/create_translated_story_request_payload.py +88 -0
  33. camb_sdk-1.0.0/cambai/models/create_translated_tts_request_payload.py +120 -0
  34. camb_sdk-1.0.0/cambai/models/create_translation_stream_request_payload.py +108 -0
  35. camb_sdk-1.0.0/cambai/models/create_tts_request_payload.py +102 -0
  36. camb_sdk-1.0.0/cambai/models/create_tts_stream_request_payload.py +100 -0
  37. camb_sdk-1.0.0/cambai/models/dialogue_item.py +93 -0
  38. camb_sdk-1.0.0/cambai/models/dictionary.py +96 -0
  39. camb_sdk-1.0.0/cambai/models/dub_alt_format_response_body.py +92 -0
  40. camb_sdk-1.0.0/cambai/models/dubbed_output_in_alt_format_request_payload.py +91 -0
  41. camb_sdk-1.0.0/cambai/models/end_to_end_dubbing_request_payload.py +99 -0
  42. camb_sdk-1.0.0/cambai/models/expire_api_key_request_payload.py +87 -0
  43. camb_sdk-1.0.0/cambai/models/formalities.py +37 -0
  44. camb_sdk-1.0.0/cambai/models/gender.py +39 -0
  45. camb_sdk-1.0.0/cambai/models/http_validation_error.py +95 -0
  46. camb_sdk-1.0.0/cambai/models/language_item.py +91 -0
  47. camb_sdk-1.0.0/cambai/models/languages.py +183 -0
  48. camb_sdk-1.0.0/cambai/models/orchestrator_pipeline_result.py +95 -0
  49. camb_sdk-1.0.0/cambai/models/output_api_key.py +105 -0
  50. camb_sdk-1.0.0/cambai/models/output_format.py +134 -0
  51. camb_sdk-1.0.0/cambai/models/output_type.py +37 -0
  52. camb_sdk-1.0.0/cambai/models/request_dubbed_output_in_alt_format200_response.py +137 -0
  53. camb_sdk-1.0.0/cambai/models/run_info_response.py +101 -0
  54. camb_sdk-1.0.0/cambai/models/story_run_info_response.py +99 -0
  55. camb_sdk-1.0.0/cambai/models/task_id.py +87 -0
  56. camb_sdk-1.0.0/cambai/models/task_status.py +40 -0
  57. camb_sdk-1.0.0/cambai/models/text_to_voice_run_info_response.py +87 -0
  58. camb_sdk-1.0.0/cambai/models/transcript_data_type.py +37 -0
  59. camb_sdk-1.0.0/cambai/models/transcript_file_format.py +38 -0
  60. camb_sdk-1.0.0/cambai/models/translation_result.py +87 -0
  61. camb_sdk-1.0.0/cambai/models/tts_stream_output_format.py +40 -0
  62. camb_sdk-1.0.0/cambai/models/validation_error.py +99 -0
  63. camb_sdk-1.0.0/cambai/models/validation_error_loc_inner.py +138 -0
  64. camb_sdk-1.0.0/cambai/models/video_output_type_without_avi.py +38 -0
  65. camb_sdk-1.0.0/cambai/models/voice_item.py +102 -0
  66. camb_sdk-1.0.0/cambai/py.typed +0 -0
  67. camb_sdk-1.0.0/cambai/rest.py +258 -0
  68. camb_sdk-1.0.0/pyproject.toml +96 -0
  69. camb_sdk-1.0.0/setup.cfg +4 -0
  70. camb_sdk-1.0.0/test/test_apis_api.py +283 -0
  71. camb_sdk-1.0.0/test/test_audio_output_file_url_response.py +51 -0
  72. camb_sdk-1.0.0/test/test_audio_output_type.py +33 -0
  73. camb_sdk-1.0.0/test/test_audio_separation_api.py +52 -0
  74. camb_sdk-1.0.0/test/test_audio_separation_run_info_response.py +52 -0
  75. camb_sdk-1.0.0/test/test_body_translate_translate_post.py +66 -0
  76. camb_sdk-1.0.0/test/test_create_api_key_request_payload.py +54 -0
  77. camb_sdk-1.0.0/test/test_create_custom_voice_out.py +51 -0
  78. camb_sdk-1.0.0/test/test_create_text_to_audio_request_payload.py +52 -0
  79. camb_sdk-1.0.0/test/test_create_text_to_voice_request_payload.py +54 -0
  80. camb_sdk-1.0.0/test/test_create_translated_story_request_payload.py +51 -0
  81. camb_sdk-1.0.0/test/test_create_translated_tts_request_payload.py +64 -0
  82. camb_sdk-1.0.0/test/test_create_translation_stream_request_payload.py +58 -0
  83. camb_sdk-1.0.0/test/test_create_tts_request_payload.py +58 -0
  84. camb_sdk-1.0.0/test/test_create_tts_stream_request_payload.py +59 -0
  85. camb_sdk-1.0.0/test/test_dialogue_item.py +58 -0
  86. camb_sdk-1.0.0/test/test_dictionaries_api.py +38 -0
  87. camb_sdk-1.0.0/test/test_dictionary.py +55 -0
  88. camb_sdk-1.0.0/test/test_dub_alt_format_response_body.py +51 -0
  89. camb_sdk-1.0.0/test/test_dub_api.py +52 -0
  90. camb_sdk-1.0.0/test/test_dubbed_output_in_alt_format_request_payload.py +52 -0
  91. camb_sdk-1.0.0/test/test_end_to_end_dubbing_request_payload.py +64 -0
  92. camb_sdk-1.0.0/test/test_expire_api_key_request_payload.py +52 -0
  93. camb_sdk-1.0.0/test/test_formalities.py +33 -0
  94. camb_sdk-1.0.0/test/test_gender.py +33 -0
  95. camb_sdk-1.0.0/test/test_http_validation_error.py +58 -0
  96. camb_sdk-1.0.0/test/test_language_item.py +53 -0
  97. camb_sdk-1.0.0/test/test_languages.py +33 -0
  98. camb_sdk-1.0.0/test/test_orchestrator_pipeline_result.py +52 -0
  99. camb_sdk-1.0.0/test/test_output_api_key.py +63 -0
  100. camb_sdk-1.0.0/test/test_output_format.py +50 -0
  101. camb_sdk-1.0.0/test/test_output_type.py +33 -0
  102. camb_sdk-1.0.0/test/test_request_dubbed_output_in_alt_format200_response.py +52 -0
  103. camb_sdk-1.0.0/test/test_run_info_response.py +60 -0
  104. camb_sdk-1.0.0/test/test_stories_api.py +66 -0
  105. camb_sdk-1.0.0/test/test_story_run_info_response.py +59 -0
  106. camb_sdk-1.0.0/test/test_task_id.py +51 -0
  107. camb_sdk-1.0.0/test/test_task_status.py +33 -0
  108. camb_sdk-1.0.0/test/test_text_to_audio_api.py +52 -0
  109. camb_sdk-1.0.0/test/test_text_to_speech_api.py +45 -0
  110. camb_sdk-1.0.0/test/test_text_to_voice_api.py +52 -0
  111. camb_sdk-1.0.0/test/test_text_to_voice_run_info_response.py +53 -0
  112. camb_sdk-1.0.0/test/test_transcript_data_type.py +33 -0
  113. camb_sdk-1.0.0/test/test_transcript_file_format.py +33 -0
  114. camb_sdk-1.0.0/test/test_translation_result.py +53 -0
  115. camb_sdk-1.0.0/test/test_tts_stream_output_format.py +33 -0
  116. camb_sdk-1.0.0/test/test_validation_error.py +60 -0
  117. camb_sdk-1.0.0/test/test_validation_error_loc_inner.py +50 -0
  118. camb_sdk-1.0.0/test/test_video_output_type_without_avi.py +33 -0
  119. camb_sdk-1.0.0/test/test_voice_item.py +58 -0
camb_sdk-1.0.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Camb AI
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,266 @@
1
+ Metadata-Version: 2.4
2
+ Name: camb-sdk
3
+ Version: 1.0.0
4
+ Summary: Camb AI Python SDK for Text-to-Speech, Voice Generation, and Audio APIs
5
+ Author-email: Camb AI <support@camb.ai>
6
+ License: MIT
7
+ Project-URL: Repository, https://github.com/Camb-ai/cambai-python-sdk
8
+ Project-URL: Documentation, https://docs.camb.ai
9
+ Keywords: AI,Dubbing,Text-to-Speech,Voice,Audio,SDK
10
+ Requires-Python: >=3.9
11
+ Description-Content-Type: text/markdown
12
+ License-File: LICENSE
13
+ Requires-Dist: urllib3<3.0.0,>=2.1.0
14
+ Requires-Dist: python-dateutil>=2.8.2
15
+ Requires-Dist: pydantic>=2
16
+ Requires-Dist: typing-extensions>=4.7.1
17
+ Dynamic: license-file
18
+
19
+ # Camb AI Python SDK 🎙️
20
+
21
+ [![PyPI version](https://img.shields.io/pypi/v/camb-ai-sdk.svg?style=flat-square)](https://pypi.org/project/camb-ai-sdk/)
22
+ [![License](https://img.shields.io/pypi/l/camb-ai-sdk.svg?style=flat-square)](https://github.com/your-org/camb-ai-python-sdk/blob/main/LICENSE)
23
+ [![Build Status](https://img.shields.io/github/actions/workflow/status/your-org/camb-ai-python-sdk/ci.yml?branch=main&style=flat-square)](https://github.com/your-org/camb-ai-python-sdk/actions)
24
+
25
+ The official Python SDK for interacting with Camb AI's powerful voice and audio generation APIs. Create expressive speech, unique voices, and rich soundscapes with just a few lines of Python.
26
+
27
+ ---
28
+
29
+ ## ✨ Features
30
+ - **Dubbing**: Dub your videos into multiple languages with voice cloning!
31
+ - **Expressive Text-to-Speech**: Convert text into natural-sounding speech using a wide range of pre-existing voices.
32
+ - **Generative Voices**: Create entirely new, unique voices from text prompts and descriptions.
33
+ - **Soundscapes from Text**: Generate ambient audio and sound effects from textual descriptions.
34
+ - Access to voice cloning, translation, and more (refer to full API documentation).
35
+
36
+ ---
37
+
38
+ ## 📦 Installation
39
+
40
+ Install the SDK using pip, ensure **Python 3.9+**:
41
+
42
+ ```bash
43
+ pip install camb-sdk
44
+ ````
45
+
46
+ Or through
47
+
48
+ ```bash
49
+ pip install git+https://github.com/Camb-ai/cambai-python-sdk
50
+ ```
51
+
52
+ ---
53
+
54
+ ## 🔑 Authentication
55
+
56
+ To use the Camb AI SDK, you'll need an API key. You can authenticate in either of the following ways:
57
+
58
+ ### 1. Pass the API key directly
59
+
60
+ ```python
61
+ from cambai import CambAI
62
+
63
+ client = CambAI(api_key="YOUR_CAMB_API_KEY")
64
+ ```
65
+
66
+ ### 2. Use an environment variable
67
+ Set your API key as an environment variable named `CAMB_API_KEY`:
68
+
69
+ ```bash
70
+ export CAMB_API_KEY="your_actual_api_key_here"
71
+ ```
72
+ ---
73
+
74
+ ## 🚀 Getting Started: Examples
75
+
76
+ ### 1. Text-to-Speech (TTS)
77
+
78
+ Convert text into spoken audio using one of Camb AI's high-quality voices.
79
+
80
+ #### a) Get an Audio URL
81
+
82
+ This is useful if you want to play the audio in a web application or share a link.
83
+
84
+ ```python
85
+ from cambai import CambAI
86
+ from cambai.rest import ApiException
87
+
88
+ # Initialize client (ensure API key is set)
89
+ client = CambAI(api_key="YOUR_CAMB_API_KEY")
90
+
91
+ try:
92
+ print("Generating speech and getting audio URL...")
93
+ audio_url = client.text_to_speech(
94
+ text="Hello from Camb AI! This is a test of our Text-to-Speech API.",
95
+ voice_id=20303 # Example voice ID, find more with client.list_voices()
96
+ )
97
+ print(f"Success! Your audio is ready at: {audio_url}")
98
+
99
+ except ApiException as e:
100
+ print(f"API Exception when calling text_to_speech: {e}\n")
101
+ ```
102
+
103
+ #### b) Save Audio Directly to a File
104
+
105
+ Generate speech and save it as an MP3 file (or other supported formats).
106
+
107
+ ```python
108
+ from cambai import CambAI
109
+ from cambai.models.output_type import OutputType
110
+ from cambai.rest import ApiException
111
+
112
+ # Initialize client
113
+ client = CambAI(api_key="YOUR_CAMB_API_KEY")
114
+
115
+ file_path = "my_generated_speech.mp3"
116
+
117
+ try:
118
+ print(f"Generating speech and saving to {file_path}...")
119
+
120
+ client.text_to_speech(
121
+ text="This is another test, saving directly to a file.",
122
+ voice_id=20303, # Example voice ID
123
+ output_type=OutputType.RAW_BYTES, # Specify raw bytes for direct saving
124
+ save_to_file=file_path,
125
+ verbose=True # For more detailed logging from the SDK
126
+ )
127
+ print(f"Success! Audio saved to {file_path}")
128
+
129
+ except ApiException as e:
130
+ print(f"API Exception when calling text_to_speech (save to file): {e}\n")
131
+ ```
132
+
133
+ #### c) List Available Voices
134
+
135
+ You can list available voices to find a `voice_id` that suits your needs:
136
+
137
+ ```python
138
+ try:
139
+ voices = client.list_voices()
140
+ print(f"Found {len(voices)} voices:")
141
+ for voice in voices[:5]: # Print first 5 as an example
142
+ print(f" - ID: {voice.id}, Name: {voice.voice_name}, Gender: {voice.gender}, Language: {voice.language}")
143
+ except ApiException as e:
144
+ print(f"Could not list voices: {e}")
145
+ ```
146
+
147
+ ---
148
+
149
+ ### 2. Text-to-Voice (Generative Voice)
150
+
151
+ Create completely new and unique voices from a textual description of the desired voice characteristics.
152
+
153
+ ```python
154
+ from cambai import CambAI
155
+ from cambai.rest import ApiException
156
+
157
+ # Initialize client
158
+ client = CambAI(api_key="YOUR_CAMB_API_KEY")
159
+
160
+ output_file = "generated_voice_output.mp3"
161
+
162
+ try:
163
+ print("Generating a new voice and speech...")
164
+ # The 'text_to_voice' method returns a dict consisting of 3 sample URLs
165
+ result = client.text_to_voice(
166
+ text="Crafting a unique voice with a hint of mystery and warmth.",
167
+ voice_description="A smooth, baritone voice with a slight echo, perfect for storytelling.",
168
+ verbose=True
169
+ )
170
+ print(result)
171
+
172
+ except ApiException as e:
173
+ print(f"API Exception when calling text_to_voice: {e}\n")
174
+ ```
175
+
176
+ ---
177
+ ### 3. Text-to-Audio (Sound Generation)
178
+
179
+ Generate sound effects or ambient audio from a descriptive prompt.
180
+
181
+ ```python
182
+ from cambai import CambAI
183
+ from cambai.rest import ApiException
184
+
185
+ # Initialize client
186
+ client = CambAI(api_key="YOUR_CAMB_API_KEY")
187
+
188
+ output_file = "generated_sound_effect.mp3"
189
+
190
+ try:
191
+ print(f"Generating sound effect and saving to {output_file}...")
192
+
193
+ client.text_to_audio(
194
+ prompt="A gentle breeze rustling through autumn leaves in a quiet forest.",
195
+ duration=10,
196
+ save_to_file=output_file,
197
+ verbose=True
198
+ )
199
+ print(f"Success! Sound effect saved to {output_file}")
200
+
201
+ except ApiException as e:
202
+ print(f"API Exception when calling text_to_audio: {e}\n")
203
+ ```
204
+
205
+ ---
206
+ ### 4. End-to-End Dubbing
207
+
208
+ Dub videos into different languages with voice cloning and translation capabilities.
209
+
210
+ ```python
211
+ from cambai import CambAI
212
+ from cambai.rest import ApiException
213
+
214
+ # Initialize client
215
+ client = CambAI(api_key="YOUR_CAMB_API_KEY")
216
+
217
+ # Call all target languages
218
+ print("Listing target languages...")
219
+ target_languages = clinet.get_target_languages()
220
+ print(f"Found {len(target_languages)} target languages:")
221
+ for language in target_languages:
222
+ print(f" - {language}")
223
+
224
+ try:
225
+ print("Starting end-to-end dubbing process...")
226
+
227
+ result = client.end_to_end_dubbing(
228
+ video_url="your_accesible_video_url",
229
+ source_language=cambai.Languages.NUMBER_1, # English
230
+ target_languages=[cambai.Languages.NUMBER_81], # Add more target languages as needed
231
+ verbose=True
232
+ )
233
+
234
+ print("Dubbing completed successfully!")
235
+ # The result contains output_video_url, output_audio_url, and transcript information with timing and speaker details
236
+ print(f"Result: {result}")
237
+
238
+ except ApiException as e:
239
+ print(f"API Exception when calling end_to_end_dubbing: {e}\n")
240
+ ```
241
+
242
+ ---
243
+
244
+ ## ⚙️ Advanced Usage & Other Features
245
+
246
+ The Camb AI SDK offers a wide range of capabilities beyond these examples, including:
247
+
248
+ * Voice Cloning
249
+ * Translated TTS
250
+ * Audio Dubbing
251
+ * Transcription
252
+ * And more!
253
+
254
+ Please refer to the [**Official Camb AI API Documentation**](https://docs.camb.ai/introduction) for a comprehensive list of features and advanced usage patterns.
255
+
256
+ ---
257
+
258
+ ## License
259
+
260
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
261
+
262
+ ---
263
+
264
+
265
+
266
+
@@ -0,0 +1,248 @@
1
+ # Camb AI Python SDK 🎙️
2
+
3
+ [![PyPI version](https://img.shields.io/pypi/v/camb-ai-sdk.svg?style=flat-square)](https://pypi.org/project/camb-ai-sdk/)
4
+ [![License](https://img.shields.io/pypi/l/camb-ai-sdk.svg?style=flat-square)](https://github.com/your-org/camb-ai-python-sdk/blob/main/LICENSE)
5
+ [![Build Status](https://img.shields.io/github/actions/workflow/status/your-org/camb-ai-python-sdk/ci.yml?branch=main&style=flat-square)](https://github.com/your-org/camb-ai-python-sdk/actions)
6
+
7
+ The official Python SDK for interacting with Camb AI's powerful voice and audio generation APIs. Create expressive speech, unique voices, and rich soundscapes with just a few lines of Python.
8
+
9
+ ---
10
+
11
+ ## ✨ Features
12
+ - **Dubbing**: Dub your videos into multiple languages with voice cloning!
13
+ - **Expressive Text-to-Speech**: Convert text into natural-sounding speech using a wide range of pre-existing voices.
14
+ - **Generative Voices**: Create entirely new, unique voices from text prompts and descriptions.
15
+ - **Soundscapes from Text**: Generate ambient audio and sound effects from textual descriptions.
16
+ - Access to voice cloning, translation, and more (refer to full API documentation).
17
+
18
+ ---
19
+
20
+ ## 📦 Installation
21
+
22
+ Install the SDK using pip, ensure **Python 3.9+**:
23
+
24
+ ```bash
25
+ pip install camb-sdk
26
+ ````
27
+
28
+ Or through
29
+
30
+ ```bash
31
+ pip install git+https://github.com/Camb-ai/cambai-python-sdk
32
+ ```
33
+
34
+ ---
35
+
36
+ ## 🔑 Authentication
37
+
38
+ To use the Camb AI SDK, you'll need an API key. You can authenticate in either of the following ways:
39
+
40
+ ### 1. Pass the API key directly
41
+
42
+ ```python
43
+ from cambai import CambAI
44
+
45
+ client = CambAI(api_key="YOUR_CAMB_API_KEY")
46
+ ```
47
+
48
+ ### 2. Use an environment variable
49
+ Set your API key as an environment variable named `CAMB_API_KEY`:
50
+
51
+ ```bash
52
+ export CAMB_API_KEY="your_actual_api_key_here"
53
+ ```
54
+ ---
55
+
56
+ ## 🚀 Getting Started: Examples
57
+
58
+ ### 1. Text-to-Speech (TTS)
59
+
60
+ Convert text into spoken audio using one of Camb AI's high-quality voices.
61
+
62
+ #### a) Get an Audio URL
63
+
64
+ This is useful if you want to play the audio in a web application or share a link.
65
+
66
+ ```python
67
+ from cambai import CambAI
68
+ from cambai.rest import ApiException
69
+
70
+ # Initialize client (ensure API key is set)
71
+ client = CambAI(api_key="YOUR_CAMB_API_KEY")
72
+
73
+ try:
74
+ print("Generating speech and getting audio URL...")
75
+ audio_url = client.text_to_speech(
76
+ text="Hello from Camb AI! This is a test of our Text-to-Speech API.",
77
+ voice_id=20303 # Example voice ID, find more with client.list_voices()
78
+ )
79
+ print(f"Success! Your audio is ready at: {audio_url}")
80
+
81
+ except ApiException as e:
82
+ print(f"API Exception when calling text_to_speech: {e}\n")
83
+ ```
84
+
85
+ #### b) Save Audio Directly to a File
86
+
87
+ Generate speech and save it as an MP3 file (or other supported formats).
88
+
89
+ ```python
90
+ from cambai import CambAI
91
+ from cambai.models.output_type import OutputType
92
+ from cambai.rest import ApiException
93
+
94
+ # Initialize client
95
+ client = CambAI(api_key="YOUR_CAMB_API_KEY")
96
+
97
+ file_path = "my_generated_speech.mp3"
98
+
99
+ try:
100
+ print(f"Generating speech and saving to {file_path}...")
101
+
102
+ client.text_to_speech(
103
+ text="This is another test, saving directly to a file.",
104
+ voice_id=20303, # Example voice ID
105
+ output_type=OutputType.RAW_BYTES, # Specify raw bytes for direct saving
106
+ save_to_file=file_path,
107
+ verbose=True # For more detailed logging from the SDK
108
+ )
109
+ print(f"Success! Audio saved to {file_path}")
110
+
111
+ except ApiException as e:
112
+ print(f"API Exception when calling text_to_speech (save to file): {e}\n")
113
+ ```
114
+
115
+ #### c) List Available Voices
116
+
117
+ You can list available voices to find a `voice_id` that suits your needs:
118
+
119
+ ```python
120
+ try:
121
+ voices = client.list_voices()
122
+ print(f"Found {len(voices)} voices:")
123
+ for voice in voices[:5]: # Print first 5 as an example
124
+ print(f" - ID: {voice.id}, Name: {voice.voice_name}, Gender: {voice.gender}, Language: {voice.language}")
125
+ except ApiException as e:
126
+ print(f"Could not list voices: {e}")
127
+ ```
128
+
129
+ ---
130
+
131
+ ### 2. Text-to-Voice (Generative Voice)
132
+
133
+ Create completely new and unique voices from a textual description of the desired voice characteristics.
134
+
135
+ ```python
136
+ from cambai import CambAI
137
+ from cambai.rest import ApiException
138
+
139
+ # Initialize client
140
+ client = CambAI(api_key="YOUR_CAMB_API_KEY")
141
+
142
+ output_file = "generated_voice_output.mp3"
143
+
144
+ try:
145
+ print("Generating a new voice and speech...")
146
+ # The 'text_to_voice' method returns a dict consisting of 3 sample URLs
147
+ result = client.text_to_voice(
148
+ text="Crafting a unique voice with a hint of mystery and warmth.",
149
+ voice_description="A smooth, baritone voice with a slight echo, perfect for storytelling.",
150
+ verbose=True
151
+ )
152
+ print(result)
153
+
154
+ except ApiException as e:
155
+ print(f"API Exception when calling text_to_voice: {e}\n")
156
+ ```
157
+
158
+ ---
159
+ ### 3. Text-to-Audio (Sound Generation)
160
+
161
+ Generate sound effects or ambient audio from a descriptive prompt.
162
+
163
+ ```python
164
+ from cambai import CambAI
165
+ from cambai.rest import ApiException
166
+
167
+ # Initialize client
168
+ client = CambAI(api_key="YOUR_CAMB_API_KEY")
169
+
170
+ output_file = "generated_sound_effect.mp3"
171
+
172
+ try:
173
+ print(f"Generating sound effect and saving to {output_file}...")
174
+
175
+ client.text_to_audio(
176
+ prompt="A gentle breeze rustling through autumn leaves in a quiet forest.",
177
+ duration=10,
178
+ save_to_file=output_file,
179
+ verbose=True
180
+ )
181
+ print(f"Success! Sound effect saved to {output_file}")
182
+
183
+ except ApiException as e:
184
+ print(f"API Exception when calling text_to_audio: {e}\n")
185
+ ```
186
+
187
+ ---
188
+ ### 4. End-to-End Dubbing
189
+
190
+ Dub videos into different languages with voice cloning and translation capabilities.
191
+
192
+ ```python
193
+ from cambai import CambAI
194
+ from cambai.rest import ApiException
195
+
196
+ # Initialize client
197
+ client = CambAI(api_key="YOUR_CAMB_API_KEY")
198
+
199
+ # Call all target languages
200
+ print("Listing target languages...")
201
+ target_languages = clinet.get_target_languages()
202
+ print(f"Found {len(target_languages)} target languages:")
203
+ for language in target_languages:
204
+ print(f" - {language}")
205
+
206
+ try:
207
+ print("Starting end-to-end dubbing process...")
208
+
209
+ result = client.end_to_end_dubbing(
210
+ video_url="your_accesible_video_url",
211
+ source_language=cambai.Languages.NUMBER_1, # English
212
+ target_languages=[cambai.Languages.NUMBER_81], # Add more target languages as needed
213
+ verbose=True
214
+ )
215
+
216
+ print("Dubbing completed successfully!")
217
+ # The result contains output_video_url, output_audio_url, and transcript information with timing and speaker details
218
+ print(f"Result: {result}")
219
+
220
+ except ApiException as e:
221
+ print(f"API Exception when calling end_to_end_dubbing: {e}\n")
222
+ ```
223
+
224
+ ---
225
+
226
+ ## ⚙️ Advanced Usage & Other Features
227
+
228
+ The Camb AI SDK offers a wide range of capabilities beyond these examples, including:
229
+
230
+ * Voice Cloning
231
+ * Translated TTS
232
+ * Audio Dubbing
233
+ * Transcription
234
+ * And more!
235
+
236
+ Please refer to the [**Official Camb AI API Documentation**](https://docs.camb.ai/introduction) for a comprehensive list of features and advanced usage patterns.
237
+
238
+ ---
239
+
240
+ ## License
241
+
242
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
243
+
244
+ ---
245
+
246
+
247
+
248
+