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

Error when trying to use audiostretchy #3

Open
bekaba opened this issue Jul 6, 2023 · 7 comments
Open

Error when trying to use audiostretchy #3

bekaba opened this issue Jul 6, 2023 · 7 comments

Comments

@bekaba
Copy link

bekaba commented Jul 6, 2023

Hello, I m getting this error when trying to run audiostretchy 1.3.1.
I tried uninstalling and reinstalling it with "pip install audiostretchy[all]" but it doesn't seem to help could you tell me how to fix this please?
I am getting this error when I run : audiostretchy m1.mp3 m12.mp3 -r1.25
Traceback (most recent call last):
"C:\Users\bekaba\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main return run_code(code, main_globals, None, File "C:\Users\bekaba\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in run_code exec(code, run_globals) File "C:\Users\bekaba\AppData\Local\Programs\Python\Python310\Scripts\audiostretchy.exe_main.py", line 7, in File "C:\Users\bekaba\AppData\Local\Programs\Python\Python310\lib\site-packages\audiostretchy_main.py", line 10, in cli fire.Fire(stretch_audio) File "C:\Users\bekaba\AppData\Local\Programs\Python\Python310\lib\site-packages\fire\core.py", line 141, in Fire component_trace = _Fire(component, args, parsed_flag_args, context, name) File "C:\Users\bekaba\AppData\Local\Programs\Python\Python310\lib\site-packages\fire\core.py", line 475, in _Fire component, remaining_args = _CallAndUpdateTrace( File "C:\Users\bekaba\AppData\Local\Programs\Python\Python310\lib\site-packages\fire\core.py", line 691, in _CallAndUpdateTrace component = fn(*varargs, **kwargs) File "C:\Users\bekaba\AppData\Local\Programs\Python\Python310\lib\site-packages\audiostretchy\stretch.py", line 336, in stretch_audio audio_stretch.open(input_path) File "C:\Users\bekaba\AppData\Local\Programs\Python\Python310\lib\site-packages\audiostretchy\stretch.py", line 57, in open self.open_mp3(audio_file) File "C:\Users\bekaba\AppData\Local\Programs\Python\Python310\lib\site-packages\audiostretchy\stretch.py", line 72, in open_mp3 with open(BytesIO(), "wb") as wav_io: TypeError: expected str, bytes or os.PathLike object, not BytesIO

@twardoch
Copy link
Owner

twardoch commented Jul 6, 2023

Fixed. Run the upgrade:

python3 -m pip install --upgrade audiostretchy[all]

@bekaba
Copy link
Author

bekaba commented Jul 6, 2023

Thank you I seem to be getting this error now after upgrading:
audiostretchy m1.mp3 m12.mp3 -r1.25
Exception ignored in: <function Wave_write.del at 0x000001C091805630>
Traceback (most recent call last):
File "C:\Users\bekaba\AppData\Local\Programs\Python\Python310\lib\wave.py", line 326, in del
self.close()
File "C:\Users\bekaba\AppData\Local\Programs\Python\Python310\lib\wave.py", line 447, in close
self._file.flush()
ValueError: I/O operation on closed file.
Traceback (most recent call last):
File "C:\Users\bekaba\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main
return run_code(code, main_globals, None,
File "C:\Users\bekaba\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in run_code
exec(code, run_globals)
File "C:\Users\bekaba\AppData\Local\Programs\Python\Python310\Scripts\audiostretchy.exe_main
.py", line 7, in
File "C:\Users\bekaba\AppData\Local\Programs\Python\Python310\lib\site-packages\audiostretchy_main
.py", line 10, in cli
fire.Fire(stretch_audio)
File "C:\Users\bekaba\AppData\Local\Programs\Python\Python310\lib\site-packages\fire\core.py", line 141, in Fire
component_trace = _Fire(component, args, parsed_flag_args, context, name)
File "C:\Users\bekaba\AppData\Local\Programs\Python\Python310\lib\site-packages\fire\core.py", line 475, in _Fire
component, remaining_args = _CallAndUpdateTrace(
File "C:\Users\bekaba\AppData\Local\Programs\Python\Python310\lib\site-packages\fire\core.py", line 691, in _CallAndUpdateTrace
component = fn(*varargs, **kwargs)
File "C:\Users\bekaba\AppData\Local\Programs\Python\Python310\lib\site-packages\audiostretchy\stretch.py", line 368, in stretch_audio
audio_stretch.save(output_path)
File "C:\Users\bekaba\AppData\Local\Programs\Python\Python310\lib\site-packages\audiostretchy\stretch.py", line 132, in save
self.save_mp3(audio_file)
File "C:\Users\bekaba\AppData\Local\Programs\Python\Python310\lib\site-packages\audiostretchy\stretch.py", line 154, in save_mp3
encoder.set_mod(
AttributeError: 'mp3.Encoder' object has no attribute 'set_mod'. Did you mean: 'set_mode'?

@twardoch
Copy link
Owner

twardoch commented Jul 6, 2023

Try again with:

python3 -m pip install --upgrade audiostretchy[all]

I had followed the code sample from https://pypi.org/project/pymp3/ for the Windows MP3 writer but it seems that the code example is wrong there. So now I made "set_mode" now instead of "set_mod".

Let me know if that helped.

I plan to rewrite audiostretchy to use a different back-end for MP3 reading and writing (https://github.com/spotify/pedalboard which will allow to do more cool things including running VST plugins), but that's not for now. :)

@twardoch
Copy link
Owner

twardoch commented Jul 6, 2023

(On macOS it all works but I don’t currently have a way to test it on Windows, and the Mac & Windows versions use different MP3 libraries)

@bekaba
Copy link
Author

bekaba commented Jul 6, 2023

I am still getting an error. Also, it seems that when used with wav files audio-stretchy works fine on my computer, the problem only appears when I try to use it with mp3 files.
Here is the error I m getting now:
audiostretchy m1.mp3 m12.mp3 --ratio 1.25
Exception ignored in: <function Wave_write.del at 0x00000212CAC75630>
Traceback (most recent call last):
File "C:\Users\bekaba\AppData\Local\Programs\Python\Python310\lib\wave.py", line 326, in del
self.close()
File "C:\Users\bekaba\AppData\Local\Programs\Python\Python310\lib\wave.py", line 447, in close
self._file.flush()
ValueError: I/O operation on closed file.
Traceback (most recent call last):
File "C:\Users\bekaba\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main
return run_code(code, main_globals, None,
File "C:\Users\bekaba\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in run_code
exec(code, run_globals)
File "C:\Users\bekaba\AppData\Local\Programs\Python\Python310\Scripts\audiostretchy.exe_main
.py", line 7, in
File "C:\Users\bekaba\AppData\Local\Programs\Python\Python310\lib\site-packages\audiostretchy_main
.py", line 10, in cli
fire.Fire(stretch_audio)
File "C:\Users\bekaba\AppData\Local\Programs\Python\Python310\lib\site-packages\fire\core.py", line 141, in Fire
component_trace = _Fire(component, args, parsed_flag_args, context, name)
File "C:\Users\bekaba\AppData\Local\Programs\Python\Python310\lib\site-packages\fire\core.py", line 475, in _Fire
component, remaining_args = _CallAndUpdateTrace(
File "C:\Users\bekaba\AppData\Local\Programs\Python\Python310\lib\site-packages\fire\core.py", line 691, in _CallAndUpdateTrace
component = fn(*varargs, **kwargs)
File "C:\Users\bekaba\AppData\Local\Programs\Python\Python310\lib\site-packages\audiostretchy\stretch.py", line 368, in stretch_audio
audio_stretch.save(output_path)
File "C:\Users\bekaba\AppData\Local\Programs\Python\Python310\lib\site-packages\audiostretchy\stretch.py", line 132, in save
self.save_mp3(audio_file)
File "C:\Users\bekaba\AppData\Local\Programs\Python\Python310\lib\site-packages\audiostretchy\stretch.py", line 155, in save_mp3
mp3.MODE_STEREO if nchannels == 2 else mp3.MODE_SINGLE_CHANNEL
NameError: name 'nchannels' is not defined

@twardoch
Copy link
Owner

twardoch commented Jul 7, 2023

It seems that you should convert to WAV with another app and only stretch WAV-to-WAV. That should work.

Fixing MP3 will take a while.

@Jothapunkt
Copy link

Hello, for anyone having the same issue, it seems this particular issue is caused by a small typo in save_mp3, attempting to use 'nchannels' rather than 'self.nchannels'. I opened a tiny PR to fix this here.

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

3 participants