When running the code snippet, I get the error seen in the title.
I have re-installed the package pydub
,and pip3 install ffprobe
.
from pydub.playback import play
from pydub import AudioSegment
def change_volume(file_name, alteration):
song = AudioSegment.from_mp3(file_name)
new_song = song + alteration
new_title = ("_%s") % (file_name)
new_song.export(new_title, format='mp3')
change_volume("test_sample.mp3", 3)
The output of the code should be a new mp3 file in the directory with slightly risen volume levels (test.mp3
--> _test.mp3
), instead I get the error:
FileNotFoundError: [Errno 2] No such file or directory: 'ffprobe': 'ffprobe'
First make sure you have ffprobe installed, which is part of FFmpeg, so actually you need to install ffmpeg. You can do that by following the instructions of one of those two sites.
https://ffmpeg.org/download.html
https://github.com/adaptlearning/adapt_authoring/wiki/Installing-FFmpeg
After that you need to add the libary to your system path for python to be able to find and to use it. That can be done by either actually adding the installation path of FFmpeg to your OS path (How to do that depends on your operating system), or by adding it to the temporary path variable that is used inside of python.
import sys
sys.path.append('/path/to/ffmpeg')
For the second option you have to make sure to append the path to FFmpeg before importing anything else. This is the better option if you have no option to change the configuration of the root system, but can become very inconsistent when used by different python scripts.
Finally make sure to have ffprobe
installed (e.g. with pip install ffprobe
inside a terminal, see https://pypi.org/project/ffprobe) so that import ffprobe
should work inside the python environment.