The official Python library for the Cartesia API.
Project description
Cartesia Python API Library
The official Cartesia Python library which provides convenient access to the Cartesia REST and Websocket API from any Python 3.8+ application.
Note: This API is still in alpha. Please expect breaking changes and report any issues you encounter.
Installation
pip install cartesia
# pip install in editable mode w/ dev dependencies
pip install -e '.[dev]'
Usage
from cartesia.tts import CartesiaTTS
from IPython.display import Audio
client = CartesiaTTS(api_key=os.environ.get("CARTESIA_API_KEY"))
voices = client.get_voices()
embedding = voices["Milo"]["embedding"]
transcript = "Hello! Welcome to Cartesia"
# No streaming
output = client.generate(transcript=transcript, voice=embedding)
Audio(output["audio"], rate=output["sampling_rate"])
# Streaming
for output in client.generate(transcript=transcript, voice=embedding, stream=True):
arr = output["audio"] # a numpy array
rate = output["sampling_rate"]
We recommend using python-dotenv
to add CARTESIA_API_KEY="my-api-key"
to your .env file so that your API Key is not stored in the source code.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
cartesia-0.0.2.tar.gz
(9.1 kB
view hashes)
Built Distribution
Close
Hashes for cartesia-0.0.2-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3d9e36104e97485caec3b7cfca1954898792c263b29d773b961b267e056c1d46 |
|
MD5 | dcf020e7490981a360ef4ae5a82ce798 |
|
BLAKE2b-256 | 2b862b11423643b001ceb7ab870c0085c72d9ae28bb611a4ad1fc71bc7fcdf88 |