# Towards an Indoor Gunshot Detection and Notification System Using Deep Learning
## 3 Materials and Methods
### A Deep Learning Model for Gunshot Detection  
#### 3.1.1 Dataset Generation  
This project has generated a substantial dataset consisting of 670,000 sound samples, each with a duration of one second. This dataset comprises two distinct classes: 'gunshot' and 'other'. The 'other' sounds are any sound other than gunshot sounds, i.e., they are non-gunshot sounds. To classify a sound as a 'gunshot' or 'other' class, the deep learning model needs to be trained with examples of both classes of sounds. In the developed dataset, each class has 335,000 samples. The gunshot sounds were collected from different online sources such as the BGG dataset [17; 18], the Free Firearm Sound Effects Library [19], the Gunshot audio dataset [20; 21], the Gunshot Audio Forensics Dataset [22], the Gunshot/Gunfire Audio Dataset [23; 24], and gunshot sounds from the Urbansound8k Dataset [25; 26]. The 'other' sounds were also collected from online sources such as the Urbansound8k Dataset [25; 26], the ESC-50 Dataset [27; 28], the FSD50K dataset [29; 30], and the snoring dataset [31; 32]. The collected gunshot WAV audio files had a collection of gunshots from different guns such as AK-12, AK-47, IMI Desert Eagle, M4, M16, M249, MG-42, MP5, and Zastava \begin{table}
\begin{tabular}{p{42.7 pt} p{42.7 pt} p{42.7 pt} p{42.7 pt} p{42.7 pt} p{42.7 pt} p{42.7 pt} p{42.7 pt} p{42.7 pt}} \hline \hline  & **[PERSON], et al. [10]** & **[PERSON] et al. [11]** & **[PERSON] et al. [11]** & **[PERSON] et al. [12]** & **[PERSON] et al. [13]** & **[PERSON] et al. [14]** & **[PERSON] et al. [15]** & **Proposed** \\ \hline Classifier & ANN & NMF & GMM & SVM & ANN & CNN & CNN & CNN \\ \hline Dataset size & 11,004 & 215 & - & 49 videos & 917 & 7000 & \textless{}90,000 & 670,000 \\ \hline Accuracy & - & - & - & - & 99\% & 99\% & 99\% & 98\% \\ \hline Precision & 69.3\% & - & 93\% & 73.46\% & - & - & - & 98\% \\ \hline Embedded system & no & no & no & no & no & no & yes & yes \\ \hline Record gunshot with timestamp & no & no & no & yes & no & yes \\ \hline Plot on map & no & no & no & no & no & no & yes \\ \hline User and device configuration & no & no & no & no & no & no & yes \\ \hline Database implementation & no & no & no & no & no & no & yes \\ \hline Smartphone notification & no & no & no & no & no & yes (using SMS) & yes \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Comparison with other works. M92. These audio files had different durations. Moreover, these files often contained silence, human talking, environmental sounds, bullet shell falling and trailing sound after a gunshot, etc., for more than one second. These sounds must be removed from the gunshot class samples to make a high-quality dataset and to increase the accuracy of the trained model. To do that, all these files were first joined using WavePad Sound Editor [33]. Then, using the silence threshold function of the sound editor software, silences are removed. However, it was found that this method is not fully accurate and some silences were still there. Then, the joined file was split into equal-sized one-second duration files. As the joined file was not evenly divisible by one second, the last split file was deleted. We define a valid one-second gunshot sound file that contains at least one starting of a gunshot sound at any place in the one-second duration. To automatically remove silent sound files, a Python code was written that reads the maximum absolute amplitude of each WAV file, compares it with a threshold, and removes the files if it is below the threshold. However, this time-domain approach is still not so accurate to filter out all the silences. To remove the unwanted sounds, all the one-second gunshot sound files, approximately 20,000 samples, were manually heard by humans and filtered. This manual effort is necessary to make the dataset a high-quality dataset and to reduce false alarms from the trained model.