File size: 1,375 Bytes
f563475
312aa6f
f563475
 
b861704
f563475
 
 
 
 
 
d6da344
 
 
 
f563475
 
312aa6f
 
 
 
 
 
 
 
 
 
 
f563475
 
 
 
 
 
d6da344
312aa6f
 
 
 
 
d6da344
 
b861704
d6da344
b861704
d6da344
312aa6f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
"""
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
        
    @abstractmethod
    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
    
    @abstractmethod
    def get_supported_voices(self) -> Dict[str, str]:
        """Get list of supported voices"""
        pass
    
    @abstractmethod
    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