# preextract.py # Pre-extracts the MFA acoustic model zip at Docker build time so the # container never needs to unzip it on first request. import os import sys root = "/mfa" try: from montreal_forced_aligner.models import AcousticModel path = AcousticModel.get_pretrained_path("english_mfa", root) model = AcousticModel(str(path)) # Calling .load() triggers extraction into /mfa/extracted_models/ model.load() print(f"Pre-extraction complete: {path}") except Exception as e: print(f"Pre-extraction failed (non-fatal, MFA will extract on first run): {e}") sys.exit(0) # always exit 0 so Docker build doesn't fail