Skip to main content

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


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)

Uploaded Source

Built Distribution

cartesia-0.0.2-py2.py3-none-any.whl (6.0 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page