{"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"},{"sourceId":8201343,"sourceType":"datasetVersion","datasetId":4843817},{"sourceId":8202523,"sourceType":"datasetVersion","datasetId":4859485},{"sourceId":8202728,"sourceType":"datasetVersion","datasetId":4859631}],"dockerImageVersionId":30698,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"import os\nimport pandas as pd\nimport librosa\nimport librosa.display\nimport numpy as np\nimport IPython.display as ipd\nimport matplotlib.pyplot as plt\nimport random\nimport torch\nimport torchaudio\nfrom tqdm import tqdm\nimport shutil","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2024-04-23T08:14:02.389643Z","iopub.execute_input":"2024-04-23T08:14:02.390853Z","iopub.status.idle":"2024-04-23T08:14:02.402590Z","shell.execute_reply.started":"2024-04-23T08:14:02.390788Z","shell.execute_reply":"2024-04-23T08:14:02.401030Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"core_train_audio_path = '/kaggle/input/ben10/ben10/16_kHz_train_audio'\n\nnew_barishal_audio_path = '/kaggle/input/barishal-305-clip-dataset/chunks'\nnew_barishal_audio_path_2 = '/kaggle/input/barishal-new-data-1/chunks'\n\nmerged_train_audio_path = '/kaggle/working/bengali-asr-latest-dataset/train/'\ntrain_csv_path = '/kaggle/input/final-train-dataset/Final Train - Sheet1.csv'","metadata":{"execution":{"iopub.status.busy":"2024-04-23T08:14:02.408205Z","iopub.execute_input":"2024-04-23T08:14:02.409238Z","iopub.status.idle":"2024-04-23T08:14:02.417510Z","shell.execute_reply.started":"2024-04-23T08:14:02.409149Z","shell.execute_reply":"2024-04-23T08:14:02.415336Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"len(os.listdir(new_barishal_audio_path))","metadata":{"execution":{"iopub.status.busy":"2024-04-23T08:14:02.419506Z","iopub.execute_input":"2024-04-23T08:14:02.420070Z","iopub.status.idle":"2024-04-23T08:14:02.439591Z","shell.execute_reply.started":"2024-04-23T08:14:02.420033Z","shell.execute_reply":"2024-04-23T08:14:02.438297Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"rm -rf '/kaggle/working/bengali-asr-latest-dataset'","metadata":{"execution":{"iopub.status.busy":"2024-04-23T08:14:02.443661Z","iopub.execute_input":"2024-04-23T08:14:02.444695Z","iopub.status.idle":"2024-04-23T08:14:05.100983Z","shell.execute_reply.started":"2024-04-23T08:14:02.444648Z","shell.execute_reply":"2024-04-23T08:14:05.099023Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"os.makedirs(merged_train_audio_path, exist_ok=True)","metadata":{"execution":{"iopub.status.busy":"2024-04-23T08:14:05.103545Z","iopub.execute_input":"2024-04-23T08:14:05.104014Z","iopub.status.idle":"2024-04-23T08:14:05.112835Z","shell.execute_reply.started":"2024-04-23T08:14:05.103975Z","shell.execute_reply":"2024-04-23T08:14:05.111210Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import os\nimport shutil\n\n# Function to merge audio files from source directory to destination directory\ndef merge_audio(source_dir, destination_dir):\n    for root, dirs, files in os.walk(source_dir):\n        for file in tqdm(files):\n            # Get the full path of the source file\n            source_file_path = os.path.join(root, file)\n            # Create a new file path in the destination directory\n            destination_file_path = os.path.join(destination_dir, file)\n            # Copy the source file to the destination directory\n            shutil.copyfile(source_file_path, destination_file_path)\n\n# Merge audio files from both directories\nmerge_audio(core_train_audio_path, merged_train_audio_path)\nmerge_audio(new_barishal_audio_path, merged_train_audio_path)\n\nprint(\"Audio files merged successfully!\")","metadata":{"execution":{"iopub.status.busy":"2024-04-23T08:14:05.115136Z","iopub.execute_input":"2024-04-23T08:14:05.116912Z","iopub.status.idle":"2024-04-23T08:15:26.545488Z","shell.execute_reply.started":"2024-04-23T08:14:05.116860Z","shell.execute_reply":"2024-04-23T08:15:26.543760Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"merge_audio(new_barishal_audio_path_2, merged_train_audio_path)","metadata":{"execution":{"iopub.status.busy":"2024-04-23T08:15:26.547250Z","iopub.execute_input":"2024-04-23T08:15:26.547621Z","iopub.status.idle":"2024-04-23T08:15:40.541008Z","shell.execute_reply.started":"2024-04-23T08:15:26.547591Z","shell.execute_reply":"2024-04-23T08:15:40.539220Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(len(os.listdir(core_train_audio_path)))\nprint(len(os.listdir('/kaggle/working/bengali-asr-latest-dataset/train')))","metadata":{"execution":{"iopub.status.busy":"2024-04-23T08:15:40.543348Z","iopub.execute_input":"2024-04-23T08:15:40.543928Z","iopub.status.idle":"2024-04-23T08:15:40.567782Z","shell.execute_reply.started":"2024-04-23T08:15:40.543880Z","shell.execute_reply":"2024-04-23T08:15:40.566860Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"shutil.copy(train_csv_path, '/kaggle/working/bengali-asr-latest-dataset/')","metadata":{"execution":{"iopub.status.busy":"2024-04-23T08:15:40.569098Z","iopub.execute_input":"2024-04-23T08:15:40.570096Z","iopub.status.idle":"2024-04-23T08:15:40.692793Z","shell.execute_reply.started":"2024-04-23T08:15:40.570061Z","shell.execute_reply":"2024-04-23T08:15:40.691817Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"mv '/kaggle/working/bengali-asr-latest-dataset/Final Train - Sheet1.csv' '/kaggle/working/bengali-asr-latest-dataset/final_train.csv'","metadata":{"execution":{"iopub.status.busy":"2024-04-23T08:15:40.696057Z","iopub.execute_input":"2024-04-23T08:15:40.696828Z","iopub.status.idle":"2024-04-23T08:15:41.822857Z","shell.execute_reply.started":"2024-04-23T08:15:40.696786Z","shell.execute_reply":"2024-04-23T08:15:41.820955Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!ls bengali-asr-latest-dataset","metadata":{"execution":{"iopub.status.busy":"2024-04-23T08:15:41.825259Z","iopub.execute_input":"2024-04-23T08:15:41.827602Z","iopub.status.idle":"2024-04-23T08:15:42.939860Z","shell.execute_reply.started":"2024-04-23T08:15:41.827554Z","shell.execute_reply":"2024-04-23T08:15:42.938391Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df = pd.read_csv('/kaggle/working/bengali-asr-latest-dataset/final_train.csv')","metadata":{"execution":{"iopub.status.busy":"2024-04-23T08:16:44.195044Z","iopub.execute_input":"2024-04-23T08:16:44.195648Z","iopub.status.idle":"2024-04-23T08:16:44.418671Z","shell.execute_reply.started":"2024-04-23T08:16:44.195604Z","shell.execute_reply":"2024-04-23T08:16:44.417139Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import csv\ndef search_csv(filename, keyword):\n    with open(filename, 'r', newline='', encoding='utf-8') as csvfile:\n        reader = csv.reader(csvfile)\n        found_in_rows = []\n        for row in reader:\n            for cell in row:\n                if keyword.lower() in cell.lower():\n                    found_in_rows.append(row)\n                    break  # If you want to stop searching the row after finding the keyword, remove this line\n    return found_in_rows\n\ndirectory = \"/kaggle/working/bengali-asr-latest-dataset/final_train.csv\"  # Replace this with the directory containing your CSV files\nkeyword = \"barishal\"\n\nfiltered_files = search_csv(directory, keyword)\nlen(filtered_files)","metadata":{"execution":{"iopub.status.busy":"2024-04-23T08:20:41.087040Z","iopub.execute_input":"2024-04-23T08:20:41.088546Z","iopub.status.idle":"2024-04-23T08:20:41.220951Z","shell.execute_reply.started":"2024-04-23T08:20:41.088488Z","shell.execute_reply":"2024-04-23T08:20:41.219500Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}