Spaces:
Running
Running
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""" | |
| def name(self): | |
| """Return the name of the model""" | |
| pass | |
| def description(self): | |
| """Return the description of the model""" | |
| pass | |
| def initialize(self): | |
| """Initialize the model""" | |
| pass | |
| class TTSModel(BaseModel): | |
| """Abstract base class for Text-to-Speech models""" | |
| 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""" | |
| 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"] |