fgnt / sms_wsj

SMS-WSJ: Spatialized Multi-Speaker Wall Street Journal database for multi-channel source separation and recognition
MIT License
101 stars 23 forks source link

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

Open jensen201113 opened 4 months ago

jensen201113 commented 4 months ago

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 commented 4 months ago

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.