Convert multiple audio file formats in a folder and make a separate folder to store

351 Views Asked by At

I want to convert multiple audio file formats from a folder (named as "aud_test") to a unique WAV format using python 3. After this, Save all files in another folder (named as "re_test") as mentioned in the below code.

    import os              
    from pydub import AudioSegment  
    wrong_folder_path = "/output/aud_test"      
    right_folder_path = "/output/re_test"    
    
    def make_wav(wrong_folder_path, right_folder_path):           
        for file in os.scandir(wrong_folder_path):                 
            if (ext == ".mp3" or ext == ".m4a" or ext == ".aac" or ext == ".opus" or ext == ".ogg" or ext == ".wma"):         
                out_file=right_folder_path+'/'+os.path.splitext(os.path.basename(file.path))[0]+".wav"      
            AudioSegment.from_file(file.path).export(out_file, format="wav")   
            print(f"{out_file}")

Getting an Error message as mentioned below:

TypeError: Traceback (most recent call last) <ipython-input-4-ad47c4ef00c8> in <module> ----> 1 "".join(1,2,3)  TypeError: join() takes exactly one argument (3 given) 
0

There are 0 best solutions below