A method for controlling volume of an electronic device, wherein the electronic device is installed with microphones, and the method comprises: receiving an external sound picked up by the microphones; extracting content information of the external sound; determining, according to the content information of the external sound, whether a prestored sound template database comprises a sound that is matched with the content information of the external sound, and generating a first determining result, wherein the prestored sound template database is stored in the electronic device or on a cloud; and if the first determining result is yes, generating a prompt tone, turning off a sound that is being output, and outputting the prompt tone; wherein the number of the microphones is at least two; before the generating a prompt tone, turning off a sound that is being output, and outputting the prompt tone, the method further comprises: calculating, according to a microphone array formed by the at least two microphones, a position of a sound source of the external sound and a distance between the sound source of the external sound and the electronic device; the generating a prompt tone, turning off a sound that is being output, and outputting the prompt tone comprises: determining whether the position of the sound source of the external sound and the distance meet a preset condition, and generating a second determining result; and if the second determining result is yes, generating the prompt tone, turning off the sound that is being output, and outputting the prompt tone. receiving an external sound picked up by the microphones; extracting content information of the external sound; determining, according to the content information of the external sound, whether a prestored sound template database comprises a sound that is matched with the content information of the external sound, and generating a first determining result, wherein the prestored sound template database is stored in the electronic device or on a cloud; and if the first determining result is yes, generating a prompt tone, turning off a sound that is being output, and outputting the prompt tone; wherein the number of the microphones is at least two; before the generating a prompt tone, turning off a sound that is being output, and outputting the prompt tone, the method further comprises: calculating, according to a microphone array formed by the at least two microphones, a position of a sound source of the external sound and a distance between the sound source of the external sound and the electronic device; the generating a prompt tone, turning off a sound that is being output, and outputting the prompt tone comprises: determining whether the position of the sound source of the external sound and the distance meet a preset condition, and generating a second determining result; and if the second determining result is yes, generating the prompt tone, turning off the sound that is being output, and outputting the prompt tone. calculating, according to a microphone array formed by the at least two microphones, a position of a sound source of the external sound and a distance between the sound source of the external sound and the electronic device; the generating a prompt tone, turning off a sound that is being output, and outputting the prompt tone comprises: determining whether the position of the sound source of the external sound and the distance meet a preset condition, and generating a second determining result; and if the second determining result is yes, generating the prompt tone, turning off the sound that is being output, and outputting the prompt tone. determining whether the position of the sound source of the external sound and the distance meet a preset condition, and generating a second determining result; and if the second determining result is yes, generating the prompt tone, turning off the sound that is being output, and outputting the prompt tone.