TTS (tts/cartesia.py)

Patter · libraries/python/getpatter/tts/cartesia.py · python · MIT
voice, Voice / Speech

Cartesia TTS for Patter pipeline mode.

# Source: https://github.com/PatterAI/Patter | License: MIT | Copyright 2026 Patter Contributors
# Provided via justclaw.it.com; keep this notice with the code.
"""Cartesia TTS for Patter pipeline mode."""

from __future__ import annotations

import os
from typing import ClassVar, Optional

from getpatter.providers.cartesia_tts import CartesiaTTS as _CartesiaTTS

__all__ = ["TTS"]


def _resolve_api_key(api_key: str | None) -> str:
    key = api_key or os.environ.get("CARTESIA_API_KEY")
    if not key:
        raise ValueError(
            "Cartesia TTS requires an api_key. Pass api_key='...' or "
            "set CARTESIA_API_KEY in the environment."
        )
    return key


class TTS(_CartesiaTTS):
    """Cartesia HTTP TTS (``sonic-3`` GA, ~90 ms TTFB).

    The default model is ``soni

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key