Files
sdb2-backend/app/services/tts/base.py

38 lines
1006 B
Python

"""Base TTS provider interface."""
from abc import ABC, abstractmethod
from typing import Any
class TTSProvider(ABC):
"""Abstract base class for TTS providers."""
@abstractmethod
async def generate_speech(self, text: str, **options: Any) -> bytes:
"""Generate speech from text with provider-specific options.
Args:
text: The text to convert to speech
**options: Provider-specific options
Returns:
Audio data as bytes
"""
@abstractmethod
def get_supported_languages(self) -> list[str]:
"""Return list of supported language codes."""
@abstractmethod
def get_option_schema(self) -> dict[str, Any]:
"""Return schema for provider-specific options."""
@property
@abstractmethod
def name(self) -> str:
"""Return the provider name."""
@property
@abstractmethod
def file_extension(self) -> str:
"""Return the default file extension for this provider."""