Glass breaking sound detection method and related equipment
By performing frame processing and spectrum analysis on the sound signal, the burst sound peak is determined, and whether it is a glass breaking sound based on the energy attenuation range is determined, which solves the problems of complex computing and inaccurate detection in the prior art, and realizes high accuracy and low complexity glass breaking sound detection.
Patent Information
- Application Number
- CN202011180908.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-10-29
- Publication Date
- 2025-04-04
- Estimated Expiration
- 2040-10-29
AI Technical Summary
The existing glass breaking detection methods have problems such as complex operations and inaccurate detection, especially processing methods based on neural networks and methods to determine whether it is a glass breaking sound based on the intensity of the sound signal.
By acquiring the sound signal and performing frame processing, if the spectrum parameters of the current audio frame meet the burst sound characteristics, the burst sound peak value is determined. If the subsequent audio frame energy attenuation is within the preset range, it is determined to be a glass breaking sound.
It improves the detection accuracy of glass breaking sound, and the calculation is simple, which can effectively eliminate short burst interference and improves the reliability of the system.
Smart Images

Figure CN114429769B_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of audio processing technology, and in particular relates to a glass breaking sound detection method and related equipment. Background Art
[0002] The traditional method of detecting broken glass generally involves installing a piezoelectric module on the glass and determining whether the glass is broken based on the current generated by the piezoelectric module. Although this method can effectively detect the sound of broken glass, the piezoelectric module is cumbersome to install and affects the appearance. In order to avoid installing a piezoelectric module, it is possible to detect whether the broken glass is broken by determining whether the acquired sound signal contains the sound of broken glass. Existing methods for detecting broken glass based on sound signals are generally based on neural network processing methods, or determine whether it is the sound of broken glass based on the intensity of the sound signal. However, the processing method based on neural networks has the problem of complex calculations, and the method of determining whether it is the sound of broken glass based on the intensity of the sound signal has the problem of inaccurate detection. Summary of the Invention
[0003] In view of this, the embodiments of the present application provide a glass breaking sound detection method and related equipment, which can improve the accuracy of detecting glass breaking sounds and simplify calculations.
[0004] A first aspect of an embodiment of the present application provides a method for detecting glass breaking sound, comprising:
[0005] Acquire a sound signal, perform frame processing on the sound signal, and obtain M audio frames, where M represents an integer greater than 0;
[0006] If the current audio frame is determined to be a crackle sound according to the spectrum parameters of the current audio frame, determining a peak value of the crackle sound according to the spectrum parameters of the current audio frame and the spectrum parameters of an audio frame subsequent to the current audio frame;
[0007] If the N after the current audio frame p If the attenuation of the energy of the N audio frames relative to the peak value of the popping sound is within the preset attenuation range, the sound signal is determined to be the sound of glass breaking, and the N p Represents an integer greater than 0, and M>N p .
[0008] In a possible implementation of the first aspect, if the current audio frame is determined to be a crackle according to spectral parameters of the current audio frame, determining the crackle peak according to the spectral parameters of the current audio frame and spectral parameters of an audio frame subsequent to the current audio frame includes:
[0009] If the current audio frame is determined to be a crackle sound according to the spectrum parameters of the current audio frame, and N B If white noise is detected in an audio frame, the peak value of the crackle sound is determined according to the spectrum parameters of the current audio frame and the spectrum parameters of the audio frame after the current audio frame. B Represents an integer greater than 0, and M>N B .
[0010] In a possible implementation manner of the first aspect, the audio frame includes at least one frequency band, the spectrum parameter includes energy of the frequency band, and the N frequency bands after the current audio frame include: B White noise was detected in audio frames, including:
[0011] If the N after the current audio frame B If a target audio frame exists among the audio frames, a calculation formula for a first count value is determined, where the target audio frame is an audio frame whose energy between frequency bands satisfies a first preset relationship, and the calculation formula for the first count value corresponds to the first preset relationship;
[0012] The first count value is determined according to a calculation formula of the first count value, and if the first count value is greater than a preset first threshold, the target audio frame is determined to be white noise.
[0013] In a possible implementation of the first aspect, the audio frame includes at least one subframe, the spectral parameter includes energy of the subframe, the audio frame includes at least one frequency band, and the spectral parameter includes energy of the frequency band. Determining, based on the spectral parameter of the current audio frame, that the current audio frame is a crackle includes:
[0014] If the maximum energy of the subframe of the current audio frame is greater than a preset second threshold, then:
[0015] determining an energy ratio of the current audio frame according to energy of a subframe of the current audio frame;
[0016] determining an energy ratio of a current audio frame to the previous audio frame based on energy of a frequency band of the current audio frame and energy of a frequency band of an audio frame previous to the current audio frame;
[0017] determining an energy difference between the current audio frame and the previous audio frame according to energy of a subframe of the current audio frame and energy of a subframe of the previous audio frame;
[0018] determining an energy ratio of the previous audio frame according to energy of a subframe of the previous audio frame;
[0019] If the energy ratio of the current audio frame to the previous audio frame is greater than a first preset value, and the energy ratio of the current audio frame is greater than a second preset value;
[0020] or, if the energy ratio of the current audio frame to the previous audio frame is greater than a first preset value, and the energy ratio of the previous audio frame is greater than a second preset value;
[0021] or, if the energy ratio of the current audio frame to the previous audio frame is greater than a third preset value, and the energy ratio of the current audio frame is greater than a fourth preset value;
[0022] or, if the energy ratio of the current audio frame to the previous audio frame is greater than a third preset value, and the energy ratio of the previous audio frame is greater than a fourth preset value;
[0023] or, if the energy difference between the current audio frame and the previous audio frame is greater than a fifth preset value, and the energy ratio between the current audio frame and the previous audio frame is greater than a sixth preset value, and the energy ratio of the current audio frame is greater than a seventh preset value;
[0024] or, if the energy difference between the current audio frame and the previous audio frame is greater than a fifth preset value, and the energy ratio between the current audio frame and the previous audio frame is greater than a sixth preset value, and the energy ratio of the previous audio frame is greater than a seventh preset value;
[0025] It is determined that the current audio frame is a crackle sound.
[0026] In a possible implementation of the first aspect, the audio frame includes at least one frequency band, the spectral parameter includes energy of the frequency band, and determining the crackle peak value based on the spectral parameter of the current audio frame and the spectral parameter of an audio frame subsequent to the current audio frame includes:
[0027] Taking the sum of the energies of each frequency band of the current audio frame as the peak value of the crackle sound;
[0028] Using an audio frame following the current audio frame as the first audio frame;
[0029] Calculating the sum of energies of each frequency band of the first audio frame;
[0030] If the total energy of each frequency band of the first audio frame is greater than the peak value of the crackle sound, updating the peak value of the crackle sound to the total energy of each frequency band of the first audio frame;
[0031] The next audio frame after the first audio frame is used as the first audio frame, and the step of calculating the energy sum of each frequency band of the first audio frame and subsequent steps are executed again until a preset end condition is met.
[0032] In a possible implementation of the first aspect, the audio frame includes at least one frequency band, the spectrum parameter includes the energy of the frequency band, and if the N p If the attenuation of the energy of the audio frames relative to the peak value of the popping sound is within a preset attenuation range, then the sound signal is determined to be the sound of glass breaking, including:
[0033] If the N after the current audio frame p If the attenuation of the energy of each audio frame relative to the peak of the popping sound is within a preset attenuation range and the sound signal meets a first preset condition, the sound signal is determined to be the sound of glass breaking; the first preset condition includes any one or more of the following: the duration of the sound signal is within a preset duration, the spectrum parameters of the sound signal meet preset spectrum characteristics, the energy difference between the frequency bands of the sound signal is within a first preset range, the difference between the target frequencies of the sound signal is within a second preset range, and the target frequency is the frequency corresponding to the energy peak of the frequency band.
[0034] In a possible implementation of the first aspect, the duration of the sound signal is within a preset duration, including:
[0035] calculating a decay rate and / or a decay time of energy of a frequency band of the sound signal relative to a peak value of the crackle sound;
[0036] If the decay speed is within a preset speed range, and / or the decay time is within a preset time range, it is determined that the duration of the sound signal is within the preset duration.
[0037] In a possible implementation of the first aspect, the spectrum parameters of the sound signal conform to preset spectrum characteristics, including:
[0038] Determining the number of audio frames in the sound signal whose energy between frequency bands satisfies a second preset relationship;
[0039] If the number of audio frames satisfying the second preset relationship and the duration of the sound signal satisfy a third preset relationship, it is determined that the energy of the first preset frequency band of the sound signal meets the preset spectrum characteristics.
[0040] In a possible implementation of the first aspect, the energy difference between the frequency bands of the sound signal is within a first preset range, including:
[0041] If, in the sound signal, the energy of the frequency band of the nth audio frame and the energy of the frequency band of the (n-1)th audio frame satisfy a fourth preset relationship,
[0042] or if the energy of the frequency band of the nth audio frame and the energy of the frequency band of the (n-2)th audio frame satisfy a fifth preset relationship, then the set second count value is updated, where n represents an integer greater than 2, and M≥n;
[0043] If the second count value and the duration of the sound signal satisfy a sixth preset relationship, it is determined that the energy difference between the frequency bands of the sound signal is within a first preset range.
[0044] In a possible implementation manner of the first aspect, the difference between the target frequencies of the sound signals is within a second preset range, including:
[0045] If the difference between the target frequency of the ith frequency band of the nth audio frame and the target frequency of the ith frequency band of the (n-1)th audio frame in the sound signal is within a preset difference range,
[0046] or if a difference between the target frequency of the i-th frequency band of the n-th audio frame and the target frequency of the i-th frequency band of the (n-2)-th audio frame is within a preset difference range, updating the set third count value, where n represents an integer greater than 2, M ≥ n, and i represents an integer greater than 0;
[0047] If the third count value and the duration of the sound signal satisfy a seventh preset relationship, it is determined that the difference between the target frequencies of the sound signal is within a second preset range.
[0048] A second aspect of an embodiment of the present application provides a glass breaking sound detection device, characterized by comprising:
[0049] an acquisition module, configured to acquire a sound signal, perform frame processing on the sound signal, and obtain M audio frames, where M represents an integer greater than 0;
[0050] a calculation module, configured to, if the current audio frame is determined to be a crackle according to the spectrum parameters of the current audio frame, determine a peak value of the crackle according to the spectrum parameters of the current audio frame and the spectrum parameters of an audio frame subsequent to the current audio frame;
[0051] A determination module is used to determine if N after the current audio frame p If the attenuation of the energy of the N audio frames relative to the peak value of the popping sound is within the preset attenuation range, the sound signal is determined to be the sound of glass breaking, and the N p Represents an integer greater than 0, and M>N p .
[0052] In a possible implementation of the second aspect, the calculation module includes a first calculation unit, where the first calculation unit is configured to:
[0053] If the current audio frame is determined to be a crackle sound according to the spectrum parameters of the current audio frame, and N B If white noise is detected in an audio frame, the peak value of the crackle sound is determined according to the spectrum parameters of the current audio frame and the spectrum parameters of the audio frame after the current audio frame. B Represents an integer greater than 0, and M>N B .
[0054] In a possible implementation of the second aspect, the audio frame includes at least one frequency band, the spectrum parameter includes the energy of the frequency band, and the first calculation unit is specifically configured to: if N after the current audio frame B If a target audio frame exists among the audio frames, a calculation formula for a first count value is determined, where the target audio frame is an audio frame whose energy between frequency bands satisfies a first preset relationship, and the calculation formula for the first count value corresponds to the first preset relationship;
[0055] The first count value is determined according to a calculation formula of the first count value, and if the first count value is greater than a preset first threshold, the target audio frame is determined to be white noise.
[0056] In a possible implementation of the second aspect, the audio frame includes at least one subframe, the spectral parameter includes energy of the subframe, the audio frame includes at least one frequency band, the spectral parameter includes energy of the frequency band, and the calculation module further includes a second calculation unit, the second calculation unit being specifically configured to:
[0057] If the maximum energy of the subframe of the current audio frame is greater than a preset second threshold, then:
[0058] determining an energy ratio of the current audio frame according to energy of a subframe of the current audio frame;
[0059] determining an energy ratio of a current audio frame to the previous audio frame based on energy of a frequency band of the current audio frame and energy of a frequency band of an audio frame previous to the current audio frame;
[0060] determining an energy difference between the current audio frame and the previous audio frame according to energy of a subframe of the current audio frame and energy of a subframe of the previous audio frame;
[0061] determining an energy ratio of the previous audio frame according to energy of a subframe of the previous audio frame;
[0062] If the energy ratio of the current audio frame to the previous audio frame is greater than a first preset value, and the energy ratio of the current audio frame is greater than a second preset value;
[0063] or, if the energy ratio of the current audio frame to the previous audio frame is greater than a first preset value, and the energy ratio of the previous audio frame is greater than a second preset value;
[0064] or, if the energy ratio of the current audio frame to the previous audio frame is greater than a third preset value, and the energy ratio of the current audio frame is greater than a fourth preset value;
[0065] or, if the energy ratio of the current audio frame to the previous audio frame is greater than a third preset value, and the energy ratio of the previous audio frame is greater than a fourth preset value;
[0066] or, if the energy difference between the current audio frame and the previous audio frame is greater than a fifth preset value, and the energy ratio between the current audio frame and the previous audio frame is greater than a sixth preset value, and the energy ratio of the current audio frame is greater than a seventh preset value;
[0067] or, if the energy difference between the current audio frame and the previous audio frame is greater than a fifth preset value, and the energy ratio between the current audio frame and the previous audio frame is greater than a sixth preset value, and the energy ratio of the previous audio frame is greater than a seventh preset value;
[0068] It is determined that the current audio frame is a crackle sound.
[0069] In a possible implementation of the second aspect, the audio frame includes at least one frequency band, the spectral parameter includes energy of the frequency band, and the calculation unit further includes a third calculation unit, where the third calculation unit is specifically configured to:
[0070] Taking the sum of the energies of each frequency band of the current audio frame as the peak value of the crackle sound;
[0071] Using an audio frame following the current audio frame as the first audio frame;
[0072] Calculating the sum of energies of each frequency band of the first audio frame;
[0073] If the total energy of each frequency band of the first audio frame is greater than the peak value of the crackle sound, updating the peak value of the crackle sound to the total energy of each frequency band of the first audio frame;
[0074] The next audio frame after the first audio frame is used as the first audio frame, and the step of calculating the energy sum of each frequency band of the first audio frame and subsequent steps are executed again until a preset end condition is met.
[0075] In a possible implementation manner of the second aspect, the audio frame includes at least one frequency band, the spectral parameter includes energy of the frequency band, and the determination module is specifically configured to:
[0076] If the N after the current audio frame p If the attenuation of the energy of each audio frame relative to the peak of the popping sound is within a preset attenuation range and the sound signal meets a first preset condition, the sound signal is determined to be the sound of glass breaking; the first preset condition includes any one or more of the following: the duration of the sound signal is within a preset duration, the spectrum parameters of the sound signal meet preset spectrum characteristics, the energy difference between the frequency bands of the sound signal is within a first preset range, the difference between the target frequencies of the sound signal is within a second preset range, and the target frequency is the frequency corresponding to the energy peak of the frequency band.
[0077] In a possible implementation manner of the second aspect, the determining module is further configured to:
[0078] calculating a decay rate and / or a decay time of energy of a frequency band of the sound signal relative to a peak value of the crackle sound;
[0079] If the decay speed is within a preset speed range, and / or the decay time is within a preset time range, it is determined that the duration of the sound signal is within the preset duration.
[0080] In a possible implementation manner of the second aspect, the determining module is further configured to:
[0081] Determining the number of audio frames in the sound signal whose energy between frequency bands satisfies a second preset relationship;
[0082] If the number of audio frames satisfying the second preset relationship and the duration of the sound signal satisfy a third preset relationship, it is determined that the energy of the first preset frequency band of the sound signal meets the preset spectrum characteristics.
[0083] In a possible implementation manner of the second aspect, the determining module is further configured to:
[0084] If, in the sound signal, the energy of the frequency band of the nth audio frame and the energy of the frequency band of the (n-1)th audio frame satisfy a fourth preset relationship,
[0085] or if the energy of the frequency band of the nth audio frame and the energy of the frequency band of the (n-2)th audio frame satisfy a fifth preset relationship, then the set second count value is updated, where n represents an integer greater than 2, and M≥n;
[0086] If the second count value and the duration of the sound signal satisfy a sixth preset relationship, it is determined that the energy difference between the frequency bands of the sound signal is within a first preset range.
[0087] In a possible implementation manner of the second aspect, the determining module is further configured to:
[0088] If the difference between the target frequency of the ith frequency band of the nth audio frame and the target frequency of the ith frequency band of the (n-1)th audio frame in the sound signal is within a preset difference range,
[0089] or if a difference between the target frequency of the i-th frequency band of the n-th audio frame and the target frequency of the i-th frequency band of the (n-2)-th audio frame is within a preset difference range, updating the set third count value, where n represents an integer greater than 2, M ≥ n, and i represents an integer greater than 0;
[0090] If the third count value and the duration of the sound signal satisfy a seventh preset relationship, it is determined that the difference between the target frequencies of the sound signal is within a second preset range.
[0091] A third aspect of an embodiment of the present application provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the glass breaking sound detection method as described in the first aspect above is implemented.
[0092] A fourth aspect of an embodiment of the present application provides a glass breaking sound detection system, comprising: a sound collection device, an alarm device, and the electronic device as described in the third aspect above, wherein the electronic device is communicatively connected to the sound collection device and the alarm device.
[0093] A fifth aspect of the embodiments of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the glass breaking sound detection method as described in the first aspect above is implemented.
[0094] A sixth aspect of the embodiments of the present application provides a computer program product. When the computer program product is run on an electronic device, the electronic device executes the glass breaking sound detection method as described in the first aspect above.
[0095] Compared with the prior art, the embodiment of the present application has the following advantages: by acquiring a sound signal, performing frame processing on the sound signal, obtaining M audio frames, if the current audio frame is determined to be a crackle sound according to the spectrum parameters of the current audio frame, then determining the peak value of the crackle sound according to the spectrum parameters of the current audio frame and the spectrum parameters of the audio frame after the current audio frame, and if the N frames after the current audio frame are the peak values of the crackle sound, pIf the attenuation of the energy of the N audio frames relative to the peak value of the popping sound is within the preset attenuation range, the sound signal is determined to be the sound of glass breaking. Since popping sounds are also detected when clapping, knocking, raining, and other short popping sounds are obtained, and the energy of short popping sounds decays faster than that of glass breaking sounds, when a popping sound is detected, the N audio frames after the current audio frame are further calculated. p The system determines the sound signal as glass breaking if the attenuation of the energy of each audio frame relative to the peak value of the popping sound is within a preset range. This eliminates the possibility of short popping sounds, improving the accuracy of detecting glass breaking sounds. Furthermore, since the attenuation of the energy of an audio frame can be determined based on the spectral parameters of the audio frame, the computational process is simpler than using a neural network algorithm to determine whether glass is breaking. BRIEF DESCRIPTION OF THE DRAWINGS
[0096] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the embodiments or descriptions of the prior art.
[0097] Figure 1 is a schematic diagram of a glass breaking sound detection system provided in an embodiment of the present application;
[0098] Figure 2 is a schematic diagram of a sound collection device provided in an embodiment of the present application;
[0099] Figure 3 This is a schematic diagram of the implementation process of the glass breaking sound detection method provided in one embodiment of the present application;
[0100] Figure 4 This is a flowchart of detecting whether a sound signal is a short pop sound provided by an embodiment of the present application;
[0101] Figure 5 This is a flowchart of detecting whether the current audio frame is a crackle sound provided by an embodiment of the present application;
[0102] Figure 6 This is a flow chart of white noise detection provided by an embodiment of the present application;
[0103] Figure 7 is a flow chart of a glass breaking sound detection method provided by another embodiment of the present application;
[0104] Figure 8 This is a flowchart of an embodiment of the present application for determining whether a sound signal is within a preset time period;
[0105] Figure 9 This is a flowchart of an embodiment of the present application for determining whether the spectrum parameters of a sound signal meet the preset spectrum characteristics;
[0106] Figure 10 This is a flowchart of determining whether the energy difference between frequency bands of a sound signal is within a first preset range provided by an embodiment of the present application;
[0107] Figure 11 is a flowchart of determining whether the difference between target frequencies of sound signals is within a second preset range provided by an embodiment of the present application;
[0108] Figure 12 is a schematic diagram of a glass breaking sound detection device provided in an embodiment of the present application;
[0109] Figure 13 Schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0110] In the following description, specific details such as specific system structures and techniques are provided for purposes of illustration rather than limitation to facilitate a thorough understanding of the embodiments of the present application. However, it will be apparent to those skilled in the art that the present application may be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to avoid obscuring the description of the present application with unnecessary detail.
[0111] In order to illustrate the technical solution described in this application, specific embodiments are provided below.
[0112] It will be understood that when used in this specification and the appended claims, the term "comprising" indicates the presence of described features, integers, steps, operations, elements and / or components, but does not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or groups thereof.
[0113] It should also be understood that the terms used in this specification are for the purpose of describing specific embodiments only and are not intended to limit the present application. As used in this specification and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms unless the context clearly indicates otherwise.
[0114] It should be further understood that the term "and / or" used in this specification and the appended claims refers to and includes any and all possible combinations of one or more of the associated listed items.
[0115] As used in this specification and the appended claims, the term "if" can be interpreted as "when" or "upon" or "in response to determining" or "in response to detecting," depending on the context. Similarly, the phrase "if it is determined" or "if [described condition or event] is detected" can be interpreted as meaning "upon determination" or "in response to determining" or "upon detection of [described condition or event]" or "in response to detecting [described condition or event]," depending on the context.
[0116] In addition, in the description of the present application, the terms "first", "second", "third", etc. are only used to distinguish the description and cannot be understood as indicating or implying relative importance.
[0117] Existing methods for detecting glass breaking based on sound signals generally rely on neural network processing or determine whether the sound is glass breaking based on the intensity of the sound signal. However, neural network processing methods are computationally complex, and methods that determine whether the sound is glass breaking based on the intensity of the sound signal are prone to inaccurate detection. Therefore, embodiments of the present application provide a glass breaking sound detection method that can improve the accuracy of glass breaking sound detection while simplifying the computation.
[0118] The glass breaking sound detection method provided in the embodiment of the present application is applied to a glass breaking sound detection system, such as Figure 1 As shown, the glass breaking sound detection system provided in the embodiment of the present application includes a sound collection device 100, an electronic device 200, and an alarm device 300. The electronic device 200 is communicatively connected to the sound collection device 100 and the alarm device 300. The sound collection device 100, the electronic device 200, and the alarm device 300 can be integrated into the same device or can be independent devices. If the electronic device 200 is an independent device, it can be a computing device such as a desktop computer, laptop, PDA, or cloud server.
[0119] like Figure 2As shown, in one possible implementation, the sound collection device 100 includes a microphone 11, an amplifier 12, a filter 13, and an analog-to-digital converter 14. The microphone 11 is used to collect sound, convert the collected sound into a current signal, and input the current signal into the amplifier 12. The amplifier 12 is used to adjust the current signal according to a set amplification ratio, and input the adjusted current signal into the filter 13. The filter 13 is used to perform signal amplification, signal equalization, and filtering on the adjusted current signal to obtain a filtered signal, and input the filtered signal into the analog-to-digital converter 14. The filtered signal is an analog signal, and the analog-to-digital converter 14 is used to convert the filtered signal into a digital signal according to a set sampling frequency and number of bits, and output the digital signal to the electronic device 200. The electronic device 200 then converts the digital signal into an analog signal, and the analog signal is the sound signal described below.
[0120] The electronic device 200 is used to determine whether the received sound signal is the sound of glass breaking. If it is determined that the received sound signal is the sound of glass breaking, a glass breaking alarm is generated and sent to the alarm device 300. The alarm device 300 is used to emit sound or light according to the glass breaking alarm to remind the user that the glass is broken.
[0121] like Figure 3 As shown, a glass breaking sound detection method provided by an embodiment of the present application includes:
[0122] S101: Acquire a sound signal, perform frame processing on the sound signal, and obtain M audio frames, where M represents an integer greater than 0.
[0123] The duration of each audio frame may be 30ms, and a Hamming window may be used to perform frame processing on the sound signal. Since the Hamming window has the characteristic of reducing information loss, the spectral distortion of the sound signal may be reduced by using the Hamming window to perform frame processing on the sound signal.
[0124] In a possible implementation, after the sound signal is framed, spectrum compensation is performed on the audio frame to compensate for the distortion of the sound signal so that the amplitude response of the processed sound signal in each frequency band approaches a state.
[0125] S102: If the current audio frame is determined to be a crackle sound according to the spectrum parameters of the current audio frame, a peak value of the crackle sound is determined according to the spectrum parameters of the current audio frame and the spectrum parameters of an audio frame subsequent to the current audio frame.
[0126] Specifically, the audio frame is subjected to Fourier transform processing and re-framing processing to obtain the spectrum parameters of the audio frame. Among them, the audio frame is a time domain signal. The audio frame is subjected to Fourier transform processing to obtain the frequency domain signal corresponding to the audio frame. The frequency domain signal is divided into several frequency bands, and the amplitude of each frequency in each frequency band is averaged to obtain the energy of each frequency band. According to the divided frequency bands, the peak value of each frequency band and the frequency corresponding to the peak value can also be determined. The audio frame is re-framing processed to obtain at least one subframe, and the waveform data of the time domain signal of the subframe is root mean squared to obtain the energy of each subframe. The energy of the frequency band, the peak value of the frequency band and the frequency corresponding to the peak value, and the energy of the subframe are all spectrum parameters.
[0127] In one possible implementation, if it is detected that the maximum value of the energy of the subframe of the current audio frame is greater than a preset value, the current audio frame is determined to be a popping sound. After determining that the current audio frame is a popping sound, the sum of the energies of the frequency bands of the current audio frame can be determined as the popping sound peak. Alternatively, after determining the sum of the energies of the frequency bands of the current audio frame as the popping sound peak, the next audio frame after the current audio frame is used as the first audio frame, and the sum of the energies of the frequency bands of the first audio frame is calculated. If the sum of the energies of the frequency bands of the first audio frame is greater than the popping sound peak, the popping sound peak is updated to the sum of the energies of the frequency bands of the first audio frame, and the next audio frame after the first audio frame is used as the first audio frame, and the step of calculating the sum of the energies of the frequency bands of the first audio frame and subsequent steps are returned to execute until a preset end condition is met. The preset end condition can be when a preset duration is reached, or when the sum of the energies of the frequency bands of the first audio frame reaches within a preset energy range.
[0128] S103: If N after the current audio frame p If the attenuation of the energy of the audio frames relative to the peak value of the burst sound is within the preset attenuation range, the sound signal is determined to be the sound of glass breaking, N p Represents an integer greater than 0, and M>N p .
[0129] Specifically, the N following the current audio frame can be used p The attenuation is calculated by the ratio or difference between the energy of the audio frames and the peak value of the crackle sound. p is a pre-set empirical value, for example, N p =4.
[0130] In one possible implementation, starting from the next audio frame of the current audio frame, the ratio of the total energy of the frequency band of each audio frame to the peak value of the crackle sound is calculated. If the ratio is greater than a preset ratio, it means that the energy attenuation of the corresponding audio frame is within the preset attenuation range. If the N audio frames after the current audio frame pIf the ratio of the total energy of each audio frame to the peak value of the popping sound in the audio frames is greater than the preset ratio, the sound signal is determined to be the sound of glass breaking.
[0131] In the above embodiment, when some short popping sounds such as clapping, knocking, bottle squeezing, mahjong, coin dropping, and rain are acquired, a popping sound is also detected. The energy of the short popping sound decays faster than that of the glass breaking sound. Therefore, when a popping sound is detected, the N number of frames after the current audio frame is further calculated. p The attenuation of the energy of each audio frame relative to the peak value of the popping sound is determined. If the attenuation is within a preset range, the sound signal is determined to be the sound of glass breaking. Otherwise, the sound signal is not the sound of glass breaking. The situation where the popping sound is a short popping sound can be ruled out, thereby improving the accuracy of detecting the sound of glass breaking. The attenuation of the energy of the audio frame can be determined based on the spectral parameters of the audio frame. Compared with the method of detecting the sound of glass breaking through the neural network algorithm, the calculation process is relatively simple.
[0132] In one possible implementation, the process of detecting whether the sound signal is a short burst sound is as follows: Figure 4 As shown, first calculate the sum of the energy of the frequency band of the current audio frame and the maximum value of the energy of the frequency band, and set the sum of the energy of the frequency band of the audio frame or the maximum value of the energy of the frequency band as the peak value of the popping sound. After setting the peak value of the popping sound, the first audio frame after the current audio frame is set as the first audio frame, and the frame count value of the audio frame is set to FrameCount, and the initial value of FrameCount is 1. For the first audio frame, first determine whether FrameCount satisfies FrameCount≤N p If FrameCount does not satisfy FrameCount≤N p , then continue to the next stage of detection, for example, to determine the sound of glass breaking, or continue to detect other spectrum parameters of the sound signal; if FrameCount satisfies FrameCount≤N p , FrameCount is updated to FrameCount+1, and the summed energy Efs of the frequency bands of the first audio frame, or the maximum energy Efmax of the frequency bands, is calculated. For example, if the set crackle peak value is the summed energy of the frequency bands of the current audio frame, the summed energy of the frequency bands of the first audio frame is calculated. If the set crackle peak value is the maximum energy of the frequency bands of the current audio frame, the maximum energy of the frequency bands of the first audio frame is calculated.
[0133] Taking the example of setting the crackle peak value as the sum of the energy of the frequency band of the current audio frame, if the sum of the energy of the frequency band of the first audio frame is greater than the crackle peak value, it means that a new crackle peak value is detected, and the crackle peak value is updated to the sum of the energy of the frequency band of the first audio frame, and the position corresponding to the new crackle peak value is recorded, that is, the current FrameCount. After the crackle peak value is updated, the next audio frame of the first audio frame (that is, the second audio frame) is used as the first audio frame, and the above-mentioned detection process of the first audio frame is repeated, that is, returning to execute whether the FrameCount satisfies FrameCount≤N p If the total energy of the frequency band of the second audio frame is greater than the peak value of the crackle sound, the peak value of the crackle sound is updated to the total energy of the frequency band of the second audio frame, and the next audio frame after the second audio frame is used as the first audio frame, and the above-mentioned detection process for the first audio frame is repeated.
[0134] In another possible implementation, to prevent abnormal signals from being identified as crackle peaks, the formula Efs>Ef_max*Ar and Efs*As>Ef_min can be used to determine whether to update the crackle peak value, where "*" represents a multiplication operation, Efs is the total energy of the frequency band of the first audio frame, Ef_max is the currently set crackle peak value, Ef_min is the set minimum value of the crackle peak value, and Ar and As are set constants. For example, 0.8≤Ar<1 and As≤0.7 can be set. If Efs satisfies the formula Efs>Ef_max*Ar and Ef_max*As>Ef_min, it means that a new crackle peak value has been detected.
[0135] If the sum of the energy of the frequency bands of the first audio frame is less than or equal to the peak value of the popping sound, it means that no new popping sound peak is detected. The attenuation of the sum of the energy of the frequency bands of the first audio frame relative to the peak value of the popping sound is calculated. If the attenuation is within the preset attenuation range, it means that the first audio frame is not attenuated quickly. The next audio frame is used as the first audio frame, and the above detection process of the first audio frame is repeated, that is, the execution returns to determine whether FrameCount satisfies FrameCount≤N p If the attenuation is not within the preset attenuation range, it indicates that the energy of the first audio frame is attenuated too quickly, and the first audio frame is determined to be a short burst sound, and the detection state is returned to the set initial detection state, that is, waiting for the acquisition of the sound signal again.
[0136] Among them, it can be determined whether the energy of the first audio frame decays too fast according to the formula Efs*Decay_i < Ef_max, where Decay_i is the energy decay coefficient corresponding to the first audio frame, i = FrameCount, and Decay_i increases as FrameCount increases. For example, Decay_i = FrameCount - 2. If Efs satisfies the formula Efs*Decay_i < Ef_max, it means that the energy of the first audio frame decays too fast, otherwise it means that the energy of the first audio frame does not decay fast.
[0137] In the above embodiments, by calculating the energy of the frequency bands of each audio frame, it is determined whether a new popping sound peak appears. If a new popping sound peak appears, the popping sound peak is updated, thereby improving the accuracy of the determined popping sound peak, and further improving the accuracy of the calculated energy decay amount, and further improving the accuracy of short popping sound detection.
[0138] In a possible implementation manner, the process of detecting whether the current audio frame is a popping sound is as Figure 5 shown. First, calculate the maximum value E_Max(n) of the energy of the sub-frames of the current audio frame. If the maximum value E_Max(n) of the energy of the sub-frames of the current audio frame is less than the preset second threshold E_MAX, return to detect the next audio frame. If the maximum value E_Max(n) of the energy of the sub-frames of the current audio frame is greater than the preset second threshold E_MAX, determine the energy ratio E_Ratio(n) of the current audio frame according to the energy of the sub-frames of the current audio frame, determine the energy ratio E_Ratio(n - 1) of the previous audio frame according to the energy of the sub-frames of the previous audio frame, and determine the energy ratio Ef_Ratio(n) between the current audio frame and the previous audio frame according to the energy of the frequency band of the current audio frame and the energy of the frequency band of the previous audio frame of the current audio frame; determine the energy difference E_Dist(n) between the current audio frame and the previous audio frame according to the energy of the sub-frames of the current audio frame and the energy of the sub-frames of the previous audio frame. Taking the audio frame including four sub-frames as an example, the calculation formula of the energy ratio E_Ratio(n) of the current audio frame is E_Ratio(n) =
[0139] MAX(Ej(n) / Ej-1(n))|j=1-4, where Ej(n) represents the energy of the j-th subframe of the current audio frame, Ej(n-1) represents the energy of the j-th subframe of the audio frame before the current audio frame, Ej(n) / Ej-1(n) represents the ratio of the energy of the current subframe to the energy of the previous subframe, "MAX" represents the maximum value, and Ej-1(n)>0. The energy ratio of the previous audio frame, E_Ratio(n-1), is calculated in the same way as the energy ratio of the current audio frame. The energy ratio of the current audio frame to the previous audio frame, Ef_Ratio(n), is calculated as Ef_Ratio(n)=Efh(n) / Efh(n-1), where Efh(n) represents the energy of the highest frequency band in the current audio frame, Efh(n-1) represents the energy of the highest frequency band in the previous audio frame, and Efh(n-1)>0. The energy difference E_Dist(n) between the current audio frame and the previous audio frame is calculated as E_Dist(n)=MAX(Ej(n)-Ej(n-1))|j=1-4.
[0140] If the energy ratio Ef_Ratio(n) of the current audio frame to the previous audio frame is greater than the first preset value Ef_RATIO_THRD_1, and the energy ratio of the current audio frame is greater than the second preset value E_RATIO_THRD_1;
[0141] or, if the energy ratio of the current audio frame to the previous audio frame is greater than the first preset value Ef_RATIO_THRD_1, and the energy ratio of the previous audio frame is greater than the second preset value E_RATIO_THRD_1;
[0142] or, if the energy ratio Ef_Ratio(n) of the current audio frame to the previous audio frame is greater than the third preset value Ef_RATIO_THRD_2, and the energy ratio E_Ratio(n) of the current audio frame is greater than the fourth preset value E_RATIO_THRD_2;
[0143] or, if the energy ratio Ef_Ratio(n) of the current audio frame to the previous audio frame is greater than the third preset value Ef_RATIO_THRD_2, and the energy ratio of the previous audio frame is greater than the fourth preset value E_RATIO_THRD_2;
[0144] or, if the energy difference E_Dist(n) between the current audio frame and the previous audio frame is greater than a fifth preset value ED_MAX, and the energy ratio Ef_Ratio(n) between the current audio frame and the previous audio frame is greater than a sixth preset value Ef_RATIO_THRD_3, and the energy ratio of the current audio frame is greater than a seventh preset value E_RATIO_THRD_3;
[0145] or, if the energy difference E_Dist(n) between the current audio frame and the previous audio frame is greater than the fifth preset value ED_MAX, and the energy ratio Ef_Ratio(n) between the current audio frame and the previous audio frame is greater than the sixth preset value Ef_RATIO_THRD_3, and the energy ratio of the previous audio frame is greater than the seventh preset value E_RATIO_THRD_3;
[0146] The current audio frame is determined to be a crackle. Otherwise, the next audio frame after the current audio frame is used as the current audio frame, and the above detection process for the current audio frame is repeated. That is, the process returns to the step of calculating the maximum energy of the subframes of the current audio frame and subsequent steps.
[0147] Here, E0(n) = E4(n-1), meaning the energy of the 0th subframe of the current audio frame is equal to the energy of the 4th subframe of the previous audio frame. E_RATIO_THRD_1, E_RATIO_THRD_2, E_RATIO_THRD_3, Ef_RATIO_THRD_1, Ef_RATIO_THRD_2, Ef_RATIO_THRD_3, and ED_MAX are parameters pre-set based on experience. For example, E_MAX = 5000, E_RATIO_THRD_1 = 10, E_RATIO_THRD_2 = 20, E_RATIO_THRD_3 = 5, Ef_RATIO_THRD_1 = 40, Ef_RATIO_THRD_2 = 20, and Ef_RATIO_THRD_3 = 10.
[0148] In the above embodiment, when it is detected that the maximum value of the energy of the subframe of the current audio frame is greater than the preset second threshold, the energy ratio of the current audio frame, the energy ratio of the previous audio frame, the energy ratio of the current audio frame and the previous audio frame, and the energy difference between the current audio frame and the previous audio frame are further calculated. The energy ratio of the current audio frame, the energy ratio of the previous audio frame, the energy ratio of the current audio frame and the previous audio frame, and the energy difference between the current audio frame and the previous audio frame are used to further determine whether the current audio frame is a crackle sound, thereby improving the accuracy of crackle sound detection.
[0149] In a possible implementation, after the electronic device determines that the current audio frame is a crackle sound according to the spectrum parameters of the current audio frame, it determines the N subsequent audio frames. B Is there white noise in the audio frames, where N B is a pre-set empirical value, for example, N B =3. If N after the current audio frame BThe system detects white noise in an audio frame and further calculates the attenuation of the energy of the audio frame after the current audio frame relative to the peak value of the popping sound, thereby further improving the accuracy of detecting the sound of glass breaking.
[0150] In one possible implementation, the white noise detection process is as follows: Figure 6 As shown, the frame count value FrameCount of the audio frame is set, the initial value of FrameCount is 1, and the first audio frame after the current audio frame is taken as the first audio frame. For the first audio frame, first determine whether FrameCount satisfies FrameCount≤N B , if FrameCount≤N B , update FrameCount to FrameCount+1, and calculate the spectrum parameters of the first audio frame. In this embodiment of the present application, the spectrum parameters of the first audio frame are the energy of each frequency band of the first audio frame. Specifically, the first audio frame is divided into a plurality of frequency bands according to a preset frequency band division rule. For example, set the highest frequency to 8000Hz and the sampling frequency to 16000Hz, and divide the first audio frame into 10 frequency bands, namely Ef0, Ef1, Ef2, Ef3, Ef4, Ef5, Ef6, Ef7, Ef8, and Ef9. The frequency bands of each frequency band are Ef0: 0~500Hz, Ef1: 500~1000Hz, Ef2: 1000~1500Hz, Ef3: 1500~2000Hz, Ef4: 2000~2500Hz, Ef5: 2500~3500Hz, Ef6: 3500~4500Hz, Ef7: 4500~5500Hz, Ef8: 5500~6500Hz, Ef9: 6500~8000Hz, and Ef9 is the highest frequency band Efh. After calculating the energy of each frequency band, set the first count value WhiteNoiseDecisionCnt, and the initial value of WhiteNoiseDecisionCnt is 0. If the energy of the frequency bands of the first audio frame satisfies the first preset relationship, the first audio frame is used as the target audio frame, and the first count value is determined according to the calculation formula of the first count value. If the first count value is less than the first threshold WNDC, the next audio frame of the first audio frame is used as the first audio frame, and the above-mentioned detection process of the first audio frame is repeated, that is, return to execute to determine whether FrameCount satisfies FrameCount≤N Band subsequent steps. If the first count value is greater than the first threshold WNDC, record WhiteNoiseDetected=WhiteNoiseDetected+1, and then determine whether WhiteNoiseDetected satisfies WhiteNoiseDetected>0. If WhiteNoiseDetected>0 is satisfied, the first audio frame is white noise, and continue with the next stage of detection, that is, calculate the attenuation of the energy of the audio frame after the current audio frame relative to the peak value of the crackle sound. If WhiteNoiseDetected>0 is not satisfied, return to the initial detection state. If the FrameCount corresponding to the first audio frame does not satisfy FrameCount≤N B , then directly judge whether WhiteNoiseDetected satisfies WhiteNoiseDetected>0.
[0151] Wherein, the first preset relational expression is any one or more of the following relational expressions: Efi>Efi+1*WN_VAR) and (Efi+1>Efi*WN_VAR), i=0,1,2,...8; Efi>Efi+2*WN_VAR) and (Efi+2>Efi*WN_VAR), i= 0,1,2,…7; Efi>Efi+3*WN_VAR) and (Efi+3>Efi*WN_VAR), i=0,1,2,…6; (Ef1+Ef2+Ef3+Ef4)*WN_VAR>Ef0; (Ef5+Ef6+Ef7+Ef8)*WN_VAR>Efh.
[0152] In one possible implementation, the calculation formula of the first count value WhiteNoiseDecisionCnt is: if Efi>Efi+1*WN_VAR) and (Efi+1>Efi*WN_VAR), then WhiteNoiseDecisionCnt increases by N1; if Efi>Efi+2*WN_VAR) and (Efi+2>Efi*WN_VAR), then WhiteNoiseDecisionCnt increases by N2; if Efi>Efi+3*WN_VAR) and (Efi+3>Efi*WN_VAR), then WhiteNoiseDecisionCnt increases by N3; if (Ef1+Ef2+Ef3+Ef4)*WN_VAR>Ef0, then WhiteNoiseDecisionCnt increases by N4; if (Ef5+Ef6+Ef7+Ef8)*WN_VAR>Efh), then WhiteNoiseDecisionCnt increases by N5. Among them, WN_VAR, N1, N2, N3, N4, N5, and WNDC are all preset empirical values, for example, WN_VAR = 0.5, N1 = 3, N2 = 2, N3 = 1, N4 = 3, N5 = 3, and WNDC = 7. Finally, the value of WhiteNoiseDecisionCnt is determined based on the increase in WhiteNoiseDecisionCnt (the sum of the accumulated values of N1, N2, N3, N4, and N5).
[0153] It should be noted that, in other possible implementations, any one or more of the above calculation formulas may be used as the calculation formula for the first count value WhiteNoiseDecisionCnt.
[0154] In the above embodiment, since the relationship between the spectral energies reflects the energy distribution of the audio frame, whether the audio frame is white noise is detected based on the relationship between the spectral energies, thereby improving the detection accuracy.
[0155] In other possible implementations, whether white noise exists in the audio frame following the current audio frame may be determined based on whether the energy of the frequency band of the current audio frame is within a preset energy range.
[0156] In another embodiment, after the electronic device determines that the current audio frame is a crackle sound according to the spectrum parameters of the current audio frame, it determines the N subsequent audio frames. B Is there white noise in the N audio frames? BWhite noise is detected in N audio frames, and then the energy attenuation of the audio frame after the current audio frame relative to the peak value of the burst sound is further calculated. If N audio frames after the current audio frame p If the attenuation of the energy of each audio frame relative to the peak value of the popping sound is within a preset attenuation range, the sound signal is further determined to meet a first preset condition. If the sound signal meets the first preset condition, the sound signal is determined to be the sound of glass breaking, thereby further improving the accuracy of glass breaking sound detection. The first preset condition includes any one or more of the following: the duration of the sound signal is within a preset duration, the spectral parameters of the sound signal meet preset spectral characteristics, the energy difference between the frequency bands of the sound signal is within a first preset range, and the difference between the target frequencies of the sound signal is within a second preset range, where the target frequency is the frequency corresponding to the energy peak of the frequency band.
[0157] Detecting whether the spectral parameters of a sound signal meet preset spectral characteristics is used to exclude special audio signals, such as human voices, wood knocking, drums, musical instruments, metal knocking, high heels walking, rain, etc. Detecting whether the energy difference between frequency bands of a sound signal is within a first preset range is used to exclude fixed-spectrum sound signals, such as air conditioner sounds, fan sounds, vacuum cleaner sounds, motor sounds, etc. Detecting whether the difference between target frequencies of a sound signal is within a second preset range is used to exclude resonant audio signals, such as bells, alarms, horns, and cup knocking sounds.
[0158] In one possible implementation, the first preset condition includes that the duration of the sound signal is within a preset duration, the spectrum parameters of the sound signal conform to preset spectrum characteristics, the energy difference between the frequency bands of the sound signal is within a first preset range, and the difference between the target frequencies of the sound signal is within a second preset range. Correspondingly, the process of the glass breaking sound detection method is as follows: Figure 7 As shown, after receiving the sound signal, the electronic device is first set to the initial detection state, and then pre-processes the sound signal. The pre-processing is the aforementioned framing of the sound signal and the spectrum compensation of the audio frame. After the sound signal is pre-processed, the spectrum parameters of the audio frame are obtained, and the first stage of the detection of the popping sound is first performed. The detection of the popping sound is to determine whether the current audio frame is a popping sound. If the current audio frame is not a popping sound, it returns to the initial detection state. If the current audio frame is a popping sound, the second stage of white noise detection is performed. White noise detection is to determine whether the N audio frames after the current audio frame are popping sounds. B Whether white noise is detected in the N audio frames after the current audio frame. BIf no white noise is detected in any of the audio frames, the system returns to the initial detection state. If white noise is detected, the system proceeds to the third stage of short pop detection. Short pop detection determines whether the sound signal is a short pop based on the attenuation of the audio frame following the current frame relative to the peak value of the pop. If it is, the system returns to the initial detection state. If it is not, the system proceeds to the fourth stage of sound length detection, special audio detection, fixed spectrum detection, and resonant audio detection. If the sound signal's length is within the preset duration and the sound signal is not a special audio signal, a fixed spectrum signal, or a resonant audio signal, the sound signal is determined to be glass breaking and a glass break alarm is generated. Otherwise, the system returns to the initial detection state.
[0159] Among them, the electronic device determines whether the sound signal is within the preset duration based on the decay rate and / or decay time of the energy of the frequency band of the sound signal relative to the peak value of the popping sound. If the decay rate is within the preset speed range, and / or the decay time is within the preset time range, it is determined that the duration of the sound signal is within the preset duration.
[0160] In a possible implementation, the process of determining whether the sound signal is within a preset time period is as follows: Figure 8As shown, the next audio frame of the current audio frame is used as the first audio frame. First, calculate the number E_cnt of sub - frames in the first audio frame whose energy is greater than the preset first detection energy E_MIN. For example, if the first audio frame includes 4 sub - frames, set the initial value of E_cnt to 0, and calculate the energy Ej of each sub - frame in turn, where j = 1~4. If Ej > E_MIN, then update E_cnt to E_cnt + 1. Then calculate the number Emax_cnt of sub - frames in the first audio frame whose energy is greater than the preset second detection energy E_MAX, where E_MAX > E_MIN. For example, set the initial value of Emax_cnt to 0, and calculate the energy Ej of each sub - frame in turn. If Ej > E_MAX, then update Emax_cnt to Emax_cnt + 1. Then calculate the maximum value Ej_Max of the energy of the sub - frames in the first audio frame. After obtaining E_cnt, Emax_cnt, and Ej_Max, first judge whether the sound end condition is reached, that is, whether the sound is about to end. In one possible implementation, the average energy of the first audio frame can be calculated. The average energy of the first audio frame is (E1 + E2 + E3 + E4) / 4. If the average energy of the first audio frame is less than 1 / 4 of the peak energy of the popping sound, it means that the sound end condition is reached. In another possible implementation, the maximum value Ej_Max of the energy of the sub - frames can be calculated. If Ej_Max < E_MIN, it means that the sound end condition is reached, where the peak energy of the popping sound is the maximum value of the energy of the frequency band in the audio frame of the detected popping sound. If the sound is about to end, judge whether E_cnt ≥ T_MIN and Emax_cnt > 0 are satisfied. If E_cnt ≥ T_MIN and Emax_cnt > 0 are not satisfied, it means that the energy of the first audio frame is small, which further indicates that the energy attenuation speed of the sound signal is fast, and then return to the initial detection state. If E_cnt ≥ T_MIN and Emax_cnt > 0 are satisfied, then judge whether E_cnt ≤ T_MAX is satisfied. If E_cnt ≤ T_MAX is satisfied, it means that the duration of the sound signal is within the preset duration, and continue the next - stage detection, otherwise return to the initial detection state. Here, T_MIN and T_MAX are preset constants, and T_MAX > T_MIN.
[0161] If the voice end condition is not met, it is determined whether the average energy of the first audio frame is less than 1 / 2 of the plosive peak value. If the average energy of the first audio frame is less than 1 / 2 of the plosive peak value, it is determined whether E_cnt >= T_DECAY2 is satisfied, where T_DECAY2 is the frame count value of the audio frame corresponding to the energy decay to 1 / 2 of the plosive peak value preset in advance. If E_cnt >= T_DECAY2 is satisfied, it indicates that the energy decay time of the voice signal is relatively long, and the initial detection state is returned. If the average energy of the first audio frame is greater than or equal to 1 / 2 of the plosive peak value, or E_cnt < T_DECAY2, it indicates that the first audio frame is adjacent to the current audio frame, and the energy of the first audio frame has not started to decay significantly. The next audio frame of the first audio frame is used as the first audio frame, and the above detection process of the first audio frame is repeated, that is, the step of returning to execute the calculation of the number E_cnt of sub-frames in the first audio frame with energy greater than the preset first detection energy E_MIN and the subsequent steps is performed.
[0162] In other possible implementation manners, it is also possible to calculate the duration of the voice signal according to the size of FrameCount of the first audio frame when the first audio frame reaches the voice end condition; it is also possible to determine the decay rate of the energy of the first audio frame relative to the plosive peak value according to the ratio of the first audio frame to the plosive peak value and the duration between the current audio frame and the first audio frame.
[0163] In a possible implementation manner, the method for an electronic device to determine whether the spectrum parameter of a voice signal conforms to a preset spectrum feature includes: determining the number of audio frames in the voice signal whose energy between frequency bands satisfies a second preset relational expression. If the number of audio frames that satisfy the second preset relational expression and the duration of the voice signal satisfy a third preset relational expression, it is determined that the energy of the first preset frequency band of the voice signal conforms to the preset spectrum feature. Among them, the audio frame includes 10 frequency bands: Ef0, Ef1, Ef2, Ef3, Ef4, Ef5, Ef6, Ef7, Ef8, Ef9, Ef9 = Efh, and Ef0 includes two frequency bands: Ef00 (0 - 250 Hz) and Ef01 (250 - 500 Hz). The second preset relational expression is any one or more of the following formulas: Efh * 5 <= Ef0, Efh * 5 <= Ef1, Efh * 8 <= Ef1 + Ef2, (Ef5 + Ef6 + Ef7 + Ef8 + Efh) * 3 <= (Ef0 + Ef1 + Ef2 + Ef3 + Ef4), Ef00 * 5 <= Ef01, Ef0 * 5 <= Ef1, (Ef0 + Ef1 + Ef2) * 12 <= (Ef4 + Ef5 + Ef6 + Ef7 + Ef8 + Efh).
[0164] If the energy between frequency bands of an audio frame satisfies the second predetermined relationship, the audio frame's characteristics meet the special audio feature. The duration of the sound signal can be represented by the frame count value FrameCount of the audio frame corresponding to the end of the sound signal. The third predetermined relationship can be used to represent the magnitude or proportional relationship between the number of audio frames that satisfy the second predetermined relationship and the duration of the sound signal.
[0165] In a possible implementation, the process of the electronic device determining whether the spectrum parameters of the sound signal meet the preset spectrum characteristics is as follows: Figure 9 As shown, after determining that the current audio frame is a crackle, the next audio frame of the current audio frame is used as the first audio frame, and the parameter SpecialSpectrumCount(i)=0, i=1,2,3,... is set. First, whether the first audio frame meets the special audio feature is determined based on whether the energy between the frequency bands of the first audio frame satisfies the second preset relationship. If the energy between the frequency bands of the first audio frame satisfies the second preset relationship, it means that the feature of the first audio frame meets the special audio feature, and the number of audio frames whose energy between the frequency bands meets the second preset relationship is increased by 1. In the embodiment of the present application, SpecialSpectrumCount(i) is updated to SpecialSpectrumCount(i)+Wi, where Wi is a preset constant and may not be 1. Different second preset relationships correspond to different special audio features, and the value of Wi is also different.
[0166] In one possible implementation, the calculation formula for SpecialSpectrumCount(i) is as follows:
[0167] If Efh*5≤Ef0, then SpecialSpectrumCount(1) is updated to SpecialSpectrumCount(1)+1;
[0168] If Efh*5≤Ef1, then SpecialSpectrumCount(2) is updated to SpecialSpectrumCount(2)+1;
[0169] If Efh*8≤Ef1+Ef2, then SpecialSpectrumCount(3) is updated to SpecialSpectrumCount(3)+2;
[0170] If (Ef5+Ef6+Ef7+Ef8+Efh)*3≤(Ef0+Ef1+Ef2+Ef3+Ef4), then SpecialSpectrumCount(4) is updated to SpecialSpectrumCount(4)+3;
[0171] If Ef00*5≤Ef01, then SpecialSpectrumCount(5) is updated to SpecialSpectrumCount(5)+2;
[0172] If Ef0*5≤Ef1, then SpecialSpectrumCount(6) is updated to SpecialSpectrumCount(6)+2;
[0173] If (Ef0+Ef1+Ef2)*12≤(Ef4+Ef5+Ef6+Ef7+Ef8+Efh), then SpecialSpectrumCount(7) is updated to SpecialSpectrumCount(7)+3.
[0174] After calculating SpecialSpectrumCount(i), the next audio frame after the first audio frame is used as the first audio frame, and the above-described first audio frame detection process is repeated, that is, returning to the step of determining whether the first audio frame meets the special audio feature and subsequent steps. If the difference between the frequency bands of the first audio frame does not satisfy the second preset relationship, it indicates that the characteristics of the first audio frame do not meet the special audio feature. The next audio frame after the first audio frame is used as the first audio frame, and the above-described first audio frame detection process is repeated until the last audio frame of the sound signal is detected. After detecting the last audio frame, it is determined whether SpecialSpectrumCount(i) and the duration of the sound signal, FrameCount, meet the third relationship. If the third relationship is not satisfied, it indicates that the spectral parameters of the sound signal meet the preset spectral characteristics, that is, the sound signal meets the detection conditions for special audio, and that the sound signal is special audio, which further indicates that the sound signal is not a glass breaking sound, and the process returns to the initial detection state. If the third relationship is satisfied, it indicates that the spectral parameters of the sound signal do not meet the preset spectral characteristics, that is, the sound signal does not meet the detection conditions for special audio, and the next stage of detection is performed.
[0175] The third relational expression may be a magnitude relationship between SpecialSpectrumCount(i) and the duration FrameCount of the sound signal. In an embodiment of the present application, in order to exclude the sound signal of special audio, the spectral parameters of the sound signal may be set to conform to a relational expression of preset spectral characteristics, that is, SpecialSpectrumCount(i) and the duration FrameCount of the sound signal may be set to not satisfy the third relational expression. For example, the condition that SpecialSpectrumCount(i) and the duration FrameCount of the sound signal do not satisfy the third relational expression includes:
[0176] (SpecialSpectrumCount(1)>3) and (SpecialSpectrumCount(1)≥FrameCount*2-2)),
[0177] or (SpecialSpectrumCount(2)>3) and (SpecialSpectrumCount(2)≥FrameCount*2-2)),
[0178] or (SpecialSpectrumCount(3)>3) and (SpecialSpectrumCount(3)≥FrameCount*2-4)),
[0179] or (SpecialSpectrumCount(4)>3) and (SpecialSpectrumCount(4)≥FrameCount-2)),
[0180] or (SpecialSpectrumCount(5)>3) and (SpecialSpectrumCount(5)≥FrameCount*2-2)),
[0181] or (SpecialSpectrumCount(6)>3) and (SpecialSpectrumCount(6)≥FrameCount*2-2)),
[0182] or (SpecialSpectrumCount(7)>3) and (SpecialSpectrumCount(7)≥FrameCount-3)),
[0183] Or SpecialSpectrumCount>10 and SpecialSpectrumCount≥FrameCount*4-3, where SpecialSpectrumCount=SpecialSpectrumCount(1)+SpecialSpectrumCount(2)+…+SpecialSpectrumCount(7).
[0184] In the above embodiment, by setting the second relationship corresponding to a plurality of special audio features, the sound signal of the special audio can be eliminated more comprehensively, thereby improving the accuracy of glass breaking sound detection.
[0185] In one possible implementation, a method for an electronic device to determine whether the energy difference between frequency bands of a sound signal is within a first preset range includes: if, in the sound signal, the energy of the frequency band of the nth audio frame and the energy of the frequency band of the n-1th audio frame satisfy a fourth preset relationship, or the energy of the frequency band of the nth audio frame and the energy of the frequency band of the n-2th audio frame satisfy a fifth preset relationship, then updating the set second count value, where n represents an integer greater than 2, and M≥n; if the second count value and the duration of the sound signal satisfy a sixth preset relationship, then determining that the energy difference between the frequency bands of the sound signal is within the first preset range.
[0186] The n-1th audio frame is the audio frame preceding the nth audio frame, and the n-2th audio frame is the two audio frames preceding the nth audio frame. The energy of the frequency band of the nth audio frame satisfies the fourth preset relationship formula, indicating that the energy of the frequency band of the nth audio frame and the energy of the frequency band of the n-1th audio frame are within a preset variation range. The energy of the frequency band of the nth audio frame and the energy of the frequency band of the n-2th audio frame satisfy the fifth preset relationship formula, indicating that the energy of the frequency band of the nth audio frame and the energy of the frequency band of the n-2th audio frame are within a preset variation range. The duration of the sound signal can be represented by the frame count value FrameCount of the audio frame corresponding to the end of the sound signal. The sixth preset relationship formula can be used to represent the magnitude relationship or ratio relationship between the second count value and the duration of the sound signal. If the second count value and the duration of the sound signal do not satisfy the sixth preset relationship formula, it indicates that each audio frame in the sound signal has a non-varying frequency response with respect to its adjacent audio frames, that is, the sound signal has a fixed spectrum.
[0187] In a possible implementation, the electronic device determines whether the energy difference between the frequency bands of the sound signal is within a first preset range. Figure 10As shown, after determining that the current audio frame is a popping sound, for the nth audio frame, the second count value ConstantSpectrumCount is set to 0. Then, it is determined whether the energy of the frequency band of the nth audio frame satisfies the fourth preset relationship between the energy of the frequency band of the nth audio frame and the energy of the frequency band of the n-1th audio frame, and whether the energy of the frequency band of the nth audio frame and the energy of the frequency band of the n-2th audio frame satisfy the fifth preset relationship. If only the fourth preset relationship is satisfied, it indicates that the energy of the frequency band of the nth audio frame and the energy of the frequency band of the n-1th audio frame are within a preset variation range, NC = NC1. If only the fifth preset relationship is satisfied, it indicates that the energy of the frequency band of the nth audio frame and the energy of the frequency band of the n-2th audio frame are within a preset variation range, NC = NC2. If both the fourth and fifth preset relationships are satisfied, NC = NC1 + NC2. The second count value ConstantSpectrumCount is then updated to ConstantSpectrumCount + NC. NC1 and NC2 are preset constants, for example, NC1 = 2 and NC2 = 1. After calculating ConstantSpectrumCount, the above-mentioned detection process of the nth audio frame is repeated for the n+1th audio frame, that is, returning to execute the step of determining whether the energy of the frequency band of the nth audio frame and the energy of the frequency band of the n-1th audio frame satisfy the fourth preset relationship and subsequent steps.
[0188] If the energy difference between the frequency band of the nth audio frame and the energy difference between the frequency band of the n-1th audio frame is not within the preset variation range, and the energy difference between the frequency band of the nth audio frame and the energy difference between the frequency band of the n-2th audio frame is not within the preset variation range, the above-mentioned detection process for the nth audio frame is repeated for the n+1th audio frame until the last audio frame of the sound signal is detected. After the last audio frame is detected, it is determined whether ConstantSpectrumCount and FrameCount satisfy the sixth relationship. If the sixth relationship is not satisfied, it means that the energy difference between the frequency bands of the sound signal is not within the first preset range, that is, the sound signal meets the detection conditions of the fixed spectrum, that is, the sound signal is a sound signal with a fixed spectrum and is not the sound of glass breaking, and the detection state returns to the initial detection state. If the sixth relationship is satisfied, it means that the energy difference between the frequency bands of the sound signal is within the first preset range, that is, the sound signal does not meet the detection conditions of the fixed spectrum, and the next stage of detection is carried out.
[0189] In one possible implementation, the fourth preset relationship is (Ef(i)>Ef_Pre(i)*SP_VAR) and (Ef1_Pre(i)>Ef(i)*SP_VAR)), and the fifth preset relationship is (Ef(i)>Ef_Pre2(i)*SP_VAR2) and (Ef1_Pre2(i)>Ef(i)*SP_VAR2)), where i=1,2,3,…, Ef(i) represents the energy of the i-th frequency band of the n-th audio frame, Ef_Pre(i) represents the energy of the i-th frequency band of the n-1-th audio frame, Ef_Pre2(i) represents the energy of the i-th frequency band of the n-2-th audio frame, and SP_VAR and SP_VAR2 are preset constants, for example, SP_VAR=0.8, SP_VAR2=0.5. The sixth relationship is ConstantSpectrumCount <FrameCount*0.6。
[0190] In other possible implementations, it may also be determined whether the energy difference between the audio frames is within the first preset range based on the relationship between the sums of the energies of the frequency bands of the audio frames.
[0191] In the above embodiment, by calculating the difference between the energy of the frequency band of the nth audio frame and the energy of the frequency band of the n-1th audio frame, and calculating the difference between the energy of the frequency band of the nth audio frame and the energy of the frequency band of the n-2th audio frame, sound signals with fixed spectra can be eliminated, thereby improving the detection accuracy of glass breaking sounds.
[0192] In one possible implementation, a method for an electronic device to determine whether the difference between the target frequencies of a sound signal is within a second preset range includes: if in the sound signal, the difference between the target frequency of the i-th frequency band of the n-th audio frame and the target frequency of the i-th frequency band of the n-1-th audio frame is within the preset difference range, or the difference between the target frequency of the i-th frequency band of the n-th audio frame and the target frequency of the i-th frequency band of the n-2-th audio frame is within the preset difference range, then updating the set third count value, n represents an integer greater than 2, and M≥n, i represents an integer greater than 0; if the third count value and the duration of the sound signal satisfy the seventh preset relationship, then determining that the difference between the target frequencies of the sound signal is within the second preset range.
[0193] Among them, since the target frequency is the frequency corresponding to the energy peak of the frequency band, if the difference between the target frequency of the i-th frequency band of the n-th audio frame and the target frequency of the i-th frequency band of the n-1-th audio frame is within the preset difference range, it means that the n-th audio frame and the n-1-th audio frame have the same frequency peak. If the difference between the target frequency of the i-th frequency band of the n-th audio frame and the target frequency of the i-th frequency band of the n-2-th audio frame is within the preset difference range, it means that the n-th audio frame and the n-2-th audio frame have the same frequency peak. The duration of the sound signal can be represented by the frame count value FrameCount of the audio frame corresponding to the end of the sound signal, and the seventh preset relationship can be used to characterize the size relationship or ratio relationship between the third count value and the duration of the sound signal. If the third count value and the duration of the sound signal do not satisfy the seventh preset relationship, it means that there is a relatively long fixed resonant frequency in the sound signal, that is, the sound signal is a resonant audio sound signal.
[0194] In a possible implementation, the electronic device determines that the difference between the target frequencies of the sound signal is within the second preset range. Figure 11 As shown, after determining that the current audio frame is a popping sound, for the nth audio frame, frequency band division is first performed, and the nth audio frame is divided into NA frequency bands, NA is a constant set according to an empirical value, and the third count value SameMaxPeakPosCnt(i) is set to 0, correspondingly, i = 1, 2, 3, ..., NA.
[0195] After completing the frequency band division, the target frequency for each frequency band of the nth audio frame is calculated, that is, the frequency corresponding to the energy peak of each frequency band. In one possible implementation, the amplitude of frequency band i is set to X(k), and the maximum value among the amplitude peaks is the energy peak. Wherein, k is the frequency index of frequency band i. The frequency index corresponds to the frequency and is an integer greater than 0. For example, if the frequency band is 500-600 Hz, k = 1 for a frequency of 500 Hz, and k = 2 for a frequency of 505 Hz. For each amplitude X(k), if X(k) > X(k-1) and X(k) > X(k-2)*2 and X(k) > X(k-3)*3 and X(k) > X(k+1) and X(k) > X(k+2)*2 and X(k) > X(k+3)*3, then X(k) is an amplitude peak, also known as a peak value, and the position corresponding to the peak value is the frequency index k. Then calculate the maximum value of each amplitude peak, and use the maximum value of the amplitude peak as the energy peak MaxPeakPosi(n) of the frequency band. The frequency corresponding to the energy peak is the position corresponding to the energy peak, that is, the frequency index k corresponding to the energy peak.
[0196] After calculating the positions corresponding to the energy peaks of each frequency band of the n-th audio frame, the energy peak MaxPeakPosi(n-1) and its corresponding position of the n-1-th audio frame are calculated using the same method. A determination is then made as to whether the position corresponding to the energy peak MaxPeakPosi(n) and the position corresponding to the energy peak MaxPeakPosi(n-1) are within a preset difference range. The preset difference range can be set to 1 or 2. If the position corresponding to the energy peak MaxPeakPosi(n) and the position corresponding to the energy peak MaxPeakPosi(n-1) are within the preset difference range, it indicates that the difference between the target frequency of the i-th frequency band of the n-th audio frame and the target frequency of the i-th frequency band of the n-1-th audio frame is within the preset difference range. NS=NS1, where NS1 is a preset constant, for example, NS1=1. The energy peak MaxPeakPosi(n-2) and its corresponding position of the n-2-th audio frame are calculated using the same method. A determination is then made as to whether the position corresponding to the energy peak MaxPeakPosi(n) and the position corresponding to the energy peak MaxPeakPosi(n-2) are within the preset difference range. If the position corresponding to the energy peak MaxPeakPosi(n) and the position corresponding to the energy peak MaxPeakPosi(n-2) are within a preset difference range, indicating that the difference between the target frequency of the i-th frequency band of the n-th audio frame and the target frequency of the i-th frequency band of the n-2-th audio frame is within the preset difference range, then NS=NS2, where NS2 is a preset constant, for example, NS2=1. If the position corresponding to the energy peak MaxPeakPosi(n) and the position corresponding to the energy peak MaxPeakPosi(n-1), as well as the position corresponding to the energy peak MaxPeakPosi(n) and the position corresponding to the energy peak MaxPeakPosi(n-2), are both within the preset difference range, then NS=NS1+NS2. Then, the third count value SameMaxPeakPosCnt(i) is updated to SameMaxPeakPosCnt(i)+NS. After SameMaxPeakPosCnt(i) is calculated, the detection process of the nth audio frame is repeated for the n+1th audio frame, that is, the step of dividing the nth audio frame into frequency bands and subsequent steps are returned to execute.
[0197] If the difference between the target frequency of the i-th frequency band of the n-th audio frame and the target frequency of the i-th frequency band of the n-1-th audio frame, as well as the difference between the target frequency of the i-th frequency band of the n-th audio frame and the target frequency of the i-th frequency band of the n-2-th audio frame, are not within the preset difference range, the above-mentioned detection process of the n-th audio frame is repeated for the n+1-th audio frame until the last audio frame of the sound signal is detected. After the last audio frame is detected, it is determined whether SameMaxPeakPosCnt(i) and FrameCount satisfy the seventh relationship. If the seventh relationship is not satisfied, it means that the difference between the target frequencies of the sound signal is not within the second preset range, that is, the sound signal meets the detection conditions of the resonant audio, that is, the sound signal is a sound signal of the resonant audio, not the sound of glass breaking, and the detection returns to the initial detection state. If the seventh relationship is satisfied, it means that the difference between the target frequencies of the sound signal is within the second preset range, and the next stage of detection is continued.
[0198] In the embodiment of the present application, in order to exclude the sound signal of resonant audio, a relationship equation can be set to determine whether the sound signal meets the detection conditions of resonant audio. That is, the condition that SameMaxPeakPosCnt(i) and FrameCount do not satisfy the seventh relationship equation is set. For example, the condition that SameMaxPeakPosCnt(i) and FrameCount do not satisfy the seventh relationship equation includes:
[0199] FrameCount>5 and SameMaxPeakPosCnt(0)≥FrameCount*1.5-2;
[0200] or FrameCount>5 and SameMaxPeakPosCnt(1)≥FrameCount*1.5-2;
[0201] or FrameCount>5 and SameMaxPeakPosCnt(2)≥FrameCount*1.5-2;
[0202] or FrameCount>5 and SameMaxPeakPosCnt(3)≥FrameCount*1.5-2;
[0203] Or FrameCount>5 and SameMaxPeakPosCnt(0)+SameMaxPeakPosCnt(1)≥FrameCount*2-2;
[0204] Or FrameCount>5 and SameMaxPeakPosCnt(0)+SameMaxPeakPosCnt(1)+SameMaxPeakPosCnt(2)+SameMaxPeakPosCnt(3)≥FrameCount*3-2)).
[0205] In the above embodiment, by calculating the difference between the target frequency of the i-th frequency band of the n-th audio frame and the target frequency of the i-th frequency band of the n-1-th audio frame, and the difference between the target frequency of the i-th frequency band of the n-th audio frame and the target frequency of the i-th frequency band of the n-2-th audio frame, the sound signal of the resonant audio can be eliminated, thereby improving the detection accuracy of the glass breaking sound.
[0206] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.
[0207] Corresponding to the glass breaking sound detection method described in the above embodiment, Figure 12 The structural block diagram of the glass breaking device provided in the embodiment of the present application is shown. For the convenience of explanation, only the parts related to the embodiment of the present application are shown.
[0208] like Figure 12 As shown, the glass breaking sound detection device includes:
[0209] An acquisition module 10 is configured to acquire a sound signal, perform frame processing on the sound signal, and obtain M audio frames, where M represents an integer greater than 0;
[0210] a calculation module 20 for determining a crackle peak value based on the spectral parameters of the current audio frame and the spectral parameters of an audio frame subsequent to the current audio frame, if the current audio frame is determined to be a crackle according to the spectral parameters of the current audio frame;
[0211] The determination module 30 is configured to determine if N after the current audio frame p If the attenuation of the energy of the N audio frames relative to the peak value of the popping sound is within the preset attenuation range, the sound signal is determined to be the sound of glass breaking, and the N p Represents an integer greater than 0, and M>N p .
[0212] In a possible implementation, the calculation module 20 includes a first calculation unit, which is configured to:
[0213] If the current audio frame is determined to be a crackle sound according to the spectrum parameters of the current audio frame, and N B If white noise is detected in an audio frame, the peak value of the crackle sound is determined according to the spectrum parameters of the current audio frame and the spectrum parameters of the audio frame after the current audio frame. B Represents an integer greater than 0, and M>N B .
[0214] In a possible implementation, the audio frame includes at least one frequency band, the spectrum parameter includes the energy of the frequency band, and the first calculation unit is specifically configured to: if N after the current audio frame B If a target audio frame exists among the audio frames, a calculation formula for a first count value is determined, where the target audio frame is an audio frame whose energy between frequency bands satisfies a first preset relationship, and the calculation formula for the first count value corresponds to the first preset relationship;
[0215] The first count value is determined according to a calculation formula of the first count value, and if the first count value is greater than a preset first threshold, the target audio frame is determined to be white noise.
[0216] In one possible implementation, the audio frame includes at least one subframe, the spectral parameter includes energy of the subframe, the audio frame includes at least one frequency band, the spectral parameter includes energy of the frequency band, and the calculation module 20 further includes a second calculation unit, wherein the second calculation unit is specifically configured to:
[0217] If the maximum energy of the subframe of the current audio frame is greater than a preset second threshold, then:
[0218] determining an energy ratio of the current audio frame according to energy of a subframe of the current audio frame;
[0219] determining an energy ratio of a current audio frame to the previous audio frame based on energy of a frequency band of the current audio frame and energy of a frequency band of an audio frame previous to the current audio frame;
[0220] determining an energy difference between the current audio frame and the previous audio frame according to energy of a subframe of the current audio frame and energy of a subframe of the previous audio frame;
[0221] determining an energy ratio of the previous audio frame according to energy of a subframe of the previous audio frame;
[0222] If the energy ratio of the current audio frame to the previous audio frame is greater than a first preset value, and the energy ratio of the current audio frame is greater than a second preset value;
[0223] or, if the energy ratio of the current audio frame to the previous audio frame is greater than a first preset value, and the energy ratio of the previous audio frame is greater than a second preset value;
[0224] or, if the energy ratio of the current audio frame to the previous audio frame is greater than a third preset value, and the energy ratio of the current audio frame is greater than a fourth preset value;
[0225] or, if the energy ratio of the current audio frame to the previous audio frame is greater than a third preset value, and the energy ratio of the previous audio frame is greater than a fourth preset value;
[0226] or, if the energy difference between the current audio frame and the previous audio frame is greater than a fifth preset value, and the energy ratio between the current audio frame and the previous audio frame is greater than a sixth preset value, and the energy ratio of the current audio frame is greater than a seventh preset value;
[0227] or, if the energy difference between the current audio frame and the previous audio frame is greater than a fifth preset value, and the energy ratio between the current audio frame and the previous audio frame is greater than a sixth preset value, and the energy ratio of the previous audio frame is greater than a seventh preset value;
[0228] It is determined that the current audio frame is a crackle sound.
[0229] In a possible implementation, the audio frame includes at least one frequency band, the spectral parameter includes energy of the frequency band, and the calculation module 20 further includes a third calculation unit, wherein the third calculation unit is specifically configured to:
[0230] Taking the sum of the energies of each frequency band of the current audio frame as the peak value of the crackle sound;
[0231] Using an audio frame following the current audio frame as the first audio frame;
[0232] Calculating the sum of energies of each frequency band of the first audio frame;
[0233] If the total energy of each frequency band of the first audio frame is greater than the peak value of the crackle sound, updating the peak value of the crackle sound to the total energy of each frequency band of the first audio frame;
[0234] The next audio frame after the first audio frame is used as the first audio frame, and the step of calculating the energy sum of each frequency band of the first audio frame and subsequent steps are executed again until a preset end condition is met.
[0235] In a possible implementation, the audio frame includes at least one frequency band, the spectrum parameter includes energy of the frequency band, and the determination module 30 is specifically configured to:
[0236] If the N after the current audio framep If the attenuation of the energy of each audio frame relative to the peak of the popping sound is within a preset attenuation range and the sound signal meets a first preset condition, the sound signal is determined to be the sound of glass breaking; the first preset condition includes any one or more of the following: the duration of the sound signal is within a preset duration, the spectrum parameters of the sound signal meet preset spectrum characteristics, the energy difference between the frequency bands of the sound signal is within a first preset range, the difference between the target frequencies of the sound signal is within a second preset range, and the target frequency is the frequency corresponding to the energy peak of the frequency band.
[0237] In a possible implementation, the determination module 30 is further configured to:
[0238] calculating a decay rate and / or a decay time of energy of a frequency band of the sound signal relative to a peak value of the crackle sound;
[0239] If the decay speed is within a preset speed range, and / or the decay time is within a preset time range, it is determined that the duration of the sound signal is within the preset duration.
[0240] In a possible implementation, the determination module 30 is further configured to:
[0241] Determining the number of audio frames in the sound signal whose energy between frequency bands satisfies a second preset relationship;
[0242] If the number of audio frames satisfying the second preset relationship and the duration of the sound signal satisfy a third preset relationship, it is determined that the energy of the first preset frequency band of the sound signal meets the preset spectrum characteristics.
[0243] In a possible implementation, the determination module 30 is further configured to:
[0244] If, in the sound signal, the energy of the frequency band of the nth audio frame and the energy of the frequency band of the (n-1)th audio frame satisfy a fourth preset relationship,
[0245] or if the energy of the frequency band of the nth audio frame and the energy of the frequency band of the (n-2)th audio frame satisfy a fifth preset relationship, then the set second count value is updated, where n represents an integer greater than 2, and M≥n;
[0246] If the second count value and the duration of the sound signal satisfy a sixth preset relationship, it is determined that the energy difference between the frequency bands of the sound signal is within a first preset range.
[0247] In a possible implementation, the determination module 30 is further configured to:
[0248] If the difference between the target frequency of the ith frequency band of the nth audio frame and the target frequency of the ith frequency band of the (n-1)th audio frame in the sound signal is within a preset difference range,
[0249] or if a difference between the target frequency of the i-th frequency band of the n-th audio frame and the target frequency of the i-th frequency band of the (n-2)-th audio frame is within a preset difference range, updating the set third count value, where n represents an integer greater than 2, M ≥ n, and i represents an integer greater than 0;
[0250] If the third count value and the duration of the sound signal satisfy a seventh preset relationship, it is determined that the difference between the target frequencies of the sound signal is within a second preset range.
[0251] It should be noted that the information interaction, execution process, etc. between the above-mentioned devices / units are based on the same concept as the method embodiment of this application. Their specific functions and technical effects can be found in the method embodiment section and will not be repeated here.
[0252] Figure 13 Schematic diagram of the electronic device provided in Example 3 of this application. Figure 13 As shown, the electronic device of this embodiment includes: a processor 21, a memory 22, and a computer program 23 stored in the memory 22 and executable on the processor 21. When the processor 21 executes the computer program 23, the steps in the above-mentioned glass breaking sound detection method embodiment are implemented, such as Figure 3 Alternatively, when the processor 21 executes the computer program 23, the functions of the modules / units in the above-mentioned device embodiments are realized, for example, Figure 12 The functions of the acquisition module 10 to the determination module 30 are shown.
[0253] Exemplarily, the computer program 23 may be divided into one or more modules / units, which are stored in the memory 22 and executed by the processor 21 to implement the present application. The one or more modules / units may be a series of computer program instruction segments capable of performing specific functions, and the instruction segments are used to describe the execution process of the computer program 23 in the electronic device.
[0254] Those skilled in the art will understand that Figure 13 These are merely examples of electronic devices and do not constitute a limitation of the electronic device. The electronic device may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, the electronic device may also include input and output devices, network access devices, buses, etc.
[0255] The processor 21 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor.
[0256] The memory 22 may be an internal storage unit of the electronic device, such as a hard disk or memory of the electronic device. The memory 22 may also be an external storage device of the electronic device, such as a plug-in hard disk, a smart memory card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the electronic device. Furthermore, the memory 12 may also include both an internal storage unit of the electronic device and an external storage device. The memory 22 is used to store the computer program and other programs and data required by the electronic device. The memory 22 may also be used to temporarily store data that has been output or is to be output.
[0257] Those skilled in the art can clearly understand that, for the convenience and brevity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In actual applications, the above-mentioned functions can be distributed and completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated into one processing unit, or each unit can exist physically alone, or two or more units can be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.
[0258] In the above embodiments, the description of each embodiment has its own focus. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant description of other embodiments.
[0259] In the embodiments provided in the present application, it should be understood that the disclosed devices / electronic devices and methods can be implemented in other ways. For example, the device / electronic device embodiments described above are merely schematic. For example, the division of the modules or units is merely a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0260] The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected to achieve the purpose of this embodiment according to actual needs.
[0261] In addition, the functional units in the various embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.
[0262] If the integrated module / unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the process in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Wherein, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form, etc. The computer-readable medium may include: any entity or device that can carry the computer program code, recording medium, U disk, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electric carrier signal, telecommunication signal and software distribution medium, etc.
[0263] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0264] The above-described embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various embodiments of the present application, and should all be included in the scope of protection of the present application.
Claims
1. A method for detecting glass breaking sound, characterized in that: include: Acquire a sound signal, perform frame processing on the sound signal, and obtain M audio frames, where M represents an integer greater than 0; If it is determined that the current audio frame is a crackle sound according to the spectrum parameters of the current audio frame, then determining the peak value of the crackle sound according to the spectrum parameters of the current audio frame and the spectrum parameters of an audio frame after the current audio frame; If the N after the current audio frame p If the attenuation of the energy of the audio frames relative to the peak value of the burst sound is within a preset attenuation range, and the sound signal satisfies a first preset condition, then the sound signal is determined to be a glass breaking sound; the audio frame includes at least one frequency band, and the spectrum parameter includes the energy of the frequency band, and the first preset condition includes any one or more of the following: the duration of the sound signal is within a preset duration, the spectrum parameter of the sound signal meets the preset spectrum characteristics, the energy difference between the frequency bands of the sound signal is within a first preset range, the difference between the target frequencies of the sound signal is within a second preset range, and the target frequency is the frequency corresponding to the energy peak of the frequency band, and the N p Represents an integer greater than 0, and M>N p ; The spectrum parameters of the sound signal conform to the preset spectrum characteristics, including: Determine the number of audio frames in the sound signal whose energy of frequency bands satisfies a second preset relationship; If the number of audio frames satisfying the second preset relationship and the duration of the sound signal satisfy a third preset relationship, it is determined that the energy of the first preset frequency band of the sound signal meets the preset spectrum characteristics.
2. The glass breaking sound detection method according to claim 1, characterized in that: If it is determined that the current audio frame is a crackle sound according to the spectrum parameters of the current audio frame, determining the peak value of the crackle sound according to the spectrum parameters of the current audio frame and the spectrum parameters of an audio frame after the current audio frame includes: If the current audio frame is determined to be a crackle sound according to the spectrum parameters of the current audio frame, and N B If white noise is detected in an audio frame, the peak value of the crackle sound is determined according to the spectrum parameters of the current audio frame and the spectrum parameters of the audio frame after the current audio frame, and the N B Represents an integer greater than 0, and M>N B .
3. The glass breaking sound detection method according to claim 2, characterized in that: The audio frame includes at least one frequency band, the spectrum parameter includes the energy of the frequency band, and the N B White noise was detected in audio frames, including: If the N after the current audio frame B If there is a target audio frame among the audio frames, a calculation formula for a first count value is determined, wherein the target audio frame is an audio frame whose energy between frequency bands satisfies a first preset relationship, and the calculation formula for the first count value corresponds to the first preset relationship; The first count value is determined according to a calculation formula of the first count value, and if the first count value is greater than a preset first threshold, the target audio frame is determined to be white noise.
4. The glass breaking sound detection method according to claim 1, characterized in that: The audio frame includes at least one subframe, the spectrum parameter includes energy of the subframe, the audio frame includes at least one frequency band, the spectrum parameter includes energy of the frequency band, and determining that the current audio frame is a crackle sound according to the spectrum parameter of the current audio frame includes: If the maximum value of the energy of the subframe of the current audio frame is greater than the preset second threshold, then: Determining an energy ratio of the current audio frame according to energy of a subframe of the current audio frame; Determining an energy ratio of a current audio frame to a previous audio frame according to energy of a frequency band of the current audio frame and energy of a frequency band of an audio frame previous to the current audio frame; Determining an energy difference between the current audio frame and the previous audio frame according to energy of a subframe of the current audio frame and energy of a subframe of the previous audio frame; determining an energy ratio of the previous audio frame according to energy of a subframe of the previous audio frame; If the energy ratio of the current audio frame to the previous audio frame is greater than a first preset value, and the energy ratio of the current audio frame is greater than a second preset value; or, if the energy ratio of the current audio frame to the previous audio frame is greater than a first preset value, and the energy ratio of the previous audio frame is greater than a second preset value; or, if the energy ratio of the current audio frame to the previous audio frame is greater than a third preset value, and the energy ratio of the current audio frame is greater than a fourth preset value; or, if the energy ratio of the current audio frame to the previous audio frame is greater than a third preset value, and the energy ratio of the previous audio frame is greater than a fourth preset value; or, if the energy difference between the current audio frame and the previous audio frame is greater than a fifth preset value, and the energy ratio between the current audio frame and the previous audio frame is greater than a sixth preset value, and the energy ratio of the current audio frame is greater than a seventh preset value; or, if the energy difference between the current audio frame and the previous audio frame is greater than a fifth preset value, and the energy ratio between the current audio frame and the previous audio frame is greater than a sixth preset value, and the energy ratio of the previous audio frame is greater than a seventh preset value; It is determined that the current audio frame is a crackle sound.
5. The glass breaking sound detection method according to claim 1, characterized in that: The audio frame includes at least one frequency band, the spectrum parameter includes energy of the frequency band, and determining the peak value of the crackle sound according to the spectrum parameter of the current audio frame and the spectrum parameter of an audio frame after the current audio frame includes: Taking the sum of the energies of each frequency band of the current audio frame as the peak value of the crackle sound; Using an audio frame following the current audio frame as a first audio frame; Calculating the sum of energies of each frequency band of the first audio frame; If the total energy of each frequency band of the first audio frame is greater than the peak value of the crackle sound, updating the peak value of the crackle sound to the total energy of each frequency band of the first audio frame; The next audio frame after the first audio frame is used as the first audio frame, and the step of calculating the energy sum of each frequency band of the first audio frame and subsequent steps are executed again until a preset end condition is met.
6. The glass breaking sound detection method according to claim 1, characterized in that: The duration of the sound signal is within a preset duration, including: Calculating the decay speed and / or decay time of the energy of the frequency band of the sound signal relative to the peak value of the crackle sound; If the decay speed is within a preset speed range, and / or the decay time is within a preset time range, it is determined that the duration of the sound signal is within the preset duration.
7. The glass breaking sound detection method according to claim 1, characterized in that: The energy difference between the frequency bands of the sound signal is within a first preset range, including: If in the sound signal, the energy of the frequency band of the nth audio frame and the energy of the frequency band of the n-1th audio frame satisfy a fourth preset relationship, or, if the energy of the frequency band of the nth audio frame and the energy of the frequency band of the n-2th audio frame satisfy a fifth preset relationship, then updating the set second count value, wherein n represents an integer greater than 2, and M≥n; If the second count value and the duration of the sound signal satisfy a sixth preset relationship, it is determined that the energy difference between the frequency bands of the sound signal is within a first preset range.
8. The glass breaking sound detection method according to claim 1, characterized in that: The difference between the target frequencies of the sound signals is within a second preset range, including: If in the sound signal, the difference between the target frequency of the ith frequency band of the nth audio frame and the target frequency of the ith frequency band of the (n-1)th audio frame is within a preset difference range, or, if in the sound signal, a difference between a target frequency of an i-th frequency band of an n-th audio frame and a target frequency of an i-th frequency band of an n-2-th audio frame is within a preset difference range, then updating the set third count value, wherein n represents an integer greater than 2, and M≥n, and i represents an integer greater than 0; If the third count value and the duration of the sound signal satisfy a seventh preset relationship, it is determined that the difference between the target frequencies of the sound signal is within a second preset range.
9. A glass breaking sound detection device, characterized in that: include: An acquisition module, used to acquire a sound signal, perform frame processing on the sound signal, and obtain M audio frames, where M represents an integer greater than 0; a calculation module, configured to determine a peak value of the popping sound according to the spectrum parameters of the current audio frame and the spectrum parameters of an audio frame after the current audio frame, if the current audio frame is determined to be a popping sound according to the spectrum parameters of the current audio frame; A determination module is used to determine if N after the current audio frame p If the attenuation of the energy of the audio frames relative to the peak value of the burst sound is within a preset attenuation range, and the sound signal satisfies a first preset condition, then the sound signal is determined to be a glass breaking sound; the audio frame includes at least one frequency band, and the spectrum parameter includes the energy of the frequency band, and the first preset condition includes any one or more of the following: the duration of the sound signal is within a preset duration, the spectrum parameter of the sound signal meets the preset spectrum characteristics, the energy difference between the frequency bands of the sound signal is within a first preset range, the difference between the target frequencies of the sound signal is within a second preset range, and the target frequency is the frequency corresponding to the energy peak of the frequency band, and the N p Represents an integer greater than 0, and M>N p ; Among them, the judgment module is specifically used to determine the number of audio frames in the sound signal whose energy of frequency bands satisfies a second preset relationship; if the number of audio frames satisfying the second preset relationship and the duration of the sound signal satisfy a third preset relationship, it is determined that the energy of the first preset frequency band of the sound signal meets the preset spectral characteristics.
10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the method according to any one of claims 1 to 8 is implemented.
11. A glass breaking sound detection system, characterized in that: include: A sound collection device, an alarm device, and the electronic device as claimed in claim 10, wherein the electronic device is communicatively connected with the sound collection device and the alarm device.
12. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 8 is implemented.
Citation Information
Patent Citations
Audio burst white noise detection method and device and storage medium
CN108492837A
Apparatus, method, and medium for detecting and discriminating impact sound
US20050199064A1