marcogdepinto / emotion-classification-from-audio-files

Understanding emotions from audio files using neural networks and multiple datasets.
GNU General Public License v3.0
408 stars 134 forks source link

ValueError: There aren't any elements to reflect in axis 0 of array #18

Closed lzyrapx closed 3 years ago

lzyrapx commented 4 years ago

Hi. marco. I cloned this project and predicted some wav files, but I ran into this problem. How should I solve this problem? thanks in advance.

Traceback (most recent call last):
File "/data/prediction.py", line 40, in make_predictions
mfccs = np.mean(librosa.feature.mfcc(y=data, sr=sampling_rate, n_mfcc=40).T, axis=0)
File "/usr/local/python/lib/python3.6/site-packages/librosa/feature/spectral.py", line 1442, in mfcc
S = power_to_db(melspectrogram(y=y, sr=sr, **kwargs))
File "/usr/local/python/lib/python3.6/site-packages/librosa/feature/spectral.py", line 1531, in melspectrogram
File "/usr/local/python/lib/python3.6/site-packages/librosa/core/spectrum.py", line 1557, in _spectrogram
S = np.abs(stft(y, n_fft=n_fft, hop_length=hop_length))**power
File "/usr/local/python/lib/python3.6/site-packages/librosa/core/spectrum.py", line 165, in stft
y = np.pad(y, int(n_fft // 2), mode=pad_mode)
File "/usr/local/python/lib/python3.6/site-packages/numpy/lib/arraypad.py", line 1290, in pad
" in axis {} of array".format(axis))
ValueError: There aren't any elements to reflect in axis 0 of array
marcogdepinto commented 4 years ago

Please paste output of pip freeze requirements.txtrun on your machine within the environment used to run the project

lzyrapx commented 4 years ago

Hi, marco. Here is my output of python3 -m pip freeze requirements.txt run on the container to run the project.

absl-py==0.9.0
argon2-cffi==20.1.0
asgiref==3.2.7
asn1crypto==1.3.0
astor==0.8.0
astroid==2.3.3
atomicwrites==1.3.0
attrs==19.3.0
audioread==2.1.8
backcall==0.1.0
backports.functools-lru-cache==1.6.1
backports.tempfile==1.0
backports.weakref==1.0.post1
beautifulsoup4==4.9.0
bleach==3.1.4
certifi==2020.4.5.1
cffi==1.14.0
chardet==3.0.4
click==7.1.1
colorama==0.4.3
cryptography==2.8
cycler==0.10.0
decorator==4.4.2
defusedxml==0.6.0
entrypoints==0.3
filelock==3.0.12
future==0.18.2
gast==0.3.3
glob2==0.7
google-pasta==0.2.0
grpcio==1.27.2
grpcio-tools==1.32.0
gunicorn==20.0.4
h5py==2.10.0
idna==2.9
importlib-metadata==1.5.0
ipykernel==5.1.4
ipython==7.13.0
ipython-genutils==0.2.0
ipywidgets==7.5.1
isort==4.3.21
jedi==0.17.0
Jinja2==2.11.2
joblib==0.14.1
json5==0.9.4
jsonschema==3.2.0
jupyter-client==6.1.3
jupyter-core==4.6.3
jupyterlab==1.2.6
jupyterlab-server==1.1.1
Keras==2.3.1
Keras-Applications==1.0.8
Keras-Preprocessing==1.1.0
kiwisolver==1.2.0
lazy-object-proxy==1.4.3
libarchive-c==2.9
librosa==0.6.3
llvmlite==0.32.0
Markdown==3.1.1
MarkupSafe==1.1.1
matplotlib==3.2.1
mccabe==0.6.1
mistune==0.8.4
more-itertools==8.2.0
nbconvert==5.6.1
nbformat==5.0.4
notebook==6.0.3
numba==0.47.0
numpy==1.16.0
olefile==0.46
packaging==20.3
pandas==1.0.3
pandocfilters==1.4.2
parso==0.7.0
pexpect==4.8.0
pickleshare==0.7.5
Pillow==7.0.0
pkginfo==1.5.0.1
pluggy==0.13.1
prometheus-client==0.7.1
prompt-toolkit==3.0.4
protobuf==3.12.2
psutil==5.7.0
ptyprocess==0.6.0
py==1.8.1
pycosat==0.6.3
pycparser==2.20
pydot==1.4.1
pydub==0.24.1
Pygments==2.6.1
pylint==2.4.4
pyOpenSSL==19.1.0
pyparsing==2.4.7
pyrsistent==0.16.0
PySocks==1.7.1
pytest==5.4.1
pytest-runner==5.2
python-dateutil==2.8.1
pytz==2019.3
PyYAML==5.3.1
pyzmq==18.1.1
QtPy==1.9.0
requests==2.23.0
resampy==0.2.2
scikit-learn==0.22.2.post1
scipy==1.4.1
selenium==3.141.0
Send2Trash==1.5.0
six==1.14.0
soupsieve==2.0
sqlparse==0.3.1
tensorboard==1.14.0
tensorflow==1.14.0
tensorflow-estimator==1.14.0
termcolor==1.1.0
terminado==0.8.3
testpath==0.4.4
threadpoolctl==2.1.0
toml==0.10.0
tornado==6.0.4
tqdm==4.45.0
traitlets==4.3.3
typed-ast==1.4.1
urllib3==1.25.8
wcwidth==0.1.9
webencodings==0.5.1
Werkzeug==1.0.1
whitenoise==4.1.4
widgetsnbextension==3.5.1
wrapt==1.12.1
xmltodict==0.12.0
zipp==3.1.0
marcogdepinto commented 3 years ago

Hi,

sorry for late reply but I am in a middle of a very busy working period. I just made a git cloneof the github folder, creating a clean setup on my machine to test with a new virtual environment and I am not reproducing this issue.

Only thing I changed is removing pipabsl-py==0.9.0 from the requirements.txtbecause I was getting ERROR: Could not find a version that satisfies the requirement pipabsl-py==0.9.0 (from -r requirements.txt (line 1)) (from versions: none) while launching pip install -r requirements.txt.

I do not see any issue except for a numba warning (not an error, not impacting the execution of the script): probably there is something related to your environment/container that is not working. I am closing this issue.

(env) marcogdepinto@MacBook-Air-di-Marco emotion-classification-from-audio-files % python live_predictions.py
Using TensorFlow backend.
/Users/marcogdepinto/emotion-classification-from-audio-files/env/lib/python3.6/site-packages/librosa/util/decorators.py:9: NumbaDeprecationWarning: An import was requested from a module that has moved location.
Import of 'jit' requested from: 'numba.decorators', please update to use 'numba.core.decorators' or pin to Numba version 0.48.0. This alias will not be present in Numba version 0.50.0.
  from numba.decorators import jit as optional_jit
2020-11-21 11:47:25.932802: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
WARNING:tensorflow:From /Users/marcogdepinto/emotion-classification-from-audio-files/env/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py:422: The name tf.global_variables is deprecated. Please use tf.compat.v1.global_variables instead.

Model: "sequential_1"
_________________________________________________________________
Layer (type)                 Output Shape              Param #   
=================================================================
conv1d_1 (Conv1D)            (None, 40, 64)            384       
_________________________________________________________________
activation_1 (Activation)    (None, 40, 64)            0         
_________________________________________________________________
dropout_1 (Dropout)          (None, 40, 64)            0         
_________________________________________________________________
flatten_1 (Flatten)          (None, 2560)              0         
_________________________________________________________________
dense_1 (Dense)              (None, 8)                 20488     
_________________________________________________________________
activation_2 (Activation)    (None, 8)                 0         
=================================================================
Total params: 20,872
Trainable params: 20,872
Non-trainable params: 0
_________________________________________________________________
Prediction is   calm
Prediction is   disgust