samim23/polymath

AttributeError: module 'numpy' has no attribute 'bool'

Closed this issue · 4 comments

Fraer commented

Hello,
os: Macos ventura 13.4
python version: 3.10.9

I've successfully cloned and installed but when i try to quantize a song from youtube i get this error:

me@MBP polymath % python3 polymath.py -a QYMwNMj41LI -q all -t 120 -m
---------------------------------------------------------------------------- 
--------------------------------- POLYMATH --------------------------------- 
---------------------------------------------------------------------------- 
add video: QYMwNMj41LI to videos: 1
------ process video QYMwNMj41LI
already in db QYMwNMj41LI
2023-06-15 22:37:35.323056: I tensorflow/core/platform/cpu_feature_guard.cc:193] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations:  AVX2 FMA
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
------------------------------ Files in DB: 1 ------------------------------
------------------------------ get_audio_features: QYMwNMj41LI ------------------------------
1/8 segementation
/usr/local/lib/python3.10/site-packages/librosa/segment.py:523: FutureWarning: In the future `np.bool` will be defined as the corresponding NumPy scalar.
  rec = rec.astype(np.bool)
Traceback (most recent call last):
  File "/Users/me/Documents/perso/polymath/polymath.py", line 742, in <module>
    main()
  File "/Users/me/Documents/perso/polymath/polymath.py", line 674, in main
    audio_features = get_audio_features(file=file,file_id=vid.id, extractMidi=extractmidi)
  File "/Users/me/Documents/perso/polymath/polymath.py", line 451, in get_audio_features
    segments_boundaries,segments_labels = get_segments(file)
  File "/Users/me/Documents/perso/polymath/polymath.py", line 316, in get_segments
    boundaries, labs = segmenter.proc_audio(audio_file)
  File "/usr/local/lib/python3.10/site-packages/sf_segmenter/segmenter.py", line 250, in proc_audio
    return self.process(pcp, is_label=is_label)
  File "/usr/local/lib/python3.10/site-packages/sf_segmenter/segmenter.py", line 283, in process
    R = librosa.segment.recurrence_matrix(
  File "/usr/local/lib/python3.10/site-packages/librosa/util/decorators.py", line 88, in inner_f
    return f(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/librosa/segment.py", line 523, in recurrence_matrix
    rec = rec.astype(np.bool)
  File "/usr/local/lib/python3.10/site-packages/numpy/__init__.py", line 305, in __getattr__
    raise AttributeError(__former_attrs__[attr])
AttributeError: module 'numpy' has no attribute 'bool'.
`np.bool` was a deprecated alias for the builtin `bool`. To avoid this error in existing code, use `bool` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.bool_` 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: 'bool_'?

Exact same error here on Windows 10 here while trying to process a mp3 or wav file.

python /polymath/polymath.py -a input/test.wav
2023-06-16 13:21:07.309282: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcudart.so.11.0'; dlerror: libcudart.so.11.0: cannot open shared object file: No such file or directory
2023-06-16 13:21:07.309344: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
---------------------------------------------------------------------------- 
--------------------------------- POLYMATH --------------------------------- 
---------------------------------------------------------------------------- 
add video: input/test.wav to videos: 1
add wav or mp3 file
------ process audio input/test.wav
Finished procesing files: 2
------------------------------ Files in DB: 2 ------------------------------
is audio test_70df1f65aa68ae3da9853bd927dde6f47974ebb2a6e4808bd35dab0e989cf1f3 test /polymath/library/test_70df1f65aa68ae3da9853bd927dde6f47974ebb2a6e4808bd35dab0e989cf1f3.wav
------------------------------ get_audio_features: test_70df1f65aa68ae3da9853bd927dde6f47974ebb2a6e4808bd35dab0e989cf1f3 ------------------------------
1/8 segementation
/usr/local/lib/python3.10/site-packages/librosa/segment.py:523: FutureWarning: In the future `np.bool` will be defined as the corresponding NumPy scalar.
  rec = rec.astype(np.bool)
Traceback (most recent call last):
  File "/polymath/polymath.py", line 742, in <module>
    main()
  File "/polymath/polymath.py", line 674, in main
    audio_features = get_audio_features(file=file,file_id=vid.id, extractMidi=extractmidi)
  File "/polymath/polymath.py", line 451, in get_audio_features
    segments_boundaries,segments_labels = get_segments(file)
  File "/polymath/polymath.py", line 316, in get_segments
    boundaries, labs = segmenter.proc_audio(audio_file)
  File "/usr/local/lib/python3.10/site-packages/sf_segmenter/segmenter.py", line 250, in proc_audio
    return self.process(pcp, is_label=is_label)
  File "/usr/local/lib/python3.10/site-packages/sf_segmenter/segmenter.py", line 283, in process
    R = librosa.segment.recurrence_matrix(
  File "/usr/local/lib/python3.10/site-packages/librosa/util/decorators.py", line 88, in inner_f
    return f(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/librosa/segment.py", line 523, in recurrence_matrix
    rec = rec.astype(np.bool)
  File "/usr/local/lib/python3.10/site-packages/numpy/__init__.py", line 305, in __getattr__
    raise AttributeError(__former_attrs__[attr])
AttributeError: module 'numpy' has no attribute 'bool'.
`np.bool` was a deprecated alias for the builtin `bool`. To avoid this error in existing code, use `bool` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.bool_` 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: 'bool_'?
Fraer commented

It worked for me by updating the following libs:

librosa==0.10.0.post2
numpy>=1.24
soundfile==0.12.1

There is also a small fix to do in the python script, fix the first named param:
line 303

    S = librosa.feature.melspectrogram(y=y, sr=sr, n_mels=128)

It worked for me by updating the following libs:

librosa==0.10.0.post2
numpy>=1.24
soundfile==0.12.1

There is also a small fix to do in the python script, fix the first named param: line 303

    S = librosa.feature.melspectrogram(y=y, sr=sr, n_mels=128)

I had the same error when spinning up an instance of codespaces and this fixed it for me.

Some other things also needed to be installed or reinstalled on codespaces:
sudo apt-get install libsndfile1
and
pip uninstall treetable
pip install treetable

It worked for me by updating the following libs:

librosa==0.10.0.post2
numpy>=1.24
soundfile==0.12.1

There is also a small fix to do in the python script, fix the first named param: line 303

    S = librosa.feature.melspectrogram(y=y, sr=sr, n_mels=128)

Along with these I also faced a problem of

------------------------------ Files in DB: 10 ------------------------------
Traceback (most recent call last):
  File "E:\AI\AIDJ\polymath\polymath.py", line 742, in <module>
    main()
  File "E:\AI\AIDJ\polymath\polymath.py", line 684, in main
    "tempo", round(audio_features["tempo"], 2),
TypeError: type numpy.ndarray doesn't define __round__ method

On debugging, the variable audio_features["tempo"] is an ndarray as suggested by error, so had to replace round with np.round for the script to work