This project comprises two main Python scripts that work together to detect and classify meteor bursts from audio spectrograms.
Please see also documentation.
-
prime_detection.py
- Captures audio in 30-second segments using the TwitchRealtimeHandler.
- Creates spectrograms with the
plot_spectrogram
function. - Processes the spectrograms to detect and classify meteor bursts.
-
detector_and_classification.py
- Contains the
detect_and_cluster_bursts
function. - Uses ORB feature detection and DBSCAN clustering to identify meteor bursts.
- Classifies bursts into:
- Critical bursts: Bursts lasting at least 0.5 seconds.
- Non-critical bursts: Bursts lasting less than 0.5 seconds.
- Contains the
- Audio Recording: Captures live audio streams from a Twitch source.
- Spectrogram Generation: Converts audio data into spectrogram images for processing.
- CSV Logging: Logs results, including the count of critical and non-critical bursts, to a daily CSV file.
-
Audio Capture:
- Records 30-second audio segments from a specified Twitch stream.
- Saves the audio as a WAV file.
-
Spectrogram Generation:
- Plots and saves a spectrogram image from the recorded audio.
- Dynamically adjusts the noise threshold based on spectrogram analysis.
-
Burst Detection:
- Calls
detect_and_cluster_bursts
fromdetector_and_classification.py
. - Updates hourly and daily burst counts.
- Calls
-
Daily CSV Logging:
- Records timestamped results to a CSV file.
- Creates a new CSV file each day.
-
ORB Detection:
- Uses the ORB algorithm to detect keypoints in the spectrogram image.
-
DBSCAN Clustering:
- Groups keypoints into clusters.
- Labels clusters as bursts.
-
Burst Classification:
- Measures the duration of each burst.
- Classifies bursts based on a duration threshold of 0.5 seconds.
-
Feature Detection:
- Reads a spectrogram image.
- Detects keypoints using the ORB algorithm.
-
Clustering:
- Applies DBSCAN clustering to group keypoints.
- Visualizes clusters with bounding boxes (green for critical, red for non-critical).
-
Classification:
- Classifies bursts based on their duration.
- Returns lists of critical and non-critical bursts.
- Annotated spectrogram image with detected bursts.
- Lists of critical and non-critical bursts.
- Python 3.8+
- Required libraries:
numpy
,opencv-python
,matplotlib
,scikit-learn
,pyaudio
,wave
,twitchrealtimehandler
,pandas
.
- Clone this repository. Set up a new virtual environment and activate it.
- Install dependencies using:
pip install -r requirements.txt
Activate your new virtual environment.
-
Run
prime_detection.py
:python prime_detection.py
- Follow prompts to select audio input devices.
-
Adjust Detection Parameters:
- Modify
eps
andmin_samples
indetect_and_cluster_bursts
for DBSCAN clustering as needed.
- Modify
- Hourly and daily burst counts logged to CSV files.
- Annotated spectrogram images saved as
spectrogram2detected.jpg
.
- Optimize ORB and DBSCAN parameters for better burst detection.
- Integrate real-time burst visualization.