prepare_tts_text (tts/__init__.py)

ccgram · src/ccgram/tts/__init__.py · python · MIT
voice

Utility for preparing TTS text and factory for speech synthesizers, supporting Edge and OpenAI providers.

# Source: https://github.com/alexei-led/ccgram | License: MIT | Copyright 2026 Alexei Ledenev
# Provided via justclaw.it.com; keep this notice with the code.
"""TTS subpackage — text-to-speech synthesis providers.

Public re-exports, shared text-preparation utility, and provider factory.
"""

from __future__ import annotations

import os
import re
from typing import Callable, Iterable

# ccgram.config only imports stdlib + dotenv + utils — no cycle risk.
from ccgram.config import config
from .base import SpeechSynthesizer, TtsAudio, TtsSynthesisError

_PAGINATION_RE = re.compile(r"\n\n\[\d+/\d+\]$")
_USER_PREFIX = "\U0001f464 "


def _make_edge() -> SpeechSynthesizer:
    # Lazy: optional dep; only load edge_tts when provider=edge
    from .edge import EdgeTtsSynthesizer

    return EdgeTt

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

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

Get a free API key