{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"A lot of ASR Models require .wav format audio. This is an easy way to do it.\n\n\nOriginal Resource : https://www.kaggle.com/code/tareksherif/easy-way-to-convert-mp3-to-wav/notebook","metadata":{}},{"cell_type":"code","source":"import os\n\nfrom tqdm import tqdm\nfrom os import path\nfrom pydub import AudioSegment\n\n\ninput_path = '../input/dlsprint/test_files/' #This is the directory where the mp3 files are stored\ntest_path=\"./test_files_wav/\" # This is the directory where the wav files will be stored\n\nos.mkdir(test_path) # Creating a folder where the .wav files will be stored\n\nfor dirname, _, filenames in os.walk(input_path):\n    for filename in tqdm(filenames):                                                                       \n        src = input_path + filename\n        dst = test_path +os.path.splitext(filename)[0]+\".wav\"\n        # convert wav to mp3                                                            \n        sound = AudioSegment.from_mp3(src)\n        sound = sound.set_frame_rate(32000)\n        sound.export(dst, format=\"wav\")","metadata":{"execution":{"iopub.status.busy":"2022-06-30T23:05:05.631573Z","iopub.execute_input":"2022-06-30T23:05:05.632758Z","iopub.status.idle":"2022-06-30T23:07:32.566354Z","shell.execute_reply.started":"2022-06-30T23:05:05.632638Z","shell.execute_reply":"2022-06-30T23:07:32.56447Z"},"trusted":true},"execution_count":null,"outputs":[]}]}