Patent Description:
With development of terminal technologies, an instant communication application (for example, Messages, WeChat, or QQ) on a mobile phone gradually becomes an indispensable communications tool in a user's life, work, and learning. When a terminal receives a message from the instant communication application, the user needs to manually operate the mobile phone to view and process the message. In some scenarios in which the user is inconvenient to operate the mobile phone, for example, the user is driving a vehicle, the terminal may interact with the user in a voice manner, to determine whether to play the message in the voice manner.

However, in a process in which the terminal interacts with the user in the voice manner, the terminal usually cannot recognize a real intention of the user in the voice, and consequently the terminal cannot perform processing, for example, message playing, according to the user intention. This affects user experience. <NPL>, discusses creating a dialog between the user and the system on the event of receiving a message. This dialog is aimed at guiding the user to replying to the message without the need to look at the phone. When a message is received, the system informs the user through speech synthesis that he/she has received a new message from a certain contact. The system then asks the user to hear the message. The system will then start the speech recognition and wait for the user to respond. <CIT> relates to sound recognition of household appliances in smart homes. <CIT> relates to speech recognition and describes that a user request that is received but not recognized can be used to generate candidate request templates in a candidate database.

This application provides a message playing method and a terminal, to learn a voice command of a user, so as to recognize an intention of the user and perform a corresponding operation. This helps improve efficiency of interaction between the user and the terminal, and improve user experience.

According to a first aspect, a method provided in an embodiment of this application is applicable to a terminal, and the method includes: receiving, by the terminal, a first message, where the first message is text information; playing, by the terminal, a first voice in response to receiving the first message, where the first voice is used to ask a user whether to play the first message in a voice manner; detecting, by the terminal, a second voice of the user; converting, by the terminal, the second voice into a first text; if the first text does not match a first keyword, continuing, by the terminal, to detect a voice of the user, where the first keyword is a positive keyword; when the terminal detects a third voice of the user, converting, by the terminal, the third voice into a second text; if the second text matches the first keyword, playing, by the terminal, the first message in the voice manner, and recording, by the terminal, a quantity of times of using the first text; and if the quantity of times of using the first text is greater than a first threshold, adding, by the terminal, the first text to the first keyword.

It can be learned that in the technical solution provided in this embodiment of this application, a non-preset reply of a user can be learned, to determine whether the reply is a positive reply, to be specific, whether the user expects to play a message. This increases accuracy of executing a command by the terminal, and a success rate of playing a message in the voice manner by the terminal, so that the terminal is more intelligent, and user experience of using the terminal is improved.

In a possible implementation, the method further includes: converting, by the terminal, the first message into a fourth voice; and the playing, by the terminal, the first message in the voice manner is specifically: playing, by the terminal, the fourth voice.

In some embodiments of this application, after determining that the second text matches the first keyword, the terminal may convert the text information of the first message into a voice message (namely, the fourth voice), and then play the voice message. In some other embodiments of this application, before determining that the second text matches the first keyword, the terminal may convert the text information of the first message into a voice message (namely, the fourth voice). After determining that the second text matches the first keyword, the terminal may directly play the voice message. This reduces a time period in which the user waits for the terminal to play the first message in the voice manner, and improves user experience. For example, after receiving the first message, or after receiving the first voice of the user, or after converting the third voice of the user into the second text, or after the user matches the second text with the preset first keyword, the terminal may convert the text information of the first message into the fourth voice. A time at which the terminal converts the text information of the first message into the voice message is not limited in this embodiment of this application.

In a possible implementation, after the adding, by the terminal, the first text to the first keyword, the method further includes: receiving, by the terminal, a second message, where the second message is text information; playing, by the terminal, a fifth voice in response to receiving the second message, where the fifth voice is used to ask the user whether to play the second message in the voice manner; detecting, by the terminal, a sixth voice of the user; converting, by the terminal, the sixth voice into the third text; and if the third text matches an added first keyword, playing, by the terminal, the second message in the voice manner.

It can be learned that after the terminal successfully learns an intention of the user in the first text, when the user uses the voice corresponding to the first text again, the terminal can quickly recognize the intention of the user, and play the second message in the voice manner. This improves efficiency of interaction between the user and the terminal and improves user experience.

In a non-claimed possible implementation, before the playing, by the terminal, a first voice, the method further includes: if the terminal determines that the first message belongs to a preset application, and/or a sender of the first message belongs to a preset contact group, and/or the first message includes a second keyword, determining, by the terminal, to play the first voice.

It can be learned that, before playing the message in the voice manner, the terminal may further filter the message. In this way, the user selects, based on a requirement, a specific message to play the message in the voice manner, to prevent excessive messages from playing in the voice manner and disturbing the user. This improves user experience.

In a non-claimed possible implementation, before the playing, by the terminal, a first voice, the method further includes: receiving, by the terminal, a third message when receiving the first message; and determining, by the terminal based on a preset priority sequence, that a priority of the first message is higher than a priority of the third message.

It can be learned that when simultaneously receiving a plurality of messages, the terminal may determine a message playing sequence based on a preset priority sequence, to meet diversified requirements of the user and improve user experience.

In a possible implementation, after the adding, by the terminal, the first text to the first keyword, the method further includes: displaying, by the terminal, prompt information, where the prompt information is used to notify the user that the first keyword has been updated.

In a possible implementation, after the playing, by the terminal, a first voice, the method further includes: if the terminal has not detected the voice of the user within a preset time period, or if the terminal has not detected the voice that is of the user and that matches the first keyword within a preset time period, determining, by the terminal, not to play the first message in the voice manner.

In a possible implementation, after the playing, by the terminal, a first voice, the method further includes: if the terminal detects, within a preset time period, that a quantity of times of using the voice that is of the user and that does not match the first keyword is greater than a second threshold, determining, by the terminal, not to play the first message in the voice manner.

In a possible implementation, the first message is a message of an instant communication application.

According to a second aspect, a message playing method provided in an embodiment of this application is applicable to a terminal, and the method includes: receiving, by the terminal, a first message, where the first message is text information; playing, by the terminal, a first voice in response to receiving the first message, where the first voice is used to ask a user whether to play the first message in a voice manner; detecting, by the terminal, a second voice of the user; converting, by the terminal, the second voice into a first text; if the first text does not match a first keyword, continuing, by the terminal, to detect a voice of the user, where the first keyword includes a positive keyword and a negative keyword; when the terminal detects a third voice of the user, converting, by the terminal, the third voice into a second text; and if the second text matches the positive keyword, playing, by the terminal, the first message in the voice manner, and recording, by the terminal, a quantity of times of using the first text; and if the quantity of times of using the first text is greater than a first threshold, adding, by the terminal, the first text to the positive keyword; or if the second text matches the negative keyword, determining, by the terminal, not to play the first message in the voice manner, and recording, by the terminal, a quantity of times of using the first text; and if the quantity of times of using the first text is greater than a first threshold, adding, by the terminal, the first text to the negative keyword.

It can be learned that in the technical solution provided in this embodiment of this application, a non-preset reply of a user can be learned, to determine whether the reply is a positive reply or a negative reply, to be specific, whether the user expects to play a message. This increases accuracy of executing a command by the terminal, and a success rate of playing a message in the voice manner by the terminal, so that the terminal is more intelligent, and user experience of using the terminal is improved.

In a possible implementation, after the adding, by the terminal, the first text to the positive keyword or the negative keyword, the method further includes: receiving, by the terminal, a second message, where the second message is text information; playing, by the terminal, a fourth voice in response to receiving the second message, where the fourth voice is used to ask the user whether to play the second message in the voice manner; detecting, by the terminal, a fifth voice of the user; converting, by the terminal, the fifth voice into the third text; and if the third text matches an added positive keyword, playing, by the terminal, the second message in the voice manner; or if the third text matches an added negative keyword, determining, by the terminal, not to play the second message in the voice manner.

In a possible implementation, before the playing, by the terminal, a first voice, the method further includes: if the terminal determines that the first message belongs to a preset application, and/or a sender of the first message belongs to a preset contact group, and/or the first message includes a second keyword, determining, by the terminal, to play the first voice.

In a possible implementation, before the playing, by the terminal, a first voice, the method further includes: receiving, by the terminal, a third message when receiving the first message; and determining, by the terminal based on a preset priority sequence, that a priority of the first message is higher than a priority of the third message.

In a possible implementation, after the adding, by the terminal, the first text to the positive keyword or the negative keyword, the method further includes: displaying, by the terminal, prompt information, where the prompt information is used to notify the user that the first keyword has been updated.

According to a third aspect, a terminal is provided. The terminal includes a processor, a memory, and a touchscreen. The memory and the touchscreen are coupled to the processor, the memory is configured to store computer program code, and the computer program code includes a computer instruction. The processor reads the computer instruction in the memory to perform the method in any one of the first aspect and the possible implementations of the first aspect.

According to a fourth aspect, a terminal is provided. The terminal includes a processor, a memory, and a touchscreen. The memory and the touchscreen are coupled to the processor, the memory is configured to store computer program code, and the computer program code includes a computer instruction. The processor reads the computer instruction in the memory to perform the method in any one of the second aspect and the possible implementations of the second aspect.

According to a fifth aspect, a computer storage medium is provided, and includes a computer instruction. When the computer instruction is run on a terminal, the terminal is enabled to perform the method in any one of the first aspect and the possible implementations of the first aspect.

According to a sixth aspect, a computer storage medium is provided, and includes a computer instruction. When the computer instruction is run on a terminal, the terminal is enabled to perform the method in any one of the second aspect and the possible implementations of the second aspect.

According to a seventh aspect, a computer program product is provided. When the computer program product runs on a computer, the computer is enabled to perform the method in any one of the first aspect and the possible implementations of the first aspect.

According to an eighth aspect, a computer program product is provided. When the computer program product runs on a computer, the computer is enabled to perform the method in any one of the second aspect and the possible implementations of the second aspect.

The following terms "first" and "second" are merely intended for a purpose of description, and shall not be understood as an indication or implication of relative importance or implicit indication of a quantity of indicated technical features. Therefore, a feature limited by "first" or "second" may explicitly or implicitly include one or more features. In descriptions of embodiments of this application, unless otherwise stated, "a plurality of" means two or more than two.

For example, a terminal in this application may be a mobile phone, a tablet computer, a personal computer (Personal Computer, PC), a personal digital assistant (personal digital assistant, PDA), a smartwatch, a netbook, a wearable electronic device, an augmented reality (Augmented Reality, AR) technology device, a virtual reality (Virtual Reality, VR) device, or the like. A specific form of the terminal is not specially limited in this application.

<FIG> is an example of a structural block diagram of a terminal <NUM> according to an embodiment of the present invention.

The terminal <NUM> may include a processor <NUM>, an external memory interface <NUM>, an internal memory <NUM>, a USB interface <NUM>, a charging management module <NUM>, a power management module <NUM>, a battery <NUM>, an antenna <NUM>, an antenna <NUM>, a radio frequency module <NUM>, a communications module <NUM>, an audio module <NUM>, a speaker 170A, a telephone receiver 170B, a microphone 170C, a headset interface 170D, a sensor module <NUM>, a key <NUM>, a motor <NUM>, an indicator <NUM>, a camera <NUM>, a display screen <NUM>, a SIM card interface <NUM>, and the like. The sensor module may include a pressure sensor 180A, a gyro sensor 180B, a barometric pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a range sensor 180F, an optical proximity sensor <NUM>, a fingerprint sensor <NUM>, a temperature sensor 180J, a touch sensor <NUM>, an ambient light sensor <NUM>, a bone conduction sensor <NUM>, and the like.

A schematic structure in this embodiment of the present invention constitutes no limitation on the terminal <NUM>. The terminal <NUM> may include more or fewer components than those shown in the figure, or combine some components, or split some components, or have different component arrangements. The components in the figure may be implemented by using hardware, software, or a combination of software and hardware.

The processor <NUM> may include one or more processing units. For example, the processor <NUM> may include an application processor (application processor, AP), a modem processor, a graphics processing unit (graphics processing unit, GPU), an image signal processor (image signal processor, ISP), a controller, a memory, a video codec, a digital signal processor (digital signal processor, DSP), a baseband processor, and/or a neural processing unit (Neural-network Processing Unit, NPU). Different processing units may be independent devices, or may be integrated into a same processor.

The controller may be a decision maker that directs each component of the terminal <NUM> to carry out coordinate work according to an instruction. The controller is a nerve center and a command center of the terminal <NUM>. The controller generates an operation control signal based on an instruction operation code and a time sequence signal, to complete control of instruction fetching and instruction execution.

In some embodiments of this application, the application processor is configured to: obtain a voice of a user, convert the obtained voice of the user into a text, and further match the converted text with a pre-stored keyword and record a quantity of times of using the text, and when the quantity of times of using the text reaches a preset quantity of times, add the text to the corresponding keyword. The application processor may be further configured to: obtain, by using the radio frequency module, the communications module, or the like, a text message sent by another terminal or server to the terminal, and convert the received text message into a voice or the like.

In addition, the memory may be further disposed in the processor <NUM> to store an instruction and data. In some embodiments, the memory in the processor is a cache. The memory may store an instruction or data that is just used or cyclically used by the processor. If the processor needs to use the instruction or the data again, the processor may directly invoke the instruction or the data from the memory, to avoid repeated access and reduce a waiting time of the processor. Therefore, system efficiency is improved.

In some embodiments of this application, the terminal may store, in the memory in the processor <NUM>, keywords preset by the user, for example, a keyword of a positive reply and/or a keyword of a negative reply. The terminal may further store, in the memory, recorded content of a voice command, a quantity of times of using the voice command, and the like. In some other embodiments of this application, the terminal may alternatively store data in the internal memory <NUM> or an external memory. This is not specifically limited in this embodiment of this application.

In some embodiments, the processor <NUM> may include an interface. The interface may include an integrated circuit (inter-integrated circuit, I2C) interface, an inter-integrated circuit sound (inter-integrated circuit sound, I2S) interface, a pulse-code modulation (pulse code modulation, PCM) interface, a universal asynchronous receiver/transmitter (universal asynchronous receiver/transmitter, UART) interface, a mobile industry processor interface (mobile industry processor interface, MIPI), a general-purpose input/output (general-purpose input/output, GPIO) interface, a subscriber identity module (subscriber identity module, SIM) interface, a universal serial bus (universal serial bus, USB) interface, and/or the like.

The I2C interface is a bidirectional synchronous serial bus, and includes a serial data line (serial data line, SDA) and a serial clock line (derail clock line, SCL). In some embodiments, the processor may include a plurality of groups of I2C buses. The processor may be coupled to the touch sensor, a charger, a flash light, the camera, and the like through different I2C bus interfaces. For example, the processor may be coupled to the touch sensor through the I2C interface, so that the processor communicates with the touch sensor through the I2C bus interface, to implement a touch function of the terminal <NUM>.

The I2S interface may be configured for audio communication. In some embodiments, the processor may include a plurality of groups of I2S buses. The processor <NUM> may be coupled to the audio module through the I2S bus, to implement communication between the processor and the audio module. In some embodiments, the audio module may transfer an audio signal to the communications module through the I2S interface, to implement a function of answering a call by using a Bluetooth headset.

The PCM interface may also be configured for audio communication, and sample, quantize, and code an analog signal. In some embodiments, the audio module may be coupled to the communications module through the PCM bus interface. In some embodiments, the audio module may alternatively transfer an audio signal to the communications module through the PCM interface, to implement the function of answering a call by using the Bluetooth headset. Both the I2S interface and the PCM interface may be configured for audio communication, and sampling rates of the two interfaces are different.

The UART interface is a universal serial data bus, and is configured for asynchronous communication. The bus is a bidirectional communications bus. The bus converts to-be-transmitted data between serial communication and parallel communication. In some embodiments, the UART interface is usually configured to connect the processor to the communications module <NUM>. For example, the processor communicates with a Bluetooth module through the UART interface, to implement a Bluetooth function. In some embodiments, the audio module may transfer an audio signal to the communications module through the UART interface, to implement a function of playing music by using the Bluetooth headset.

In this embodiment of this application, the terminal can implement voice playing of a message through any one or more of the I2S interface, the PCM interface, and the UART interface, transfer a recorded user voice to the processor, and the like.

The MIPI interface may be configured to connect the processor to a peripheral device, for example, the display screen or the camera. The MIPI interface includes a camera serial interface (camera serial interface, CSI), a display serial interface (display serial interface, DSI), and the like. In some embodiments, the processor communicates with the camera through the CSI interface, to implement a photographing function of the terminal <NUM>. The processor communicates with the display screen through the DSI interface, to implement a display function of the terminal <NUM>.

In this embodiment of this application, the terminal may display, through the MIPI interface, an interface diagram, for example, a setting interface of the user, mentioned in a process of performing voice playing by the terminal.

The GPIO interface may be configured by using software. The GPIO interface may be configured as a control signal, or may be configured as a data signal. In some embodiments, the GPIO interface may be configured to connect the processor to the camera, the display screen, the communications module, the audio module, a sensor, and the like. The GPIO interface may alternatively be configured as the I2C interface, the I2S interface, the UART interface, the MIPI interface, or the like.

The USB interface <NUM> may be a mini USB interface, a micro USB interface, a USB Type C interface, or the like. The USB interface may be configured to connect to the charger to charge the terminal <NUM>, or may be configured to transmit data between the terminal <NUM> and a peripheral device. The USB interface may alternatively be connected to a headset, to play audio by using the headset. The USB interface may alternatively be connected to another electronic device, for example, an AR device.

An interface connection relationship between the modules shown in this embodiment of the present invention is merely an example for description, and does not constitute a limitation on the structure of the terminal <NUM>. The terminal <NUM> may use different interface connection manners or a combination of a plurality of interface connection manners in this embodiment of the present invention.

The charging management module <NUM> is configured to receive charging input from the charger. The charger may be a wireless charger or a wired charger. The power management module <NUM> is connected to the battery <NUM>, the charging management module <NUM>, and the processor <NUM>. The power management module receives input of the battery and/or the charging management module, and supplies power to the processor, the internal memory, the external memory, the display screen, the camera, the communications module, and the like. A wireless communication function of the terminal <NUM> may be implemented by using the antenna <NUM>, the antenna <NUM>, the radio frequency module <NUM>, the communications module <NUM>, the modem processor, the baseband processor, and the like.

The antenna <NUM> and the antenna <NUM> are configured to transmit and receive an electromagnetic wave signal. Each antenna in the terminal <NUM> may be configured to cover one or more communication frequency bands. The radio frequency module <NUM> may provide a communications processor module that is applied to the terminal <NUM> and that includes a wireless communication solution, for example, <NUM>/<NUM>/<NUM>/<NUM>. The radio frequency module <NUM> may include at least one filter, a switch, a power amplifier, a low noise amplifier (Low Noise Amplifier, LNA), and the like. The modem processor may include a modulator and a demodulator. The modulator is configured to modulate a to-be-sent low-frequency baseband signal into a medium-high frequency signal. The demodulator is configured to demodulate a received electromagnetic wave signal into a low-frequency baseband signal. Then, the demodulator transfers the low-frequency baseband signal obtained through demodulation to the baseband processor for processing. The low-frequency baseband signal is processed by the baseband processor, and is then transferred to the application processor. The application processor outputs a sound signal by using an audio device (not limited to the speaker, the telephone receiver, or the like), or displays an image or a video by using the display screen. The communications module <NUM> may provide a communications processor module of wireless communication solutions, including a wireless local area network (wireless local area networks, WLAN), Bluetooth (bluetooth, BT), a global navigation satellite system (global navigation satellite system, GNSS), frequency modulation (frequency modulation, FM), a near field communication (near field communication, NFC) technology, an infrared (infrared, IR) technology, and the like that are applied to the terminal <NUM>. The communications module <NUM> may be one or more devices integrating at least one communications processor module. The communications module receives an electromagnetic wave by using the antenna <NUM>, performs frequency modulation and filtering processing on an electromagnetic wave signal, and sends a processed signal to the processor. The communications module <NUM> may alternatively receive a to-be-sent signal from the processor, perform frequency modulation and amplification on the signal, and convert the signal into an electromagnetic wave for radiation by using the antenna <NUM>.

In some embodiments of this application, the voice of the user may be recorded by using the microphone in the Bluetooth headset (or a Bluetooth sound box, or the like), and the recorded voice is transferred to the processor <NUM> by using a Bluetooth communications processor module and the audio module <NUM>. After the processor <NUM> converts the received text message into a voice, the terminal may further play the voice by using the Bluetooth headset (or the Bluetooth sound box, or the like) through the audio module <NUM> and the Bluetooth communication processor module.

In some embodiments, the antenna <NUM> of the terminal <NUM> is coupled to the radio frequency module, and the antenna <NUM> is coupled to the communications module. In this way, the terminal <NUM> may communicate with a network and another device by using a wireless communications technology. The wireless communications technology may include a global system for mobile communications (global system for mobile communications, GSM), a general packet radio service (general packet radio service, GPRS), code division multiple access (code division multiple access, CDMA), wideband code division multiple access (wideband code division multiple access, WCDMA), time-division code division multiple access (time-division code division multiple access, TD-SCDMA), long term evolution (long term evolution, LTE), the BT, the GNSS, the WLAN, the NFC, the FM, the IR technology, and/or the like. The GNSS may include a global positioning system (global positioning system, GPS), the global navigation satellite system (global navigation satellite system, GLONASS), a Beidou navigation satellite system (beidou navigation satellite system, BDS), a quasi-zenith satellite system (quasi-zenith satellite system, QZSS), and/or a satellite-based augmentation system (satellite based augmentation systems, SBAS).

In this embodiment of this application, the terminal may receive, by using the antenna <NUM> and the radio frequency module, a message sent by another terminal, for example, a Messages message. The terminal may alternatively receive, by using the antenna <NUM> and the communications module, a message sent by another terminal, for example, a WeChat message or a QQ message. The message is not specifically limited in this embodiment of this application.

The terminal <NUM> implements the display function by using the GPU, the display screen <NUM>, the application processor, and the like. The GPU is a microprocessor for image processing, and is connected to the display screen and the application processor. The GPU is configured to perform mathematical and geometric calculation, and is configured to render an image. The processor <NUM> may include one or more GPUs that execute a program instruction to generate or change display information.

The display screen <NUM> is configured to display an image, a video, and the like. The display screen includes a display panel. The display panel may use an LCD (liquid crystal display, liquid crystal display screen), an OLED (organic light-emitting diode, organic light-emitting diode), an active-matrix organic light-emitting diode or an active-matrix organic light-emitting diode (active-matrix organic light emitting diode, AMOLED), a flexible light-emitting diode (flex light-emitting diode, FLED), a miniled, a microLed, a micro-oLed, a quantum dot light-emitting diode (quantum dot light emitting diodes, QLED), or the like. In some embodiments, the terminal <NUM> may include one display or N display screens, where N is a positive integer greater than <NUM>.

The mobile terminal <NUM> can implement the photographing function by using the ISP, the camera <NUM>, the video codec, the GPU, the display screen, the application processor, and the like.

The external memory interface <NUM> may be connected to an external storage card, for example, a micro SD card, to extend a storage capability of the terminal <NUM>. The external storage card communicates with the processor through the external memory interface, to implement a data storage function. For example, a file, for example, music or a video, is stored into the external storage card.

The internal memory <NUM> may be configured to store computer-executable program code, and the executable program code includes an instruction. The processor <NUM> runs the instruction stored in the internal memory <NUM>, to implement various function applications and data processing of the terminal <NUM>. The memory <NUM> may include a program storage area and a data storage area. The program storage area may store an operating system, an application program required by at least one function (for example, a sound playing function or an image playing function), and the like. The data storage area may store data (for example, audio data or a phone book) created during use of the terminal <NUM>, and the like. In addition, the memory <NUM> may include a high-speed random access memory, and may further include a nonvolatile memory, for example, at least one magnetic disk storage device, a flash storage device, another volatile solid-state storage device, a universal flash storage (universal flash storage, UFS), or the like.

The terminal <NUM> can implement an audio function by using the audio module <NUM>, the speaker 170A, the telephone receiver 170B, the microphone 170C, the headset interface 170D, the application processor, and the like, for example, music playing or recording.

The audio module <NUM> is configured to convert digital audio information into an analog audio signal for output, or is configured to convert analog audio input into a digital audio signal. The audio module may be further configured to encode and decode an audio signal. In some embodiments, the audio module may be disposed in the processor <NUM>, or some functional modules in the audio module are disposed in the processor <NUM>.

The speaker 170A, also referred to as a "loudspeaker", is configured to convert an audio electrical signal into a sound signal. The terminal <NUM> may play music by using the speaker, or receive a hands-free call.

The telephone receiver 170B, also referred to as an "earpiece", is configured to convert an audio electrical signal into a sound signal. When a call is answered or voice information is received by using the terminal <NUM>, the telephone receiver may be put close to a human ear to receive a voice.

The microphone 170C, also referred to as a "mic" or a " sound conducting device", is configured to convert a sound signal into an electrical signal. When making a call or sending voice information, a user may make a sound by moving a mouth of the user near the microphone to input a sound signal to the microphone. At least one microphone may be disposed in the terminal <NUM>. In some embodiments, two microphones may be disposed in the terminal <NUM>, to collect a sound signal and further implement a noise reduction function. In some embodiments, three, four, or more microphones may alternatively be disposed in the terminal <NUM>, to collect a sound signal, reduce noise, and further recognize a sound source, implement a directional recording function, and the like.

The headset interface 170D is connected to a wired headset. The headset interface may be a USB interface, or may be a <NUM> open mobile terminal platform (open mobile terminal platform, OMTP) standard interface or a cellular telecommunications industry association of the USA (cellular telecommunications industry association of the USA, CTIA) standard interface.

In some embodiments of this application, the terminal may record the voice of the user by using the microphone 170C, and transfer the recorded voice to the processor <NUM> by using the audio module <NUM>. After the processor <NUM> converts the received text message into a voice, the terminal may further play the voice by using the speaker through the audio module <NUM>. In some other embodiments of this application, the terminal may record the voice of the user by using a microphone in the wired headset, and transfer the recorded voice to the processor <NUM> by using the headset interface 170D and the audio module <NUM>. After the processor <NUM> converts the received text message into a voice, the terminal may further play the voice by using the wired headset through the audio module <NUM> and the headset interface 170D.

The touch sensor <NUM> is also referred to as a "touch panel", may be set on the display screen, and is configured to detect a touch operation performed on or near the touch sensor <NUM>. The touch sensor <NUM> may transfer the detected touch operation to the application processor, to determine a touch event type, and provide corresponding visual output by using the display screen.

The key <NUM> includes a power key, a volume key, and the like. The key may be a mechanical key, or may be a touch key. The terminal <NUM> receives key input, and generates key signal input related to a user setting and function control of the terminal <NUM>.

The motor <NUM> may generate a vibration prompt. The motor may be used for an incoming call vibration prompt, or may be used for a touch vibration feedback. For example, touch operations performed on different applications (for example, a photographing application and an audio playing application) may correspond to different vibration feedback effects. Different touch operations performed in different areas of the display screen may also correspond to different vibration feedback effects. Different application scenarios (for example, a time reminder, information receiving, an alarm clock, a game, and the like) may also correspond to different vibration feedback effects. Customization of a touch vibration feedback effect may further be supported.

The indicator <NUM> may be an indicator light that may be configured to indicate a charging status and a battery power change, or may be configured to indicate a message, a missed call, a notification, and the like.

The SIM card interface <NUM> is connected to a subscriber identity module (subscriber identity module, SIM). A SIM card may be inserted into the SIM card interface or removed from the SIM card interface, to implement contact with or separation from the terminal <NUM>. The terminal <NUM> may support one SIM card interface or N SIM card interfaces, where N is a positive integer greater than <NUM>. The SIM card interface may support a nano SIM card, a micro SIM card, a SIM card, and the like. A plurality of cards may be inserted into a same SIM card interface simultaneously. The plurality of cards may be of a same type or different types. The SIM card interface may also be compatible with different types of SIM cards, and the SIM card interface may alternatively be compatible with the external storage card. The terminal <NUM> interacts with a network by using the SIM card, to implement functions such as calling and data communication. In some embodiments, the terminal <NUM> uses an eSIM, namely, an embedded SIM card. The eSIM card may be embedded in the terminal <NUM>, and cannot be separated from the terminal <NUM>.

A software system of the terminal <NUM> may use a layered architecture, an event-driven architecture, a microkernel architecture, a microservice architecture, or a cloud architecture. In this embodiment of the present invention, an Android system with the layered architecture is used as an example to describe a software structure of the terminal <NUM>.

In the layered architecture, software is divided into several layers, and each layer has a clear role and task. The layers communicate with each other through an interface. In some embodiments, the Android system is divided into four layers, namely, an application program layer, an application program framework layer, Android runtime (Android runtime) and a system library, and a kernel layer from top to bottom.

The application program layer may include a series of application program packages.

As shown in <FIG>, an application program package may include application programs such as camera, gallery, calendar, phone, map, navigation, WLAN, Bluetooth, music, video, Messages, WeChat, QQ, and setting.

In some embodiments of this application, the application program package mainly includes instant communication applications, including but not limited to the application programs such as Messages, WeChat, and QQ. In some other embodiments of this application, a setting application is further involved, to provide an interface for setting a message played in a voice manner for a user. Content of setting includes but is not limited to a preset application, a preset contact, a preset contact group, a preset second keyword, a playing priority, and the like.

The application program framework layer provides an application programming interface (application programming interface, API) and a programming framework for an application program at the application program layer. The application program framework layer includes some predefined functions.

As shown in <FIG>, the application program framework layer may include a window manager, a content provider, a view system, a phone manager, a resource manager, a notification manager, and the like.

The window manager is configured to manage a window program. The window manager may obtain a size of a display screen, determine whether there is a status bar, lock a screen, take a screenshot, and the like.

The content provider is configured to: store and obtain data, and make the data accessible to an application program. The data may include a video, an image, audio, calls that are made and answered, a browsing history and a bookmark, a phone book, and the like.

The view system includes visual controls such as a control for displaying a character and a control for display a picture, and the view system may be configured to construct an application program. A display interface may include one or more views. For example, a display interface including a Messages notification icon may include a view for displaying a character and a view for displaying a picture.

The phone manager is configured to provide a communication function of the terminal <NUM>, for example, management of call statuses (including a connected state, a disconnected state, and the like).

The resource manager provides various resources such as a localized character string, an icon, a picture, a layout file, and a video file for an application program.

The notification manager enables an application program to display notification information in a status bar, and may be configured to convey a notification-type message. The notification-type message may automatically disappear after the message is displayed for a short period of time without user interaction. For example, the notification manager is configured to provide a notification of download completion, a message reminder, and the like. The notification manager may alternatively be a notification that appears on the top of a status bar of a system in a text form of a graph or a scroll bar, for example, a notification of an application program running in the background or a notification that appears on a screen in a form of a dialog window. For example, text information is prompted in the status bar, a prompt tone is produced, the terminal vibrates, or the indicator light blinks.

In some embodiments of this application, the application program framework layer may further include a voice playing system, and the voice playing system provides a voice playing service for an instant message. It should be noted that the voice playing system may be an independent module at the application framework layer, or the voice playing system may invoke another module at the application program framework layer to jointly complete a voice playing function of the instant message. This is not specifically limited in this embodiment of this application.

The Android runtime includes a kernel library and a virtual machine, and the Android runtime is responsible for scheduling and management of the Android system.

The kernel library includes two parts: a function that needs to be invoked by a Java language and a kernel library of Android.

The application program layer and the application program framework layer run on the virtual machine. The virtual machine executes a Java file at the application program layer and the application program framework layer as a binary file. The virtual machine is configured to perform functions such as object lifecycle management, stack management, thread management, security and exception management, and garbage collection.

The system library may include a plurality of functional modules, for example, a surface manager (surface manager), a media library (Media Libraries), a three-dimensional graphics processing library (OpenGL ES), and a 2D graphics engine (SGL).

The surface manager is configured to: manage a display subsystem, and provide fusion of 2D and 3D layers for a plurality of application programs.

The media library supports playback and recording of a plurality of commonly used audio and video formats, static image files, and the like. The media library may support a plurality of audio and video coding formats, for example, MPEG4, H. <NUM>, MP3, AAC, AMR, JPG, and PNG.

OpenGL ES is configured to implement three-dimensional graphics drawing, image rendering, composition, layer processing, and the like.

The following uses an example in which a message of a Messages application is processed to describe a working process of software and hardware of the terminal <NUM>.

When receiving one message, the Messages application at the application program layer may invoke the display driver at the kernel layer, to display prompt information of the message on a touchscreen at a hardware layer, so as to prompt a user to view the message. In this case, after the user taps, by using the touchscreen at the hardware layer, a control corresponding to the prompt information of the message, the touchscreen may be triggered to report, to the kernel layer by using a corresponding driver, a touch event (for example, a parameter including a touch point location, a time, or the like) generated by a touch action of the user. After encapsulating the touch event, the kernel layer invokes a corresponding API to distribute the touch event to the Messages application. Then, the terminal starts the Messages application, and displays an interface for viewing the message. In this way, the user can view content of the message.

Considering that the user is inconvenient to manually operate the terminal, when receiving the one message, the Messages application at the application program layer may invoke the voice playing system at the framework layer. The voice playing system may play, by invoking the audio driver at the kernel layer and by using an audio output device (for example, a Bluetooth headset or a speaker), a voice for asking the user whether to play the message. Then, an audio input device (for example, a Bluetooth headset or a microphone) records the voice of the user, and then reports the recorded voice of the user to the kernel layer by using a corresponding driver. After encapsulating the event, the kernel layer invokes a corresponding API to distribute the event to the voice playing system of the framework layer. Then, the voice playing system determines, based on the event, whether to play the message in a voice manner. Specifically, the voice playing system may convert the reported voice of the user into a text, and match the converted text with pre-stored keywords (keywords of a positive reply and/or a keywords of a negative reply). If the converted text matches the keywords of the positive reply, it is determined that the message is played in the voice manner. In this case, the voice playing system converts the message into a voice message, invokes the audio driver at the kernel layer, and plays the voice message by using the audio output device. If the converted text matches the keywords of the negative reply, it is determined that the message is not played in the voice manner. In this way, when the user is inconvenient to manually operate the terminal, the user can also process the message.

In addition, in the embodiments of this application, the voice playing system may further record a quantity of times of using the converted text. When the quantity of times of using the converted text reaches a predetermined quantity of times, the text may be further added to the keyword, to learn the voice of the user. In addition, the voice playing system may further invoke the display driver at the kernel layer, to display, by using the touchscreen, an interface in embodiments of this application, for example, interface diagrams shown in <FIG> and <FIG>.

All methods in the following embodiments may be implemented in the terminal <NUM> having the hardware structure and the software structure.

To enable the user to process some important and urgent instant messages in a timely manner when the user uses the terminal and the user is inconvenient to manually operate the terminal, an embodiment of this application provides a method for playing an instant message in a voice manner. Further, in consideration of factors such as a factor that the user may forget a preset voice command or a language habit of the user, the voice command of the user is not a voice command preset by the terminal. Therefore, the terminal cannot recognize an intention of the user, and cannot perform an operation expected by the user. Therefore, in the technical solutions provided in the embodiments of this application, the voice command of the user can be learned, to automatically recognize a real meaning of the voice command of the user. This improves use efficiency of the terminal and improves user experience.

The following describes technical solutions provided in the embodiments of this application with reference to accompanying drawings and specific application scenarios.

In a first application scenario, a terminal asks a user whether to play a newly received message in a voice manner.

<FIG> and <FIG> are a schematic flowchart of a method for playing a message in a voice manner according to an embodiment of this application. The method specifically includes the following steps.

S301: A terminal receives a first message.

In some embodiments of this application, the terminal receives the first message sent by another terminal or a server. The first message may be a message of an instant communication application, for example, a message of a Messages application, a message of a WeChat application, or a message of a QQ application.

S302: The terminal asks, in a voice manner, whether to play the first message.

After newly receiving the first message, the terminal displays prompt information of the first message in a terminal interface. The terminal may ask, in the voice manner, the user whether to play the first message before, when, or after displaying the prompt information of the first message.

In this embodiment of this application, the terminal may perform voice playing by using an audio device, for example, a speaker, a wired headset, a wireless headset, a Bluetooth sound box, or a Bluetooth vehicle-mounted device. This is not specifically limited in this embodiment of this application.

For example, <FIG> (<NUM>) shows an interface <NUM> displayed by the terminal. The interface <NUM> may display a status bar <NUM>, a message prompt box <NUM>, a pattern <NUM>, a time widget, and the like. The status bar <NUM> may include a name of an operator (for example, China Mobile), a time, a WiFi icon, signal strength, current remaining power, and the like. The interface <NUM> is an interface diagram in which the terminal asks, in the voice manner, the user whether to play the first message. The terminal may dynamically display the pattern <NUM>, or change a color, a gray scale, or the like of the pattern <NUM>, to notify the user that the terminal is playing a voice. Alternatively, the terminal may display text information, to notify that the terminal is asking the user whether to play the first message. It should be noted that a prompt manner of the terminal is not limited in this embodiment of this application.

S303: The terminal detects a first voice of the user.

Specifically, the terminal records the first voice of the user by using an audio input device, and sends the recorded first voice of the user to an application processor of the terminal for processing.

For example, <FIG> (<NUM>) shows an interface <NUM> displayed by the terminal. The interface <NUM> may display a status bar <NUM>, a message prompt box <NUM>, a pattern <NUM>, a time widget, and the like. The interface <NUM> is an interface in which the terminal detects a voice of the user. The terminal may dynamically display the pattern <NUM>, or change a color, a gray scale, or the like of the pattern <NUM>, to notify the user that the terminal detects the voice of the user or that the terminal is processing the detected voice of the user. Alternatively, the terminal may display text information, to notify that the terminal detects the voice of the user and is processing the detected voice of the user. It should be noted that a prompt manner in which the terminal detects the voice of the user (or is processing the voice of the user) is not limited in this embodiment of this application.

S304: The terminal converts the first voice into text information, and records the text information as a first command.

S305: The terminal matches the first command with a first keyword pre-stored in the terminal.

The first keyword may include a command preset by the terminal, for example, a command of a positive reply or a command of a negative reply. The first keyword may be a default keyword of the terminal, or may be set by the user. Alternatively, the first keyword may be learned by the terminal. For a specific learning method, refer to the following description.

Specifically, in some embodiments of this application, the preset first keyword may be a keyword of a positive reply. To be specific, if the first command matches the first keyword, it can be determined that the first command is a command that the user expects to play the first message in the voice manner. If the first command does not match the first keyword, the first command needs to be learned by using the method (as shown in <FIG> and <FIG>) in this embodiment of this application, to determine whether the first command is a positive reply.

In some other embodiments of this application, the preset first keyword may alternatively be a keyword of a negative reply. To be specific, if the first command matches the first keyword, it can be determined that the first command is a command that the user does not expect to play the first message in the voice manner. In this case, the terminal learns the first command, to determine that the first command is a negative reply. In some still other embodiments of this application, the preset first keyword may alternatively include both a keyword of a positive reply and a keyword of a negative reply. In this case, the terminal needs to separately perform processing based on a type of first keyword that matches the first command. This case is explained below. This is not limited in this embodiment of this application.

In the following steps S306 to S313, an example in which the first keyword is the positive reply is used to describe a process in which the terminal learns the first command. If the first command matches the first keyword, it is determined that the first command is a positive reply, and the user expects to play the first message in the voice manner. Therefore, the terminal plays the first message in the voice manner, that is, performs step S306. If the first command does not match the first keyword, step S307 is performed.

S306: The terminal plays the first message in the voice manner.

The step of playing the first message in the voice manner specifically includes: playing content of the first message in the voice manner, or playing a name of an application to which the first message belongs, a name of a sender of the first message, or the like.

In some embodiments of this application, after determining that the first command is the positive reply, the terminal may convert the text information of the first message into a voice message, and then play the voice message.

In some other embodiments of this application, before determining that the first command is the positive reply, the terminal may convert the text information of the first message into a voice message. After determining that the first command is the positive reply, the terminal may directly play the voice message. This reduces a time period in which the user waits for the terminal to play the first message in the voice manner, and improves user experience. For example, after receiving the first message, or after receiving the first voice of the user, or after converting the first voice of the user into the first command, or after the user matches the first command with the preset first keyword, the terminal may convert the text information of the first message into a voice message. A time at which the terminal converts the text information of the first message into the voice message is not limited in this embodiment of this application.

For example, <FIG> (<NUM>) shows an interface <NUM> displayed by the terminal. The interface <NUM> may display a status bar <NUM>, a message prompt box <NUM>, a pattern <NUM>, a time widget, and the like. The interface <NUM> is an interface in which the terminal is playing the first message. The terminal may dynamically display the pattern <NUM>, or change a color, a gray scale, or the like of the pattern <NUM>, to notify the user that the terminal is playing the first message. Alternatively, the terminal may display prompt information, to notify the user that the terminal is playing the first message. It should be noted that a prompt manner in which the terminal is playing the first message is not limited in this embodiment of this application.

S307: The terminal does not play the first message temporarily, and continues to listen to a voice of the user.

For example, <FIG> (<NUM>) shows an interface <NUM> displayed by the terminal. The interface <NUM> may display a status bar <NUM>, a message prompt box <NUM>, a pattern <NUM>, a time widget, and the like. The interface <NUM> is an interface in which the terminal continues to listen to a voice of the user because the terminal fails to recognize the voice command of the user. The terminal may dynamically display the pattern <NUM>, or change a color, a gray scale, or the like of the pattern <NUM>, to notify the user that the terminal fails to recognize the voice command of the user. Alternatively, the terminal may display text information, to notify the user that the terminal continues to listen to the voice of the user because the terminal fails to recognize the voice command of the user. Alternatively, the terminal may notify, in the voice manner, the user that the terminal fails to recognize an indication of the user, and then continues to listen to the voice of the user. It should be noted that a specific prompt form of the terminal is not limited in this embodiment of this application.

S308: The terminal detects a second voice of the user.

S309: The terminal converts the detected second voice into text information, and records the text information as a second command.

S310: The terminal matches the second command with the first keyword preset by the terminal. If the second command does not match the preset first keyword, step S311 is performed. If the second command matches the preset first keyword, step S312 is performed.

S311: The terminal does not play the first message temporarily, and continues to listen to a voice of the user.

In some other embodiments of this application, if the terminal has not received the voice of the user within a preset time period (for example, <NUM> seconds, where the preset time period may be a default time period of the terminal, or may be set by the user), or when the terminal has not received, within a preset time period, the voice of the user that matches the set first keyword, the terminal may end this procedure. In other words, the terminal considers by default that the user does not expect to play the first message in the voice manner.

In some still other embodiments of this application, if the terminal detects that a quantity of times of using the voice that is of the user and that does not match the set first keyword reaches the preset quantity of times, the terminal may end this procedure. In other words, the terminal considers by default that the user does not expect to play the first message in the voice manner.

For example, <FIG> (<NUM>) shows an interface <NUM> displayed by the terminal. The interface <NUM> may display a status bar <NUM>, a message prompt box <NUM>, a pattern <NUM>, a time widget, and the like. The interface <NUM> is an interface in which the terminal determines not to play the first message. The terminal may change a color, a gray scale, or the like of the pattern <NUM>, to notify the user that the terminal does not play the first message. Alternatively, the terminal may display text information, to notify the user that the terminal does not play the first message. It should be noted that a manner in which the terminal notifies the user that the terminal does not play the first message is not limited in this embodiment of this application.

S312: The terminal plays the first message in the voice manner. In addition, the terminal records content of the first command and a quantity of times of using the first command.

It should be noted that when the first command does not match the preset first keyword, there are two possible cases. In one possible case, the user expects to play the first message, but may forget preset content of the positive reply. Therefore, the first command converted from the first voice is different from the preset positive reply. In the other possible case, the first voice of the user is not a reply made for inquiry of the terminal. For example, the first voice may be a dialogue between the user and another person. After receiving the first voice, the terminal mistakenly considers that the first voice is the first command of the user.

In this case, the terminal needs to record the content of the first command and the quantity of times that the user uses the first command.

S313: When the terminal records the quantity of times of using the first command as the predetermined quantity of times (or the quantity of times of using the first command is greater than the predetermined quantity of times), the terminal automatically adds the first command to the first keyword.

In a scenario of the predetermined quantity of times (for example, M times, where M is a natural number greater than <NUM>), if the user first answers, by using the first command, to the terminal asking whether to play the message, and then makes a reply by using the positive reply set by the terminal, the terminal may consider that the first command of the user is the positive reply and that the user expects the terminal to play the message in the voice manner. Therefore, the terminal learns that the first command of the user is the positive reply.

For example, <FIG> (<NUM>) shows an interface <NUM> displayed by the terminal. The interface <NUM> may display a status bar <NUM>, a message prompt box <NUM>, a pattern <NUM>, a time widget, and the like. The interface <NUM> is an interface in which the terminal has successfully learned the first command. The terminal may change a color, a gray scale, or the like of the pattern <NUM>, to notify the user that the terminal has learned the first command. Alternatively, the terminal may display text information, to notify the user that the terminal has successfully learned the first command, or to add the first command to the keyword of the positive reply. It should be noted that a prompt manner of the terminal is not limited in this embodiment of this application.

It should be noted that the terminal may display prompt information indicating that the first command has successfully learned after playing the message, or may display prompt information indicating that the first command has successfully learned before playing the message, or may not display prompt information indicating that the first command has successfully learned. This is not limited in this embodiment of this application.

Then, when the terminal receives a message (for example, a third message) again, the terminal asks, in the voice manner, whether to play the message. When the terminal detects a voice of the user, and the voice of the user is converted into the first command (to be specific, in this case, content of the voice of the user is the same as content of the first voice), the terminal matches the first command with the set first keyword. In this case, because the first keyword set by the terminal includes the first command (a learning result), matching succeeds. The terminal determines that the user expects to play the message in the voice manner, and therefore the terminal plays the third message in the voice manner.

For example, the user sets the positive reply to "yes" and "play". When the user replies "please say" for the first time, the terminal matches "please say" with the set positive reply. If it is determined that "please say" is not the set positive reply, the terminal does not play the message in the voice manner temporarily, and continues to listen to a reply of the user. If the user replies "play" for the second time, the terminal matches "play" with the preset positive reply. If it is determined that "play" is the set positive reply, the terminal plays the message in the voice manner. In addition, the terminal records "please say" once. Then, after the terminal asks the user whether the message needs to be played in the voice manner, if the user still replies "please say", and then replies the positive reply set by the terminal. The terminal records "please say" twice. After a quantity of times of answering "please say" recorded by the terminal reaches a preset quantity of times, the terminal learns that "please say" is the positive reply. Then, the terminal may set "please say" to the positive reply. Afterwards, when the terminal receives "please say" again used by the user, and the terminal matches "please say" with the set positive reply, it can be determined that "please say" is the positive reply, and the terminal plays the message in the voice manner.

It can be learned that in the technical solution provided in this embodiment of this application, a non-preset reply of a user can be learned, to determine a real intention of the user and whether the user expects to play a message. This increases accuracy of executing a command by the terminal, and a success rate of playing a message in the voice manner by the terminal, so that the terminal is more intelligent, and user experience of using the terminal is improved.

<FIG> and <FIG> are a schematic flowchart of another method for playing a message in a voice manner according to an embodiment of this application. The method specifically includes S101 to S113. S101 to S113 are as follows:.

S101: A terminal newly receives a message.

S102: The terminal asks, in a voice manner, a user whether to play the message.

For example, the terminal initializes parameters, for example, n = <NUM> and time = <NUM> before, when, or after S <NUM> is performed, where n is used to mark a quantity of times that the terminal detects a voice command of the user in a process from this step to end of a procedure, and time is used for timekeeping. Within a preset time period, if the terminal has not detected the voice command of the user, or a voice of the user has not been determined as a command for playing the message, the terminal ends this procedure, and considers by default that the user does not expect to play the message in the voice manner. In some embodiments of this application, the terminal may alternatively initialize time in step S101, and start timekeeping from step S101. This is not limited in this embodiment of this application.

It should be noted that m is used to mark a recorded quantity of times of learning a text of the voice in a process in which the terminal learns the voice command of the user. In some embodiments of this application, a value (m = <NUM>) of m may be initialized when the terminal records, for the first time, a voice command that needs to be learned. In some other embodiments of this application, a value (m = <NUM>) of m may be initialized when the terminal enables, for the first time, a function of playing the message in the voice manner, or when the terminal enables, for the first time, a function of learning the voice command. This is not limited in this embodiment of this application.

S103: The terminal detects a voice of the user, and records a quantity n of times that the voice of the user is detected.

It should be noted that an initial value of n in this embodiment is <NUM>. Each time after detecting the voice of the user, the terminal updates a value of n, and increases n by <NUM>. In specific implementation, this may be implemented by using code "n = n + <NUM>". The voice of the user detected this time is recorded as a voice of the user detected for the nth time.

S104: The terminal converts the voice detected for the nth time into a text.

S105: The terminal matches the converted text with a set first keyword. If the converted text does not match the set first keyword, step S <NUM> is performed. If the converted text matches the set first keyword, step S <NUM> is performed.

The first keyword set herein is a positive reply. To be specific, if the converted text matches a first keyword of a positive reply, it is considered that the user expects to play the message in the voice manner. If the converted text does not match the first keyword of the positive reply, the voice of the user needs to be further learned to determine whether the user expects to play the message in the voice manner.

S106: The terminal does not play the message in the voice manner temporarily.

S107: The terminal determines whether the time (time) reaches a preset time. If the time reaches the preset time, the procedure ends. If the time does not reach the preset time, step S103 continues to be performed.

S108: The terminal plays the message in the voice manner.

S109: The terminal determines whether n is greater than or equal to <NUM>. If n is greater than or equal to <NUM>, step S <NUM> is performed. If n is not greater than or equal to <NUM>, this procedure ends.

If n is not greater than or equal to <NUM>, it indicates that after receiving the message, when sending the voice command for the first time, the user makes a reply by using the preset first keyword of the positive reply. In this case, the terminal recognizes the voice command of the user, and plays the message in the voice manner. Therefore, there is no need to learn a last voice command of the user, to be specific, the following learning process does not need to be performed, and the procedure ends.

If n is greater than or equal to <NUM>, it indicates that after receiving the message, when sending the voice command for the second time or later time, the user makes a reply by using the preset first keyword of the positive reply. To be specific, before this, the user does not use the preset first keyword of the positive reply for at least one time when sending the voice command. Therefore, the terminal needs to learn the voice command sent for the at least one time, to determine whether the voice command sent for the at least one time is a positive reply, that is, S <NUM> and subsequent steps are performed.

S110: The terminal performs semantic analysis on a text of a voice detected last time (namely, the (n-<NUM>)th time), to determine whether the text of the voice detected last time is a positive reply. If the text of the voice detected last time is the positive reply, step S111 is performed. If the text of the voice detected last time is not the positive reply, this procedure ends.

In some embodiments of this application, in this step, whether the text of the voice detected last time is the positive reply, a negative reply, or neither may be determined through the semantic analysis. This can provide more basis for the terminal to determine whether the text of the voice detected last time is the positive reply.

In some other embodiments of this application, the terminal may perform semantic analysis on texts of voices detected before this time (from the first time to the (n-<NUM>)th time). This is because the voices detected from the first time to the (n-<NUM>)th time may be different expressions that the user expects to play the message in the voice manner. In this way, a learning capability and learning efficiency of the terminal are improved.

In some still other embodiments of this application, alternatively, the terminal may directly perform S111 without performing step S110. This is not specifically limited in this embodiment of this application.

S111: The terminal records the text of the voice detected last time (namely, (n-<NUM>)th time), and records m = m + <NUM>.

In some other embodiments of this application, the terminal may separately record the texts of all the voices detected before this time (from the first time to the (n-<NUM>)th time). In this case, a text of a voice detected each time corresponds to one m value, and m corresponding to the text of the voice detected each time is increased by <NUM>.

S112: The terminal determines whether m is a predetermined quantity of times. If m is the predetermined quantity of times, step S113 is performed. If m is not the predetermined quantity of times, this procedure ends.

In some other embodiments of this application, the terminal records the texts of the voices detected from the first time to the (n-<NUM>)th time. In this case, the terminal may determine, for an m value corresponding to a text of a voice detected each time, whether a quantity of times of using the m value corresponding to the text of the voice detected each time reaches the predetermined quantity of times.

S113: The terminal adds, to the first keyword, the text of the voice detected last time (namely, the (n-<NUM>)' time).

In some other embodiments of this application, the terminal records the texts of the voices detected from the first time to the (n-<NUM>)th time. In this case, the terminal may set, as the first keyword, a text of a voice detected for one or more times when a corresponding value of m meets the predetermined quantity of times.

<FIG> are a schematic flowchart of another method for playing a message in a voice manner according to an embodiment of this application. An example in which a set first keyword includes a positive reply and a negative reply is used for description in the procedure. The procedure specifically includes steps S101 to S104 and steps S201 to S215. Steps S201 to S215 are specifically as follows:.

S201: A terminal determines whether a text of a voice detected for the nth time matches a set key. If it is determined that the text of the voice detected for the nth time does not match a first keyword of a positive reply or a first keyword of a negative reply, step S202 is performed. If it is determined that the text of the voice detected for the nth time matches the first keyword of the positive reply, step S204 is performed. If it is determined that the text of the voice detected for the nth time matches the first keyword of the negative reply, step S210 is performed.

S202: The terminal does not play a message in a voice manner temporarily.

S203: The terminal determines whether a time (time) reaches a preset time. If the time reaches the preset time, the procedure ends. If the time does not reach the preset time, step S103 continues to be performed.

S204: The terminal plays the message in the voice manner.

S205: The terminal determines whether n is greater than or equal to <NUM>. If n is greater than or equal to <NUM>, step S206 is performed. If n is not greater than or equal to <NUM>, this procedure ends.

S206: The terminal performs semantic analysis on a text of a voice detected for the (n-<NUM>)th time, to determine whether the text of the voice detected for the (n-<NUM>)th time is a positive reply. If the text of the voice detected for the (n-<NUM>)th time is the positive reply, step S207 is performed. If the text of the voice detected for the (n-<NUM>)th time is not the positive reply, this procedure ends.

S207: The terminal records the text of the voice detected for the (n-<NUM>)th time, and records m = m + <NUM>.

S208: The terminal determines whether m is a predetermined quantity of times. If m is the predetermined quantity of times, step S209 is performed. If m is not the predetermined quantity of times, this procedure ends.

S209: The terminal adds the text of the voice detected for the (n-<NUM>)th time to the first keyword of the positive reply.

For steps S204 to S209, refer to steps S108 to S113. Details are not described.

S210: The terminal does not play the message in the voice manner.

S211: The terminal determines whether n is greater than or equal to <NUM>. If n is greater than or equal to <NUM>, step S212 is performed. If n is not greater than or equal to <NUM>, this procedure ends.

S212: The terminal performs semantic analysis on a text of a voice detected for the (n-<NUM>)th time, to determine whether the text of the voice detected for the (n-<NUM>)th time is a positive reply. If the text of the voice detected for the (n-<NUM>)th time is the positive reply, step S213 is performed. If the text of the voice detected for the (n-<NUM>)th time is not the positive reply, this procedure ends.

In some embodiments of this application, in this step, whether the text of the voice detected for the (n-<NUM>)th time is the positive reply, a negative reply, or neither may be determined through the voice analysis. This can provide more basis for the terminal to determine whether the text of the voice detected for the (n-<NUM>)th time is the negative reply.

In some other embodiments of this application, the terminal may perform semantic analysis on texts of voices detected before this time (from the first time to the (n-<NUM>)th time). This is because the voices detected from the first time to the (n-<NUM>)th time may be different expressions that a user expects not to play the message in the voice manner. In this way, a learning capability and learning efficiency of the terminal are improved.

In some still other embodiments of this application, the terminal may directly perform S213 without performing this step. This is not specifically limited in this embodiment of this application.

S213: The terminal records the text of the voice detected for the (n-<NUM>)th time, and records m = m + <NUM>.

In some other embodiments of this application, the terminal may separately record texts of voices detected before this time (from the first time to the (n-<NUM>)th time). In this case, a text of a voice detected each time corresponds to one m value, and m corresponding to the text of the voice detected each time is increased by <NUM>.

S214: The terminal determines whether m is the predetermined quantity of times. If m is the predetermined quantity of times, step S215 is performed. If m is not the predetermined quantity of times, this procedure ends.

In some other embodiments of this application, the terminal separately records texts of voices detected from the first time to the (n-<NUM>)th time. In this case, the terminal may determine, for an m value corresponding to a text of a voice detected each time, whether a quantity of times of using the m value corresponding to the text of the voice detected each time reaches the predetermined quantity of times.

S215: The terminal adds the text of the voice detected for the (n-<NUM>)th time to the first keyword of the negative reply.

In some other embodiments of this application, the terminal separately records texts of voices detected from the first time to the (n-<NUM>)th time. In this case, the terminal may set, as the first keyword, a text of a voice detected for one or more times when a corresponding value of m meets the predetermined quantity of times. This procedure ends.

It can be learned from the foregoing that, in the voice playing method provided in this embodiment of this application, when the voice command of the user is not a preset command, the terminal may learn the voice command of the user, to recognize an intention of the user and perform a corresponding operation. In this way, interaction between the user and the terminal is more personalized and intelligent. This helps improve use efficiency of the terminal and improve user experience.

In a second application scenario, a terminal automatically plays a newly received message in a voice manner.

<FIG> is a schematic flowchart of a method for playing a message in a voice manner according to an embodiment of this application. The method includes steps S501a to S505, and steps S501a to S505 are specifically as follows:.

S501a: A terminal displays a setting interface.

S501b: The terminal detects a setting operation of a user.

S501c: In response to the setting operation of the user, the terminal sets a function of automatically playing a message in a voice manner.

In some embodiments of this application, the user may set the message automatically played by the terminal. For example, the terminal may set an application (namely, a preset application) for automatically playing the message. In this case, when receiving the message from the preset application, the terminal may automatically play the message. Alternatively, the terminal may set a contact (namely, a preset contact) corresponding to the automatically played message, or a group (namely, a preset contact group) of a contact corresponding to the automatically played message. In this case, when receiving the message sent by the preset contact or the preset contact group, the terminal may automatically play the message in the voice manner. Alternatively, the terminal may set a second keyword (a preset second keyword) included in content of the automatically played message. In this case, when the message received by the terminal includes the preset second keyword, the terminal automatically plays the message. Similarly, the terminal may alternatively set a type (for example, a chat message, a Moments message, and a system message in WeChat) of the automatically played message, a time period of the automatically played message, a location of the automatically played message, or the like. Details are not described in this embodiment of this application.

In some other embodiments of this application, the terminal may alternatively set a playing priority of the message. Specifically, the user may determine the playing priority of the message based on a usage frequency of each application, importance of each contact or contact group, or specific setting content of the second keyword. For example, if the user uses WeChat more frequently, a priority of WeChat may be set to be higher than a priority of Messages. For another example, a priority of a starred contact in WeChat is set to be higher than a priority of a common contact in WeChat. For another example, if the second keyword is set to "urgent", a message priority including the second keyword may be set to the highest. This is not specifically limited in this embodiment of this application.

For example, <FIG> are a schematic diagram of some interfaces of a terminal. An interface <NUM> shown in <FIG> (<NUM>) may be used to set an application that can automatically play a message. The interface <NUM> may include a status bar <NUM>, a plurality of controls <NUM>, a plurality of controls <NUM>, and a control <NUM>. The status bar <NUM> may include a name of an operator (for example, China Mobile), a time, a WiFi icon, signal strength, current remaining power, and the like. The control <NUM> may be used to delete the application for automatically playing a message, the control <NUM> may be used to add the application for automatically playing a message, and the control <NUM> may be used to further set a selected application. For example, when the terminal receives an operation performed by the user on tapping the control <NUM> corresponding to "WeChat", for example, a tapping operation, the terminal displays an interface <NUM> shown in <FIG> (<NUM>). The interface <NUM> may be used to set a contact in "WeChat". Contact settings include a group setting and a specific contact setting. Herein, the group setting is used as an example for description. A control <NUM> may be used to enable a function of automatically playing a message in a group in contacts. To be specific, the terminal may set the group to automatically play a message. A control <NUM> is used to further set of the selected group. For example, when the terminal receives an operation performed by the user on the control <NUM> corresponding to the group, for example, tapping, the terminal displays an interface <NUM> shown in <FIG> (<NUM>). On the interface <NUM>, the user may select the group to automatically play a message, and specifically set the selected group. For example, when the terminal receives an operation performed by the user on a control <NUM> corresponding to "family", for example, tapping, the terminal displays an interface <NUM> shown in <FIG> (<NUM>). On the interface <NUM>, a function of whether to enable a keyword may be enabled. After the function of enabling a keyword is enabled, if content of a message includes the keyword, it may be considered that the message needs to be automatically played. A control <NUM> may be used to receive a keyword input by the user. In some other embodiments of this application, the function of enabling a keyword may not be associated with an application or a contact. To be specific, the terminal may alternatively be set to automatically play content of a message if the content of the message includes some keywords. This is irrelevant to an application to which the message belongs and whether the message is sent by a contact. This is not specifically limited in this embodiment of this application.

S502: The terminal receives a fourth message.

S503: The terminal determines whether the fourth message belongs to the preset application. If the fourth message belongs to the preset application, step S505 is performed. If the fourth message does not belong to the preset application, step S504 is performed.

S504: The terminal plays a prompt tone, to notify the user that the fourth message is received.

S505: The terminal determines whether the fourth message is sent by the preset contact. If the fourth message is sent by the preset contact, step S506 is performed. If the fourth message is not sent by the preset contact, step S504 is performed.

S506: The terminal determines whether content of the fourth message includes the second keyword. If the content of the fourth message includes the second keyword, step S507 is performed. If the content of the fourth message does not include the second keyword, step S504 is performed.

It should be noted that an execution sequence of steps S503 and S504 and specific determining content in the steps are not limited in this embodiment of this application. A specific determining process and specific determining content of the terminal are related to a specific setting of the user in step S501. This is not specifically limited in this embodiment of this application.

S507: The terminal plays the fourth message in the voice manner.

In some embodiments of this application, before this step, the terminal may alternatively ask, in the voice manner, the user whether to play the fourth message. For an inquiry process, refer to related content in the application scenario <NUM>.

In the first application scenario and the second application scenario, in some embodiments, to ensure privacy of user information, before the terminal plays a message (for example, the first message or the fourth message) in the voice manner, the terminal may further receive a setting of the user about whether to enable a voice playing function. If the user enables the voice playing function, the terminal has permission to play a message in the voice manner, and may play the message in the voice manner when a condition is met. If the user does not enable the voice playing function, the terminal does not have the permission to play a message in the voice manner, and cannot play the message in the voice manner.

In the first application scenario and the second application scenario, in some other embodiments, after the terminal plays a message (for example, the first message or the fourth message), the terminal may further receive a voice command of the user, and answer the message. In this case, the voice command of the user may use a third keyword as a prefix of a voice, to recognize that the voice of the user is an answer of the user to the message. For example, the third keyword may be "please answer", "please reply", or the like.

For example, after playing the first message or the fourth message, the terminal receives a fourth voice of the user. The terminal converts the fourth voice into text information. When it is determined, based on the text information, that the fourth voice starts with the third keyword, it is determined that the fourth voice is an answer of the user to the first message or the fourth message. In this case, the terminal answers, to a contact that sends the message, voice information following the third keyword in the fourth voice. Optionally, the terminal may alternatively convert the voice information following the third keyword in the fourth voice into text information, and answer the text information to the contact that sends the message. This is not specifically limited in this embodiment of this application.

It should be noted that optionally, after receiving the fourth voice, the terminal may convert the fourth voice into the text information. Optionally, when receiving the fourth voice, the terminal may convert a part of the received fourth voice into text information. When it is determined that a prefix of the fourth voice is the third keyword, it is determined that the fourth voice is an answer of the user, and subsequent steps continue to be performed. When it is determined that the prefix of the fourth voice is not the third keyword, it is determined that the fourth voice is not an answer of the user, and subsequent steps may not be performed. In this way, processing load of the terminal is reduced, and a processing capability of the terminal is improved.

In some embodiments of this application, the terminal may learn the third keyword. A learning method is similar to a method for learning the first keyword by the terminal in the application scenario <NUM>.

In some other embodiments of this application, the terminal may answer to a sender with some pictures (for example, a smiling face picture or an angry face picture in an input method) based on a voice of the user. The user may preset a correspondence between a fourth keyword and a picture in the input method. For example, "smile" corresponds to the smiling face picture, and "anger" corresponds to the angry face picture. In this way, when the terminal has determined that the fourth voice is an answer of the user to the first message or the fourth message, and detects that the fourth voice of the user includes the fourth keyword, the terminal answers a corresponding picture to the sender according to the correspondence between the fourth keyword and the picture. In this way, diversity of answered messages of the user is enriched, and user experience is improved.

Claim 1:
A message playing method, applicable to a terminal (<NUM>), wherein the method comprises:
receiving, by the terminal (<NUM>), a first message, wherein the first message is text information;
playing, by the terminal (<NUM>), a first voice in response to receiving the first message, wherein the first voice is used to ask a user whether to play the first message in a voice manner;
detecting, by the terminal (<NUM>), a second voice of the user;
converting, by the terminal (<NUM>), the second voice into a first text;
characterized by
if the first text does not match one or more first keywords, continuing, by the terminal (<NUM>), to detect a voice of the user, wherein the one or more first keywords are positive keywords indicating that the user expects the terminal to play the first message;
when the terminal (<NUM>) detects a third voice of the user, converting, by the terminal (<NUM>), the third voice into a second text;
if the second text matches the one or more first keywords, playing, by the terminal (<NUM>), the first message in the voice manner, and recording, by the terminal (<NUM>), a quantity of times of using the first text; and
if the quantity of times of using the first text is greater than a first threshold, adding, by the terminal (<NUM>), the first text to the one or more first keywords.