Feat/cartesia integration fixes#2496
Feat/cartesia integration fixes#2496dirkbrnd merged 8 commits intoagno-agi:feat/cartesia-integrationfrom
Conversation
cookbook/tools/cartesia_tools.py
Outdated
| from dotenv import load_dotenv | ||
|
|
||
| # Get Cartesia API key from environment or use a default for demo | ||
| cartesia_api_key = os.environ.get("CARTESIA_API_KEY", "sk_car_4y7Jz9aKsF6VeLpBKzKwJ") |
There was a problem hiding this comment.
Your API key will get leaked
cookbook/tools/cartesia_tools.py
Outdated
| Example script for using the Cartesia toolkit with an Agno agent for text-to-speech generation. | ||
| """ | ||
|
|
There was a problem hiding this comment.
We usually add setup steps at the top for that tool
libs/agno/agno/tools/cartesia.py
Outdated
| self.client = Cartesia(api_key=self.api_key) | ||
|
|
||
| # Set default output directory for audio files | ||
| self.output_dir = os.path.join(os.getcwd(), "cartesia_output") |
libs/agno/agno/tools/cartesia.py
Outdated
| self.client = Cartesia(api_key=self.api_key) | ||
|
|
||
| # Set default output directory for audio files | ||
| self.output_dir = os.path.join(os.getcwd(), "tmp/cartesia") |
There was a problem hiding this comment.
Please use from pathlib import Path instead of os.path
There was a problem hiding this comment.
made the change
cookbook/tools/cartesia_tools.py
Outdated
| - Set the following environment variable: | ||
| export CARTESIA_API_KEY="your_api_key" | ||
| import os | ||
| import sys |
There was a problem hiding this comment.
Do we need to import these two libraries entirely?
There was a problem hiding this comment.
made the change
| # ) | ||
|
|
||
| # Example 5: Stream TTS - Generate speech with streaming capabilities | ||
| agent.print_response( |
There was a problem hiding this comment.
Please comment out the first example, this looks odd
libs/agno/agno/tools/cartesia.py
Outdated
| import json | ||
| from os import getenv | ||
| from typing import Dict, List, Optional, Any | ||
| import os |
cookbook/tools/cartesia_tools.py
Outdated
| cartesia_api_key = os.environ.get("CARTESIA_API_KEY") | ||
| load_dotenv() |
There was a problem hiding this comment.
Don't need either of these
libs/agno/agno/tools/cartesia.py
Outdated
| output_format_bit_rate: int = 128000, | ||
| output_format_encoding: str = None, | ||
| output_path: str = None, | ||
| **kwargs, |
There was a problem hiding this comment.
We can't have kwargs. How would the model know what to pass?
libs/agno/agno/tools/cartesia.py
Outdated
| output_format_sample_rate: int = 44100, | ||
| output_format_bit_rate: int = 128000, | ||
| output_format_encoding: str = None, | ||
| **kwargs, |
| logger.error(f"Error saving audio data: {e}") | ||
| return json.dumps({"error": str(e)}) | ||
|
|
||
| def text_to_speech_stream( |
There was a problem hiding this comment.
What is the difference with this function? It still just dumps everything?
There was a problem hiding this comment.
Cartesia basically has 3 different text-to-speech options: https://docs.cartesia.ai/2024-06-10/api-reference/tts/bytes. I have added all of them. We might need them later when we build advanced agents / apps
Description
Fixes # (issue)
Type of change
Please check the options that are relevant:
Checklist
./scripts/format.shand./scripts/validate.shto ensure code is formatted and linted.Additional Notes
Include any deployment notes, performance implications, security considerations, or other relevant information (e.g., screenshots or logs if applicable).