{"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":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true,"execution":{"iopub.status.busy":"2025-03-17T16:31:33.562843Z","iopub.execute_input":"2025-03-17T16:31:33.563246Z","iopub.status.idle":"2025-03-17T16:32:28.522441Z","shell.execute_reply.started":"2025-03-17T16:31:33.563210Z","shell.execute_reply":"2025-03-17T16:32:28.521242Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"train = pd.read_csv('/kaggle/input/birdclef-2025/train.csv')","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-17T16:32:28.523783Z","iopub.execute_input":"2025-03-17T16:32:28.524128Z","iopub.status.idle":"2025-03-17T16:32:28.640382Z","shell.execute_reply.started":"2025-03-17T16:32:28.524092Z","shell.execute_reply":"2025-03-17T16:32:28.639382Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"train['secondary_labels'].value_counts()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-17T16:07:04.115851Z","iopub.execute_input":"2025-03-17T16:07:04.116196Z","iopub.status.idle":"2025-03-17T16:07:04.129471Z","shell.execute_reply.started":"2025-03-17T16:07:04.116165Z","shell.execute_reply":"2025-03-17T16:07:04.128401Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"train.head()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-17T16:03:53.381238Z","iopub.execute_input":"2025-03-17T16:03:53.381632Z","iopub.status.idle":"2025-03-17T16:03:53.415457Z","shell.execute_reply.started":"2025-03-17T16:03:53.381580Z","shell.execute_reply":"2025-03-17T16:03:53.414502Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import librosa\nimport matplotlib.pyplot as plt\nfrom IPython.display import Audio\nimport os","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-17T16:33:09.866277Z","iopub.execute_input":"2025-03-17T16:33:09.866668Z","iopub.status.idle":"2025-03-17T16:33:09.871613Z","shell.execute_reply.started":"2025-03-17T16:33:09.866639Z","shell.execute_reply":"2025-03-17T16:33:09.870256Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"len(next(os.walk('/kaggle/input/birdclef-2025/train_audio/'))[1])","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-17T16:33:54.993943Z","iopub.execute_input":"2025-03-17T16:33:54.994265Z","iopub.status.idle":"2025-03-17T16:33:55.005111Z","shell.execute_reply.started":"2025-03-17T16:33:54.994240Z","shell.execute_reply":"2025-03-17T16:33:55.003282Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"train_audio_sample, sr = librosa.load('/kaggle/input/birdclef-2025/train_audio/1139490/CSA36389.ogg', sr=32000)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-17T16:26:19.729003Z","iopub.execute_input":"2025-03-17T16:26:19.729354Z","iopub.status.idle":"2025-03-17T16:26:19.865348Z","shell.execute_reply.started":"2025-03-17T16:26:19.729327Z","shell.execute_reply":"2025-03-17T16:26:19.864211Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"fig, ax = plt.subplots(nrows=2, sharex=True)\nS = librosa.feature.melspectrogram(y=train_audio_sample, sr=sr, n_mels=128,\n                                   fmax=8000)\nmfccs = librosa.feature.mfcc(y=train_audio_sample, sr=sr, n_mfcc=40)\nimg = librosa.display.specshow(librosa.power_to_db(S, ref=np.max),\n                               x_axis='time', y_axis='mel', fmax=8000,\n                               ax=ax[0])\n\nfig.colorbar(img, ax=[ax[0]])\nax[0].set(title='Mel spectrogram')\nax[0].label_outer()\nimg = librosa.display.specshow(mfccs, x_axis='time', ax=ax[1])\nfig.colorbar(img, ax=[ax[1]])\nax[1].set(title='MFCC')","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-17T16:26:21.800497Z","iopub.execute_input":"2025-03-17T16:26:21.800900Z","iopub.status.idle":"2025-03-17T16:26:23.957465Z","shell.execute_reply.started":"2025-03-17T16:26:21.800868Z","shell.execute_reply":"2025-03-17T16:26:23.956366Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"Audio(data=train_audio_sample, rate=sr)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-17T16:26:27.138326Z","iopub.execute_input":"2025-03-17T16:26:27.138691Z","iopub.status.idle":"2025-03-17T16:26:27.332455Z","shell.execute_reply.started":"2025-03-17T16:26:27.138660Z","shell.execute_reply":"2025-03-17T16:26:27.330824Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"","metadata":{"trusted":true},"outputs":[],"execution_count":null}]}