Spaces:
Building
Building
""" | |
TTS Interface for Flare | |
""" | |
from abc import ABC, abstractmethod | |
from typing import Optional, Dict, Any, Set | |
from datetime import datetime | |
import sys | |
class TTSInterface(ABC): | |
"""Abstract base class for TTS providers""" | |
def __init__(self): | |
self.preprocessing_flags: Set[str] = set() | |
self.supports_ssml: bool = False | |
async def synthesize(self, text: str, voice_id: Optional[str] = None, **kwargs) -> bytes: | |
""" | |
Convert text to speech and return audio bytes | |
Args: | |
text: Text to convert to speech | |
voice_id: Optional voice ID specific to the provider | |
**kwargs: Additional provider-specific parameters | |
Returns: | |
Audio data as bytes (MP3 or WAV format) | |
""" | |
pass | |
def get_supported_voices(self) -> Dict[str, str]: | |
"""Get list of supported voices""" | |
pass | |
def get_provider_name(self) -> str: | |
"""Get provider name for logging""" | |
pass | |
def get_preprocessing_flags(self) -> Set[str]: | |
"""Get preprocessing flags for this provider""" | |
return self.preprocessing_flags | |
def supports_ssml_format(self) -> bool: | |
"""Check if provider supports SSML""" | |
return self.supports_ssml |