{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.12","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":91844,"databundleVersionId":11361821,"sourceType":"competition"}],"dockerImageVersionId":30918,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"# This Python 3 environment comes with many helpful analytics libraries installed\n# It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python\n# For example, here's several helpful packages to load\n\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n\n# Input data files are available in the read-only \"../input/\" directory\n# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory\n\nimport os\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n    for filename in filenames:\n        print(os.path.join(dirname, filename))\n\n# You can write up to 20GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using \"Save & Run All\" \n# You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session","metadata":{"_uuid":"c41b18f1-a0a5-4df1-afbe-3a5b44e04552","_cell_guid":"1d4a6f65-bf06-457c-b3f4-016f893ad886","trusted":true,"collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2025-03-18T12:09:02.297722Z","iopub.execute_input":"2025-03-18T12:09:02.298097Z","iopub.status.idle":"2025-03-18T12:09:37.785082Z","shell.execute_reply.started":"2025-03-18T12:09:02.298065Z","shell.execute_reply":"2025-03-18T12:09:37.783722Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import pandas as pd\ntaxonomy_file_path = '/kaggle/input/birdclef-2025/taxonomy.csv'  # Update this with the actual path to your file\ntaxonomy_data = pd.read_csv(taxonomy_file_path)\nprint(taxonomy_data.head(20))","metadata":{"_uuid":"250f0046-38ac-4858-9a4f-6827250a6d9b","_cell_guid":"5b347c60-2515-48f4-8578-2fb7ca46b2e7","trusted":true,"collapsed":false,"execution":{"iopub.status.busy":"2025-03-18T12:09:37.786514Z","iopub.execute_input":"2025-03-18T12:09:37.787130Z","iopub.status.idle":"2025-03-18T12:09:37.819487Z","shell.execute_reply.started":"2025-03-18T12:09:37.787093Z","shell.execute_reply":"2025-03-18T12:09:37.818197Z"},"jupyter":{"outputs_hidden":false}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"\nscientific_names = taxonomy_data['scientific_name']  \ncommon_names = taxonomy_data['common_name'] \nclass_name=taxonomy_data['class_name']\nfor sci_name, com_name, cl_name in zip(scientific_names[:5], common_names[:5],class_name[:5]):\n    print(f\"Scientific Name: {sci_name}, Common Name: {com_name},Class Name:{cl_name}\")","metadata":{"_uuid":"0c8770d7-9273-4927-afc1-5ac71a808852","_cell_guid":"4143b03e-99e5-44bb-bb57-e1867f46e0c9","trusted":true,"collapsed":false,"execution":{"iopub.status.busy":"2025-03-18T12:09:37.821325Z","iopub.execute_input":"2025-03-18T12:09:37.821812Z","iopub.status.idle":"2025-03-18T12:09:37.840659Z","shell.execute_reply.started":"2025-03-18T12:09:37.821753Z","shell.execute_reply":"2025-03-18T12:09:37.839209Z"},"jupyter":{"outputs_hidden":false}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import os\n\ndirectory_path = '/kaggle/input/birdclef-2025/train_soundscapes'\n\n# List files inside the directory\nfiles = os.listdir(directory_path)\n\n# Check the files to see if it contains audio files\nprint(files)","metadata":{"_uuid":"aaf326b9-5b4b-4855-bae6-444e3aed4c28","_cell_guid":"df69af64-26ec-47c6-92f8-55d0685d8978","trusted":true,"collapsed":false,"execution":{"iopub.status.busy":"2025-03-18T12:09:37.843283Z","iopub.execute_input":"2025-03-18T12:09:37.843772Z","iopub.status.idle":"2025-03-18T12:09:37.878119Z","shell.execute_reply.started":"2025-03-18T12:09:37.843709Z","shell.execute_reply":"2025-03-18T12:09:37.875759Z"},"jupyter":{"outputs_hidden":false}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import os\nimport librosa\n\n# Path to the train_soundscapes directory\ntrain_soundscapes_dir = '/kaggle/input/birdclef-2025/train_soundscapes'\n\n# List all files in the directory\nfiles = os.listdir(train_soundscapes_dir)\n\n# Filter to keep only audio files (e.g., .wav files, adjust the extension if needed)\naudio_files = [f for f in files if f.endswith('.wav')]  # Change this to match your file format\n\n# Iterate through the audio files and load them using librosa\nfor audio_file in audio_files:\n    file_path = os.path.join(train_soundscapes_dir, audio_file)\n    \n    try:\n        # Load the audio file (using librosa, for example)\n        audio, sr = librosa.load(file_path, sr=22050)\n        print(f\"Successfully loaded {audio_file} with sample rate {sr}\")\n        \n        # Process the audio here (e.g., feature extraction, classification)\n        # Extract features, make predictions, etc.\n        \n    except Exception as e:\n        print(f\"Error loading {audio_file}: {e}\")","metadata":{"_uuid":"b656de4c-3e0c-4265-a875-8d47c07d56b8","_cell_guid":"719aa196-c8aa-4456-a993-3a0a2d8637db","trusted":true,"collapsed":false,"execution":{"iopub.status.busy":"2025-03-18T12:09:37.882691Z","iopub.execute_input":"2025-03-18T12:09:37.883039Z","iopub.status.idle":"2025-03-18T12:09:37.904046Z","shell.execute_reply.started":"2025-03-18T12:09:37.883006Z","shell.execute_reply":"2025-03-18T12:09:37.903033Z"},"jupyter":{"outputs_hidden":false}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# List all files without filtering by extension\nfiles = os.listdir(train_soundscapes_dir)\nprint(files)  # To check what files are in the directory","metadata":{"_uuid":"0b7a43b8-71de-4d3d-9a68-822cf8bc8256","_cell_guid":"23fa224f-05d4-4811-852f-68abb41acabe","trusted":true,"collapsed":false,"execution":{"iopub.status.busy":"2025-03-18T12:09:37.905163Z","iopub.execute_input":"2025-03-18T12:09:37.905589Z","iopub.status.idle":"2025-03-18T12:09:37.928031Z","shell.execute_reply.started":"2025-03-18T12:09:37.905520Z","shell.execute_reply":"2025-03-18T12:09:37.926400Z"},"jupyter":{"outputs_hidden":false}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Iterate through the directory and only process files, skip directories\nfor file in os.listdir(train_soundscapes_dir):\n    file_path = os.path.join(train_soundscapes_dir, file)\n    if os.path.isfile(file_path):  # Skip directories\n        try:\n            # Process the audio file\n            audio, sr = librosa.load(file_path, sr=22050)\n            print(f\"Successfully loaded {file} with sample rate {sr}\")\n        except Exception as e:\n            print(f\"Error loading {file}: {e}\")","metadata":{"_uuid":"238a2efd-3e1e-4a06-b945-178684b24bbd","_cell_guid":"0d171ee7-6bc7-4cf7-9938-2fa609fd5873","trusted":true,"collapsed":false,"execution":{"iopub.status.busy":"2025-03-18T12:09:37.929355Z","iopub.execute_input":"2025-03-18T12:09:37.929718Z"},"jupyter":{"outputs_hidden":false}},"outputs":[],"execution_count":null}]}