Techniques for alarm sound processing in noisy environments
An audio information processing method, an electronic device, and a computer-readable storage medium are disclosed. The audio information processing method includes: obtaining audio information, where the audio information is obtained by collecting sounds of an environment in which an electronic device is located; determining that the audio information includes an alarm sound; determining first location information of the alarm sound based on the audio information; determining a first sound, where the first sound includes second location information, both the first sound and the second location information are used to indicate an acoustic source direction of the alarm sound; and playing the first sound. The audio information is obtained by collecting the sounds of the environment in which the electronic device is located. When the audio information includes an alarm sound, the first sound used to indicate the acoustic source direction of the alarm sound is played.
1 . An audio information processing method, comprising:
obtaining audio information, wherein the audio information is obtained by collecting sounds of an environment in which an electronic device is located;
determining that the audio information comprises a first alarm sound;
determining first location information of the first alarm sound based on the audio information, wherein the first location information is used to indicate an acoustic source direction of the first alarm sound; and
in response to determining that the audio information and previous audio information that comprises a second alarm sound have not been obtained within a preset duration:
determining a first sound, wherein the first sound comprises second location information, the second location information is used to indicate the acoustic source direction of the first alarm sound, the second location information is the same as or different from the first location information, the first sound is a 3D notification sound, and the 3D notification sound is a third alarm sound carrying a direction,
sending the first sound to headphones, and
playing, by the headphones, the first sound comprising the second location information; and
in response to determining that the audio information and the previous audio information that comprises the second alarm sound are obtained within the preset duration:
determining that a difference between the first location information of the first alarm sound in the audio information and first location information of the second alarm sound in the previous audio information that comprises the second alarm sound are within a preset range, detecting that the first alarm sound in the audio information and the second alarm sound in the previous audio information that comprises the second alarm sound are a same sound, and generating a distance coefficient, wherein the distance coefficient is used to represent an energy gain of the audio information relative to the previous audio information that comprises the second alarm sound,
determining a second sound, wherein the second sound comprises the second location information and the energy gain, and
playing, by the headphones, the second sound comprising the second location information and the energy gain.
2 . The audio information processing method according to claim 1 , wherein the playing the second sound comprises:
sending the second sound to the headphones, and playing, by the headphones, the second sound.
3 . The audio information processing method according to claim 1 , wherein the determining first location information of the first alarm sound based on the audio information comprises:
locating, by using the audio information, an acoustic source of the first alarm sound based on an acoustic source localization algorithm of a microphone array to obtain the first location information of the first alarm sound.
4 . The audio information processing method according to claim 1 , wherein the determining first location information of the first alarm sound based on the audio information comprises:
determining third location information of the first alarm sound based on the audio information, wherein the third location information is used to indicate an acoustic source direction of the first alarm sound relative to the electronic device; and
performing coordinate transformation on the third location information of the first alarm sound to obtain the first location information of the first alarm sound.
5 . The audio information processing method according to claim 1 , wherein the determining a first sound, comprises:
obtaining a standard sound; and
processing the standard sound based on the first location information of the first alarm sound to obtain the first sound, wherein the first sound comprises the second location information.
6 . The audio information processing method according to claim 5 , wherein the processing the standard sound based on the first location information of the first alarm sound to obtain the first sound comprises:
obtaining a head-related impulse response (HRIR) value corresponding to the first location information of the first alarm sound; and
separately performing convolutional processing on the standard sound and the HRIR value to obtain the first sound.
7 . The audio information processing method according to claim 5 , wherein the processing the standard sound based on the first location information of the first alarm sound to obtain the first sound comprises:
obtaining a head-related transfer function (HRTF) value corresponding to the first location information of the first alarm sound; and
performing Fourier transform on the standard sound, and multiplying the standard value by the HRTF value to obtain the first sound.
8 . The audio information processing method according to claim 1 , wherein the detecting that the first alarm sound in the audio information and the alarm sound in the previous audio information that comprises the second alarm sound are a same sound comprises:
separately performing time domain to frequency domain conversion on the audio information and the previous audio information that comprises the second alarm sound to obtain amplitude spectra of the audio information and the previous audio information that comprises the second alarm sound; and
performing similarity calculation on the audio information and the previous audio information that comprises the second alarm sound by using the amplitude spectra of the audio information and the previous audio information that comprises the second alarm sound to obtain a calculation result, wherein the calculation result is used to represent whether the audio information and the previous audio information that comprises the second alarm sound are a same sound.
9 . The audio information processing method according to claim 8 , wherein the performing similarity calculation on the audio information and the previous audio information that comprises the second alarm sound by using the amplitude spectra of the audio information and the previous audio information that comprises the second alarm sound to obtain a calculation result comprises:
performing similarity calculation on the audio information and the previous audio information that comprises the second alarm sound by using a Pearson correlation function to obtain a similarity, wherein
if the similarity is greater than a threshold, the audio information and the previous audio information that comprises the second alarm sound are a same sound; or if the similarity is not greater than the threshold, the audio information and the previous audio information that comprises the second alarm sound are not a same sound.
10 . The audio information processing method according to claim 8 , wherein the performing similarity calculation on the audio information and the previous audio information that comprises the second alarm sound by using the amplitude spectra of the audio information and the previous audio information that comprises the second alarm sound to obtain a calculation result comprises:
predicting, by using a classification model, whether the audio information and the previous audio information that comprises the second alarm sound are a same sound.
11 . The audio information processing method according to claim 1 , wherein the detecting that the alarm sound in the audio information and the alarm sound in the previous audio information that comprises the second alarm sound are a same sound comprises:
separately extracting alarm sounds from the audio information and the previous audio information that comprises the second alarm sound; and
determining whether the two extracted alarm sounds are a same alarm sound.
12 . The audio information processing method according to claim 11 , wherein the determining whether the two extracted alarm sounds are a same alarm sound comprises:
separately performing time domain to frequency domain conversion on the two extracted alarm sounds to obtain amplitude spectra of the two extracted alarm sounds; and
performing similarity calculation on the two extracted alarm sounds by using the amplitude spectra of the two extracted alarm sounds to obtain a calculation result, wherein the calculation result is used to represent whether the two extracted alarm sounds are a same alarm sound.
13 . The audio information processing method according to claim 12 , wherein the performing similarity calculation on the two extracted alarm sounds by using the amplitude spectra of the two extracted alarm sounds to obtain a calculation result comprises:
performing similarity calculation on the two extracted alarm sounds by using a Pearson correlation function to obtain a similarity, wherein
if the similarity is greater than a threshold, the two extracted alarm sounds are a same alarm sound; or if the similarity is not greater than a threshold, the two extracted alarm sounds are not a same alarm sound.
14 . The audio information processing method according to claim 12 , wherein the performing similarity calculation on the two extracted alarm sounds by using the amplitude spectra of the two extracted alarm sounds to obtain a calculation result comprises:
predicting, by using a classification model, whether the two extracted alarm sounds are a same alarm sound.
15 . The audio information processing method according to claim 1 , wherein after the generating a distance coefficient, the method further comprises:
determining that the distance coefficient is within a range of the distance coefficient.
16 . The audio information processing method according to claim 15 , further comprising:
determining that the distance coefficient is out of the range of the distance coefficient;
determining a third sound, wherein the third sound comprises the second location information and energy gains represented by endpoint values of the range of the distance coefficient; and
playing the third sound.
17 . The audio information processing method according to claim 1 , wherein the determining that the audio information comprises the first alarm sound comprises:
invoking an alarm sound detection model to detect whether the audio information comprises the first alarm sound to obtain a detection result, wherein the detection result is used to indicate whether the audio information comprises the first alarm sound.
18 . An electronic device, comprising:
one or more processors, a memory, and a wireless communication module, wherein
the memory and the wireless communication module are coupled to the one or more processors, the memory is configured to store computer program code, the computer program code comprises computer instructions, and when the one or more processors execute the computer instructions, the one or more processors are caused to:
obtain audio information, wherein the audio information is obtained by collecting sounds of an environment in which an electronic device is located;
determine that the audio information comprises a first alarm sound;
determine first location information of the first alarm sound based on the audio information, wherein the first location information is used to indicate an acoustic source direction of the first alarm sound;
determine that the audio information and previous audio information that comprises a second alarm sound have not been obtained within a preset duration and, in response:
determine a first sound, wherein the first sound comprises second location information, the second location information is used to indicate the acoustic source direction of the first alarm sound, the second location information is the same as or different from the first location information, the first sound is a 3D notification sound, and the 3D notification sound is a third alarm sound carrying a direction,
send the first sound to headphones, and
play, by the headphones, the first sound comprising the second location information; and
determine that the audio information and the previous audio information that comprises the second alarm sound are obtained within the preset duration and, in response:
determine that a difference between the first location information of the first alarm sound in the audio information and first location information of the second alarm sound in the previous audio information that comprises the second alarm sound are within a preset range, detecting that the first alarm sound in the audio information and the second alarm sound in the previous audio information that comprises the second alarm sound are a same sound, and generating a distance coefficient, wherein the distance coefficient is used to represent an energy gain of the audio information relative to the previous audio information that comprises the second alarm sound;
determine a second sound, wherein the second sound comprises the second location information and the energy gain; and
play, by the headphones, the second sound comprising the second location information and the energy gain.
19 . A non-transitory computer storage medium, configured to store a computer program, wherein when the computer program is executed by a processor, the the processor is caused to:
obtain audio information, wherein the audio information is obtained by collecting sounds of an environment in which an electronic device is located;
determine that the audio information comprises a first alarm sound;
determine first location information of the first alarm sound based on the audio information, wherein the first location information is used to indicate an acoustic source direction of the first alarm sound;
determine that the audio information and previous audio information that comprises a second alarm sound have not been obtained within a preset duration and, in response:
determine a first sound, wherein the first sound comprises second location information, the second location information is used to indicate the acoustic source direction of the first alarm sound, the second location information is the same as or different from the first location information, the first sound is a 3D notification sound, and the 3D notification sound is a third alarm sound carrying a direction,
send the first sound to headphones, and
play, by the headphones, the first sound comprising the second location information; and
determine that the audio information and the previous audio information that comprises the second alarm sound are obtained within the preset duration and, in response:
determine that a difference between the first location information of the first alarm sound in the audio information and first location information of the second alarm sound in the previous audio information that comprises the second alarm sound are within a preset range, detecting that the first alarm sound in the audio information and the second alarm sound in the previous audio information that comprises the second alarm sound are a same sound, and generating a distance coefficient, wherein the distance coefficient is used to represent an energy gain of the audio information relative to the previous audio information that comprises the second alarm sound;
determine a second sound, wherein the second sound comprises the second location information and the energy gain; and
play, by the headphones, the second sound comprising the second location information and the energy gain.