Michael Hu
refactor: replace inline model definitions with ModelFactory and remove unused imports
ef4db28
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"]