# Cicada Species Recognition Based on Acoustic Signals
## 3 Materials and Methods
### Audio Segmentation  
#### 3.5.1 Harma Syllable Segmentation Algorithm  
The Harma syllable segmentation (Harma) algorithm was introduced by [PERSON] [17]. Figure 6 shows the flowchart for the Harma algorithm. Initially, the pre-processed audio signal was passed to the algorithm along with a value of the stopping criteria, MINDB, in \begin{table}
\begin{tabular}{l c c c c} \hline \hline
**Species** & **No. of Recordings** & **Length of Recordings** & **Total Active Calling (min)** & **No. of Syllables from Each Recording (Average)** \\ \cline{3-4}  & & & **Harma** & **Improved Harma** \\ \hline Magiconda cassiii & 14 & 7 s-1 min & 4.60 & 21 & 10 \\ Magiconda septendican & 15 & 3-37 s & 3.85 & 12 & 2 \\ Magiconda septendecala & 14 & 5-50 s & 5.27 & 14 & 3 \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Details of audio recordings. Figure 4: Frequency domain of signals before and after pre-processing. Figure 5: Time domain of signals before and after pre-processing. decibels and the parameters required to generate a spectrogram matrix, which are sampling frequency, window size, overlap size, and Fast Fourier Transform (FFT) size. The output of each step involved in the Harma algorithm is shown in Figure 7. The spectrogram images are for illustration purposes only. Only one spectrogram image will be generated upon complete execution of the algorithm. Figure 6: Flowchart of the Hármá syllable segmentation algorithm. Figure 7: Output of steps involved in the Hármá syllable segmentation algorithm. The algorithm generated a spectrogram matrix, \(S(f,\ t)\), from the input audio. The algorithm finds the maximum value, \(|S(f_{n},\ t_{n})|\), in the spectrogram matrix and converts the value to decibels before assigning to the variable \(argMax\) defined in (1). \[argMax=20\ log_{10}|\ S(f_{n},\ t_{n})| \tag{1}\]  
In the first iteration, the algorithm defined \(cutoff\) as (2) and \(minAmp\) as (3). \[cutoff=argMax-MINDB \tag{2}\]  
\[minAmp=argMax-MINDB \tag{3}\]  
In the following iterations, the \(cutoff\) value remained unchanged while the value of \(minAmp\) was updated using (3). The algorithm then checked if \(argMax\) is greater than or equal to \(cutoff\). If true, the algorithm proceeds with the next step. Else, the algorithm ends. Figure 7(2) shows the output of this step. The white marker shows the position of \(argMax\) in the spectrogram. The algorithm searched in the left (\(t<t_{n}\)) and right (\(t>t_{n}\)) region of \(argMax\) found in the previous step. If the maximum peak at that time, \(|S(f,\ t)|\), was greater or equal to \(minAmp\), its frequency will be stored as \(freq(i)=f_{n}\) and maximum amplitude as \(amps(i)=argMax\), where \(i\) denotes the number of iterations. The search continued until no peak of adjacent signals is above the threshold. The adjacent signals found forms a region and the region was considered as a syllable, \(S(f,\ [t_{s},\ t_{s}+1,\ldots,\ t_{e}])\), where \(t_{s}\) and \(t_{e}\) represents the start and end time of the syllable. Figure 7(3) represents a sample output of this step. The blue markers show the syllable found in this iteration. The values of the syllable were removed from the spectrogram matrix by setting \(S(f,\ [t_{s},\ t_{s}+1,\ldots,\ t_{e}])=0\). Steps 2 to 4 were repeated until the maximum value in the spectrogram matrix at that iteration, \(argMax\), is lower than \(cutoff\). After Step 5, all syllables were found in the input signal after applying the Harma algorithm. The syllables found were marked with blue markers. The spectrogram of the final output is shown in Figure 7, where the syllables were cropped out from the original signal. By comparing the original spectrogram and the spectrogram after applying the Harma algorithm, it was observed that most of the syllables in the signal were found, while some shorter syllables were not identified, possibly due to the size of the window used.