File size: 1,284 Bytes
feaf7eb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/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()