| |
| """ |
| VYNL Local Configuration |
| Environment detection and configuration for local vs HuggingFace deployment |
| """ |
|
|
| import os |
| import sys |
| from pathlib import Path |
|
|
| |
| |
| |
|
|
| def is_huggingface_space(): |
| """Check if running on HuggingFace Spaces""" |
| return os.environ.get('SPACE_ID') is not None |
|
|
| def is_gpu_available(): |
| """Check if GPU is available""" |
| try: |
| import torch |
| return torch.cuda.is_available() |
| except ImportError: |
| return False |
|
|
| def get_device(): |
| """Get the compute device""" |
| if is_gpu_available(): |
| import torch |
| return torch.device('cuda') |
| return 'cpu' |
|
|
| |
| |
| |
|
|
| def get_output_dir(): |
| """Get output directory""" |
| if is_huggingface_space(): |
| import tempfile |
| return Path(tempfile.gettempdir()) / 'vynl_output' |
| else: |
| return Path(os.environ.get('VYNL_OUTPUT_DIR', Path.cwd() / 'output')) |
|
|
| def get_catalog_dir(): |
| """Get catalog directory""" |
| return Path(os.environ.get('VYNL_CATALOG_DIR', Path.home() / '.vynl_catalog')) |
|
|
| def get_models_dir(): |
| """Get models directory""" |
| return Path(os.environ.get('VYNL_MODELS_DIR', Path.home() / '.vynl_models')) |
|
|
| |
| |
| |
|
|
| class Config: |
| """VYNL Configuration""" |
|
|
| IS_HF_SPACE = is_huggingface_space() |
| HAS_GPU = is_gpu_available() |
| DEVICE = get_device() |
|
|
| OUTPUT_DIR = get_output_dir() |
| CATALOG_DIR = get_catalog_dir() |
| MODELS_DIR = get_models_dir() |
|
|
| |
| OUTPUT_DIR.mkdir(parents=True, exist_ok=True) |
| CATALOG_DIR.mkdir(parents=True, exist_ok=True) |
| MODELS_DIR.mkdir(parents=True, exist_ok=True) |
|
|
| |
| ENABLE_AUDIOCRAFT = True |
| ENABLE_RVC = True |
| ENABLE_DEMUCS = True |
|
|
| |
| MAX_DURATION_SECONDS = 600 |
| MAX_FILE_SIZE_MB = 100 |
|
|
| @classmethod |
| def print_status(cls): |
| """Print configuration status""" |
| print(f"VYNL Configuration:") |
| print(f" Environment: {'HuggingFace Space' if cls.IS_HF_SPACE else 'Local'}") |
| print(f" GPU Available: {cls.HAS_GPU}") |
| print(f" Device: {cls.DEVICE}") |
| print(f" Output Dir: {cls.OUTPUT_DIR}") |
| print(f" Catalog Dir: {cls.CATALOG_DIR}") |
| print(f" Models Dir: {cls.MODELS_DIR}") |
|
|
| if __name__ == "__main__": |
| Config.print_status() |
|
|