{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.12.12","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"gpu","dataSources":[{"sourceId":129271,"databundleVersionId":15506307,"sourceType":"competition"}],"dockerImageVersionId":31260,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":true}},"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":"2026-01-30T16:07:40.154690Z","iopub.execute_input":"2026-01-30T16:07:40.154925Z","iopub.status.idle":"2026-01-30T16:07:41.172366Z","shell.execute_reply.started":"2026-01-30T16:07:40.154896Z","shell.execute_reply":"2026-01-30T16:07:41.171539Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import os\nimport json\nimport pandas as pd\n\n# 1. Define the directory where your test files are located\n# Based on your input, it seems to be here:\ntest_audio_dir = \"/kaggle/input/dl-sprint-4-0-bengali-speaker-diarization-challenge/diarization/diarization/test/audio\"\n\n# 2. Get all .wav files from that directory\ntry:\n    test_files = [f for f in os.listdir(test_audio_dir) if f.endswith('.wav')]\n    print(f\"Found {len(test_files)} test files.\")\nexcept FileNotFoundError:\n    print(\"Directory not found. Using the list provided in the prompt for demonstration.\")\n    # Fallback list based on your input\n    test_files = [\n        \"test_019.wav\", \"test_016.wav\", \"test_021.wav\", \"test_020.wav\", \n        \"test_030.wav\", \"test_022.wav\", \"test_029.wav\", \"test_012.wav\", \n        \"test_032.wav\", \"test_027.wav\", \"test_010.wav\", \"test_024.wav\", \n        \"test_018.wav\", \"test_023.wav\"\n    ]\n\n# 3. Create dummy predictions (Replace this logic with your actual model inference!)\n# Format: List of dictionaries with start, end, and speaker_id\ndummy_segments = [\n    {\"start_time\": 0.0, \"end_time\": 5.0, \"speaker_id\": \"SPEAKER_00\"},\n    {\"start_time\": 5.5, \"end_time\": 12.0, \"speaker_id\": \"SPEAKER_01\"},\n    {\"start_time\": 12.5, \"end_time\": 18.0, \"speaker_id\": \"SPEAKER_00\"}\n]\n\n# 4. Generate the submission list\nsubmission_data = []\n\nfor audio_file in test_files:\n    # Remove extension to get the ID (e.g., \"test_019.wav\" -> \"test_019\")\n    file_id = os.path.splitext(audio_file)[0]\n    \n    # Convert list of dicts to a JSON string (CRITICAL STEP)\n    json_string = json.dumps(dummy_segments)\n    \n    submission_data.append({\n        \"filename\": file_id,\n        \"diarization\": json_string\n    })\n\n# 5. Create DataFrame and save\ndf = pd.DataFrame(submission_data)\ndf.to_csv(\"submission.csv\", index=False)\n\nprint(\"✅ submission.csv created successfully!\")\nprint(df.head())","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-01-30T16:09:12.493823Z","iopub.execute_input":"2026-01-30T16:09:12.494224Z","iopub.status.idle":"2026-01-30T16:09:12.529769Z","shell.execute_reply.started":"2026-01-30T16:09:12.494180Z","shell.execute_reply":"2026-01-30T16:09:12.529005Z"}},"outputs":[],"execution_count":null}]}