langchain-camb 0.1.0__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.
- langchain_camb/__init__.py +81 -0
- langchain_camb/toolkits/__init__.py +5 -0
- langchain_camb/toolkits/camb_toolkit.py +148 -0
- langchain_camb/tools/__init__.py +40 -0
- langchain_camb/tools/audio_separation.py +189 -0
- langchain_camb/tools/base.py +161 -0
- langchain_camb/tools/text_to_sound.py +156 -0
- langchain_camb/tools/transcription.py +189 -0
- langchain_camb/tools/translated_tts.py +340 -0
- langchain_camb/tools/translation.py +150 -0
- langchain_camb/tools/tts.py +182 -0
- langchain_camb/tools/voice_clone.py +152 -0
- langchain_camb/tools/voice_list.py +108 -0
- langchain_camb/version.py +3 -0
- langchain_camb-0.1.0.dist-info/METADATA +307 -0
- langchain_camb-0.1.0.dist-info/RECORD +17 -0
- langchain_camb-0.1.0.dist-info/WHEEL +4 -0
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: langchain-camb
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: LangChain integration for CAMB AI - multilingual audio and localization tools
|
|
5
|
+
Project-URL: Homepage, https://github.com/camb-ai/langchain-camb
|
|
6
|
+
Project-URL: Documentation, https://docs.camb.ai
|
|
7
|
+
Project-URL: Repository, https://github.com/camb-ai/langchain-camb
|
|
8
|
+
Author-email: CAMB AI <support@camb.ai>
|
|
9
|
+
License-Expression: MIT
|
|
10
|
+
Keywords: audio,camb,langchain,localization,multilingual,text-to-speech,transcription,translation,tts,voice-cloning
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Topic :: Multimedia :: Sound/Audio :: Speech
|
|
20
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
21
|
+
Requires-Python: >=3.9
|
|
22
|
+
Requires-Dist: camb-sdk>=1.5.0
|
|
23
|
+
Requires-Dist: langchain-core>=0.3.0
|
|
24
|
+
Requires-Dist: pydantic>=2.0.0
|
|
25
|
+
Provides-Extra: dev
|
|
26
|
+
Requires-Dist: langchain-tests>=0.3.0; extra == 'dev'
|
|
27
|
+
Requires-Dist: mypy>=1.0.0; extra == 'dev'
|
|
28
|
+
Requires-Dist: pytest-asyncio>=0.21.0; extra == 'dev'
|
|
29
|
+
Requires-Dist: pytest-cov>=4.0.0; extra == 'dev'
|
|
30
|
+
Requires-Dist: pytest>=7.0.0; extra == 'dev'
|
|
31
|
+
Requires-Dist: ruff>=0.1.0; extra == 'dev'
|
|
32
|
+
Description-Content-Type: text/markdown
|
|
33
|
+
|
|
34
|
+
# langchain-camb
|
|
35
|
+
|
|
36
|
+
LangChain integration for [CAMB AI](https://camb.ai) - multilingual audio and localization services supporting 140+ languages.
|
|
37
|
+
|
|
38
|
+
## Installation
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
pip install langchain-camb
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Quick Start
|
|
45
|
+
|
|
46
|
+
```python
|
|
47
|
+
from langchain_camb import CambToolkit, CambTTSTool
|
|
48
|
+
from langchain_openai import ChatOpenAI
|
|
49
|
+
from langgraph.prebuilt import create_react_agent
|
|
50
|
+
|
|
51
|
+
# Set your API key
|
|
52
|
+
import os
|
|
53
|
+
os.environ["CAMB_API_KEY"] = "your-api-key"
|
|
54
|
+
|
|
55
|
+
# Use individual tools
|
|
56
|
+
tts = CambTTSTool()
|
|
57
|
+
audio_path = tts.invoke({
|
|
58
|
+
"text": "Hello, world!",
|
|
59
|
+
"language": "en-us",
|
|
60
|
+
"voice_id": 147320
|
|
61
|
+
})
|
|
62
|
+
print(f"Audio saved to: {audio_path}")
|
|
63
|
+
|
|
64
|
+
# Or use the toolkit with a LangChain agent
|
|
65
|
+
toolkit = CambToolkit()
|
|
66
|
+
agent = create_react_agent(ChatOpenAI(), toolkit.get_tools())
|
|
67
|
+
|
|
68
|
+
result = agent.invoke({
|
|
69
|
+
"messages": [{"role": "user", "content": "Say 'Good morning' in Spanish"}]
|
|
70
|
+
})
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Available Tools
|
|
74
|
+
|
|
75
|
+
| Tool | Description |
|
|
76
|
+
|------|-------------|
|
|
77
|
+
| `CambTTSTool` | Text-to-Speech - Convert text to natural speech |
|
|
78
|
+
| `CambTranslatedTTSTool` | Translate text and convert to speech in one step |
|
|
79
|
+
| `CambTranslationTool` | Text translation between 140+ languages |
|
|
80
|
+
| `CambTranscriptionTool` | Speech-to-text with speaker identification |
|
|
81
|
+
| `CambVoiceListTool` | List available voices for TTS |
|
|
82
|
+
| `CambVoiceCloneTool` | Clone voices from 2+ second audio samples |
|
|
83
|
+
| `CambTextToSoundTool` | Generate music and sound effects from text |
|
|
84
|
+
| `CambAudioSeparationTool` | Separate vocals from background audio |
|
|
85
|
+
|
|
86
|
+
## Tool Examples
|
|
87
|
+
|
|
88
|
+
### Text-to-Speech
|
|
89
|
+
|
|
90
|
+
```python
|
|
91
|
+
from langchain_camb import CambTTSTool
|
|
92
|
+
|
|
93
|
+
tts = CambTTSTool()
|
|
94
|
+
result = tts.invoke({
|
|
95
|
+
"text": "Hello, how are you today?",
|
|
96
|
+
"language": "en-us",
|
|
97
|
+
"voice_id": 147320,
|
|
98
|
+
"speech_model": "mars-flash", # or "mars-pro", "mars-instruct"
|
|
99
|
+
"speed": 1.0, # 0.5 to 2.0
|
|
100
|
+
"output_format": "file_path" # or "base64", "bytes"
|
|
101
|
+
})
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### Translation
|
|
105
|
+
|
|
106
|
+
```python
|
|
107
|
+
from langchain_camb import CambTranslationTool
|
|
108
|
+
|
|
109
|
+
translator = CambTranslationTool()
|
|
110
|
+
result = translator.invoke({
|
|
111
|
+
"text": "Hello, how are you?",
|
|
112
|
+
"source_language": 1, # English (en-us)
|
|
113
|
+
"target_language": 54, # Spanish (es-es)
|
|
114
|
+
"formality": 1 # 1=formal, 2=informal
|
|
115
|
+
})
|
|
116
|
+
print(result) # "Hola, ¿cómo está usted?"
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### Transcription
|
|
120
|
+
|
|
121
|
+
```python
|
|
122
|
+
from langchain_camb import CambTranscriptionTool
|
|
123
|
+
|
|
124
|
+
transcriber = CambTranscriptionTool()
|
|
125
|
+
result = transcriber.invoke({
|
|
126
|
+
"audio_url": "https://example.com/audio.mp3",
|
|
127
|
+
"language": 1 # English
|
|
128
|
+
})
|
|
129
|
+
# Returns JSON with text, segments, and speaker identification
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### Voice Cloning
|
|
133
|
+
|
|
134
|
+
```python
|
|
135
|
+
from langchain_camb import CambVoiceCloneTool
|
|
136
|
+
|
|
137
|
+
cloner = CambVoiceCloneTool()
|
|
138
|
+
result = cloner.invoke({
|
|
139
|
+
"voice_name": "My Custom Voice",
|
|
140
|
+
"audio_file_path": "/path/to/sample.wav", # 2+ seconds
|
|
141
|
+
"gender": 2, # 1=Male, 2=Female
|
|
142
|
+
"description": "A warm, friendly voice"
|
|
143
|
+
})
|
|
144
|
+
# Returns new voice_id to use with TTS
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### Text-to-Sound
|
|
148
|
+
|
|
149
|
+
```python
|
|
150
|
+
from langchain_camb import CambTextToSoundTool
|
|
151
|
+
|
|
152
|
+
sound_gen = CambTextToSoundTool()
|
|
153
|
+
result = sound_gen.invoke({
|
|
154
|
+
"prompt": "Upbeat electronic music with a driving beat",
|
|
155
|
+
"duration": 30,
|
|
156
|
+
"audio_type": "music" # or "sound"
|
|
157
|
+
})
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### Audio Separation
|
|
161
|
+
|
|
162
|
+
```python
|
|
163
|
+
from langchain_camb import CambAudioSeparationTool
|
|
164
|
+
|
|
165
|
+
separator = CambAudioSeparationTool()
|
|
166
|
+
result = separator.invoke({
|
|
167
|
+
"audio_file_path": "/path/to/mixed_audio.mp3"
|
|
168
|
+
})
|
|
169
|
+
# Returns JSON with paths to vocals and background audio
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
## Using the Toolkit
|
|
173
|
+
|
|
174
|
+
The `CambToolkit` bundles all tools and allows filtering:
|
|
175
|
+
|
|
176
|
+
```python
|
|
177
|
+
from langchain_camb import CambToolkit
|
|
178
|
+
|
|
179
|
+
# All tools
|
|
180
|
+
toolkit = CambToolkit()
|
|
181
|
+
tools = toolkit.get_tools()
|
|
182
|
+
|
|
183
|
+
# TTS-focused toolkit
|
|
184
|
+
tts_toolkit = CambToolkit(
|
|
185
|
+
include_tts=True,
|
|
186
|
+
include_voice_list=True,
|
|
187
|
+
include_translation=False,
|
|
188
|
+
include_transcription=False,
|
|
189
|
+
include_translated_tts=False,
|
|
190
|
+
include_voice_clone=False,
|
|
191
|
+
include_text_to_sound=False,
|
|
192
|
+
include_audio_separation=False,
|
|
193
|
+
)
|
|
194
|
+
|
|
195
|
+
# Translation-focused toolkit
|
|
196
|
+
translation_toolkit = CambToolkit(
|
|
197
|
+
include_tts=False,
|
|
198
|
+
include_translated_tts=True,
|
|
199
|
+
include_translation=True,
|
|
200
|
+
include_transcription=True,
|
|
201
|
+
include_voice_list=False,
|
|
202
|
+
include_voice_clone=False,
|
|
203
|
+
include_text_to_sound=False,
|
|
204
|
+
include_audio_separation=False,
|
|
205
|
+
)
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
## Language Codes
|
|
209
|
+
|
|
210
|
+
CAMB AI uses integer language codes. Common codes:
|
|
211
|
+
|
|
212
|
+
| Code | Language | BCP-47 |
|
|
213
|
+
|------|----------|--------|
|
|
214
|
+
| 1 | English (US) | en-us |
|
|
215
|
+
| 31 | German (Germany) | de-de |
|
|
216
|
+
| 54 | Spanish (Spain) | es-es |
|
|
217
|
+
| 76 | French (France) | fr-fr |
|
|
218
|
+
| 87 | Italian | it-it |
|
|
219
|
+
| 88 | Japanese | ja-jp |
|
|
220
|
+
| 94 | Korean | ko-kr |
|
|
221
|
+
| 108 | Dutch | nl-nl |
|
|
222
|
+
| 111 | Portuguese (Brazil) | pt-br |
|
|
223
|
+
| 114 | Russian | ru-ru |
|
|
224
|
+
| 139 | Chinese (Simplified) | zh-cn |
|
|
225
|
+
|
|
226
|
+
Use `client.languages.get_source_languages()` for the full list of 140+ languages.
|
|
227
|
+
|
|
228
|
+
For TTS, use BCP-47 codes like `"en-us"`, `"es-es"`, `"fr-fr"`.
|
|
229
|
+
|
|
230
|
+
## Configuration
|
|
231
|
+
|
|
232
|
+
### API Key
|
|
233
|
+
|
|
234
|
+
Set your API key via environment variable or parameter:
|
|
235
|
+
|
|
236
|
+
```python
|
|
237
|
+
# Environment variable
|
|
238
|
+
import os
|
|
239
|
+
os.environ["CAMB_API_KEY"] = "your-api-key"
|
|
240
|
+
|
|
241
|
+
# Or pass directly
|
|
242
|
+
tool = CambTTSTool(api_key="your-api-key")
|
|
243
|
+
toolkit = CambToolkit(api_key="your-api-key")
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
### Timeouts and Polling
|
|
247
|
+
|
|
248
|
+
For async operations (transcription, text-to-sound, etc.):
|
|
249
|
+
|
|
250
|
+
```python
|
|
251
|
+
tool = CambTranscriptionTool(
|
|
252
|
+
timeout=60.0, # HTTP request timeout
|
|
253
|
+
max_poll_attempts=60, # Max polling attempts
|
|
254
|
+
poll_interval=2.0, # Seconds between polls
|
|
255
|
+
)
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
## Agent Integration
|
|
259
|
+
|
|
260
|
+
### LangGraph ReAct Agent
|
|
261
|
+
|
|
262
|
+
```python
|
|
263
|
+
from langchain_camb import CambToolkit
|
|
264
|
+
from langchain_openai import ChatOpenAI
|
|
265
|
+
from langgraph.prebuilt import create_react_agent
|
|
266
|
+
|
|
267
|
+
toolkit = CambToolkit()
|
|
268
|
+
agent = create_react_agent(ChatOpenAI(model="gpt-4"), toolkit.get_tools())
|
|
269
|
+
|
|
270
|
+
# TTS
|
|
271
|
+
result = agent.invoke({
|
|
272
|
+
"messages": [{"role": "user", "content": "Say 'Hello world' in a friendly tone"}]
|
|
273
|
+
})
|
|
274
|
+
|
|
275
|
+
# Translation
|
|
276
|
+
result = agent.invoke({
|
|
277
|
+
"messages": [{"role": "user", "content": "Translate 'Good morning' to French and German"}]
|
|
278
|
+
})
|
|
279
|
+
|
|
280
|
+
# Transcription
|
|
281
|
+
result = agent.invoke({
|
|
282
|
+
"messages": [{"role": "user", "content": "Transcribe https://example.com/audio.mp3"}]
|
|
283
|
+
})
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
## Development
|
|
287
|
+
|
|
288
|
+
```bash
|
|
289
|
+
# Install dev dependencies
|
|
290
|
+
pip install -e ".[dev]"
|
|
291
|
+
|
|
292
|
+
# Run unit tests
|
|
293
|
+
pytest tests/unit/
|
|
294
|
+
|
|
295
|
+
# Run integration tests (requires CAMB_API_KEY)
|
|
296
|
+
CAMB_API_KEY=your-key pytest tests/integration/ -m integration
|
|
297
|
+
|
|
298
|
+
# Lint
|
|
299
|
+
ruff check .
|
|
300
|
+
|
|
301
|
+
# Type check
|
|
302
|
+
mypy langchain_camb/
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
## License
|
|
306
|
+
|
|
307
|
+
MIT
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
langchain_camb/__init__.py,sha256=S7r0ohLJv41r5526YflCo2nmmYoLJ0QRhn3gOjb0Blg,1935
|
|
2
|
+
langchain_camb/version.py,sha256=7EtB2_SBceTNBe8WDAqFol_HvwbXsmbQxgR66U5BitE,69
|
|
3
|
+
langchain_camb/toolkits/__init__.py,sha256=GPTYILnePtU7utUwbI9NVqgb5PfYflw72WjDKm10izI,123
|
|
4
|
+
langchain_camb/toolkits/camb_toolkit.py,sha256=-PenuVyBX-Al5FqyXoOSR2YQSDPM-njR6y4BrQGxgTQ,4202
|
|
5
|
+
langchain_camb/tools/__init__.py,sha256=qunsMGavyO_jvWlch0RiVQj2NpWhpHuHYrZyxciycXI,1250
|
|
6
|
+
langchain_camb/tools/audio_separation.py,sha256=GsrIPCrkDC588tVm2ctF4PD-vIG-xur9Kl4E8_lkSpw,6304
|
|
7
|
+
langchain_camb/tools/base.py,sha256=cFRQPbZ10jUlnE7MMMeMz6U8k34wJp5V2vd1yvfSKGY,5143
|
|
8
|
+
langchain_camb/tools/text_to_sound.py,sha256=EzBiEtXgdJMsgK5O1Zz-8mx_GglAUCjFPOcG6LmIuFA,4893
|
|
9
|
+
langchain_camb/tools/transcription.py,sha256=HeFjd4gLCyCiA8Bbg-3o2qet-VgP84J3gLQon5lhoak,6323
|
|
10
|
+
langchain_camb/tools/translated_tts.py,sha256=RKPDnqlvA8HKdHkpDxQxZIPDnKsR_mRFtgcDIhcsUeY,12056
|
|
11
|
+
langchain_camb/tools/translation.py,sha256=Ja8q3h7jMZDk_wx3Gcb5Npj4kAk5ChFJtcI68mSXl4E,4765
|
|
12
|
+
langchain_camb/tools/tts.py,sha256=J3WQvDtDv41k62OFcGqd8l5-avbmu-PbmZdeg-thB7A,5838
|
|
13
|
+
langchain_camb/tools/voice_clone.py,sha256=Ua-NjDzUTFmXyRqkGw5dHrU5FXZbTWwxJtByVABozUY,4410
|
|
14
|
+
langchain_camb/tools/voice_list.py,sha256=ov8a1SrOI94eZJiHght0o4-Gx22jxHYTU6g2bNJLcbg,3508
|
|
15
|
+
langchain_camb-0.1.0.dist-info/METADATA,sha256=6liWskzqX3i5Z43CbbU5DbS-DHXYUQeaGJ5YUymv488,7908
|
|
16
|
+
langchain_camb-0.1.0.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
17
|
+
langchain_camb-0.1.0.dist-info/RECORD,,
|