Spaces:
Running on Zero
Running on Zero
File size: 1,485 Bytes
ffe9fdb 03cad88 ffe9fdb 5b481bb ffe9fdb 34086c6 ffe9fdb 34086c6 ffe9fdb 03cad88 ffe9fdb | 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 | #!/usr/bin/env python3
"""
HuggingFace Spaces entry point for Voice Tools.
This file serves as the main entry point when deploying to HuggingFace Spaces
with ZeroGPU support.
"""
# CRITICAL: Import spaces BEFORE any torch/CUDA imports for ZeroGPU
try:
import spaces
except ImportError:
pass # Not on Spaces, spaces package not available
import os
import sys
from pathlib import Path
# Add src directory to Python path BEFORE any imports
root_dir = Path(__file__).parent
src_dir = root_dir / "src"
# Insert at beginning of path to ensure our modules are found first
if str(src_dir.parent) not in sys.path:
sys.path.insert(0, str(src_dir.parent))
# Set up logging
import logging
logging.basicConfig(
level=logging.INFO, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s"
)
logger = logging.getLogger(__name__)
# Log environment information
from src.config.gpu_config import GPUConfig
logger.info("Voice Tools starting on HuggingFace Spaces")
logger.info(f"Environment: {GPUConfig.get_environment_type()}")
logger.info(f"GPU Available: {GPUConfig.GPU_AVAILABLE}")
logger.info(f"ZeroGPU Mode: {GPUConfig.IS_ZEROGPU}")
# Import and launch the Gradio app
from src.web.app import create_app
if __name__ == "__main__":
app = create_app()
# Launch with appropriate settings for HuggingFace Spaces
app.queue() # Enable queue for ZeroGPU
app.launch(
server_name="0.0.0.0",
server_port=7860,
show_error=True,
)
|