Disclosure of Invention
In view of the above, an object of the embodiments of the present invention is to provide a method and an apparatus for providing sound, which can provide external sound for a user using a headset.
In order to achieve the above object, an embodiment of the present invention provides a method for providing sound, which is characterized by comprising the following steps: when detecting that an earphone is connected and sound is played through the earphone, acquiring external sound through a microphone; judging whether the acquired external sound exceeds a preset threshold value or not; and when the acquired external sound exceeds a preset threshold value, the acquired external sound is played through the earphone.
According to the embodiment of the invention, when the terminal plays the sound through the earphone, the external sound meeting the conditions is played through the earphone, so that the user can clearly obtain the external sound when using the earphone, and the user can conveniently master the external condition.
Preferably, the threshold is a decibel value. According to the scheme, when the external sound exceeds the preset decibel, the external sound is played through the earphone, so that noise or irrelevant sound can be avoided from being heard, and the interference to a user is reduced.
As a preferable aspect of the above technique, before the external sound is captured by the microphone, the method further includes: judging whether an instruction for providing external sound is received; the acquiring of the external sound through the microphone includes: when receiving an instruction for requesting the provision of the external sound, the external sound is acquired through the microphone. According to the scheme, the external sound is obtained only when the user requires to provide the external sound, so that the electric power is saved.
As a preferable aspect of the foregoing technology, before the external sound is played through the earphone, the method further includes: filtering the acquired external sound; the playing the acquired external sound through the earphone comprises: and playing the filtered external sound through the earphone. In the scheme, the external sound can be further filtered, so that the external sound which is clearer or meets the requirement better can be provided.
As a preferable aspect of the foregoing technology, before the external sound is played through the earphone, the method further includes: judging whether the acquired external sound has sound within a preset frequency range; the playing the acquired external sound through the earphone comprises: and when the acquired external sound has sound within a preset frequency range, the acquired external sound is played through the earphone. In the scheme, when the sound which accords with the frequency exists in the external sound, the external sound is played, so that resources can be saved, and the external sound which does not accord with the requirement is prevented from being provided for a user.
Preferably, the playing the acquired external sound through the earphone includes: the original sound is paused to be played, and only the acquired external sound is played through the earphone; or mixing the acquired external sound with the original sound and then playing the mixed sound through the earphone. The scheme provides two alternative playing schemes.
As a preferable aspect of the foregoing technology, before the external sound is played through the earphone, the method further includes: judging whether the acquired external sound is a preset voice instruction or not; when the acquired external sound is a preset voice instruction, forwarding the voice instruction; the playing the acquired external sound through the earphone comprises: and when the acquired external sound is not a preset voice instruction, the acquired external sound is played through the earphone. The scheme further judges whether the external sound is a voice instruction, and provides application of the voice instruction for a user using the earphone.
The invention also proposes a device for providing sound, said device comprising:
the acquisition module is used for acquiring external sound through a microphone when detecting that the earphone is connected and sound is played through the earphone;
the first judgment module is used for judging whether the acquired external sound exceeds a preset threshold value or not;
and the playing module is used for playing the acquired external sound through the earphone when the acquired external sound exceeds a preset threshold value.
As a preferable aspect of the above technique, the apparatus further includes:
the second judgment module is used for judging whether an instruction for requesting to provide external sound is received or not;
the playing module is used for acquiring the external sound through the microphone when receiving an instruction of requiring to provide the external sound.
Preferably, the threshold is a decibel value.
As a preferable aspect of the above technique, the apparatus further includes:
the filtering module is used for filtering the acquired external sound;
the playing module is used for playing the filtered external sound through the earphone.
As a preferable aspect of the above technique, the apparatus further includes:
the third judgment module is used for judging whether the acquired external sound has sound within a preset frequency range;
the playing module is used for playing the acquired external sound through the earphone when the acquired external sound has sound within a preset frequency range.
As a preferable aspect of the foregoing technology, the playing module is configured to:
the original sound is paused to be played, and only the acquired external sound is played through the earphone; or,
and mixing the acquired external sound with the original sound and then playing the mixed sound through the earphone.
As a preferable aspect of the above technique, the apparatus further includes:
the fourth judgment module is used for judging whether the acquired external sound is a preset voice instruction or not;
the forwarding module is used for forwarding the voice instruction when the acquired external sound is a preset voice instruction;
the playing module is used for playing the acquired external sound through the earphone when the acquired external sound is not a preset voice instruction.
Additional features and advantages of embodiments of the invention will be set forth in the description which follows, and in part will be obvious from the description, or may be learned by the practice of the invention. The objectives and other advantages of the invention will be realized and attained by the structure particularly pointed out in the written description and claims hereof as well as the appended drawings.
The technical solutions of the embodiments of the present invention are further described in detail with reference to the accompanying drawings and embodiments.
Detailed Description
The preferred embodiments of the present invention will be described in detail below with reference to the accompanying drawings, and it should be understood that the preferred embodiments described herein are merely illustrative and explanatory of the embodiments of the present invention, and are not restrictive of the embodiments of the invention.
The method for providing the sound provided by the embodiment of the invention can be executed in any terminal capable of providing the sound, wherein the terminal comprises a mobile phone, a tablet computer, a desktop computer, a multimedia player and the like. Fig. 1 shows a main flow of a method for providing sound according to an embodiment of the present invention, which includes the following steps:
step S101: when detecting that the earphone is connected and the sound is played through the earphone, acquiring the external sound through the microphone.
The microphone may be carried by the terminal itself or connected with the terminal.
Step S102: and judging whether the acquired external sound exceeds a preset threshold value.
Preferably, the threshold is a decibel value indicating the magnitude of the sound. Only when the external sound exceeds the preset decibel, the external sound is played through the earphone, so that irrelevant sound or noise can be prevented from being reacted, and the interference to a user is reduced.
Step S103: and when the acquired external sound exceeds a preset threshold value, the acquired external sound is played through the earphone.
Preferably, when the acquired external sound is played through the earphone, playing of the original sound can be suspended, and only the acquired external sound is played through the earphone; or mixing the acquired external sound with the original sound and then playing the mixed sound through the earphone.
According to the embodiment of the invention, when the terminal plays the sound through the earphone, the external sound meeting the conditions is played through the earphone. Therefore, the external sound is provided for the user using the earphone, so that the user can clearly acquire the external sound when using the earphone, and the user can conveniently master the external condition. And the terminal can open the microphone to sense the external sound only when playing the sound through the earphone, and the microphone does not need to be opened for sensing in other times, so that the electric power can be saved.
In the embodiment shown in fig. 2, before the external sound is acquired through the microphone, a determination may be made to determine whether the user allows acquiring and playing the external sound, specifically, the method includes the following steps:
step S201: the terminal detects whether an earphone is connected or not and plays sound through the earphone; if yes, go to step S202; if not, the process is ended.
Step S202: the terminal judges whether an instruction for requesting to provide external sound is received, if so, step S203 is executed; if not, the process is ended.
When the user selects the function of providing the external sound, the instruction of requesting to provide the external sound is issued, or the user or the terminal sets the function of requesting to provide the external sound in advance and the instruction of requesting to provide the external sound is issued.
Step S203: the terminal acquires external sound through the microphone.
Step S204: the terminal judges whether the acquired external sound exceeds a preset decibel value, if so, step S205 is executed; if not, the step is repeated.
Step S205: the terminal pauses playing original sound and only plays the acquired external sound through the connected earphone.
In the embodiment, the external sound is acquired only when the user requires to provide the external sound, so that resources are saved.
In the embodiment shown in fig. 3, before the acquired external sound is played through the earphone, the external sound may be filtered, specifically, the method includes the following steps:
step S301: the terminal detects whether an earphone is connected or not and plays sound through the earphone; if yes, go to step S302; if not, the process is ended.
Step S302: the terminal acquires external sound through the microphone.
Step S303: the terminal judges whether the acquired external sound exceeds a preset decibel value, if so, the step S304 is executed; if not, the step is repeated.
Step S304: and the terminal filters the acquired external sound.
In this step, noise, background sound, etc. in the external sound may be filtered, or the external sound may be filtered according to a preset frequency or frequency range. For example, high frequency parts (10000 Hz-20000 Hz) and low frequency parts (20 Hz-100 Hz) in the external sound are filtered, and only the middle frequency part, namely, only the human sound is retained. The mid-frequency section can be customized, such as 100Hz (male bass) to 10000Hz (female treble). For the reserved frequencies, the size, bandwidth and center frequency can be adjusted. The self-defining of the frequency for filtering can adapt to different use environments and different use habits.
Step S305: the terminal pauses playing original sound, and only plays the filtered external sound through the connected earphone.
In this embodiment, the filtered sound and the original sound volume average value may be further dynamically compared, and the volume of the filtered sound and the original sound volume average value may be adjusted to achieve balance, so as to provide a clearer or more satisfactory external sound.
As shown in fig. 4, before playing the acquired external sound through the earphone, it may be further determined whether the external sound conforms to a sound set by a user, specifically, the method includes the following steps:
step S401: the terminal detects whether an earphone is connected or not and plays sound through the earphone; if yes, go to step S402; if not, the process is ended.
Step S402: the terminal acquires external sound through the microphone.
Step S403: the terminal judges whether the acquired external sound exceeds a preset decibel value, if so, the step S404 is executed; if not, the step is repeated.
Step S404: the terminal judges whether the acquired external sound has sound within a preset frequency range; if yes, go to step S405; if not, the process is ended.
For example, the user needs to play the external sound through the earphone only when the external sound includes a voice, and then, it should be determined whether the acquired external sound includes a sound within a preset frequency range of 100Hz (male bass) to 10000Hz (female treble). For example, the preset frequency range can be customized, and can adapt to different use environments and different use habits.
Step S405: and the terminal processes the external sound and amplifies the sound in a preset frequency range in the external sound.
This step is a preferable step, and it is possible to further make the sound within the preset frequency range out of the external sound prominent.
Step S406: and the terminal mixes the processed external sound with the original sound.
Wherein, the mixing proportion can be adjusted manually or dynamically and automatically, for example, the original sound accounts for 60 percent, and the external sound accounts for 40 percent.
Step S407: and the terminal plays the mixed sound through the connected earphone.
In this embodiment, when there is a sound with a frequency in the external sound, the external sound is played, so that resources can be saved and the external sound which does not meet the requirement is prevented from being provided for the user.
As shown in fig. 5, before the acquired external sound is played through the earphone, it may be further determined whether the external sound is a preset voice instruction, specifically, the method includes the following steps:
step S501: detecting whether an earphone is connected and playing sound through the earphone; if yes, go to step S502; if not, the process is ended.
Step S502: the external sound is acquired through the microphone.
Step S503: judging whether the acquired external sound exceeds a preset decibel value, if so, executing a step 5404; if not, the step is repeated.
Step S504: judging whether the acquired external sound is a preset voice command, if so, executing step S505; if not, go to step S506.
Step S505: and forwarding the voice instruction to a module for executing the voice instruction to execute corresponding operation.
Step S506: and playing the acquired external sound through the connected earphone.
In the embodiment of the invention, whether the external sound is the voice instruction can be further judged, and the application of the voice instruction is provided for a user using the earphone. The preset voice command is a plurality of recognizable languages.
Preferably, it can be further determined whether the external sound is a special sound or a group of special tones or intervals, as the application of the voice command.
As shown in fig. 6, an embodiment of the present invention further provides an apparatus for providing sound, including:
an obtaining module 601, configured to obtain external sound through a microphone when detecting that an earphone is connected and sound is played through the earphone;
a first determining module 602, configured to determine whether the acquired external sound exceeds a preset threshold;
the playing module 603 is configured to play the acquired external sound through the earphone when the acquired external sound exceeds a preset threshold.
Preferably, as shown in fig. 7, the apparatus further includes:
a second judging module 604, configured to judge whether an instruction for providing an external sound is received;
the playing module 603 is configured to obtain the external sound through the microphone when receiving an instruction that the external sound is required to be provided.
Preferably, as shown in fig. 7, the apparatus further includes:
a filtering module 605, configured to filter the acquired external sound;
the playing module 603 is configured to play the filtered external sound through the earphone.
Preferably, as shown in fig. 7, the apparatus further includes:
a third determining module 606, configured to determine whether there is a sound within a preset frequency range in the acquired external sound;
the playing module 603 is configured to play the acquired external sound through the earphone when the acquired external sound has a sound within a preset frequency range.
Preferably, the playing module 603 is configured to:
the original sound is paused to be played, and only the acquired external sound is played through the earphone; or,
and mixing the acquired external sound with the original sound and then playing the mixed sound through the earphone.
Preferably, as shown in fig. 7, the apparatus further includes:
a fourth determining module 607, configured to determine whether the obtained external sound is a preset voice instruction;
a forwarding module 608, configured to forward the voice instruction when the obtained external sound is a preset voice instruction;
the playing module 603 is configured to play the acquired external sound through the earphone when the acquired external sound is not a preset voice instruction.
An embodiment of the present invention further provides a terminal, and fig. 8 is a schematic structural diagram of a terminal device according to an embodiment of the present invention. Referring to fig. 8, the terminal device may be used to implement the method for recommending an application program provided in the above embodiment.
Terminal device 1100 may include components such as a communication unit 110, memory 120 including one or more computer-readable storage media, an input unit 130, a display unit 140, a sensor 150, audio circuitry 160, a WiFi (wireless fidelity) module 170, a processor 180 including one or more processing cores, and a power supply 190. Those skilled in the art will appreciate that the terminal device configuration shown in fig. 8 does not constitute a limitation of the terminal device and may include more or fewer components than those shown, or some components may be combined, or a different arrangement of components. Wherein:
the communication unit 110 may be used for receiving and transmitting information or signals during a call, and the communication unit 110 may be an RF (Radio Frequency) circuit, a router, a modem, or other network communication devices. In particular, when the communication unit 110 is an RF circuit, downlink information of the base station is received and then processed by the one or more processors 180; in addition, data relating to uplink is transmitted to the base station. Generally, the RF circuit as a communication unit includes, but is not limited to, an antenna, at least one Amplifier, a tuner, one or more oscillators, a Subscriber Identity Module (SIM) card, a transceiver, a coupler, an LNA (Low Noise Amplifier), a duplexer, and the like. In addition, the communication unit 110 may also communicate with a network and other devices through wireless communication. The wireless communication may use any communication standard or protocol, including but not limited to GSM (Global System for Mobile communications), GPRS (general packet Radio Service), CDMA (Code Division Multiple Access), WCDMA (Wideband Code Division Multiple Access), LTE (long term Evolution), email, SMS (Short Messaging Service), and the like. The memory 120 may be used to store software programs and modules, and the processor 180 executes various functional applications and data processing by operating the software programs and modules stored in the memory 120. The memory 120 may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required by at least one function (such as a sound playing function, an image playing function, etc.), and the like; the storage data area may store data (such as audio data, a phonebook, etc.) created according to the use of the terminal device 1100, and the like. Further, the memory 120 may include high speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid state storage device. Accordingly, the memory 120 may further include a memory controller to provide the processor 180 and the input unit 130 with access to the memory 120.
The input unit 130 may be used to receive input numeric or character information and generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function control. Input unit 130 may include a touch-sensitive surface 131 as well as other input devices 132. The touch-sensitive surface 131, also referred to as a touch display screen or a touch pad, can capture touch operations of a user on or near the touch-sensitive surface 131 (e.g., operations of a user on or near the touch-sensitive surface 131 using a finger, a stylus, or any other suitable object or attachment), and drive the corresponding connection device according to a predetermined program. Alternatively, the touch sensitive surface 131 may comprise two parts, a touch detection means and a touch controller. The touch detection device detects the touch direction of a user, detects a signal brought by touch operation and transmits the signal to the touch controller; the touch controller receives touch information from the touch sensing device, converts the touch information into touch point coordinates, sends the touch point coordinates to the processor 180, and can receive and execute commands sent by the processor 180. Additionally, the touch-sensitive surface 131 may be implemented using various types of resistive, capacitive, infrared, and surface acoustic waves. In addition to the touch-sensitive surface 131, the input unit 130 may also include other input devices 132. Other input devices 132 may include, but are not limited to, one or more of a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a trackball, a mouse, a joystick, and the like.
The display unit 140 may be used to display information input by or provided to a user and various graphic user interfaces of the terminal device 1100, which may be configured by graphics, text, icons, video, and any combination thereof. The display unit 140 may include a display panel 141, and optionally, the display panel 141 may be configured in the form of an LCD (Liquid crystal display), an OLED (Organic Light-Emitting Diode), or the like. Further, the touch-sensitive surface 131 may cover the display panel 141, and when a touch operation is detected on or near the touch-sensitive surface 131, the touch operation is transmitted to the processor 180 to determine the type of the touch event, and then the processor 180 provides a corresponding visual output on the display panel 141 according to the type of the touch event. Although in FIG. 8, touch-sensitive surface 131 and display panel 141 are shown as two separate components to implement input and output functions, in some embodiments, touch-sensitive surface 131 may be integrated with display panel 141 to implement input and output functions.
Terminal device 1100 can also include at least one sensor 150, such as a light sensor, motion sensor, and other sensors. The light sensor may include an ambient light sensor that adjusts the brightness of the display panel 141 according to the brightness of ambient light, and a proximity sensor that turns off the display panel 141 and/or a backlight when the terminal device 1100 is moved to the ear. As one of the motion sensors, the gravity acceleration sensor may detect the magnitude of acceleration in each direction (generally, three axes), detect the magnitude and direction of gravity when the mobile phone is stationary, and may be used for applications of recognizing gestures of a mobile phone (for example, horizontal and vertical screen switching, related games, magnetometer gesture calibration), vibration recognition related functions (for example, pedometer, tapping), and the like, and as for the terminal device 1100, other sensors such as a gyroscope, a barometer, a hygrometer, a thermometer, an infrared sensor, and the like may be further configured, which are not described herein again.
Audio circuitry 160, speaker 161, microphone 162 may provide an audio interface between a user and terminal device 1100. The audio circuit 160 may transmit the electrical signal converted from the received audio data to the speaker 161, and convert the electrical signal into a sound signal for output by the speaker 161; on the other hand, the microphone 162 converts the acquired sound signal into an electric signal, converts the electric signal into audio data after being received by the audio circuit 160, and outputs the audio data to the processor 180 for processing, and then transmits the audio data to, for example, another terminal device via the RF circuit 110, or outputs the audio data to the memory 120 for further processing. The audio circuit 160 also includes an earpiece jack to provide communication of a peripheral headset with the terminal device 1100.
To implement wireless communication, a wireless communication unit 170 may be configured on the terminal device, and the wireless communication unit 170 may be a WiFi module. WiFi belongs to a short-range wireless transmission technology, and the terminal device 700 can help a user to send and receive e-mail, browse a web page, access streaming media, and the like through the wireless communication unit 170, which provides the user with wireless broadband internet access. Although fig. 8 shows the wireless communication unit 170, it is understood that it does not belong to the essential constitution of the terminal device 1100 and may be omitted entirely as needed within the scope not changing the essence of the invention.
The processor 180 is a control center of the terminal device 1100, connects various parts of the entire mobile phone by using various interfaces and lines, and performs various functions of the terminal device 1100 and processes data by operating or executing software programs and/or modules stored in the memory 120 and calling data stored in the memory 120, thereby performing overall monitoring of the mobile phone. Optionally, processor 180 may include one or more processing cores; preferably, the processor 180 may integrate an application processor, which mainly handles operating systems, user interfaces, application programs, etc., and a modem processor, which mainly handles wireless communications. It will be appreciated that the modem processor described above may not be integrated into the processor 180.
Terminal device 1100 also includes a power supply 190 (e.g., a battery) for powering the various components, which may preferably be logically coupled to processor 180 via a power management system to manage charging, discharging, and power consumption management functions via the power management system. The power supply 190 may also include any component including one or more of a dc or ac power source, a recharging system, a power failure detection circuit, a power converter or inverter, a power status indicator, and the like.
Although not shown, the terminal device 1100 may further include a camera, a bluetooth module, and the like, which will not be described herein. In this embodiment, the display unit of the terminal device is a touch screen display, the terminal device further includes a memory, and one or more programs, where the one or more programs are stored in the memory and configured to be executed by the one or more processors include instructions for:
when detecting that an earphone is connected and sound is played through the earphone, acquiring external sound through a microphone;
judging whether the acquired external sound exceeds a preset threshold value or not;
and when the acquired external sound exceeds a preset threshold value, the acquired external sound is played through the earphone.
Preferably, before the external sound is captured by the microphone, the method further includes:
judging whether an instruction for providing external sound is received;
the acquiring of the external sound through the microphone includes: when receiving an instruction for requesting the provision of the external sound, the external sound is acquired through the microphone.
Preferably, the threshold is a decibel value.
Preferably, before the external sound to be acquired is played through the earphone, the method further includes:
filtering the acquired external sound;
the playing the acquired external sound through the earphone comprises: and playing the filtered external sound through the earphone.
Preferably, before the external sound to be acquired is played through the earphone, the method further includes:
judging whether the acquired external sound has sound within a preset frequency range;
the playing the acquired external sound through the earphone comprises: and when the acquired external sound has sound within a preset frequency range, the acquired external sound is played through the earphone.
Preferably, the playing the acquired external sound through the earphone includes:
the original sound is paused to be played, and only the acquired external sound is played through the earphone; or,
and mixing the acquired external sound with the original sound and then playing the mixed sound through the earphone.
Preferably, before the external sound is captured by the microphone, the method further includes:
judging whether the acquired external sound is a preset voice instruction or not;
when the acquired external sound is a preset voice instruction, forwarding the voice instruction;
the playing the acquired external sound through the earphone comprises: and when the acquired external sound is not a preset voice instruction, the acquired external sound is played through the earphone.
As will be appreciated by one skilled in the art, embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, optical storage, and the like) having computer-usable program code embodied therein.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
It will be apparent to those skilled in the art that various changes and modifications may be made in the present invention without departing from the spirit and scope of the invention. Thus, if such modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include such modifications and variations.