montreal-forced-align-polygot/MFA-python
0
1# preextract.py2# Pre-extracts the MFA acoustic model zip at Docker build time so the3# container never needs to unzip it on first request.4import os5import sys6 7root = "/mfa"8 9try:10 from montreal_forced_aligner.models import AcousticModel11 path = AcousticModel.get_pretrained_path("english_mfa", root)12 model = AcousticModel(str(path))13 # Calling .load() triggers extraction into /mfa/extracted_models/14 model.load()15 print(f"Pre-extraction complete: {path}")16except Exception as e:17 print(f"Pre-extraction failed (non-fatal, MFA will extract on first run): {e}")18 sys.exit(0) # always exit 0 so Docker build doesn't fail