This repository provides tools for analyzing and visualizing sound events detected by recorders from the Sounds of Home Dataset. The analysis framework leverages the hierarchical structure of the AudioSet ontology, enabling systematic exploration and categorization of domestic soundscapes.
The main analysis interface allows comprehensive exploration of the dataset:
Generated visualizations display sound event distributions:
- Environment Requirements:
- Python 3.6 or higher
- Git (for cloning the repository)
- Install Project:
git clone https://github.com/gbibbo/sounds_of_home_analysis.git
cd sounds_of_home_analysis
pip install -e .- Download Dataset:
- Visit the Sounds of Home Dataset page
- Download the prediction JSON files
- Create a 'data' directory in the repository root:
mkdir data- Place downloaded JSON files in the 'data' directory
- Configure Data Path:
- Open
src/config.py - Set
PREDICTIONS_ROOT_DIR = 'data'
- Launch Interface:
python scripts/main.py --gui- Select Parameters:
- Confidence Threshold: Filter events by prediction confidence
- Recorders: Select the recorders to be used for audio analysis. Note how the recorders were originally installed
- Sound Classes: Select event types to analyze
- Days: Specify analysis timeframe
- Generate Analysis:
- Click
Plotfor time series analysis, orPlot and Analysisfor time series analysis, basic statistical analysis, correlation analysis, PCA, heatmaps and clustering, peak activity analysis - View graph showing event distribution
- Results automatically save to
assets/imagesdirectory
The batch_analysis.py script performs analysis across multiple confidence thresholds:
- Threshold Options:
- Fixed thresholds: [0.0, 0.05, 0.1, 0.15, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45, 0.5]
- Variable threshold: Adapts based on AudioSet label quality
- Uses linear interpolation:
threshold = 0.1 + (0.35 - 0.1) * (label_quality / 100)
- Example:
- For 100% quality label: threshold = 0.5
- For 50% quality label: threshold = 0.35
- For 0% quality label: threshold = 0.2
- Uses linear interpolation:
- Usage:
python scripts/batch_analysis.py- Output Directory Structure:
analysis_results/
└── batch_analysis_results/
├── analysis_results_threshold_0.0.json
├── analysis_results_threshold_0.05.json
...
├── analysis_results_threshold_0.5.json
└── analysis_results_threshold_variable.json- Customizing Analysis:
- Configure data selection in
src/config.py:SELECTED_RECORDERS = [] # Empty list means all recorders SELECTED_DAYS = [] # Empty list means all available days SELECTED_HOURS = [] # Empty list means all hours
### Granger Causality Analysis
The `granger.py` script analyzes temporal relationships between sound events:
1. **Analysis Features**:
- Time Series Analysis using ARIMA models
- Cross-Correlation Functions with Lag Analysis
- Granger Causality Tests
- Principal Component Analysis (PCA)
- UMAP and t-SNE visualizations
- Animated temporal evolution visualization
2. **Usage**:
```bash
python scripts/granger.py
- Output Directory Structure:
granger/
├── figures/
│ ├── time_series.png
│ ├── correlation_matrix.png
│ ├── top_correlations.png
│ ├── pca_results.png
│ ├── umap_results.png
│ ├── tsne_results.png
│ ├── umap_frames/
│ └── umap_animation_custom.gif
├── results/
│ ├── significant_correlations.json
│ ├── granger_causality_results.json
│ └── umap_intermediate_data.pkl
└── logs/
└── analysis_log_[timestamp].txtThe generate_minute_data.py script processes audio events with minute-level resolution:
- Features:
- Aggregates detection counts across all recorders
- Applies quality-based confidence thresholds
- Processes individual AudioSet classes without ontology aggregation
- Usage:
python scripts/generate_minute_data.py- Output:
analysis_results/
└── minute_analysis_results/
└── minute_counts.json # Minute-by-minute event countsThe events_statistics.py script generates comprehensive statistical information about sound event occurrences:
- Analysis Features:
- Processes multiple JSON prediction files
- Handles hierarchical AudioSet relationships
- Applies confidence thresholds
- Generates category and subcategory statistics
- Creates visualization plots
- Usage:
python scripts/events_statistics.py- Output Directory Structure:
analysis_results/
└── events_statistics_results/
├── events_statistics_results.json
├── main_categories.png # Overall category distribution
└── subcategories_*.png # Detailed subcategory analysis- Configuration Options:
- Adjust in
src/config.py:PREDICTIONS_ROOT_DIR: Data locationDEFAULT_CONFIDENCE_THRESHOLD: Base thresholdUSE_LABEL_QUALITY_THRESHOLDS: Enable/disable quality-based thresholdsGENERATE_GRAPHS: Control visualization outputCUSTOM_CATEGORIES: Define category structure
Here's a dynamic preview of the application interface that you can also find in the dataset website
This project is designed to run with the dataset that can be downloaded from:
Download the dataset and ensure the prediction files (JSON files) are located in the appropriate directory within the project, as specified in the configuration.
.
├── analysis_results
│ ├── batch_analysis_results
│ │ └── analysis_results_threshold_*.json
│ └── events_statistics_results
│ ├── events_statistics_results.json
│ ├── main_categories.png
│ └── subcategories_*.png
├── assets
│ └── images
│ ├── interface.png
│ └── plot.png
├── metadata
│ ├── class_labels_indices.csv
│ └── ontology.json
├── README.md
├── requirements.txt
├── scripts
│ ├── batch_analysis.py
│ ├── events_statistics.py
│ ├── main.py
│ └── plot_results.py
├── setup.py
├── src
│ ├── config.py
│ ├── data_processing
│ │ ├── load_data.py
│ │ ├── process_data.py
│ │ └── utils.py
│ ├── gui
│ │ └── tkinter_interface.py
│ └── visualization
│ └── plot_data.py
└── tests
└── test_data_processing.py
Note: The directories and files excluded by .gitignore (such as sample data and analysis results) are not shown in the project structure.
Contributions are welcome. To contribute:
-
Fork the repository.
-
Create your feature branch:
git checkout -b feature/new-feature- Commit your changes:
git commit -m 'Add new feature'- Push to the branch:
git push origin feature/new-feature- Open a Pull Request on GitHub.
This project is licensed under the MIT License. See the LICENSE file for details.
For questions or support, you can reach me through:
- GitHub: gbibbo
- Email: [email protected]