#!/bin/bash # Startup script that installs dependencies and starts the Vosk service echo "๐Ÿš€ Starting Vosk service with automatic dependency installation..." # Check if we're in the right directory if [ ! -f "app_optimized.py" ]; then echo "โŒ Please run this script from the vosk_service directory" exit 1 fi # Install dependencies if needed echo "๐Ÿ“ฆ Checking and installing dependencies..." # Check if Flask is installed if ! python -c "import flask" 2>/dev/null; then echo "โš ๏ธ Flask not found. Installing dependencies..." # Install core dependencies pip install vosk>=0.3.45 pip install Flask>=2.3.0 pip install soundfile>=0.12.1 pip install aiohttp>=3.8.0 pip install gunicorn>=21.0.0 pip install numpy>=1.24.0 pip install requests>=2.31.0 echo "โœ… Dependencies installed!" else echo "โœ… Dependencies already installed!" fi # Test imports echo "๐Ÿงช Testing imports..." python -c " try: import flask import aiohttp import gunicorn import vosk import soundfile import numpy import requests print('โœ… All modules imported successfully!') except ImportError as e: print(f'โŒ Import error: {e}') exit(1) " if [ $? -ne 0 ]; then echo "โŒ Import test failed. Please check your Python environment." exit 1 fi # Start the service echo "๐ŸŽฏ Starting Vosk service..." # Choose the startup method if [ "$USE_GUNICORN" = "true" ]; then echo "๐Ÿš€ Starting with Gunicorn (production mode)..." gunicorn -c gunicorn_config.py app_optimized:app elif [ "$USE_ASYNC" = "true" ]; then echo "โšก Starting async service..." python start_service.py else echo "๐ŸŒ Starting Flask service..." python start_service.py fi