# Rock Crack Types Identification by Machine Learning on the Sound Signal+
## 2 Automatic Recognition Method-Based Spectrograms for Hard Rock Crack Types
### Sound Signals of Tensile and Shear Cracks Collected during Rock Tests
#### 2.2.3 Extracting Spectrograms of the Tensile Cracks and Shear Cracks  
Taking the tested specimens GBD-S-2 and GDS-2 as examples, the extracting spectrograms are described in detail as follows. First, because the obtained sound signals are non-stationarity, \"framing\" should be performed to ensure that the sound signal is \"smooth\" within this frame length. Changes between two adjacent frames will affect the subsequent feature extraction of the sound signals, including tone color, tone, and other parameters of the sound signals. Therefore, the interval between the two frames is set, which is also called the frame shift. The overlap between the two frames can be calculated by overlap = frame length--frame shift. The frame of the signal is shown in Figure 7, and the frame parameters are determined as follows: the frame length is 10 ms, and the frame shift is 5 ms.  
Second, windowing should be performed. Fourier transform is generally employed to obtain the frequency domain representation of the signal. In our study, the short-time Fourier transform (STFT) was used to draw the sound spectrograms. When the signal is truncated, there will be a \"leakage\" of spectrum energy during the Fourier transform. To reduce the impact caused by the discontinuities and reduce the leakage of the spectrum energy, window functions should be used to intercept the signals. We choose the Hamming  
Figure 7: Framing the sound signal with the given frame length, frame shift, and overlap. window to avoid spectrum energy leakage. The calculation principle of the Hamming window is as follows [26]:  
\[\omega(n)= \begin{cases}0.54\left[1-0.85\cos\left(\frac{2\pi n}{M-1}\right)\right]& 0\leq n\leq M-1\\ 0&others\end{cases}  \tag{1}\]  
As an improved cosine window, the side lobe of the Hamming window is small and the side lobe attenuation speed of the Hamming window is slow, which can more effectively approach the spectrum of the original speech and avoid spectrum leakage. Third, the duration of the time-domain sound signal corresponding to a crack, a single sound signal, was determined. The general duration of a single sound signal used in current sound recognition is 10-50 ms. Considering the sampling frequency of the sound recording instrument used in this work, the duration used was 20 ms. With this duration, the sound signals were intercepted as shown in Figure 8.  
Then the short-time Fourier transform (STFT) to sound signal was implemented to obtain the spectrograms, and the calculation formula of STFT is as follows:  
\[X_{n}\left(e^{i\
u}\right)=\sum_{m=-\infty}^{\infty}x\left(m\right)w(n-m)e^{-i \
u m} \tag{2}\]  
In this formula, \(X_{n}\) is the speech signal sequence, w(m) is the window function, and w is the frequency. With the transformation of the sequence variable n, the Fourier transform result of the entire signal at different frame positions can be achieved. Figure 8: Selecting the objective sound signals with a time interval of 20 ms obtained from (**a**) Brazilian splitting test on the specimen GBD-S-2 and (**b**) direct shear test on the specimen GDS-2. The typical spectrograms of the tensile and shear sound signals are presented in Figure 9. In each spectrogram, the abscissa indicates time, and the ordinate indicates the frequency. The color indicates the amplitude: as the color changes from blue to red, the amplitude increases. Therefore, the spectrograms can express the dynamic time-frequency amplitude of the sound signal. Obviously, from the perspective of texture and color of spectrograms, there are some differences between the tensile spectrograms and shear spectrograms. In addition, the characteristics of the spectrograms are described in detail in Table 3.  
The spectrogram of the tensile crack shows an aggregate \"bar\" form in the short interval. The main frequency ranged from 0 to 30 kHz.