42 lines
1.1 KiB
Python
42 lines
1.1 KiB
Python
"""Base TTS provider interface."""
|
|
|
|
from abc import ABC, abstractmethod
|
|
|
|
# Type alias for TTS options
|
|
TTSOptions = dict[str, str | bool | int | float]
|
|
|
|
|
|
class TTSProvider(ABC):
|
|
"""Abstract base class for TTS providers."""
|
|
|
|
@abstractmethod
|
|
async def generate_speech(self, text: str, **options: str | bool | float) -> 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, dict[str, str | list[str] | bool]]:
|
|
"""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."""
|