File size: 1,937 Bytes
ef4db28
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
from abc import ABC, abstractmethod
import tempfile
import os

class BaseModel(ABC):
    """Base abstract class for all models"""
    
    @property
    @abstractmethod
    def name(self):
        """Return the name of the model"""
        pass
    
    @property
    @abstractmethod
    def description(self):
        """Return the description of the model"""
        pass
    
    @abstractmethod
    def initialize(self):
        """Initialize the model"""
        pass

class TTSModel(BaseModel):
    """Abstract base class for Text-to-Speech models"""
    
    @abstractmethod
    def generate_speech(self, text, **kwargs):
        """
        Generate speech from text
        
        Args:
            text (str): Text to convert to speech
            **kwargs: Additional model-specific parameters
            
        Returns:
            str: Path to the generated audio file
        """
        pass
    
    def supports_voice_cloning(self):
        """Whether the model supports voice cloning"""
        return False
    
    def supports_multilingual(self):
        """Whether the model supports multiple languages"""
        return False
    
    def get_supported_languages(self):
        """Get list of supported languages"""
        return ["English"]

class STTModel(BaseModel):
    """Abstract base class for Speech-to-Text models"""
    
    @abstractmethod
    def transcribe(self, audio_path, **kwargs):
        """
        Transcribe speech to text
        
        Args:
            audio_path (str): Path to the audio file
            **kwargs: Additional model-specific parameters
            
        Returns:
            str: Transcribed text
        """
        pass
    
    def supports_multilingual(self):
        """Whether the model supports multiple languages"""
        return False
    
    def get_supported_languages(self):
        """Get list of supported languages"""
        return ["English"]