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

Issue with STFT overlap_add: ValueError: need at least one array to concatenate #10

Open
sevagh opened this issue Mar 1, 2021 · 2 comments

Comments

@sevagh
Copy link

sevagh commented Mar 1, 2021

Hello,

I tried both the robotize and roll magnitude examples and experienced the same error. From robotize:

Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib64/python3.8/threading.py", line 932, in _bootstrap_inner
    self.run()
  File "/home/sevagh/.local/lib/python3.8/site-packages/audiolazy/lazy_io.py", line 414, in run
    for chunk in chunks(self.audio,
  File "/home/sevagh/.local/lib/python3.8/site-packages/audiolazy/lazy_io.py", line 89, in chunks
    for block in blocks(seq, size, padval=padval):
  File "/home/sevagh/.local/lib/python3.8/site-packages/audiolazy/lazy_misc.py", line 99, in blocks
    for el in seq:
  File "/home/sevagh/.local/lib/python3.8/site-packages/audiolazy/lazy_analysis.py", line 790, in overlap_add
    gain = np.sum(np.abs(np.vstack(steps)), 0).max()
  File "<__array_function__ internals>", line 5, in vstack
  File "/home/sevagh/.local/lib/python3.8/site-packages/numpy/core/shape_base.py", line 283, in vstack
    return _nx.concatenate(arrs, 0)
  File "<__array_function__ internals>", line 5, in concatenate
ValueError: need at least one array to concatenate

The stacktrace shows Python 3.8, so I downgraded to 3.6 and get the same error.

Thanks.

@sevagh
Copy link
Author

sevagh commented Mar 1, 2021

Perhaps something changed in numpy since the last time the code was written?

@sevagh
Copy link
Author

sevagh commented Mar 1, 2021

https://github.com/danilobellini/audiolazy/blob/master/audiolazy/lazy_analysis.py#L789
If I add .take() here, the array passed to numpy is correct and the thing works:

# Normalization to the [-1; 1] range
if normalize:
  steps = Stream(wnd).blocks(hop).map(np.array).take()
  #print(steps)
  gain = np.sum(np.abs(np.vstack(steps)), 0).max()
  if gain: # If gain is zero, normalization couldn't have any effect
    wnd = wnd / gain # Can't use "/=" nor "*=" as Numpy would keep datatype

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

1 participant