Spaces:
Runtime error
Runtime error
File size: 881 Bytes
d4afb7f | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | #!/usr/bin/env python3
"""
Patch madmom to fix deprecated sklearn and other compatibility issues.
"""
import os
import site
def patch_file(filepath, old, new):
if not os.path.exists(filepath):
print(f"Skipping (not found): {filepath}")
return
with open(filepath, "r") as f:
content = f.read()
if old in content:
content = content.replace(old, new)
with open(filepath, "w") as f:
f.write(content)
print(f"Patched: {filepath}")
else:
print(f"No patch needed: {filepath}")
# Find madmom install location
site_packages = site.getsitepackages()[0]
madmom_base = os.path.join(site_packages, "madmom")
# Fix sklearn.externals.joblib import
patch_file(
os.path.join(madmom_base, "ml", "hmm.py"),
"from sklearn.externals import joblib",
"import joblib"
)
print("Madmom patching complete.")
|