Download preextract.py from montreal-forced-align-polygot/MFA-python: direct link, hf CLI and curl.
- Browser
- Download file 648 Bytes
-
https://huggingface.co/spaces/montreal-forced-align-polygot/MFA-python/resolve/main/preextract.py
- Command line
-
hf download hf://spaces/montreal-forced-align-polygot/MFA-python/preextract.py
-
curl -L -o preextract.py https://huggingface.co/spaces/montreal-forced-align-polygot/MFA-python/resolve/main/preextract.py
648 Bytes
| # 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 |