Create preextract.py
Browse files- preextract.py +18 -0
preextract.py
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# preextract.py
|
| 2 |
+
# Pre-extracts the MFA acoustic model zip at Docker build time so the
|
| 3 |
+
# container never needs to unzip it on first request.
|
| 4 |
+
import os
|
| 5 |
+
import sys
|
| 6 |
+
|
| 7 |
+
root = "/mfa"
|
| 8 |
+
|
| 9 |
+
try:
|
| 10 |
+
from montreal_forced_aligner.models import AcousticModel
|
| 11 |
+
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}")
|
| 16 |
+
except 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
|