voice-tools / app.py
jcudit's picture
jcudit HF Staff
refactor: rename Voice Profiler to Voice Tools throughout codebase
03cad88
#!/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,
)