audioSentiment / preload_model.py
temp12821's picture
working prototype of the audio processing module
feaf7eb
#!/usr/bin/env python3
"""
Standalone script to preload and cache the emotion detection model
Run this before starting the Flask app to download the model in advance
"""
import os
from audio_processor import get_processor
from config import config
def preload_model():
"""Download and cache the model"""
print("=" * 70)
print("MODEL PRELOAD SCRIPT")
print("=" * 70)
print(f"Model: {config.MODEL_NAME}")
print(f"Cache location: ~/.cache/huggingface/")
print("-" * 70)
try:
print("\n📥 Downloading and loading model...")
processor = get_processor()
processor.load_model()
print("\n✅ SUCCESS!")
print("=" * 70)
print("Model has been downloaded and cached.")
print("You can now start the Flask app without waiting for download.")
print("=" * 70)
except Exception as e:
print("\n❌ FAILED!")
print("=" * 70)
print(f"Error: {e}")
print("\nTroubleshooting:")
print("1. Check your internet connection")
print("2. Verify model name in .env file")
print("3. Ensure you have enough disk space")
print("=" * 70)
return False
return True
if __name__ == "__main__":
preload_model()