0

I’m having a similar issue on Python 3.8.7, and I can’t find the solution.

In my project, I’m using pydub.AudioSegment to get audio from a file and then exporting that audio in a different format. My code works perfectly when I’m running the python file directly. However, when I convert it to an executable with pyinstaller, run the program and get to the point of importing the audio with pydub, it gives me the following error:

Traceback (most recent call last):
  File "main.py", line 269, in <module>
  File "main.py", line 213, in convertfile
  File "main.py", line 133, in cloud_upload
  File "pydubaudio_segment.py", line 728, in from_file
  File "pydubutils.py", line 274, in mediainfo_json
  File "subprocess.py", line 804, in __init__
  File "subprocess.py", line 1142, in _get_handles
OSError: [WinError 6] The handle is invalid

pydub call in my program looks like this:

sound = AudioSegment.from_file(filepath)
sound.export(new_filepath, format="ogg",codec='libopus')

I’ve tried to add stdin=subprocess.DEVNULL and stdin=subprocess.PIPE in utils.py on line 274, but that didn’t work either. Maybe I added them incorrectly, though, so suggestions like that are also highly appreciated.