Skip to main content

Cartesia Text-to-Speech Plugin

High-quality Text-to-Speech (TTS) plugin for GetStream backed by the Cartesia Sonic model. It lets a Python process speak PCM audio into a Stream call.

Installation

Install from PyPI (installs both getstream and the Cartesia SDK):

pip install "getstream-plugins-cartesia[webrtc]"

If you already have the Stream SDK in your project just add the Cartesia plugin:

pip install cartesia getstream-plugins-cartesia

Usage

from getstream.plugins.cartesia import CartesiaTTS
from getstream.video.rtc.audio_track import AudioStreamTrack

async def speak():
    # Option A: read key from env var (CARTESIA_API_KEY)
    tts = CartesiaTTS()

    # Option B: pass explicitly
    # tts = CartesiaTTS(api_key="<your key>")

    # Audio MUST be 16-kHz, 16-bit PCM (matches Cartesia Sonic model)
    track = AudioStreamTrack(framerate=16000)
    tts.set_output_track(track)

    # Listen for every raw PCM chunk that gets produced
    @tts.on("audio")
    def _on_audio(chunk: bytes, user):
        print("🔊 got", len(chunk), "bytes of audio")

    await tts.send("Hello from Cartesia!")

# Run inside an event-loop, e.g. `asyncio.run(speak())`

Configuration Options

  • api_key (str, optional) – Cartesia API key (falls back to CARTESIA_API_KEY).
  • model_id (str) – Which model to hit ("sonic-2" by default).
  • voice_id (str | None) – Cartesia voice to use (pass None for model default).
  • sample_rate (int) – Target sample-rate in Hz. Must match the AudioStreamTrack.framerate you attach (defaults to 16000). If they don't match a TypeError is raised early so you don't get distorted audio on the call.

Events emitted:

• audio – each raw PCM chunk, arguments: chunk: bytes, user: dict | None

• error – any exception raised during synthesis

Requirements

  • Python 3.10+
  • cartesia>=2.0.5 (automatically installed)

Testing

Run the offline unit-tests:

pytest -q getstream/plugins/cartesia/tests

To additionally exercise the live Cartesia API set CARTESIA_API_KEY in your environment; the integration test will be executed automatically.


💡 See examples/tts_cartesia/ for a fully-working bot that joins a Stream call and greets participants using this plugin.

Metadata

Release files for getstream-plugins-cartesia 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for getstream-plugins-cartesia 0.1.0
File Interpreter ABI Platform Actions
getstream_plugins_cartesia-0.1.0-py3-none-any.whl Python 3 none any Details for getstream_plugins_cartesia-0.1.0-py3-none-any.whl

Release files / getstream_plugins_cartesia-0.1.0-py3-none-any.whl

Download URL getstream_plugins_cartesia-0.1.0-py3-none-any.whl
Size 7.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2475bb3d3b00459900deffb2656e4cfef08ee152c9e39e283d5a36b6b0459bc6
BLAKE2b-256 checksum
How to use checksums
01726b8a9776a3c489bcc2f50dd0abcc4f6d68220c0bb6a4a3c31c7dc4e12bbf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.3

Security for getstream-plugins-cartesia 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page