Sound signal processing method and electronic device
Embodiments of this application provide a sound signal processing method and an electronic device, which can reduce an interference sound signal in a sound during video recording and improve quality of a sound signal during the video recording. The method is applied to an electronic device. The method includes: acquiring, by the electronic device, a first sound signal; the first sound signal being a sound signal during video recording; processing, by the electronic device, the first sound signal to obtain a second sound signal; and outputting, by the electronic device, the second sound signal when playing back a recorded video file. Energy of a sound signal in the second sound signal in a non-target orientation is lower than energy of a sound signal in the first sound signal in the non-target orientation. The non-target orientation is an orientation outside a field of view range of a camera during video recording.
1 . A sound signal processing method, the method comprising:
enabling, by an electronic device, a camera comprising a shooting range corresponding to a field of view of the camera;
displaying a preview interface, the preview interface comprising a first control;
detecting a first operation on the first control;
starting shooting in response to the first operation;
displaying a shooting interface at a first moment, the shooting interface comprising a first image, the first image being an image captured by the camera in real time, the first image comprising a first target object in the field of view and not comprising a second target object not in the field of view;
collecting, by a microphone comprised on the electronic device, a first audio at the first moment, the first audio comprising a first audio signal and a second audio signal, the first audio signal corresponding to the first target object, the second audio signal corresponding to the second target object;
calculating, by the electronic device, a probability that the second audio signal is within a target orientation, wherein the target orientation is an orientation within a field of view range of the camera during video recording, and wherein the first target object is within the target orientation, and the second target object is not within the target orientation;
determining, by the electronic device, a gain of the second audio signal according to the probability that the second audio signal is within the target orientation;
detecting a second operation on a first control of the shooting interface; and
stopping shooting and saving a first video in response to the second operation, wherein
a first image and a second audio are comprised at the first moment of the first video, the second audio comprises the first audio signal and a third audio signal, the third audio signal is obtained by the electronic device by applying the gain to the second audio signal in response to the second target object not being in the field of view, and energy of the third audio signal is lower than energy of the second audio signal.
2 . The method according to claim 1 , wherein
the first audio further comprises a fourth audio signal, the fourth audio signal being a diffuse field noise audio signal; and
the second audio further comprises a fifth audio signal, the fifth audio signal being a diffuse field noise audio signal, wherein
the fifth audio signal is obtained by the electronic device by processing the fourth audio signal, and energy of the fifth audio signal is lower than energy of the fourth audio signal.
3 . The method according to claim 2 , wherein the fifth audio signal being obtained by the electronic device by processing the fourth audio signal comprises:
performing suppression processing on the fourth audio signal to obtain a sixth audio signal; and
performing compensation processing on the sixth audio signal to obtain the fifth audio signal, wherein the sixth audio signal is a diffuse field noise audio signal, energy of the sixth audio signal is lower than the energy of the fourth audio signal, and the sixth audio signal is less than the fifth audio signal.
4 . The method according to claim 2 , wherein the fifth audio signal being obtained by the electronic device by processing the fourth audio signal comprises:
configuring gain of the fourth audio signal to be less than 1; and
obtaining the fifth audio signal according to the fourth audio signal and the gain of the fourth audio signal.
5 . The method according to claim 1 , wherein the third audio signal being obtained by the electronic device by processing the second audio signal comprises:
configuring the gain of the second audio signal to be less than 1; and
obtaining the third audio signal according to the second audio signal and the gain of the second audio signal.
6 . The method according to claim 1 , wherein the third audio signal being obtained by the electronic device by processing the second audio signal comprises:
obtaining, by the electronic device, the third audio signal according to the second audio signal and the gain of the second audio signal, wherein the gain of the second audio signal is equal to 1 if the probability that the second audio signal is within the target orientation is greater than a preset probability threshold; and the gain of the second audio signal is less than 1 if the probability that the second audio signal is within the target orientation is less than or equal to the preset probability threshold.
7 . The method according to claim 1 , wherein the method further comprises:
processing, by the electronic device, the first audio to obtain the second audio after the microphone collects the first audio at the first moment.
8 . The method according to claim 1 , wherein the method further comprises:
processing, by the electronic device, the first audio to obtain the second audio after stopping shooting in response to the second operation.
9 . An electronic device, wherein the electronic device comprises:
a microphone configured to collect a sound signal during video recording or live streaming;
a camera configured to collect an image signal during the video recording or live streaming;
one or more processors; and
a memory, storing instructions that, when executed by the one or more processors, cause the electronic device to,
enable the camera comprising a shooting range corresponding to a field of view of the camera;
display a preview interface, the preview interface comprising a first control;
detect a first operation on the first control;
start shooting in response to the first operation;
display a shooting interface at a first moment, the shooting interface comprising a first image, the first image being an image captured by the camera in real time, the first image comprising a first target object in the field of view and not comprising a second target object not in the field of view;
collect, by the microphone, a first audio at the first moment, the first audio comprising a first audio signal and a second audio signal, the first audio signal corresponding to the first target object, the second audio signal corresponding to the second target object;
calculate a probability that the second audio signal is within a target orientation, wherein the target orientation is an orientation within a field of view range of the camera during video recording, and wherein the first target object is within the target orientation, and the second target object is not within the target orientation;
determine a gain of the second audio signal according to the probability that the second audio signal is within the target orientation;
detect a second operation on a first control of the shooting interface; and
stop shooting and saving a first video in response to the second operation, wherein
a first image and a second audio are comprised at the first moment of the first video, the second audio comprises the first audio signal and a third audio signal, the third audio signal is obtained by the electronic device by applying the gain to the second audio signal in response to the second target object not being in the field of view, and energy of the third audio signal is lower than energy of the second audio signal.
10 . The electronic device according to claim 9 , wherein
the first audio further comprises a fourth audio signal, the fourth audio signal being a diffuse field noise audio signal; and
the second audio further comprises a fifth audio signal, the fifth audio signal being a diffuse field noise audio signal, wherein
the fifth audio signal is obtained by the electronic device by processing the fourth audio signal, and energy of the fifth audio signal is lower than energy of the fourth audio signal.
11 . The electronic device according to claim 10 , wherein the fifth audio signal being obtained by the electronic device by processing the fourth audio signal, the electronic device is further to:
perform suppression processing on the fourth audio signal to obtain a sixth audio signal; and
perform compensation processing on the sixth audio signal to obtain the fifth audio signal, wherein the sixth audio signal is a diffuse field noise audio signal, energy of the sixth audio signal is lower than the energy of the fourth audio signal, and the sixth audio signal is less than the fifth audio signal.
12 . The electronic device according to claim 10 , wherein the fifth audio signal being obtained by the electronic device by processing the fourth audio signal, the electronic device is further to:
configure gain of the fourth audio signal to be less than 1; and
obtain the fifth audio signal according to the fourth audio signal and the gain of the fourth audio signal.
13 . The electronic device according to claim 9 , wherein the third audio signal being obtained by the electronic device by processing the second audio signal, the electronic device is further to:
configure the gain of the second audio signal to be less than 1; and
obtain the third audio signal according to the second audio signal and the gain of the second audio signal.
14 . The electronic device according to claim 9 , wherein the third audio signal being obtained by the electronic device by processing the second audio signal, the electronic device is further to:
obtain the third audio signal according to the second audio signal and the gain of the second audio signal, wherein the gain of the second audio signal is equal to 1 if the probability that the second audio signal is within the target orientation is greater than a preset probability threshold; and the gain of the second audio signal is less than 1 if the probability that the second audio signal is within the target orientation is less than or equal to the preset probability threshold.
15 . The electronic device according to claim 9 , wherein when executed by the processor, cause the electronic device to:
process the first audio to obtain the second audio after the microphone collects the first audio at the first moment.
16 . The electronic device according to claim 9 , wherein when executed by the processor, cause the electronic device to:
process the first audio to obtain the second audio after stopping shooting in response to the second operation.
17 . A non-transitory computer-readable storage medium, storing a computer program, wherein the computer program, when executed on an electronic device, causes the electronic device to:
enable a camera comprising a shooting range corresponding to a field of view of the camera;
display a preview interface, the preview interface comprising a first control;
detect a first operation on the first control;
start shooting in response to the first operation;
display a shooting interface at a first moment, the shooting interface comprising a first image, the first image being an image captured by the camera in real time, the first image comprising a first target object in the field of view and not comprising a second target object not in the field of view;
collect, by a microphone, a first audio at the first moment, the first audio comprising a first audio signal and a second audio signal, the first audio signal corresponding to the first target object, the second audio signal corresponding to the second target object;
calculate a probability that the second audio signal is within a target orientation, wherein the target orientation is an orientation within a field of view range of the camera during video recording, and wherein the first target object is within the target orientation, and the second target object is not within the target orientation;
determine a gain of the second audio signal according to the probability that the second audio signal is within the target orientation;
detect a second operation on a first control of the shooting interface; and
stop shooting and saving a first video in response to the second operation, wherein
a first image and a second audio are comprised at the first moment of the first video, the second audio comprises the first audio signal and a third audio signal, the third audio signal is obtained by the electronic device by applying the gain to the second audio signal in response to the second target object not being in the field of view, and energy of the third audio signal is lower than energy of the second audio signal.
18 . The non-transitory computer-readable storage medium according to claim 17 , wherein
the first audio further comprises a fourth audio signal, the fourth audio signal being a diffuse field noise audio signal; and
the second audio further comprises a fifth audio signal, the fifth audio signal being a diffuse field noise audio signal, wherein
the fifth audio signal is obtained by the electronic device by processing the fourth audio signal, and energy of the fifth audio signal is lower than energy of the fourth audio signal.
19 . The non-transitory computer-readable storage medium according to claim 18 , wherein the fifth audio signal being obtained by the electronic device by processing the fourth audio signal, the electronic device is further to:
perform suppression processing on the fourth audio signal to obtain a sixth audio signal; and
perform compensation processing on the sixth audio signal to obtain the fifth audio signal, wherein the sixth audio signal is a diffuse field noise audio signal, energy of the sixth audio signal is lower than the energy of the fourth audio signal, and the sixth audio signal is less than the fifth audio signal.
20 . The non-transitory computer-readable storage medium according to claim 18 , wherein the fifth audio signal being obtained by the electronic device by processing the fourth audio signal, the electronic device is further to:
configure gain of the fourth audio signal to be less than 1; and
obtain the fifth audio signal according to the fourth audio signal and the gain of the fourth audio signal.