Run uv pip install cartesia to install the dependencies.
Copy
Ask AI
from agno.agent import Agentfrom agno.tools.cartesia import CartesiaToolsfrom agno.utils.audio import write_audio_to_file# ---------------------------------------------------------------------------# Create Agent# ---------------------------------------------------------------------------# Initialize Agent with Cartesia toolsagent = Agent( name="Cartesia TTS Agent", description="An agent that uses Cartesia for text-to-speech.", tools=[CartesiaTools()],)# ---------------------------------------------------------------------------# Run Agent# ---------------------------------------------------------------------------if __name__ == "__main__": response = agent.run( """Generate a simple greeting using Text-to-Speech: Say "Welcome to Cartesia, the advanced speech synthesis platform. This speech is generated by an agent." """ ) # Save the generated audio if response.audio: write_audio_to_file( audio=response.audio[0].content, filename="tmp/greeting.mp3" )