File size: 1,490 Bytes
71905d8
 
94fd4b0
71905d8
 
 
 
 
 
 
94fd4b0
71905d8
 
 
94fd4b0
71905d8
 
 
 
94fd4b0
 
 
71905d8
 
 
 
 
 
94fd4b0
71905d8
94fd4b0
71905d8
94fd4b0
 
 
 
71905d8
94fd4b0
 
71905d8
 
 
94fd4b0
 
71905d8
 
 
 
94fd4b0
71905d8
 
 
 
 
 
 
 
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
"""
Simple startup script for C-3PO TTS API
"""

import os
import sys
import logging

# Configure logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)

def setup_environment():
    """Set up required environment variables"""
    os.environ["COQUI_TOS_AGREED"] = "1"
    os.environ["HF_HUB_DISABLE_TELEMETRY"] = "1"
    logger.info("🌍 Environment configured")

def start_api():
    """Start the C-3PO TTS API"""
    logger.info("πŸ€– Starting C-3PO TTS API...")
    
    try:
        import uvicorn
        from coqui_api import app
        
        logger.info("🎭 C-3PO TTS API starting on http://localhost:7860")
        logger.info("πŸ“– API documentation: http://localhost:7860/docs")
        
        uvicorn.run(app, host="0.0.0.0", port=7860, log_level="info")
        
    except ImportError as e:
        logger.error(f"❌ Missing dependency: {e}")
        logger.info("πŸ’‘ Install with: pip install -r requirements.txt")
        sys.exit(1)
    except Exception as e:
        logger.error(f"❌ Failed to start API: {e}")
        sys.exit(1)

def main():
    """Main startup sequence"""
    print("πŸ€– C-3PO TTS API")
    print("=" * 30)
    
    setup_environment()
    
    try:
        start_api()
    except KeyboardInterrupt:
        logger.info("\nπŸ›‘ Server stopped by user")
    except Exception as e:
        logger.error(f"❌ Server error: {e}")
        sys.exit(1)

if __name__ == "__main__":
    main()