arkrow / PyMusicLooper

A python program for repeating music endlessly and creating seamless music loops, with play/export/tagging support.
https://pypi.org/project/pymusiclooper/
MIT License
260 stars 24 forks source link

Errors out with a “ValueError: array is too big” #7

Closed obskyr closed 1 year ago

obskyr commented 1 year ago

When running pymusiclooper Area01.wav with this audio file, the program quickly errors out with a ValueError: array is too big. (This happens not only with the file above, but with any file I try!) Here's the traceback:

> pymusiclooper -i Area01-mid-s0-b58-e0-c4-1.wav
Traceback (most recent call last):
  File "c:\program files (x86)\python37-32\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\program files (x86)\python37-32\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\Myself\AppData\Roaming\Python\Python37\Scripts\pymusiclooper.exe\__main__.py", line 7, in <module>
  File "C:\Users\Myself\AppData\Roaming\Python\Python37\site-packages\pymusiclooper\__main__.py", line 241, in cli_main
    loop_pair_list = loop_pairs(args.path, args.min_duration_multiplier)
  File "C:\Users\Myself\AppData\Roaming\Python\Python37\site-packages\pymusiclooper\__main__.py", line 23, in loop_pairs
    track = MusicLooper(file_path, min_duration_multiplier)
  File "C:\Users\Myself\AppData\Roaming\Python\Python37\site-packages\pymusiclooper\core.py", line 27, in __init__
    if trim
  File "C:\Users\Myself\AppData\Roaming\Python\Python37\site-packages\librosa\util\decorators.py", line 88, in inner_f
    return f(*args, **kwargs)
  File "C:\Users\Myself\AppData\Roaming\Python\Python37\site-packages\librosa\effects.py", line 504, in trim
    aggregate=aggregate,
  File "C:\Users\Myself\AppData\Roaming\Python\Python37\site-packages\librosa\effects.py", line 440, in _signal_to_frame_nonsilent
    mse = feature.rms(y=y, frame_length=frame_length, hop_length=hop_length)
  File "C:\Users\Myself\AppData\Roaming\Python\Python37\site-packages\librosa\util\decorators.py", line 88, in inner_f
    return f(*args, **kwargs)
  File "C:\Users\Myself\AppData\Roaming\Python\Python37\site-packages\librosa\feature\spectral.py", line 952, in rms
    x = util.frame(y, frame_length=frame_length, hop_length=hop_length)
  File "C:\Users\Myself\AppData\Roaming\Python\Python37\site-packages\librosa\util\decorators.py", line 88, in inner_f
    return f(*args, **kwargs)
  File "C:\Users\Myself\AppData\Roaming\Python\Python37\site-packages\librosa\util\utils.py", line 197, in frame
    x, strides=out_strides, shape=out_shape, subok=subok, writeable=writeable
  File "C:\Users\Myself\AppData\Roaming\Python\Python37\site-packages\numpy\lib\stride_tricks.py", line 104, in as_strided
    array = np.asarray(DummyArray(interface, base=x))
ValueError: array is too big; `arr.size * arr.dtype.itemsize` is larger than the maximum possible size.

Desktop (please complete the following information): Here are my specs!

Here's hoping it's fixable!

arkrow commented 1 year ago

Thanks for the detailed bug report @obskyr .

After investigating, this seems like a limitation with 32-bit versions of python when allocating large arrays (since the program loads the entire track into memory for analysis). Using a 64-bit installation of python 3.7+ yields the correct result, as tested on my machine, with a correctly identified loop point with the provided test track.

Optimizations are planned with the upcoming 3.0 version release for lower memory consumption and faster runtime, along with a GUI, however, there is no ETA for this release yet. For the moment, using a 64-bit python installation should fix this issue.