amith33/voice_agent
0
1"""2Main entry point for Hugging Face Spaces3This file ensures the FastAPI app is properly exposed4"""5 6import os7import logging8from pathlib import Path9 10# Configure logging11logging.basicConfig(level=logging.INFO)12logger = logging.getLogger(__name__)13 14def setup_environment():15 """Setup the environment for Hugging Face Spaces"""16 logger.info("Setting up Hugging Face Spaces environment...")17 18 # Create necessary directories19 base_dirs = [20 "outputs",21 "/tmp/static_uploads",22 "/tmp/static_presets", 23 "/tmp/static_results"24 ]25 26 for dir_path in base_dirs:27 try:28 Path(dir_path).mkdir(parents=True, exist_ok=True)29 logger.info(f"Created directory: {dir_path}")30 except Exception as e:31 logger.warning(f"Could not create directory {dir_path}: {e}")32 33 logger.info("Environment setup completed")34 35def main():36 """Main entry point for Hugging Face Spaces"""37 logger.info("Starting Voice Agent Project on Hugging Face Spaces...")38 39 # Setup environment40 setup_environment()41 42 # Import and start the FastAPI app43 from app import app44 45 # Start the server46 import uvicorn47 48 # Get configuration from environment49 host = os.environ.get("HOST", "0.0.0.0")50 port = int(os.environ.get("PORT", 8000))51 52 logger.info(f"Starting server on {host}:{port}")53 54 uvicorn.run(55 app,56 host=host,57 port=port,58 log_level="info"59 )60 61if __name__ == "__main__":62 main() 