Emotion recognition method, device, equipment and medium
By analyzing the text in the voice information, judging the splicing and position relationship between emotional words and negative words, combining the scores and weights of emotional words, the problem of low user emotion recognition accuracy in voice interaction is solved, and the interaction between users and smart devices is improved Experience.
Patent Information
- Application Number
- CN202111255739.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-27
- Publication Date
- 2024-12-20
- Estimated Expiration
- 2041-10-27
AI Technical Summary
The prior art is not very accurate when recognizing user emotions based on voice interaction, which affects the interactive experience between users and smart devices.
By analyzing the text in the pronunciation information, determine whether there are pre-save emotional words and negative words, determine whether these words can be spliced into reverse emotional words, and determine the user's emotions based on the scores and weights of the emotional words, and use the intention of pre-training Identify the model to verify the sentiment probability value.
It improves the accuracy of user emotions recognition and improves the interactive experience between users and smart devices.
Smart Images

Figure CN113987123B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of intelligent interaction technology, and in particular to an emotion recognition method, device, equipment and medium. Background Art
[0002] With the rapid development of intelligent interaction, if smart devices can recognize the user's current emotions and make interactions that are consistent with the user's current emotions, it can effectively enhance the user's interactive experience with smart devices.
[0003] In the related art, when identifying user emotions, smart devices can obtain images containing the user, and identify the user's emotions based on the images containing the user and the deep learning model. However, this method is not suitable for scenarios where user emotions are identified based on voice interaction. If the user's emotions are to be identified based on voice interaction, the smart device can identify the corresponding text information in the voice interaction information, identify the keywords in the text information, and determine the user's corresponding emotions based on the pre-set correspondence between the keywords and the emotions. However, the accuracy of determining user emotions in this method is not high, which affects the user's experience of interacting with the smart device. Summary of the invention
[0004] The present application provides an emotion recognition method, apparatus, device and medium for improving the accuracy of determining user emotions and improving the user's experience of interacting with smart devices.
[0005] The present application provides an emotion recognition method, the method comprising:
[0006] Determine the text corresponding to the received voice information, and determine whether the text contains a first target emotional word and a target negative word that match the words in the pre-stored emotional word set and negative word set;
[0007] If the first target emotion word and the target negative word exist, for each first target emotion word, determine the second target emotion word according to whether the first target emotion word and the target negative word can be spliced into a target reverse emotion word;
[0008] The target emotion is determined according to the pre-saved scores of the second target emotion words and the preset weights.
[0009] Further, the determining of the second target emotion word according to whether the first target emotion word and the target negative word can be spliced into a target reverse emotion word includes:
[0010] If the first target emotion word and the target negative word can be spliced into a target reverse emotion word, the target reverse emotion word obtained by splicing the first target emotion word and the target negative word is determined as the second target emotion word; otherwise, the first target emotion word is determined as the second target emotion word.
[0011] Further, determining that the first target emotion word and the target negative word can be spliced into a target reverse emotion word includes:
[0012] According to the first position of the first target emotion word in the text and the second position of each target negative word in the text, determining whether there is a target negative word in each target negative word that has an association relationship with the first target emotion word;
[0013] If so, determine whether the number of target negative words associated with the first target emotion word is an odd number. If the number is an odd number, determine that the first target emotion word and the target negative word associated with the first target emotion word can be spliced into a target reverse emotion word.
[0014] Furthermore, the first target emotion words include:
[0015] First target negative words and first target positive words.
[0016] Further, determining the position of a word in the text includes:
[0017] If the number of characters contained in the word is greater than a preset number, the position of the first character in the word in the text is determined as the position of the word in the text.
[0018] Further, the determining, based on the first position of the first target emotion word in the text and the second position of each target negative word in the text, whether there is a target negative word in each target negative word that has an association relationship with the first target emotion word includes:
[0019] Determining the distance between the first target emotion word and each target negative word according to the first position of the first target emotion word in the text and the second position of each target negative word in the text;
[0020] The target negative words whose distance in each target negative word is less than a preset distance threshold are determined as target negative words that have an association relationship with the first target emotional word.
[0021] Further, after determining that the first target emotion word and the target negative word associated with the first target emotion word can be spliced into a target reverse emotion word, the method further includes:
[0022] Input the target reverse emotion words into a pre-trained intention recognition model, and output the emotion probability value corresponding to the target reverse emotion words;
[0023] The sum of weights is determined according to the preset numerical value and the preset first weight, the emotion probability value and the preset second weight. If the sum of weights is greater than a preset threshold, it is determined that the target reverse emotion word remains unchanged.
[0024] The present application provides an emotion recognition device, which includes:
[0025] A matching module, used to determine the text corresponding to the received voice information, and determine whether there is a first target emotional word and a target negative word in the text that match the words in the pre-stored emotional word set and negative word set;
[0026] A determination module is used to determine, if the first target emotion words and the target negative words exist, for each first target emotion word, a second target emotion word according to whether the first target emotion word and the target negative word can be spliced into a target reverse emotion word; and determine the target emotion according to the pre-saved score of the second target emotion word and a preset weight.
[0027] Furthermore, the determination module is specifically used to determine the target reverse emotion word obtained by splicing the first target emotion word and the target negative word as the second target emotion word if the first target emotion word and the target negative word can be spliced into a target reverse emotion word; otherwise, the first target emotion word is determined as the second target emotion word.
[0028] Furthermore, the determination module is specifically used to determine whether there is a target negative word in each target negative word that has an association relationship with the first target emotion word based on the first position of the first target emotion word in the text and the second position of each target negative word in the text; if so, determine whether the number of target negative words that have an association relationship with the first target emotion word is an odd number; if the number is an odd number, determine that the first target emotion word and the target negative word that has an association relationship with the first target emotion word can be spliced into a target reverse emotion word.
[0029] Furthermore, the determination module is also used to determine the position of the first character in the word in the text as the position of the word in the text if the number of characters included in the word is greater than a preset number.
[0030] Furthermore, the determination module is specifically used to determine the distance between the first target emotion word and each target negative word based on the first position of the first target emotion word in the text and the second position of each target negative word in the text; and determine the target negative word in each target negative word whose distance is less than a preset distance threshold as a target negative word that has an association relationship with the first target emotion word.
[0031] Furthermore, the determination module is also used to input the target reverse emotion word into a pre-trained intention recognition model, and output the emotion probability value corresponding to the target reverse emotion word; determine the weight sum according to a preset numerical value and a preset first weight, the emotion probability value and a preset second weight, and if the weight sum is greater than a preset threshold, determine that the target reverse emotion word remains unchanged.
[0032] The present application provides an electronic device, which includes a processor, and the processor is used to implement the steps of any of the above-mentioned emotion recognition methods when executing a computer program stored in a memory.
[0033] The present application provides a computer-readable storage medium storing a computer program executable by a terminal. When the program is run on the terminal, the terminal executes any one of the steps of the above-mentioned emotion recognition method.
[0034] In the present application, the text corresponding to the received voice information is determined, and it is determined whether there are first target emotion words and target negative words in the text that match the words in the pre-saved emotion word set and negative word set. If the first target emotion words and the target negative words exist, then for each first target emotion word, the second target emotion word is determined based on whether the first target emotion word and the target negative word can be spliced into a target reverse emotion word, and the target emotion is determined based on the pre-saved score of the second target emotion word and the preset weight. Because in the present application, it is possible to determine whether the first target emotion word and the target negative word contained in the text corresponding to the voice information can be spliced into a target reverse emotion word, and then determine the second target emotion word, and determine the target emotion based on the score of the pre-saved second target emotion word and the preset weight, rather than directly determining the target emotion based on the first target emotion word, which effectively improves the accuracy of user emotion determination and enhances the user's experience of interaction with the smart terminal. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] In order to more clearly illustrate the technical solutions in the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0036] Figure 1 A schematic diagram of a process of an emotion recognition method provided in some embodiments of the present application;
[0037] Figure 2 A schematic diagram of a process for determining whether a first target positive word and a first target negative word in a text can be spliced with a negative word provided in some embodiments of the present application;
[0038] Figure 3 A schematic diagram of a process for determining a target emotion provided in some embodiments of the present application;
[0039] Figure 4 A schematic diagram of a process for determining a target emotion based on a second target positive word and a second target negative word provided in some embodiments of the present application;
[0040] Figure 5 A schematic diagram of a process for determining a first target positive word, a first target negative word, and a target negative word provided in some embodiments of the present application;
[0041] Figure 6 A schematic diagram of the structure of an emotion recognition device provided in some embodiments of the present application;
[0042] Figure 7 A schematic diagram of the structure of an electronic device provided for some embodiments of the present application. DETAILED DESCRIPTION
[0043] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application will be further described in detail below in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present application.
[0044] In the present application, the text corresponding to the received voice information is determined, and it is determined whether there are first target emotion words and target negative words in the text that match the words in the pre-saved emotion word set and negative word set. If the first target emotion words and the target negative words exist, then for each first target emotion word, the second target emotion word is determined based on whether the first target emotion word and the target negative word can be spliced into a target reverse emotion word, and the target emotion is determined based on the pre-saved score of the second target emotion word and the preset weight.
[0045] Embodiment 1:
[0046] In order to improve the accuracy of determining user emotions and enhance the user's experience of interacting with smart devices, the present application provides an emotion recognition method, apparatus, device and medium.
[0047] Figure 1 A schematic diagram of a process of an emotion recognition method provided in some embodiments of the present application, the process includes the following steps:
[0048] S101: Determine a text corresponding to the received voice information, and determine whether the text contains a first target emotional word and a target negative word that match a word in a pre-stored emotional word set and a pre-stored negative word set.
[0049] The emotion recognition method provided in the present application is applied to a smart device, which may be a smart terminal, a smart home appliance, a PC, a server or other device.
[0050] In the present application, in order to realize the recognition of user emotions based on voice interaction, the smart device determines the text corresponding to the received voice information after receiving the voice information, wherein the text carries words representing the user emotions. The words representing the user emotions carried in the text may be one or more, and the words representing the user emotions that can be carried in the text may be words corresponding to happy emotions, words corresponding to angry emotions, words corresponding to sad emotions, and so on.
[0051] Specifically, after receiving the voice information, the smart device first obtains the initial text corresponding to the voice information, and then preprocesses the initial text to generate the text corresponding to the voice information. Specifically, the process of preprocessing the initial text includes removing special symbols in the initial text information, converting the letters in the initial text into lowercase, and converting traditional Chinese characters in the initial text into simplified Chinese characters, etc. Specifically, the process of preprocessing the initial text is a prior art and will not be elaborated here.
[0052] In order to determine the user's target emotion based on the text, in this application, the smart device pre-stores an emotional word set and a negative word set, wherein the pre-stored emotional word set can be one or more, and each emotional word set contains Chinese character information corresponding to a lot of words that can represent the user's emotions, for example, the happy emotional word set can contain happy, joyful, etc., the sad emotional word set can contain sad, painful, excruciating, unhappy, etc., and the negative word set contains Chinese character information corresponding to a lot of words that can represent negative meanings, such as no, no, not, etc. In addition, in addition to the Chinese character information corresponding to each emotional word, the pre-stored emotional word set can also include the full spelling information, English information, initials abbreviation information, etc. corresponding to each emotional word.
[0053] After determining the text corresponding to the voice information, in order to determine the user's target emotion based on the text, it is possible to first determine the words in the text that represent the user's emotion, that is, determine the emotional words and negative words contained in the text. Specifically, the words contained in the text are matched with the words in the pre-saved emotional word set and the negative word set, respectively, to determine whether there are first target emotional words and target negative words in the text that match the words in the pre-saved emotional word set and the negative word set.
[0054] In addition, if the Chinese character information, full spelling information, English information, and initials abbreviation information corresponding to each emotion word and each negative word are respectively saved in the emotion word set and the negative word set, it will take up a lot of memory. Therefore, in the present application, the emotion word set and the negative word set may respectively contain only the Chinese character information corresponding to each emotion word and the Chinese character information corresponding to each negative word. However, before matching the words contained in the text with the words in the pre-saved emotion word set and the negative word set, first determine the full spelling information, English information, and initials abbreviation information corresponding to each emotion word and each negative word based on the Chinese character information corresponding to each emotion word and the Chinese character information corresponding to each negative word in the pre-saved emotion word set and the negative word set, and then match the Chinese character information, full spelling information, English information, and initials abbreviation information corresponding to each emotion word and each negative word with the words contained in the text.
[0055] S102: If the first target emotion words and the target negative words exist, for each first target emotion word, determine a second target emotion word according to whether the first target emotion word and the target negative word can be spliced into a target reverse emotion word.
[0056] In the present application, when a negative word and an emotional word appear in a text at the same time, the negative word and the emotional word may be related, that is, the meaning of the negative word appearing in the text may be to negate the emotional word, and the expression is the opposite emotion of the emotion corresponding to the emotional word. Then, the negative word and the emotional word can be spliced into a reverse emotional word, and the reverse emotional word obtained by the splicing is the target reverse emotional word. For example, the text of "I am not very happy today" contains the emotional word "happy" and the negative word "not". At this time, the negative word and the emotional word are related, and the emotion expressed is the opposite emotion corresponding to the happy emotion, that is, the unhappy emotion. When a negative word and an emotional word appear in a text at the same time, the negative word and the emotional word may not be related, and the emotion expressed is the emotion corresponding to the emotional word. For example, the text of "It's not me, I'm too happy" contains the emotional word "happy" and the negative word "not". At this time, the negative word and the emotional word are not related, so the emotion expressed is the happy emotion.
[0057] In order to improve the accuracy of determining the target emotion, if it is determined that there are first target emotion words and target negative words, then for each first target emotion word, determine whether there is a target negative word that has an association with the first target emotion word in each target negative word in the text, that is, determine whether the first target emotion word and the target negative word can be spliced into a target reverse emotion word, and determine the second target emotion word based on whether the first target emotion word and the target negative word can be spliced into a target reverse emotion word.
[0058] S103: Determine a target emotion according to the pre-saved scores of the second target emotion words and preset weights.
[0059] In order to determine the user's target emotion, the smart device pre-saves the scores corresponding to each emotion word, wherein the scores corresponding to different emotion words belonging to the same emotion word set may be the same or different, and the scores corresponding to emotion words that do not belong to the same emotion word set are different.
[0060] After determining the second target emotion words included in the text, in order to determine the user's target emotion, in the present application, the target emotion can be determined according to the pre-saved scores of the second target emotion words and preset weights.
[0061] Specifically, a score range corresponding to each type of emotion is preset. After determining the score of the pre-saved second target emotion words, the weight sum is determined based on all the second target emotion words contained in the text and the preset weights corresponding to each second target emotion word, and then it is determined which type of emotion the weight sum is within the score range, and the type of emotion in which the weight sum is located is determined as the target emotion.
[0062] In the present application, it is possible to determine whether the first target emotion words and the target negative words contained in the text corresponding to the voice information can be spliced into the target reverse emotion words, and then determine the second target emotion words, and determine the target emotion based on the score of the pre-saved second target emotion words and the preset weight, rather than directly determining the target emotion based on the first target emotion words, thereby effectively improving the accuracy of user emotion determination and enhancing the user experience of interaction with the smart terminal.
[0063] Embodiment 2:
[0064] In order to determine the second target emotion word in the text, based on the above embodiment, in the present application, the second target emotion word is determined according to whether the first target emotion word and the target negative word can be spliced into a target reverse emotion word, including:
[0065] If the first target emotion word and the target negative word can be spliced into a target reverse emotion word, the target reverse emotion word obtained by splicing the first target emotion word and the target negative word is determined as the second target emotion word; otherwise, the first target emotion word is determined as the second target emotion word.
[0066] In the present application, in order to determine the second target emotion word in the text, if the first target emotion word and the target negative word in the text can be spliced into a target reverse emotion word, the target reverse emotion word obtained by splicing the first target emotion word and the target negative word is determined as the second target emotion word.
[0067] If the first target emotion word and the target negative word in the text cannot be spliced into a target reverse emotion word, the first target emotion word is determined as the second target emotion word.
[0068] Embodiment 3:
[0069] In order to determine whether the first target emotion word and the target negative word can be spliced into a target reverse emotion word, based on the above embodiments, in the present application, determining that the first target emotion word and the target negative word can be spliced into a target reverse emotion word includes:
[0070] According to the first position of the first target emotion word in the text and the second position of each target negative word in the text, determining whether there is a target negative word in each target negative word that has an association relationship with the first target emotion word;
[0071] If so, determine whether the number of target negative words associated with the first target emotion word is an odd number. If the number is an odd number, determine that the first target emotion word and the target negative word associated with the first target emotion word can be spliced into a target reverse emotion word.
[0072] In the present application, in order to improve the accuracy of determining the target emotion, if it is determined that there is a first target emotion word, then for each first target emotion word, it is determined whether there is a target negative word that has an association relationship with the first target emotion word in each target negative word in the text. Specifically, for each first target emotion word, based on the first position of the first target emotion word in the text and the second position of each target negative word in the text, determine the target negative word in each target negative word that has an association relationship with the first target emotion word. Among them, there may be no target negative words that have an association relationship with the first target emotion word, there may be one target negative word, or there may be multiple target negative words.
[0073] If there is no target negation word associated with the first target emotion word, it means that there is no word in the text that negates the first target emotion word. At this time, the emotion expressed is the emotion corresponding to the first target emotion word. If there is a target negation word associated with the first target emotion word, then the target negation word associated with the first target emotion word appears in the text, which may mean negating the first target emotion word or affirming the first target emotion word. In other words, the emotion expressed at this time may be the emotion corresponding to the first target emotion word, or the opposite emotion of the emotion corresponding to the first target emotion word.
[0074] For example, if the text is "I am not unhappy", and the target negative words that are associated with the first target emotion word are determined to be "no" and "no", and the first target emotion word is "happy", then the target negative words "no" and "no" that are associated with the first target emotion word appear in the text to affirm the first target emotion word "happy", and the emotion expressed at this time is the emotion corresponding to the first target emotion word, that is, the emotion corresponding to "happy". If the text is "I am not happy", and the target negative word that is associated with the first target emotion word is determined to be "no", and the first target emotion word is "happy", then the target negative word "no" that is associated with the first target emotion word appears in the text to negate the first target emotion word "happy", and the opposite emotion of the emotion corresponding to the first target emotion word is expressed at this time, that is, the opposite emotion of the "happy" emotion.
[0075] Since when there are an odd number of target negative words that are associated with the first target emotion word and are associated with the first target emotion word, the meaning of the odd number of target negative words that are associated with the first target emotion word appearing in the text is to negate the emotion word, then the odd number of target negative words that are associated with the first target emotion word and the first target emotion word can be spliced into a target reverse emotion word.
[0076] When there are an even number of target negative words that are associated with the first target emotion word and are associated with the first target emotion word, the meaning of the even number of target negative words that are associated with the first target emotion word appearing in the text is to affirm the first target emotion word, then the even number of target negative words that are associated with the first target emotion word and the first target emotion word cannot be spliced into a target reverse emotion word.
[0077] Therefore, in the present application, in order to determine whether the first target emotion word and the target negative word that is associated with the first target emotion word can be spliced into a target reverse emotion word, the number of target negative words that are associated with the first target emotion word is first determined, and then it is determined whether the number is an odd number. If so, it is determined that the first target emotion word and the target negative word that is associated with the first target emotion word can be spliced into a target reverse emotion word.
[0078] Specifically, in the process of splicing target reverse emotion words, if there is a target negative word that is associated with the first target emotion word, the target negative word that is associated with the first target emotion word can be directly spliced in front of the first character of the first target emotion word to obtain the target reverse emotion word. For example, if the second target emotion word is "happy" and the target negative word that is associated with the first target emotion word is "no", then "no" is spliced in front of "open", and the target reverse emotion word obtained by splicing is "unhappy". If there are multiple target negative words that are associated with the first target emotion word, then each target negative word that is associated with the first target emotion word can be spliced in turn according to the positional relationship of each target negative word that is associated with the first target emotion word from front to back in the text, and then each target negative word that is associated with the first target emotion word that has been spliced can be spliced in front of the first target emotion word. For example, if the text is "I am not very unhappy", then the first target emotion word is "happy", and the target negative words that are associated with the first target emotion word are "no" and "not". According to the positional relationship of each target negative word that is associated with the first target emotion word from front to back in the text, each target negative word that is associated with the first target emotion word can be spliced in turn to obtain "no not", and "no not" is spliced in front of "open", and the target reverse emotion word obtained by splicing is "no unhappiness".
[0079] Embodiment 4:
[0080] In order to determine the first target emotion words, based on the above embodiments, in this application, the first target emotion words include:
[0081] First target negative words and first target positive words.
[0082] In the present application, the first target emotional words include happy emotional words, negative emotional words, sad emotional words, etc. Since no matter whether it is happy emotion, negative emotion, sad emotion, etc., each type of emotion can generally be classified into positive emotion and negative emotion, therefore, in the present application, the first target emotional words can also be the first target negative words and the first target positive words.
[0083] Embodiment 5:
[0084] In order to determine the position of each word in the text, based on the above embodiments, in this application, determining the position of the word in the text includes:
[0085] If the number of characters contained in the word is greater than a preset number, the position of the first character in the word in the text is determined as the position of the word in the text.
[0086] The number of characters contained in each word may be one or more, wherein the word includes a first target emotion word and a target negative word. If the word contains a single character, the position of the character in the text can be directly determined as the position of the word in the text; if the word contains multiple characters, since the position of each of the multiple characters in the text is different, in order to facilitate the subsequent determination of whether there is a target negative word associated with the first target emotion word in each target negative word based on the position information of the word, the positions of the words with multiple characters in the text can be unified. Specifically, the position of the last character in the word in the text can be determined as the position of the word in the text, and the position of the word in the middle position in the word in the text can also be determined as the position of the word in the text, and so on.
[0087] In the present application, for each word, the position of the first character in the word in the text is determined as the position of the word in the text, that is, if the number of characters contained in the word is greater than a preset number, the position of the first character in the word in the text is determined as the position of the word in the text. The preset number is 1.
[0088] Embodiment 6:
[0089] In order to determine whether there is a target negative word associated with the first target emotional word in each target negative word, based on the above embodiments, in the present application, according to the first position of the first target emotional word in the text and the second position of each target negative word in the text, determining whether there is a target negative word associated with the first target emotional word in each target negative word includes:
[0090] Determining the distance between the first target emotion word and each target negative word according to the first position of the first target emotion word in the text and the second position of each target negative word in the text;
[0091] The target negative words whose distance in each target negative word is less than a preset distance threshold are determined as target negative words that have an association relationship with the first target emotional word.
[0092] In the present application, in order to determine whether there is a target negative word in each target negative word that is associated with the first target emotional word, the distance between the first target emotional word and each target negative word can be determined based on the first position of the first target emotional word in the text and the second position of each target negative word in the text. Among them, since the second position of each target negative word contained in the text is different in the text, the distance corresponding to each target negative word may also be different. Among them, for each target negative word, the smaller the distance corresponding to the target negative word, the greater the association between the target negative word and the first target emotional word.
[0093] A distance threshold is preset in the smart device of the present application. After determining the distance corresponding to each target negative word, for each target negative word, the distance corresponding to the target negative word is compared with the distance threshold. Based on the comparison result, it is determined whether the target negative word has an association relationship with the first target emotional word. If so, the target negative word is determined as a target negative word that has an association relationship with the first target emotional word.
[0094] Specifically, if the distance is less than a preset distance threshold, it means that the correlation between the first target emotion word and the target negative word is very large, and the target negative word is determined as a target negative word that has an association relationship with the first target emotion word. If the distance is not less than the preset distance threshold, it means that the correlation between the first target emotion word and the target negative word is not very large, and the target negative word is not determined as a target negative word that has an association relationship with the first target emotion word.
[0095] In order to accurately determine the target reverse emotion words in the text, based on the above embodiments, in the present application, after determining that the first target emotion word and the target negative word associated with the first target emotion word can be spliced into the target reverse emotion word, the method further includes:
[0096] Input the target reverse emotion words into a pre-trained intention recognition model, and output the emotion probability value corresponding to the target reverse emotion words;
[0097] The sum of weights is determined according to the preset numerical value and the preset first weight, the emotion probability value and the preset second weight. If the sum of weights is greater than a preset threshold, it is determined that the target reverse emotion word remains unchanged.
[0098] In the present application, if the distance between the first target emotion word and the target negative word is less than a preset distance threshold, it means that the first target emotion word and the target negative word are highly correlated, and the target negative word is directly determined as a target negative word that has an associated relationship with the first target emotion word. Then, after determining that the number of target negative words that have an associated relationship with the first target emotion word is an odd number, the first target emotion word and the target negative word that has an associated relationship with the first target emotion word are spliced into a target reverse emotion word.
[0099] In order to improve the accuracy of determining the target reverse emotion words, in the present application, after the first target emotion word and the target negative word that has an associated relationship with the first target emotion word are spliced into the target reverse emotion word, it is further determined whether the spliced target reverse emotion word is accurate, that is, it is further determined whether the word spliced by the first target emotion word and the target negative word that has an associated relationship with the first target emotion word represents a word with the opposite meaning of the first target emotion word.
[0100] In the present application, in order to improve the accuracy of the determined target reverse emotional words, the intention recognition model is pre-trained, the target reverse emotional words are input into the pre-trained intention recognition model, and the emotional probability value corresponding to the target reverse emotional words is output, wherein the greater the emotional probability value, the greater the possibility that the spliced target reverse emotional words are words representing the opposite meaning of the first target emotional words. Then, according to the preset numerical value and the preset first weight, the emotional probability value and the preset second weight, the weight sum is determined, wherein the preset numerical value is 1. The weight sum is compared with the preset threshold value, and according to the comparison result, whether the spliced target reverse emotional words are words representing the opposite meaning of the first target emotional words is further judged. If the weight sum is greater than the preset threshold value, the target reverse emotional words are determined to be words representing the opposite meaning of the first target emotional words, and the target reverse emotional words are kept unchanged. If the weight sum is not greater than the preset threshold value, it is determined that the target reverse emotional words do not represent words with the opposite meaning of the first target emotional words, and the first target emotional words are not spliced with the target negative words associated with the first target emotional words as target reverse emotional words.
[0101] Figure 2 A schematic diagram of a process for determining whether a first target positive word and a first target negative word in a text can be spliced with a negative word is provided in some embodiments of the present application. Figure 2 Provide explanation.
[0102] Taking the example that the first target emotional words include first target negative words and first target positive words, after determining the text corresponding to the received voice information, the first target positive words, the target negative words and the first target negative words are extracted respectively, that is, it is determined whether there are first target positive words, first target negative words and target negative words in the text that match the words in the pre-saved positive word set, negative word set and negative word set.
[0103] If it is determined that there is a first target positive word and there is a target negative word, then for each target positive word, determine the first position of the first target positive word in the text and the second position of each target negative word in the text, and determine the distance corresponding to each target negative word based on the first position and the second position. For the convenience of description, the distance corresponding to the first position of the first target positive word in the text and the second position of each target negative word in the text is called the first distance. For each target negative word, determine whether the first distance corresponding to the target negative word is less than a preset distance threshold. If so, determine that the target negative word is a target negative word that has an association relationship with the first target positive word. If the number of target negative words that have an association relationship with the first target positive word is an odd number, then the first target positive word and the target negative word that has an association relationship with the first target positive word are spliced into a target reverse positive word.
[0104] If it is determined that there is a first target negative word and a target negative word, then for each target negative word, determine the first position of the first target negative word in the text and the second position of each target negative word in the text, and determine the distance corresponding to each target negative word based on the first position and the second position. For the convenience of description, the distance corresponding to the first position of the first target negative word in the text and the second position of each target negative word in the text is called the second distance. For each target negative word, determine whether the second distance is less than a preset distance threshold. If so, determine that the target negative word is a target negative word that has an association relationship with the first target positive word. If the number of target negative words that have an association relationship with the first target positive word is an odd number, then the first target negative word and the target negative word are spliced into a target reverse negative word.
[0105] If there is no target negative word associated with the first target positive word or the number of target negative words associated with the first target positive word is not an odd number, the target negative word is not spliced with the first target positive word to form a target reverse positive word. If there is no target negative word associated with the first target negative word or the number of target negative words associated with the first target positive word is not an odd number, the target negative word is not spliced with the first target negative word to form a target reverse negative word.
[0106] Figure 3 A schematic diagram of a process for determining a target emotion provided in some embodiments of the present application, Figure 4 A schematic diagram of a process for determining a target emotion according to a second target emotion word provided in some embodiments of the present application is now directed to Figure 3 and Figure 4 Provide explanation.
[0107] Taking the example that the first target emotional words include the first target negative words and the first target positive words, the initial text corresponding to the received voice information is first determined, the initial text is preprocessed to generate the text corresponding to the voice information, and the emotional information is extracted from the text, that is, it is determined whether there are first target positive words, first target negative words and target negative words in the text that match the words in the pre-saved positive word set, negative word set and negative word set, and then the emotional information is converted, that is, the target reverse positive words that can be spliced with the first target positive words and the target negative words that have an association with the first target positive information are updated to the second target negative words, the target reverse negative words that can be spliced with the first target negative words that have an association with the first target negative information are updated to the second target positive words, the first target positive words that cannot be spliced are updated to the second target positive words, the first target negative words that cannot be spliced are updated to the second target negative words, and the emotional value is determined based on the second target positive words and the second target negative words.
[0108] For ease of description, the preset weight corresponding to the second target positive word is called the preset first weight, and the preset weight corresponding to the second target negative word is called the preset second weight. Specifically, all the corresponding second target positive words and all the second target negative words in the text are determined, and the first weight sum is determined according to the pre-saved scores of the second target positive words and the preset first weight, the pre-saved scores of the second target negative words and the preset second weight, and the first weight sum is determined. The first weight sum is determined as the emotion value corresponding to the text, and it is determined whether the emotion value is greater than the preset emotion threshold. That is, according to the comparison of the first weight sum with the preset first threshold and the preset second threshold, it is determined whether the target emotion is positive, negative or neutral, wherein the first threshold is less than the second threshold, the range formed by the first threshold and the second threshold is the score range corresponding to the neutral emotion, the range less than the first threshold is the score range corresponding to the negative emotion, and the range greater than the first threshold is the score range corresponding to the positive emotion.
[0109] Figure 5 A schematic diagram of a process for determining a first target positive word, a first target negative word, and a target negative word provided in some embodiments of the present application is now directed to Figure 5 Provide explanation.
[0110] Taking the first target emotional words including the first target negative words and the first target positive words as an example, first obtain the pre-saved positive word set, negative word set and negative word set, and determine the full spelling information, English information, and initials information corresponding to each positive word, each negative word and each negative word in the pre-saved positive word set, negative word set and negative word set, and match the Chinese character information, full spelling information, and initials information corresponding to each positive word, each negative word and each negative word with the words contained in the text to obtain the first target positive word, the first target negative word and the target negative word.
[0111] Embodiment 6:
[0112] Figure 6 A schematic diagram of the structure of an emotion recognition device provided in some embodiments of the present application, the device comprising:
[0113] A matching module 601 is used to determine the text corresponding to the received voice information, and determine whether there is a first target emotional word and a target negative word in the text that match the words in the pre-stored emotional word set and negative word set;
[0114] Determination module 602 is used to determine the second target emotion word for each first target emotion word if the first target emotion word and the target negative word exist, based on whether the first target emotion word and the target negative word can be spliced into a target reverse emotion word; and determine the target emotion based on the pre-saved score of the second target emotion word and the preset weight.
[0115] In a possible implementation, the determination module 602 is specifically used to determine the target reverse emotion word obtained by splicing the first target emotion word and the target negative word as the second target emotion word if the first target emotion word and the target negative word can be spliced into a target reverse emotion word; otherwise, the first target emotion word is determined as the second target emotion word.
[0116] In a possible implementation, the determination module 602 is specifically used to determine whether there is a target negative word in each target negative word that has an association relationship with the first target emotion word based on the first position of the first target emotion word in the text and the second position of each target negative word in the text; if so, determine whether the number of target negative words that have an association relationship with the first target emotion word is an odd number; if the number is an odd number, determine that the first target emotion word and the target negative word that has an association relationship with the first target emotion word can be spliced into a target reverse emotion word.
[0117] In a possible implementation, the determination module 602 is further configured to determine the position of the first character in the word in the text as the position of the word in the text if the number of characters included in the word is greater than a preset number.
[0118] In a possible implementation, the determination module 602 is specifically used to determine the distance between the first target emotion word and each target negative word based on the first position of the first target emotion word in the text and the second position of each target negative word in the text; and determine the target negative word in each target negative word whose distance is less than a preset distance threshold as a target negative word that has an association relationship with the first target emotion word.
[0119] In a possible implementation, the determination module 602 is also used to input the target reverse emotion word into a pre-trained intention recognition model, and output the emotion probability value corresponding to the target reverse emotion word; determine the weight sum according to a preset numerical value and a preset first weight, the emotion probability value and a preset second weight, and if the weight sum is greater than a preset threshold, determine that the target reverse emotion word remains unchanged.
[0120] Embodiment 7:
[0121] Based on the above embodiments, some embodiments of the present application further provide an electronic device, such as Figure 7 As shown, it includes: a processor 701 , a communication interface 702 , a memory 703 and a communication bus 704 , wherein the processor 701 , the communication interface 702 , and the memory 703 communicate with each other via the communication bus 704 .
[0122] The memory 703 stores a computer program. When the program is executed by the processor 701, the processor 701 performs the following steps:
[0123] Determine the text corresponding to the received voice information, and determine whether the text contains a first target emotional word and a target negative word that match the words in the pre-stored emotional word set and negative word set;
[0124] If the first target emotion word and the target negative word exist, for each first target emotion word, determine the second target emotion word according to whether the first target emotion word and the target negative word can be spliced into a target reverse emotion word;
[0125] The target emotion is determined according to the pre-saved scores of the second target emotion words and the preset weights.
[0126] Furthermore, the processor 701 is also used to determine the target reverse emotion word obtained by splicing the first target emotion word and the target negative word as the second target emotion word if the first target emotion word and the target negative word can be spliced into a target reverse emotion word; otherwise, determine the first target emotion word as the second target emotion word.
[0127] Furthermore, the processor 701 is also used to determine whether there is a target negative word in each target negative word that has an association relationship with the first target emotion word based on the first position of the first target emotion word in the text and the second position of each target negative word in the text; if so, determine whether the number of target negative words that have an association relationship with the first target emotion word is an odd number; if the number is an odd number, determine that the first target emotion word and the target negative word that has an association relationship with the first target emotion word can be spliced into a target reverse emotion word.
[0128] Furthermore, the processor 701 is further configured to determine the position of the first character in the word in the text as the position of the word in the text if the number of characters included in the word is greater than a preset number.
[0129] Furthermore, the processor 701 is also used to determine the distance between the first target emotion word and each target negative word based on the first position of the first target emotion word in the text and the second position of each target negative word in the text; and determine the target negative word in each target negative word whose distance is less than a preset distance threshold as a target negative word that has an association relationship with the first target emotion word.
[0130] Furthermore, the processor 701 is further configured to input the target reverse emotion word into a pre-trained intention recognition model, and output an emotion probability value corresponding to the target reverse emotion word;
[0131] The sum of weights is determined according to the preset numerical value and the preset first weight, the emotion probability value and the preset second weight. If the sum of weights is greater than a preset threshold, it is determined that the target reverse emotion word remains unchanged.
[0132] The communication bus mentioned in the above server can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.
[0133] The communication interface 702 is used for communication between the electronic device and other devices.
[0134] The memory may include a random access memory (RAM) or a non-volatile memory (NVM), such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.
[0135] The above-mentioned processor can be a general-purpose processor, including a central processing unit, a network processor (Network Processor, NP), etc.; it can also be a digital signal processing processor (Digital Signal Processing, DSP), an application-specific integrated circuit, a field programmable gate array or other programmable logic device, a discrete gate or transistor logic device, a discrete hardware component, etc.
[0136] Embodiment 8:
[0137] On the basis of the above embodiments, an embodiment of the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program executable by an electronic device, and when the program is run on the electronic device, the electronic device implements the following steps when executing:
[0138] The memory stores a computer program, and when the program is executed by the processor, the processor performs the following steps:
[0139] Determine the text corresponding to the received voice information, and determine whether the text contains a first target emotional word and a target negative word that match the words in the pre-stored emotional word set and negative word set;
[0140] If the first target emotion word and the target negative word exist, for each first target emotion word, determine the second target emotion word according to whether the first target emotion word and the target negative word can be spliced into a target reverse emotion word;
[0141] The target emotion is determined according to the pre-saved scores of the second target emotion words and the preset weights.
[0142] Further, the determining of the second target emotion word according to whether the first target emotion word and the target negative word can be spliced into a target reverse emotion word includes:
[0143] If the first target emotion word and the target negative word can be spliced into a target reverse emotion word, the target reverse emotion word obtained by splicing the first target emotion word and the target negative word is determined as the second target emotion word; otherwise, the first target emotion word is determined as the second target emotion word.
[0144] Further, determining that the first target emotion word and the target negative word can be spliced into a target reverse emotion word includes:
[0145] According to the first position of the first target emotion word in the text and the second position of each target negative word in the text, determining whether there is a target negative word in each target negative word that has an association relationship with the first target emotion word;
[0146] If so, determine whether the number of target negative words associated with the first target emotion word is an odd number. If the number is an odd number, determine that the first target emotion word and the target negative word associated with the first target emotion word can be spliced into a target reverse emotion word.
[0147] Furthermore, the first target emotion words include:
[0148] First target negative words and first target positive words.
[0149] Further, determining the position of a word in the text includes:
[0150] If the number of characters contained in the word is greater than a preset number, the position of the first character in the word in the text is determined as the position of the word in the text.
[0151] Further, the determining, based on the first position of the first target emotion word in the text and the second position of each target negative word in the text, whether there is a target negative word in each target negative word that has an association relationship with the first target emotion word includes:
[0152] Determining the distance between the first target emotion word and each target negative word according to the first position of the first target emotion word in the text and the second position of each target negative word in the text;
[0153] The target negative words whose distance in each target negative word is less than a preset distance threshold are determined as target negative words that have an association relationship with the first target emotional word.
[0154] Further, after determining that the first target emotion word and the target negative word associated with the first target emotion word can be spliced into a target reverse emotion word, the method further includes:
[0155] Input the target reverse emotion words into a pre-trained intention recognition model, and output the emotion probability value corresponding to the target reverse emotion words;
[0156] The sum of weights is determined according to the preset numerical value and the preset first weight, the emotion probability value and the preset second weight. If the sum of weights is greater than a preset threshold, it is determined that the target reverse emotion word remains unchanged.
[0157] In the present application, it is possible to determine whether the first target emotion words and the target negative words contained in the text corresponding to the voice information can be spliced into the target reverse emotion words, and then determine the second target emotion words, and determine the target emotion based on the score of the pre-saved second target emotion words and the preset weight, rather than directly determining the target emotion based on the first target emotion words, thereby effectively improving the accuracy of user emotion determination and enhancing the user experience of interaction with the smart terminal.
[0158] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0159] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0160] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0161] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0162] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.
Claims
1. An emotion recognition method, characterized in that: The method comprises: Determine the text corresponding to the received voice information, and determine whether the text contains a first target emotional word and a target negative word that match the words in the pre-stored emotional word set and negative word set; If the first target emotion word and the target negative word exist, for each first target emotion word, determine the second target emotion word according to whether the first target emotion word and the target negative word can be spliced into a target reverse emotion word; Determining a target emotion according to the pre-saved scores of the second target emotion words and a preset weight; Wherein, determining the second target emotion word according to whether the first target emotion word and the target negative word can be spliced into a target reverse emotion word comprises: According to the first position of the first target emotion word in the text and the second position of each target negative word in the text, determining whether there is a target negative word in each target negative word that has an association relationship with the first target emotion word; If so, determining whether the number of target negative words associated with the first target emotion word is an odd number; if the number is an odd number, determining that the first target emotion word and the target negative words associated with the first target emotion word can be spliced into a target reverse emotion word; If the first target emotion word and the target negative word can be spliced into a target reverse emotion word, the target reverse emotion word obtained by splicing the first target emotion word and the target negative word is determined as the second target emotion word; otherwise, the first target emotion word is determined as the second target emotion word.
2. The method according to claim 1, characterized in that: The first target emotional words include: First target negative words and first target positive words.
3. The method according to claim 1, characterized in that Determining the position of a word in the text includes: If the number of characters contained in the word is greater than a preset number, the position of the first character in the word in the text is determined as the position of the word in the text.
4. The method according to claim 1, characterized in that: The determining, based on the first position of the first target emotion word in the text and the second position of each target negative word in the text, whether there is a target negative word in each target negative word that has an association relationship with the first target emotion word comprises: Determining the distance between the first target emotion word and each target negative word according to the first position of the first target emotion word in the text and the second position of each target negative word in the text; The target negative words whose distance in each target negative word is less than a preset distance threshold are determined as target negative words that have an association relationship with the first target emotional word.
5. The method according to claim 1, characterized in that After determining that the first target emotion word and the target negative word associated with the first target emotion word can be spliced into a target reverse emotion word, the method further includes: Input the target reverse emotion words into a pre-trained intention recognition model, and output the emotion probability value corresponding to the target reverse emotion words; The sum of weights is determined according to the preset numerical value and the preset first weight, the emotion probability value and the preset second weight. If the sum of weights is greater than a preset threshold, it is determined that the target reverse emotion word remains unchanged.
6. An emotion recognition device, characterized in that: The device comprises: A matching module, used to determine the text corresponding to the received voice information, and determine whether there is a first target emotional word and a target negative word in the text that match the words in the pre-stored emotional word set and negative word set; A determination module, for determining, if the first target emotion words and the target negative words exist, for each first target emotion word, a second target emotion word according to whether the first target emotion word and the target negative word can be spliced into a target reverse emotion word; and determining a target emotion according to a pre-saved score of the second target emotion word and a preset weight; Wherein, the determination module is specifically used to determine whether there is a target negative word associated with the first target emotion word in each target negative word according to the first position of the first target emotion word in the text and the second position of each target negative word in the text; if there is, determine whether the number of target negative words associated with the first target emotion word is an odd number; if the number is an odd number, determine that the first target emotion word and the target negative word associated with the first target emotion word can be spliced into a target reverse emotion word; The determination module is specifically used to determine the target reverse emotion word obtained by splicing the first target emotion word and the target negative word as the second target emotion word if the first target emotion word and the target negative word can be spliced into a target reverse emotion word; otherwise, the first target emotion word is determined as the second target emotion word.
7. The device according to claim 6, characterized in that The determination module is further configured to determine the position of the first character in the word in the text as the position of the word in the text if the number of characters included in the word is greater than a preset number.
8. The device according to claim 6, characterized in that The determination module is specifically used to determine the distance between the first target emotion word and each target negative word based on the first position of the first target emotion word in the text and the second position of each target negative word in the text; and determine the target negative word in each target negative word whose distance is less than a preset distance threshold as a target negative word that has an association relationship with the first target emotion word.
9. The device according to claim 6, characterized in that The determination module is also used to input the target reverse emotion word into a pre-trained intention recognition model, and output the emotion probability value corresponding to the target reverse emotion word; determine the weight sum according to the preset numerical value and the preset first weight, the emotion probability value and the preset second weight, and if the weight sum is greater than the preset threshold, determine that the target reverse emotion word remains unchanged.
10. An electronic device, characterized in that: The electronic device comprises a processor, and the processor is used to implement the steps of the emotion recognition method as claimed in any one of claims 1 to 5 when executing a computer program stored in a memory.
11. A computer-readable storage medium, characterized in that: It stores a computer program executable by a terminal, and when the program is run on the terminal, the terminal executes the steps of the emotion recognition method according to any one of claims 1 to 5.
