"""TTS provider protocol + supporting dataclasses."""
from __future__ import annotations
from dataclasses import dataclass, field
from pathlib import Path
from typing import Any, Iterable, Protocol, runtime_checkable
[docs]
@dataclass(slots=True)
class AudioClip:
"""A rendered audio clip, on disk or in memory."""
path: Path | None = None
bytes_: bytes | None = None
duration: float = 0.0
sample_rate: int = 44100
channels: int = 1
voice_id: str | None = None
transcript: str | None = None
[docs]
@runtime_checkable
class TTSProvider(Protocol):
"""Text-to-speech provider."""
name: str
[docs]
def synthesize(self, text: str, voice_id: str, **kw: Any) -> AudioClip:
"""Render ``text`` in ``voice_id``'s voice. Returns an AudioClip."""
[docs]
def list_voices(self) -> Iterable[VoiceMeta]:
"""Return all voices the provider exposes."""