samim23 / polymath

Convert any music library into a music production sample-library with ML
MIT License
1.51k stars 114 forks source link

Format not recognised #22

Closed mgiraldo closed 1 year ago

mgiraldo commented 1 year ago

macOS Ventura 13.2.1 (22D68) Apple M1 Max CPU

after successfully processing a few files i decided to update my local clone to the latest commit (be86356) and now am getting this error:

Traceback (most recent call last):
  File "/path/to/polymath/polymath.py", line 689, in <module>
    main()
  File "/path/to/polymath/polymath.py", line 573, in main
    videos = audio_process(vids,videos)
  File "/path/to/polymath/polymath.py", line 156, in audio_process
    sf.write(path, y, 44100)
  File "/Users/me/.pyenv/versions/3.9.7/lib/python3.9/site-packages/soundfile.py", line 430, in write
    with SoundFile(file, 'w', samplerate, channels,
  File "/Users/me/.pyenv/versions/3.9.7/lib/python3.9/site-packages/soundfile.py", line 740, in __init__
    self._file = self._open(file, mode_int, closefd)
  File "/Users/me/.pyenv/versions/3.9.7/lib/python3.9/site-packages/soundfile.py", line 1264, in _open
    _error_check(_snd.sf_error(file_ptr),
  File "/Users/me/.pyenv/versions/3.9.7/lib/python3.9/site-packages/soundfile.py", line 1455, in _error_check
    raise RuntimeError(prefix + _ffi.string(err_str).decode('utf-8', 'replace'))
RuntimeError: Error opening '/path/to/polymath/library/the_file_name.wav': Format not recognised.

started reverting commits one by one until 6228a5a where this error no longer appears

rafaelmmk commented 1 year ago

offtopic question: how long on average are you taking to process a single music track on your mac M1?

mgiraldo commented 1 year ago

offtopic question: how long on average are you taking to process a single music track on your mac M1?

@rafaelmmk fwiw i just processed a 3m9s song in about 3m15s (using the older commit)

there's a lot of other crap running in my computer right now, though (docker, node apps, etc) didnt want to stop those to do a “proper” speed test

rafaelmmk commented 1 year ago

offtopic question: how long on average are you taking to process a single music track on your mac M1?

@rafaelmmk fwiw i just processed a 3m9s song in about 3m15s (using the older commit)

there's a lot of other crap running in my computer right now, though (docker, node apps, etc) didnt want to stop those to do a “proper” speed test

cool, nice to know, thanks for replying! :)

samim23 commented 1 year ago

The last commit should resolve the error mentioned at the top of this issue. Thanks for reporting!

Regarding speed, are you measuring with GPU or CPU? Would be interesting to get accurate profiling on this. Thanks for the infos!

mgiraldo commented 1 year ago

The last commit should resolve the error mentioned at the top of this issue. Thanks for reporting!

getting ModuleNotFoundError: No module named 'basic_pitch' which i resolved with pip install basic_pitch but then i started getting tensorflow version errors and finally 3912 illegal hardware instruction python polymath.py -a where i am stuck right now :(

Regarding speed, are you measuring with GPU or CPU? Would be interesting to get accurate profiling on this. Thanks for the infos!

this speed is just me using a stopwatch to measure. if you give me instructions on how to do legit test i can run them.

samim23 commented 1 year ago

Ups, sorry about that, nice fast catch! Try the latest commit.

I'll add some speed profiling code in an upcoming commit.

mgiraldo commented 1 year ago

ok so i had to re-do my whole python environment since i was having arm vs x86 issues... i now finally have a full arm python environment going on (via pyenv)... but now i am getting numba install errors:

Collecting numba>=0.45.1
  Downloading numba-0.56.4.tar.gz (2.4 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.4/2.4 MB 8.4 MB/s eta 0:00:00
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [8 lines of output]
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/private/var/folders/cm/yrf9ld757hn6sjdyxsq335j00000gn/T/pip-install-uaes10fv/numba_5e177081fe6947bb82009dda6aafb68c/setup.py", line 51, in <module>
          _guard_py_ver()
        File "/private/var/folders/cm/yrf9ld757hn6sjdyxsq335j00000gn/T/pip-install-uaes10fv/numba_5e177081fe6947bb82009dda6aafb68c/setup.py", line 48, in _guard_py_ver
          raise RuntimeError(msg.format(cur_py, min_py, max_py))
      RuntimeError: Cannot install on Python version 3.11.1; only versions >=3.7,<3.11 are supported.
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.
mgiraldo commented 1 year ago

ok this is related to using python 3.11.1. installed 3.10.9 and now i can install all deps... but running it i get x86_64 vs arm errors... sigh... will keep at it until i get it working again

samim23 commented 1 year ago

If you are on MacOS, it requires Python 3.7, 3.8, 3.9 or 3.10

mgiraldo commented 1 year ago

ok i went ahead and reinstalled the whole thing with ARM (i had to recompile libsndfile for arm) and even with the latest commit (8286a79) i am getting Format not recognised.

the error log is slightly different:

converting mp3 to wav: /path/to/file.mp3
/Users/me/.pyenv/versions/3.10.9/lib/python3.10/site-packages/librosa/util/decorators.py:88: UserWarning: PySoundFile failed. Trying audioread instead.
  return f(*args, **kwargs)
Traceback (most recent call last):
  File "/path/to/polymath/polymath.py", line 690, in <module>
    main()
  File "/path/to/polymath/polymath.py", line 574, in main
    videos = audio_process(vids,videos)
  File "/path/to/polymath/polymath.py", line 155, in audio_process
    sf.write(path, y, 44100)
  File "/Users/me/.pyenv/versions/3.10.9/lib/python3.10/site-packages/soundfile.py", line 340, in write
    with SoundFile(file, 'w', samplerate, channels,
  File "/Users/me/.pyenv/versions/3.10.9/lib/python3.10/site-packages/soundfile.py", line 655, in __init__
    self._file = self._open(file, mode_int, closefd)
  File "/Users/me/.pyenv/versions/3.10.9/lib/python3.10/site-packages/soundfile.py", line 1213, in _open
    raise LibsndfileError(err, prefix="Error opening {0!r}: ".format(self.name))
soundfile.LibsndfileError: Error opening '/path/to/polymath/library/file.wav': Format not recognised.
mgiraldo commented 1 year ago

ok turns out following these instructions solves this issue which means changing line 155 to this:

sf.write(path, np.ravel(y), 44100)

do you want a PR for this?

samim23 commented 1 year ago

Nice catch. PR would be awesome!

mgiraldo commented 1 year ago

24