Use this file to discover all available pages before exploring further.
CAMB AI provides multilingual audio and localization services supporting 140+ languages, including text-to-speech, translation, transcription, voice cloning, and audio generation.
import getpassimport osif "CAMB_API_KEY" not in os.environ: os.environ["CAMB_API_KEY"] = getpass.getpass("Enter your CAMB API key: ")
It’s also helpful (but not needed) to set up LangSmith for best-in-class observability/ of your tool calls. To enable automated tracing, set your LangSmith API key:
os.environ["LANGSMITH_API_KEY"] = getpass.getpass("Enter your LangSmith API key: ")os.environ["LANGSMITH_TRACING"] = "true"
Generate speech from text in multiple languages with different voices and speeds:
from langchain_camb import CambTTSTool, CambVoiceListTool# First, list available voicesvoice_list = CambVoiceListTool()voices = voice_list.invoke({})print(f"Available voices: {voices[:500]}...")# Create TTS tooltts = CambTTSTool()# Generate speech in Englishenglish_audio = tts.invoke({ "text": "Hello! Welcome to CAMB AI. We support over 140 languages for text to speech.", "language": "en-us", "voice_id": 147320, "speech_model": "mars-flash", # or "mars-pro", "mars-instruct" "output_format": "file_path",})print(f"English audio saved to: {english_audio}")# Generate speech in Spanishspanish_audio = tts.invoke({ "text": "¡Hola! Bienvenido a CAMB AI. Soportamos más de 140 idiomas.", "language": "es-es", "voice_id": 147320, "output_format": "file_path",})print(f"Spanish audio saved to: {spanish_audio}")# Generate with different speed (0.5 to 2.0)slow_audio = tts.invoke({ "text": "This is spoken slowly for clarity.", "language": "en-us", "voice_id": 147320, "speed": 0.7, "output_format": "file_path",})print(f"Slow audio saved to: {slow_audio}")
Clone a voice from a short audio sample (2+ seconds) and use it for TTS:
from langchain_camb import CambVoiceCloneTool, CambTTSToolvoice_clone = CambVoiceCloneTool()tts = CambTTSTool()# Step 1: Clone a voice from an audio sample (requires 2+ seconds)clone_result = voice_clone.invoke({ "voice_name": "My Custom Voice", "audio_file_path": "/path/to/voice_sample.wav", "gender": 2, # 1=Male, 2=Female "description": "A warm, friendly voice for customer service",})print(f"Voice cloned! New voice ID: {clone_result}")# Step 2: Use the cloned voice for TTScloned_voice_id = clone_result # The returned voice IDaudio = tts.invoke({ "text": "Hello! This is my cloned voice speaking.", "language": "en-us", "voice_id": cloned_voice_id, "output_format": "file_path",})print(f"Audio generated: {audio}")
You can use CAMB AI tools with a LangGraph agent to create powerful multilingual AI assistants:
from langchain_camb import CambToolkitfrom langchain_google_genai import ChatGoogleGenerativeAIfrom langchain.agents import create_agent# Create the toolkit with all CAMB AI toolstoolkit = CambToolkit()tools = toolkit.get_tools()print(f"Available tools: {[t.name for t in tools]}")# Create the agentllm = ChatGoogleGenerativeAI(model="gemini-2.0-flash")agent = create_agent(llm, tools)# Generate speechresult = agent.invoke({ "messages": [{"role": "user", "content": "Say 'Hello world' in English using text-to-speech"}]})print(f"Agent response: {result['messages'][-1].content}")# Translate textresult = agent.invoke({ "messages": [{"role": "user", "content": "Translate 'I love programming' to Spanish and French"}]})print(f"Agent response: {result['messages'][-1].content}")# Complex multi-step taskresult = agent.invoke({ "messages": [{ "role": "user", "content": """ I need to create a multilingual greeting for my app: 1. First, find a good voice to use 2. Then translate "Welcome to our app!" to Spanish 3. Generate audio of that Spanish greeting """ }]})print(f"Agent response: {result['messages'][-1].content}")