- Expanded package inclusion in `pyproject.toml` to support new modules. - Introduced new `adapters` and `protocol` packages for better organization. - Added backend adapter implementations for control plane integration. - Updated main application imports to reflect new package structure. - Removed deprecated core components and adjusted documentation accordingly. - Enhanced architecture documentation to clarify the new runtime and integration layers.
42 lines
1.1 KiB
Python
42 lines
1.1 KiB
Python
"""TTS extension port contracts."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from dataclasses import dataclass
|
|
from typing import AsyncIterator, Optional, Protocol
|
|
|
|
from providers.common.base import TTSChunk
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
class TTSServiceSpec:
|
|
"""Resolved runtime configuration for TTS service creation."""
|
|
|
|
provider: str
|
|
voice: str
|
|
sample_rate: int
|
|
speed: float = 1.0
|
|
api_key: Optional[str] = None
|
|
api_url: Optional[str] = None
|
|
model: Optional[str] = None
|
|
mode: str = "commit"
|
|
|
|
|
|
class TTSPort(Protocol):
|
|
"""Port for speech synthesis providers."""
|
|
|
|
async def connect(self) -> None:
|
|
"""Establish connection to TTS provider."""
|
|
|
|
async def disconnect(self) -> None:
|
|
"""Release TTS resources."""
|
|
|
|
async def synthesize(self, text: str) -> bytes:
|
|
"""Synthesize complete PCM payload for text."""
|
|
|
|
async def synthesize_stream(self, text: str) -> AsyncIterator[TTSChunk]:
|
|
"""Stream synthesized PCM chunks for text."""
|
|
|
|
async def cancel(self) -> None:
|
|
"""Cancel an in-flight synthesis request."""
|