Spaces:
Runtime error
Runtime error
| #!/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.") | |