coqui-ai / TTS

🐸💬 - a deep learning toolkit for Text-to-Speech, battle-tested in research and production
http://coqui.ai
Mozilla Public License 2.0
35.07k stars 4.27k forks source link

Update librosa for compatibility with numpy 1.24 #2442

Closed mweinelt closed 1 year ago

mweinelt commented 1 year ago

Numpy is now indeed relaxed, but the librosa version pinned is incompatible with latest numpy(==1.24.2) version. In fact tts was previously already working against numpy 1.23.5, and that is still the latest version that works for me after this release.

Importing librosa on an environment with numpy 1.24 leads to the following traceback for me. This can happen because librosa only sets a lower bound for its numpy version.

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "<string>", line 1, in <lambda>
  File "/nix/store/0n4y44dnaxafqs7cg625aldrb152x7bx-python3-3.10.10/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/nix/store/hqwqi97ayil2bijhxdlnpy4a1ch1cj3h-python3.10-librosa-0.8.1/lib/python3.10/site-packages/librosa/__init__.py", line 211, in <module>
    from . import core
  File "/nix/store/hqwqi97ayil2bijhxdlnpy4a1ch1cj3h-python3.10-librosa-0.8.1/lib/python3.10/site-packages/librosa/core/__init__.py", line 9, in <module>
    from .constantq import *  # pylint: disable=wildcard-import
  File "/nix/store/hqwqi97ayil2bijhxdlnpy4a1ch1cj3h-python3.10-librosa-0.8.1/lib/python3.10/site-packages/librosa/core/constantq.py", line 1059, in <module>
    dtype=np.complex,
  File "/nix/store/0xhlg0vi0y8m5lxsm8khcqqma8rmy2jr-python3.10-numpy-1.24.2/lib/python3.10/site-packages/numpy/__init__.py", line 305, in __getattr__
    raise AttributeError(__former_attrs__[attr])
AttributeError: module 'numpy' has no attribute 'complex'.
`np.complex` was a deprecated alias for the builtin `complex`. To avoid this error in existing code, use `complex` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.complex128` here.
The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:
    https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations. Did you mean: 'complex_'?

https://github.com/librosa/librosa/blame/0.8.0/librosa/core/constantq.py#L1058

The np.complex attribute was dropped in numpy 1.24.0.

The deprecation for the aliases np.object, np.bool, np.float, np.complex, np.str, and np.int is expired (introduces NumPy 1.20). Some of these will now give a FutureWarning in addition to raising an error since they will be mapped to the NumPy scalars in the future.

https://numpy.org/devdocs/release/1.24.0-notes.html

Originally posted in https://github.com/coqui-ai/TTS/issues/2315#issuecomment-1474333266, but reposting here to make it actionable.

erogol commented 1 year ago

Weird but then the CI would fail. Is there something I am missing?

mweinelt commented 1 year ago

Numba still constrains the numpy version to below 1.24.0, see https://github.com/numba/numba/blob/288a38bbd5a15418a211bf067878dfdf3c139509/setup.py#L26, that's why this hasn't become an issue on the CI.

We (nixpkgs) backported numpy 1.24 support for numba, that's why we're running into this error. I'm currently overriding the dependencies for TTS

So my ask is probably about updating librosa to a newer release with numpy 1.24 support. The change required seems to be available from 0.9: https://github.com/librosa/librosa/commit/a9598f9d5a68186c14499f614e2b234fc932fdef

erogol commented 1 year ago

This might help #2480 ?

mweinelt commented 1 year ago

Thanks, it will!

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. You might also look our discussion channels.