Associated Research Paper: π Elephant Sound Classification Using Deep Learning Optimization https://doi.org/10.3390/s25020352
This repository contains the full implementation, scripts, and datasets used in our study on raw-audio-based elephant vocalization classification, published in Sensors (MDPI), 2025.
The research focuses on developing efficient machine learning models that operate directly on raw waveforms, enabling deployment on resource-constrained edge devices for real-time wildlife monitoring.
We classify three elephant caller types:
- Rumble
- Roar
- Trumpet
Our results demonstrate that raw audio processing outperforms spectrogram-based pipelines, achieving higher accuracy while reducing computational overhead.
This project uses two sources of elephant vocalization data:
A curated and pre-labeled dataset containing the three caller types:
- Rumble
- Roar
- Trumpet
Access the Dataset:
π Click here to open the dataset directory
The dataset is organized into:
dataset/
βββ train/
βββ val/
βββ test/All files are preprocessed and standardized to 6-second waveform clips.
This complete classified dataset is included directly within this GitHub repository.
We experimented with the following models:
-
MobileNet V2:
- Utilized pre-trained data and fine-tuned it on our dataset.
-
YAMNet:
- Trained the model from scratch specifically for our datasets.
-
RawNet:
- Trained the model from scratch for our datasets.
-
ElephantCallerNet based from ACDNet:
- Trained the model from scratch for our datasets.
The models are trained on raw audio files. However, the audio files need to be pre-processed before training. Here are the steps for pre-processing:
- Dataset Division: The dataset is divided into test, train, and validation datasets, each containing the three classes.
- Audio Duration: The models accept 6-second audio files.
- If the waveform is greater than 6 seconds, it is trimmed to 6 seconds.
- If the audio file is greater than 8 seconds, it is segmented into equal length sizes and padded or trimmed to make each segment 6 seconds.
- Audio files with a duration less than 2 seconds are avoided.
ββββββββββββββββββββββββββ
β Raw Audio Dataset β
β (Rumble / Roar / Trumpet)
ββββββββββββββββ¬ββββββββββ
β
βΌ
ββββββββββββββββββββββββββ
β Pre-processing β
β - Trim / Pad to 6 sec β
β - Segment > 8 sec β
β - Remove < 2 sec β
ββββββββββββββββ¬ββββββββββ
β
βΌ
ββββββββββββββββββββββββββββββββββββββββββ
β Model Training (Raw Waveforms) β
β MobileNet β’ YAMNet β’ RawNet β’ ElephantCallerNet
ββββββββββββββββ¬ββββββββββββββββββββββββββ
β
βΌ
ββββββββββββββββββββββββββ
β Evaluation β
β Accuracy & Metrics β
ββββββββββββββββ¬ββββββββββ
β
βΌ
ββββββββββββββββββββββββββ
β Inference β
β Predict caller type β
ββββββββββββββββββββββββββ
| Model | Training Approach | Input Type | Accuracy |
|---|---|---|---|
| MobileNet V2 | Fine-tuned | Raw | 82% |
| YAMNet | From scratch | Raw | 78% |
| RawNet | From scratch | Raw | 84% |
| ElephantCallerNet (Proposed) | From scratch | Raw | 89% |
A visual comparison of model accuracies across MobileNet, YAMNet, RawNet, and the proposed ElephantCallerNet, demonstrating the superior performance of raw-audio-based training.
A detailed breakdown of performance metrics (accuracy) showing the advantages of processing raw waveforms over spectrogram-based approaches.
A system-level diagram of the end-to-end monitoring platform developed in this study, including audio capture, processing, classification, and dashboard visualization.
To ensure a consistent environment for running the script, we have included an environment.yml file. This file can be used to set up a conda environment with all necessary dependencies.
-
Install Conda:
-
Create the Environment:
conda env create -f environment.yml
The following steps describe how to process the raw audio files to ensure they meet the requirements of the machine learning models. The script segments, pads, or trims the audio files as necessary to produce 6-second audio files suitable for training.
-
Prepare the Script:
- Save the provided script as
process_audio.py.
- Save the provided script as
-
Run the Script:
- Run the script with the input and output directories as arguments:
python process_audio.py <input_dir> <output_dir>
Replace
<input_dir>with the path to your directory containing the raw WAV files, and<output_dir>with the path where you want to save the processed audio files.
Suppose you have a directory of raw audio files located at data/raw_audio and you want to save the processed audio files in data/processed_audio. You would run the script as follows:
python process_audio.py data/raw_audio data/processed_audioThis command processes each audio file in data/raw_audio, applies the necessary padding, segmentation, or trimming, and saves the processed files in data/processed_audio with appropriate naming.
After you have created or pre-processed your audio files, you can directly pass your audio file to inference code as follows;
python inference.py mobilenet /path/to/your/audio/file.wavReplace 'mobilnet' with your preference model. This project is supporting 04 models, namely; Mobilnet, YAMNet, RawNet, and ElephantCallerNet
If you use this repository or the associated publication, please cite:
Dewmini, H.; Meedeniya, D.; Perera, C. Elephant Sound Classification Using Deep Learning Optimization. Sensors 2025, 25, 352. https://doi.org/10.3390/s25020352
Dewmini H, Meedeniya D, Perera C. Elephant Sound Classification Using Deep Learning Optimization. Sensors. 2025; 25(2):352. https://doi.org/10.3390/s25020352
Dewmini, Hiruni, Dulani Meedeniya, and Charith Perera. 2025. "Elephant Sound Classification Using Deep Learning Optimization." Sensors 25, no. 2: 352. https://doi.org/10.3390/s25020352
Dewmini, H., Meedeniya, D., & Perera, C. (2025). Elephant Sound Classification Using Deep Learning Optimization. Sensors, 25(2), 352. https://doi.org/10.3390/s25020352
@Article{s25020352,
AUTHOR = {Dewmini, Hiruni and Meedeniya, Dulani and Perera, Charith},
TITLE = {Elephant Sound Classification Using Deep Learning Optimization},
JOURNAL = {Sensors},
VOLUME = {25},
YEAR = {2025},
NUMBER = {2},
ARTICLE-NUMBER = {352},
URL = {https://doi.org/10.3390/s25020352},
DOI = {10.3390/s25020352}
}