Spaces:
Sleeping
Sleeping
Refactor application structure: rename 'models' directory to 'db_models', update import paths across multiple files, and enhance Dockerfile to create and populate the new directory, improving organization and clarity in the codebase.
df50c8c
| """ | |
| Database models for the TTS API. | |
| """ | |
| from datetime import datetime | |
| from sqlalchemy import Column, Integer, String, DateTime, Float, Text, JSON, Boolean | |
| from sqlalchemy.ext.declarative import declarative_base | |
| Base = declarative_base() | |
| class Audiobook(Base): | |
| """Model for storing audiobook information.""" | |
| __tablename__ = 'audiobooks' | |
| id = Column(String(36), primary_key=True) | |
| title = Column(String(255), nullable=False) | |
| author = Column(String(255)) | |
| voice_id = Column(String(50), nullable=False) | |
| status = Column(String(20), nullable=False, default='pending') # pending, processing, completed, failed | |
| created_at = Column(DateTime, nullable=False, default=datetime.utcnow) | |
| updated_at = Column(DateTime, nullable=False, default=datetime.utcnow, onupdate=datetime.utcnow) | |
| duration = Column(Float) # Duration in seconds | |
| file_path = Column(String(255)) # Path to the audio file | |
| error = Column(Text) # Error message if status is 'failed' | |
| metadata = Column(JSON) # Additional metadata | |
| class Voice(Base): | |
| """Model for storing voice information.""" | |
| __tablename__ = 'voices' | |
| id = Column(String(36), primary_key=True) | |
| name = Column(String(255), nullable=False) | |
| type = Column(String(50), nullable=False) # standard, cloned | |
| speaker_id = Column(Integer) | |
| created_at = Column(DateTime, nullable=False, default=datetime.utcnow) | |
| is_active = Column(Boolean, default=True) | |
| metadata = Column(JSON) # Store voice-specific settings and data | |
| class AudioCache(Base): | |
| """Model for caching generated audio.""" | |
| __tablename__ = 'audio_cache' | |
| id = Column(String(36), primary_key=True) | |
| hash = Column(String(64), nullable=False, unique=True) # Hash of input parameters | |
| format = Column(String(10), nullable=False) # Audio format (mp3, wav, etc.) | |
| created_at = Column(DateTime, nullable=False, default=datetime.utcnow) | |
| file_path = Column(String(255), nullable=False) | |
| metadata = Column(JSON) # Store generation parameters |