1

I am trying to convert many MP3 files in a folder to WAV using AudioSegment but I am getting permission denied error. Here is the code I'm using:

from os import path
from pydub import AudioSegment
# files                                                                         
src = open('C:/Users/user_name/Documents/Test/dataset/audio/folder_name')
for file in src:
    new_file=file +".wav"
    # convert wav to mp3                                                            
    sound = AudioSegment.from_mp3(file)
    sound.export(new_file, format="wav")

Here is the error I got:

PermissionError: [Errno 13] Permission denied:

Please can anyone tell me a better way to do this

  • don't you need to add back the path to the export file name? or any other valid path? – B. Go Feb 25 '20 at 19:19
  • `open()` isn't something you can do with a *folder*, that's for reading data from files. `os.listdir()` is how you get the filenames contained in a folder. – jasonharper Feb 25 '20 at 19:59

0 Answers0