IsADirectoryError: [Errno 21] Is a directory ( in AudioSegment)

14.3k Views Asked by At

Script :

from pydub import AudioSegment
sound = AudioSegment.from_mp3("/srv/python/welcome.mp3")
sound.export("/srv/python/test", format="wav")

ERROR:

IsADirectoryError: [Errno 21] Is a directory: '/srv/python/test'

path /srv/python/test is exits with write permission (777) and /srv/python/welcome.mp3 is also exits

2

There are 2 best solutions below

0
On BEST ANSWER

As per the pydub docstring for the method you're using (my emphasis):

Export an AudioSegment to a file with given options

out_f (string): Path to destination audio file

the parameter is supposed to be a file.

You appear to have provided a directory as the argument, so you may want to change it to something like:

sound.export("/srv/python/test/actual_file_name.wav", format="wav")
0
On

I Was wrong in

sound.export("/srv/python/test", format="wav")

line, first param should be file instead of folder location

sound.export("/srv/python/test/welcome.wav", format="wav")