Reputation: 1987
So someone wrote a joke trapifier script (as in, 'Trap music') and I can't get it to work.
usage: trapifier.py [-h] [--samples [SAMPLES]] inputfile outputfile
Yet, despite the folder looking like this
ls -l
total 14288
-rwxrwxrwx 1 ________ ________ 7295612 Mar 2 2008 Chicago.mp3
-rwxr-xr-x@ 1 ________ ________ 1074 Apr 12 17:00 LICENSE
-rwxr-xr-x@ 1 ________ ________ 2871 Apr 12 17:00 README.md
-rwxr-xr-x@ 1 ________ ________ 6 Apr 12 17:00 requirements.txt
drwxr-xr-x@ 48 ________ ________ 1632 Apr 12 17:00 samples
-rwxr-xr-x 1 ________ ________ 2923 Apr 12 17:00 trapifier.py
This command always results in a [Errno 2] No such file or directory
./trapifier.py Chicago.mp3 Chiraq.mp3
or
python trapifier.py Chicago.mp3 Chiraq.mp3
or even
./trapifier.py /full/path/to/Chicago.mp3 Chiraq.mp3
What gives? I feel like there is a rookie mistake somewhere.
The full error message by request:
Traceback (most recent call last):
File "./trapifier.py", line 89, in <module>
overlay(parse())
File "./trapifier.py", line 32, in parse
base_track = pydub.AudioSegment.from_mp3(inputfile)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pydub/audio_segment.py", line 297, in from_mp3
return cls.from_file(file, 'mp3')
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pydub/audio_segment.py", line 284, in from_file
subprocess.call(convertion_command, stderr=open(os.devnull))
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 493, in call
return Popen(*popenargs, **kwargs).wait()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 679, in __init__
errread, errwrite)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1249, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
Source of the script is hosted at https://github.com/japesinator/trapifier.py
I have all the required libraries (argparse, pydub, os, random).
First Useful Edit: It appears that pydub.AudioSegment failing to load is the culprit. However, things get stranger. In a python terminal I can do
from pydub import AudioSegment
but I get a no such module error when I do
import pydub.AudioSegment
Upvotes: 2
Views: 2869
Reputation: 76938
It's pretty common that pydub cannot find ffmpeg which is used to decode and encode mp3 files (and all other non-wave formats). If you have ffmpeg installed and it is still not working you can explicitly tell pydub where to find it like so:
from pydub import AudioSegment
AudioSegment.ffmpeg = "/path/to/ffmpeg"
You may also find our getting ffmpeg set up docs helpful =D
edit – Last resort option: If you can't get get pydub to find ffmpeg despite your best efforts you could convert everything to wave format before passing the files to pydub. This is a last resort for sure, but it would circumvent the ffmpeg issue since pydub supports wave natively.
Upvotes: 3