69 lines
1.7 KiB
Bash
69 lines
1.7 KiB
Bash
#!/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 |