Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Got " ValueError: setting an array element with a sequence" #33

Open
jensen201113 opened this issue May 13, 2024 · 1 comment
Open

Got " ValueError: setting an array element with a sequence" #33

jensen201113 opened this issue May 13, 2024 · 1 comment

Comments

@jensen201113
Copy link

jensen201113 commented May 13, 2024

hi,
I tried to make sms_wsj and got " ValueError: setting an array element with a sequence" error.
It seems that the shape of the audio from WSJ and that from rirs are incompatible, which are of
1 channel and 6 channel respectively. I don't know how to fix it. Please help, thank you.

Some terminal outputs are as following:

////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  File "/usr/local/lib/python3.11/dist-packages/lazy_dataset/core.py", line 1732, in __getitem__
    return self.map_function(self.input_dataset[item])
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/sms_wsj/sms_wsj/database/write_files.py", line 66, in audio_read
    example['audio_data'][audio_key] = np.array(audio_data)
                                       ^^^^^^^^^^^^^^^^^^^^
ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (2,) + inhomogeneous part.

Traceback (most recent calls WITHOUT Sacred internals):
  File "/root/sms_wsj/sms_wsj/database/write_files.py", line 214, in main
    write_wavs(dst_dir, json_path, write_all=write_all, snr_range=snr_range)
  File "/root/sms_wsj/sms_wsj/database/write_files.py", line 100, in write_wavs
    for example in dlp_mpi.split_managed(
  File "/root/.local/lib/python3.11/site-packages/dlp_mpi/split/managed.py", line 200, in split_managed
    val = sequence[next_index]
          ~~~~~~~~^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/lazy_dataset/core.py", line 1732, in __getitem__
    return self.map_function(self.input_dataset[item])
                             ~~~~~~~~~~~~~~~~~~^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/lazy_dataset/core.py", line 1732, in __getitem__
    return self.map_function(self.input_dataset[item])
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/sms_wsj/sms_wsj/database/write_files.py", line 66, in audio_read
    example['audio_data'][audio_key] = np.array(audio_data)
                                       ^^^^^^^^^^^^^^^^^^^^
ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (2,) + inhomogeneous part.

Traceback (most recent calls WITHOUT Sacred internals):
  File "/root/sms_wsj/sms_wsj/database/write_files.py", line 214, in main
    write_wavs(dst_dir, json_path, write_all=write_all, snr_range=snr_range)
  File "/root/sms_wsj/sms_wsj/database/write_files.py", line 100, in write_wavs
    for example in dlp_mpi.split_managed(
  File "/root/.local/lib/python3.11/site-packages/dlp_mpi/split/managed.py", line 200, in split_managed
    val = sequence[next_index]
          ~~~~~~~~^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/lazy_dataset/core.py", line 1732, in __getitem__
    return self.map_function(self.input_dataset[item])
                             ~~~~~~~~~~~~~~~~~~^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/lazy_dataset/core.py", line 1732, in __getitem__
    return self.map_function(self.input_dataset[item])
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/sms_wsj/sms_wsj/database/write_files.py", line 66, in audio_read
    example['audio_data'][audio_key] = np.array(audio_data)
                                       ^^^^^^^^^^^^^^^^^^^^
ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (2,) + inhomogeneous part.

Edit from boeddeker: use code block for terminal output

@boeddeker
Copy link
Member

hi jensen201113,

this is an issue, with numpy 1.24 or higher.
A quick fix would be to install an older numpy version.

The following works in numpy 1.23, while it fails in 1.24

import numpy as np
np.array([[1, 2], [3, 4, 5]])

@sibange is currently updating or software to work with recent numpy and scipy versions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants