简体   繁体   中英

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

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

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")

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")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM