{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.13","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":73047,"databundleVersionId":8149390,"sourceType":"competition"}],"dockerImageVersionId":30673,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"!python3 -m pip install -U --pre yt-dlp[default]\n\nfrom matplotlib import pyplot as plt\nimport numpy as np\nfrom IPython.display import Audio","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2024-04-06T00:53:02.548498Z","iopub.execute_input":"2024-04-06T00:53:02.548923Z","iopub.status.idle":"2024-04-06T00:53:21.825290Z","shell.execute_reply.started":"2024-04-06T00:53:02.548887Z","shell.execute_reply":"2024-04-06T00:53:21.823416Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from glob import glob\nfrom shutil import copy\nimport os\nimport pandas as pd","metadata":{"execution":{"iopub.status.busy":"2024-04-06T00:53:56.083354Z","iopub.execute_input":"2024-04-06T00:53:56.083804Z","iopub.status.idle":"2024-04-06T00:53:57.369061Z","shell.execute_reply.started":"2024-04-06T00:53:56.083766Z","shell.execute_reply":"2024-04-06T00:53:57.367810Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!yt-dlp -x --audio-format wav https://www.youtube.com/@PrioSylhet/videos --playlist-end 2 # downloading 2 files from the channel","metadata":{"execution":{"iopub.status.busy":"2024-04-06T00:53:21.827959Z","iopub.execute_input":"2024-04-06T00:53:21.828428Z","iopub.status.idle":"2024-04-06T00:53:56.081258Z","shell.execute_reply.started":"2024-04-06T00:53:21.828387Z","shell.execute_reply":"2024-04-06T00:53:56.080124Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"paths = glob('/kaggle/working/*.wav')\nprint(len(paths))","metadata":{"execution":{"iopub.status.busy":"2024-04-06T00:54:51.291539Z","iopub.execute_input":"2024-04-06T00:54:51.291994Z","iopub.status.idle":"2024-04-06T00:54:51.299073Z","shell.execute_reply.started":"2024-04-06T00:54:51.291961Z","shell.execute_reply":"2024-04-06T00:54:51.297660Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"os.makedirs('renamed_files', exist_ok = True)","metadata":{"execution":{"iopub.status.busy":"2024-04-06T00:53:57.382645Z","iopub.execute_input":"2024-04-06T00:53:57.383290Z","iopub.status.idle":"2024-04-06T00:53:57.393426Z","shell.execute_reply.started":"2024-04-06T00:53:57.383257Z","shell.execute_reply":"2024-04-06T00:53:57.392125Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"old_names = []\nnew_names = []\nfor i_p, p in enumerate(paths):\n    src = p\n    filename = os.path.basename(src)\n    filename_new = '{:06d}.wav'.format(i_p)\n    dst = os.path.join('/kaggle/working/', 'renamed_files', filename_new)\n    \n    old_names.append(filename)\n    new_names.append(filename_new)\n    \n    copy(src,dst)\n    \ndf_mapper = pd.DataFrame({\n    'old_name': old_names,\n    'new_name': new_names\n})\ndf_mapper.to_csv('filename_metadata.csv', index = False)","metadata":{"execution":{"iopub.status.busy":"2024-04-06T00:53:57.394923Z","iopub.execute_input":"2024-04-06T00:53:57.395720Z","iopub.status.idle":"2024-04-06T00:53:58.450441Z","shell.execute_reply.started":"2024-04-06T00:53:57.395608Z","shell.execute_reply":"2024-04-06T00:53:58.449116Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!rm /kaggle/working/*.wav","metadata":{"execution":{"iopub.status.busy":"2024-04-06T00:53:58.451968Z","iopub.execute_input":"2024-04-06T00:53:58.453106Z","iopub.status.idle":"2024-04-06T00:53:59.636062Z","shell.execute_reply.started":"2024-04-06T00:53:58.453071Z","shell.execute_reply":"2024-04-06T00:53:59.633924Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"paths = glob('/kaggle/working/*/*.wav')\nprint(len(paths))","metadata":{},"execution_count":null,"outputs":[]}]}