#!/usr/bin/env python3 """ Simple startup script for Vosk service that handles Flask configuration properly. """ import os import sys from app_optimized import app, load_model def main(): """Start the Vosk service with proper configuration""" # Load the model first print("Loading Vosk model...") load_model() # Determine the mode to run in use_async = os.getenv('USE_ASYNC', 'false').lower() == 'true' use_gunicorn = os.getenv('USE_GUNICORN', 'false').lower() == 'true' if use_async: print("Starting async aiohttp service...") from aiohttp import web from app_optimized import create_async_app app_async = create_async_app() web.run_app(app_async, host='0.0.0.0', port=5000) elif use_gunicorn: print("Starting with Gunicorn (production mode)...") # Gunicorn will handle the app app.run(host='0.0.0.0', port=5000) else: print("Starting Flask service with threading...") # Use threading only (no multiprocessing in Flask) app.run(host='0.0.0.0', port=5000, threaded=True) if __name__ == '__main__': main()