feat: Implement Text-to-Speech (TTS) functionality with API endpoints, models, and service integration
This commit is contained in:
38
app/services/tts/base.py
Normal file
38
app/services/tts/base.py
Normal file
@@ -0,0 +1,38 @@
|
||||
"""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."""
|
||||
Reference in New Issue
Block a user