File size: 648 Bytes
f3f015c | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | # 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 |