Automatic composition method and device based on emotional words, equipment and storage medium
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- BEIJING QIHOOD TECHNOLOGY CO LTD
- Filing Date
- 2020-11-23
- Publication Date
- 2026-06-05
Smart Images

Figure CN114530137B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer technology, and in particular to an automatic music composition method, apparatus, device, and storage medium based on emotion words. Background Technology
[0002] In recent years, with the rapid development of artificial intelligence technology, it has been applied to more and more fields, especially the music field. Through automatic composition algorithms, it can realize the creation of different styles of music such as classical music, film and television scores, and pop music.
[0003] However, current traditional automatic music composition algorithms are based on the simple definition of semantics or the matching relationship between pitch and scale, and are implemented through partially supervised frequent pattern data mining. However, data mining in this algorithm requires a lot of computer resources, and most of the music is randomly generated by a trained model, which cannot reflect the user's emotional characteristics in a personalized way.
[0004] The above content is only used to assist in understanding the technical solution of the present invention and does not represent an admission that the above content is...
[0005] Existing technology. Summary of the Invention
[0006] The main objective of this invention is to propose an automatic music composition method, apparatus, device, and storage medium based on emotional words, aiming to solve the technical problem that existing automatic music composition algorithms cannot personalize and reflect the emotional characteristics of users.
[0007] To achieve the above objectives, the present invention provides an automatic music composition method based on emotional words, the method comprising the following steps:
[0008] Extract sentiment words from the statement to be processed and determine the chord weight values corresponding to the sentiment words;
[0009] The corresponding chord group is searched from a preset mapping dictionary based on the chord weight value and the emotion word;
[0010] An initial piece of music is generated based on the chord groups, and the user's evaluation of the initial piece of music is detected.
[0011] The chord weight values are adjusted based on the evaluation results to obtain the target chord weight values;
[0012] Generate a target melody that matches the user's preferences based on the target chord weight values.
[0013] Furthermore, to achieve the above objectives, the present invention also proposes an automatic music composition device based on emotional words, the automatic music composition device based on emotional words comprising:
[0014] The sentiment word module is used to extract sentiment words from the statement to be processed and determine the chord weight value corresponding to the sentiment word;
[0015] The chord group module is used to find the corresponding chord group from a preset mapping dictionary based on the chord weight value and the emotion word;
[0016] The initial music module is used to generate an initial music based on the chord group and detect the user's evaluation result of the initial music;
[0017] The weight adjustment module is used to adjust the chord weight value according to the evaluation result to obtain the target chord weight value;
[0018] The target music module is used to generate target music that matches the user's preferences based on the target chord weight values.
[0019] Furthermore, to achieve the above objectives, the present invention also proposes an automatic music composition device based on emotional words, the automatic music composition device based on emotional words comprising: a memory, a processor, and an automatic music composition program based on emotional words stored in the memory and executable on the processor, the automatic music composition program based on emotional words being configured with steps for implementing the automatic music composition method based on emotional words as described above.
[0020] Furthermore, to achieve the above objectives, the present invention also proposes a storage medium storing an automatic music composition program based on emotion words, wherein when the automatic music composition program based on emotion words is executed by a processor, it implements the steps of the automatic music composition method based on emotion words as described above.
[0021] This invention proposes an automatic music composition method based on emotional words. This method extracts emotional words from the statement to be processed and determines the chord weights corresponding to those emotional words. It then searches for corresponding chord groups from a preset mapping dictionary based on the chord weights and the emotional words. An initial piece of music is generated based on the chord groups, and the user's evaluation of the initial piece is detected. The chord weights are adjusted based on the evaluation results to obtain a target chord weight value. Finally, a target piece of music that matches the user's preferences is generated based on the target chord weight value. In this invention, chord groups are determined and an initial piece of music is generated using emotional words, and a target piece is generated based on the user's evaluation of the initial piece. This allows for the generation of music that reflects the user's emotional inclinations and preferences, thus personalizing the music to reflect the user's emotional characteristics. Attached Figure Description
[0022] Figure 1 This is a schematic diagram of the structure of an automatic music composition device based on emotion words in the hardware operating environment involved in the embodiments of the present invention;
[0023] Figure 2 This is a flowchart illustrating the first embodiment of the automatic music composition method based on emotional words of the present invention;
[0024] Figure 3 This is a flowchart illustrating the second embodiment of the automatic music composition method based on emotional words of the present invention;
[0025] Figure 4 This is a schematic diagram of the Magenta model, representing an embodiment of the automatic music composition method based on emotional words according to the present invention.
[0026] Figure 5 This is a schematic diagram of the Magenta model after embedding emotional information, according to an embodiment of the automatic music composition method based on emotional words of the present invention.
[0027] Figure 6 This is a flowchart illustrating the third embodiment of the automatic music composition method based on emotional words of the present invention;
[0028] Figure 7 This is a musical diagram illustrating an embodiment of the automatic music composition method based on emotional words according to the present invention.
[0029] Figure 8 This is a flowchart illustrating the fourth embodiment of the automatic music composition method based on emotional words of the present invention;
[0030] Figure 9 This is a schematic diagram of the functional modules of the first embodiment of the automatic music composition device based on emotional words of the present invention.
[0031] The realization of the objective, functional features and advantages of the present invention will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation
[0032] It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
[0033] Reference Figure 1 , Figure 1 This is a schematic diagram of the structure of an automatic music composition device based on emotion words in the hardware operating environment involved in the embodiments of the present invention.
[0034] like Figure 1As shown, the automatic music composition device based on emotion-based words may include: a processor 1001, such as a central processing unit (CPU), a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. The communication bus 1002 is used to establish communication between these components. The user interface 1003 may include a display screen and input units such as buttons; optionally, the user interface 1003 may also include a standard wired interface or a wireless interface. The network interface 1004 may optionally include a standard wired interface or a wireless interface (such as a Wi-Fi interface). The memory 1005 may be a high-speed random access memory (RAM) or a stable memory (non-volatile memory), such as a disk drive. Optionally, the memory 1005 may also be a storage device independent of the aforementioned processor 1001.
[0035] Those skilled in the art will understand that Figure 1 The device structure shown does not constitute a limitation on the automatic music composition device based on emotion words, and may include more or fewer components than shown, or combine certain components, or have different component arrangements.
[0036] like Figure 1 As shown, the memory 1005, which serves as a storage medium, may include an operating system, a network communication module, a user interface module, and an automatic music composition program based on emotion words.
[0037] exist Figure 1 In the illustrated automatic music composition device based on emotion words, the network interface 1004 is mainly used to connect to the external network and communicate with other network devices; the user interface 1003 is mainly used to connect to the user equipment and communicate with the user equipment; the device of the present invention calls the automatic music composition program based on emotion words stored in the memory 1005 through the processor 1001 and executes the automatic music composition method based on emotion words provided in the embodiment of the present invention.
[0038] Based on the above hardware structure, an embodiment of the automatic music composition method based on emotional words of the present invention is proposed.
[0039] Reference Figure 2 , Figure 2 This is a flowchart illustrating the first embodiment of the automatic music composition method based on emotional words according to the present invention.
[0040] In a first embodiment, the automatic music composition method based on emotion words includes the following steps:
[0041] Step S10: Extract sentiment words from the statement to be processed and determine the chord weight values corresponding to the sentiment words.
[0042] It should be noted that the execution subject of this embodiment can be an automatic music composition device based on emotion words. The automatic music composition device can be a computer device or other devices that can achieve the same or similar functions. This embodiment does not limit this. In this embodiment, a computer device is used as an example for explanation.
[0043] It should be understood that the statement to be processed can be a statement customized by the user according to their needs, or a statement downloaded by the user from the cloud. The statement to be processed can be presented in voice or text form, and can be a single sentence or multiple sentences; this embodiment does not impose any restrictions on this. The process of obtaining the statement to be processed can involve receiving processing instructions input by the user and obtaining the statement to be processed based on the processing instructions. The processing instructions can include the statement content.
[0044] After obtaining the statement to be processed, natural language processing can be performed on the obtained statement to obtain sentiment words. Then, the sentiment words are processed to convert the symbolic information of natural language into digital information in vector form to obtain the chord weight values corresponding to the sentiment words.
[0045] Furthermore, to improve the accuracy of extracting sentiment words from the statement to be processed and determining the chord weight values corresponding to the sentiment words, step S10 includes:
[0046] The statement to be processed is segmented into sentences, words, and parts of speech to obtain sentiment words; the sentiment words are then vectorized to determine the chord weight values corresponding to the sentiment words.
[0047] Understandably, the obtained statement to be processed can be subjected to natural language processing, that is, processing such as sentence segmentation, word segmentation and part-of-speech tagging to obtain sentiment words. Then, the sentiment words are vectorized, that is, the symbolic information of natural language is converted into digital information in vector form to obtain the chord weight value corresponding to the sentiment word. The chord weight value is the proportion of the sentiment word in the chord.
[0048] In practical implementation, the word2vec model can be used to perform natural language processing on the statement to be processed. This involves sentence segmentation, word segmentation, part-of-speech tagging, and sentiment analysis. For example, if a user enters "Please play a happy song," the server will perform natural language processing, extracting sentiment words from the statement. These sentiment words can be music-related words or words with emotional connotations. Weights are then assigned to these sentiment words, resulting in a weight of 1 for the "happy" chord. Similarly, if the user enters "Please play a happy and cheerful song," the weights for both the "happy" and "cheerful" chords will be 1.
[0049] It should be noted that the categories of the above-mentioned emotional words can be initially defined by the user and can be personalized according to the user's different understanding of the emotions. For example, different emotional information such as happiness, sadness, hesitation, and anger. The same word can belong to multiple emotional categories at the same time, but it cannot belong to opposite emotional categories at the same time. For example, a word can belong to the emotional categories of melancholy and calmness at the same time, but it cannot belong to the emotional categories of happiness and sadness at the same time.
[0050] Step S20: Search for the corresponding chord group from the preset mapping dictionary based on the chord weight value and the emotion word.
[0051] Understandably, this step can specifically be as follows: searching for the chord to be processed in a preset mapping dictionary based on the emotion words, and determining the chord group based on the chord weight value and the chord to be processed.
[0052] It should be understood that a chord refers to a group of sounds with a certain interval relationship, which can be a set of three or more notes. The preset mapping dictionary can be composed of the correspondence between multiple emotional words and chords. By obtaining a large number of historical musical scores, the correspondence between emotional words and chords can be obtained from the historical musical scores, thereby creating the preset mapping dictionary.
[0053] After extracting the emotion words from the sentences to be processed and determining the chord weights corresponding to the emotion words, the corresponding chords to be processed can be found in a preset mapping dictionary. These chords are then processed according to their weights to obtain a chord group, where a chord group can include multiple chords. For example, when the emotion words are "happy" and "sad," and the chord weights for both "happy" and "sad" are 1, the preset mapping dictionary could be {"happy": ["CAFG", "FAGC"...], "sad": ["FGCA", "GCFA"...]...}. The first chord to be processed corresponding to "happy" and the second chord to be processed corresponding to "sad" can be found in the preset mapping dictionary. It can then be determined that the chord weights for both the first and second chords are 1, and the chord group can be determined based on these chords and their weights.
[0054] Step S30: Generate an initial melody based on the chord group and detect the user's evaluation result of the initial melody.
[0055] It should be noted that after determining the chord groups corresponding to the emotional words, a preset algorithm can be used to determine the main melody and accompaniment, thereby generating an initial piece of music. The preset algorithm can be a deep learning algorithm from Google's open-source library, or other algorithms that can achieve the same or similar functions. This embodiment does not limit this.
[0056] It should be understood that after semantic analysis of emotional words and the generation of music using a preset algorithm, users are asked to rate the music in order to understand their level of liking for it.
[0057] In specific implementation, the start and end times of the initial music playback can be detected. The playback duration of the initial music is determined based on these times. If the playback duration exceeds a preset threshold, the user's liking for the generated initial music is considered high; if the playback duration is less than the preset threshold, the user's liking for the generated initial music is considered low. The preset threshold can be a value set according to actual conditions, such as 1 minute or 2 minutes; this embodiment does not impose such restrictions. Alternatively, the user can directly provide feedback on their liking for the played initial music to the terminal via voice or text, such as "I need happier music" or "The song isn't sad enough." A combination of these two methods can also be used to determine the evaluation result; this embodiment does not impose such restrictions.
[0058] Step S40: Adjust the chord weight value according to the evaluation result to obtain the target chord weight value.
[0059] Understandably, after determining the evaluation results, the chord weight values can be adjusted and optimized based on the user's evaluation results. For example, when the user's liking for the music is high, the chord weight value is increased, and when the user's liking for the music is low, the chord weight value is decreased, thereby obtaining the adjusted target chord weight values.
[0060] Step S50: Generate a target melody that matches the user's preferences based on the target chord weight values.
[0061] It should be understood that after determining the target chord weight values, the corresponding target chord group can be determined based on the target chord weight values and emotional words. Then, a target melody that meets the user's preferences can be generated based on the target chord group, thereby generating a melody that has the user's emotional inclination and meets the user's preferences.
[0062] In this embodiment, emotional words are extracted from the statement to be processed, and the chord weight values corresponding to the emotional words are determined. The corresponding chord groups are then searched from a preset mapping dictionary based on the chord weight values and the emotional words. An initial piece of music is generated based on the chord groups, and the user's evaluation of the initial piece is detected. The chord weight values are adjusted based on the evaluation results to obtain a target chord weight value. A target piece of music that matches the user's preferences is generated based on the target chord weight value. In this invention, chord groups are determined and an initial piece of music is generated using emotional words, and a target piece of music is generated based on the user's evaluation of the initial piece of music. This allows for the generation of music that reflects the user's emotional inclinations and preferences, thus personalizing the user's emotional characteristics.
[0063] In one embodiment, such as Figure 3 As shown, based on the first embodiment, a second embodiment of the automatic music composition method based on emotional words of the present invention is proposed. Step S30 includes:
[0064] Step S301: Generate an initial musical piece based on the chord group and the preset algorithm.
[0065] It should be understood that a preset algorithm and chord groups can be used to generate the initial music. This preset algorithm can be a deep learning algorithm from Google's open-source library, or other algorithms that can achieve the same or similar functions; this embodiment does not limit this. To improve the quality of the generated music, the model corresponding to the deep learning algorithm can be the Magenta model. The Magenta model is an automatic composition model for generating composite music based on recurrent neural networks. When training the Magenta model, several words with known emotional information are first determined as training data, and the emotional information of each training data is labeled as its emotional label. Based on the emotional label of the training data, multiple other emotional words with a close cosine distance are found in the word vector space. The average value of the word vectors of these emotional words is calculated to obtain a new emotional vector e. A schematic diagram of the Magenta model structure can be found in [reference needed]. Figure 4 The figure shows a generative model of a multi-layered Long Short-Term Memory (LSTM) network stack.
[0066] Furthermore, the hidden states of the LSTM can be initialized using embedded emotion terms, so that the emotion information is embedded into the model as a whole, resulting in a Magenta model with embedded emotion information. A schematic diagram of its structure can be found in [reference needed]. Figure 5 As shown, after calculating the emotion vector e, it can be obtained through a fully connected layer. This makes its dimension consistent with the dimension of the LSTM hidden state, and... This serves as the initial hidden state for each LSTM layer.
[0067] By embedding emotional information into the model, emotional characteristics can be personalized from both the overall chord and the individual notes within the chord, thus vividly reflecting different emotional features and making the expression of different emotions more powerful.
[0068] In addition, the traditional Magenta model structure uses an attention mechanism (lookback attention). This attention mechanism refers to the region that humans focus on, allowing the current RNN's predicted output to be integrated with previous outputs. Specifically, upon obtaining the current hidden state, the output of each previous time step is calculated using the following formula:
[0069] ;
[0070] ;
[0071] ;
[0072] in, This represents the hidden state from the previous time step. This represents the current cell state within the LSTM unit. , , For learnable vectors and matrices, The context vector for the current state is a weighted sum of the preceding hidden states. The weights at the current moment; after obtaining the context state. After that, you can... Hidden state at the current moment The concatenated hidden state is obtained by concatenating the hidden states. The concatenated hidden state is then mapped through a fully connected layer, so that the hidden state of the current time step is integrated with the hidden state of the context.
[0073] In this embodiment, each layer of the model structure employs a multi-head lookback attention mechanism, and the context vector is calculated using the following formula:
[0074] ;
[0075] ;
[0076] ;
[0077] ;
[0078] ;
[0079] Where d is the number of candidate attention heads. As weight, The context vector of the current state. This represents the weight at the current moment.
[0080] It should be noted that this multi-head backtracking attention mechanism calculates d candidate attention heads based on the previous hidden state and the current cell state, where d can be determined according to the number of model hyperparameters, and the weight of each attention head is calculated using the softmax function. Based on this weight, multiple attention heads are weighted and summed to obtain the true attention value k of the preceding hidden state, thus obtaining the weight a of each preceding hidden state. These weighted values are then summed again to obtain the true context vector. By using a multi-head backtracking attention mechanism, the loss in encoding hidden states in the model is reduced, allowing for the acquisition of more information and thus better modeling of preceding states.
[0081] Furthermore, in order to better generate the initial music and improve the music generation effect, step S301 includes:
[0082] Based on the chord group, a preset algorithm is used to determine the main melody and accompaniment; the drum beat group corresponding to the emotional words is determined, and a rhythm is generated based on the drum beat group; the main melody, the accompaniment, and the rhythm are matched and superimposed to generate a musical segment; the musical segment is spliced together according to preset rules to generate an initial piece of music.
[0083] Understandably, emotional information can be embedded into the model, and chord groups can be processed using algorithms to generate the melody and accompaniment. Drum beats corresponding to emotional words can be extracted from a music library, and a preset algorithm can be used to generate a rhythm based on these drum beats. The melody, accompaniment, and rhythm are then matched and superimposed to generate a musical phrase. In this generated phrase, the melody, accompaniment, and rhythm are matched to each other; the rhythm can be a drum kit track.
[0084] In this embodiment, by embedding emotional information into the model, the emotional characteristics are more comprehensively and personalized from the perspective of the chord as a whole and within the chord. Furthermore, by employing a multi-head backtracking attention mechanism during model training, the loss of hidden state encoding is reduced, thereby better integrating the preceding state into the current hidden state and further obtaining more information.
[0085] Furthermore, a complete song generally consists of a verse and a chorus, and the verse and chorus can be connected by transitional sections. To achieve a better music generation effect, before splicing the musical segments according to preset rules to generate the initial music, the process also includes:
[0086] Based on the aforementioned emotional words, historical transition segments are retrieved from a preset music library, and these historical transition segments are the connecting parts between the verse and the chorus; musical transition segments are then determined based on these historical transition segments.
[0087] Accordingly, the step of splicing the musical segments according to preset rules to generate an initial piece of music includes:
[0088] The song attributes of the musical segment are determined, and the verse and chorus are determined based on the song attributes; the transition section, the verse, and the chorus are spliced together according to preset rules to generate an initial musical piece.
[0089] It should be understood that a complete song consists of a verse and a chorus. The verse generally refers to the relatively flat introductory part at the beginning or middle of the song, while the chorus is the center, that is, the climax and essence of the song. The entire song can include multiple musical sections depending on the song structure. After matching and splicing the main melody, accompaniment, and rhythm to determine the musical sections, the song attributes of the musical sections can be determined based on the musical section structure and music theory knowledge. These song attributes include the verse and chorus. Based on the emotional words, historical transition sections are obtained from the music library, and musical transition sections are determined based on these historical transition sections. For example, one or more historical transition sections can be selected as musical transition sections, which connect the verse and chorus to generate a complete initial song.
[0090] In a specific implementation, when two musical segments are generated, the first is the verse A and the second is the chorus B. Based on the common splicing rules of popular songs, the musical segments are spliced together, which can generate ABABB, BABAA, or other splicing rules. The preset splicing rule can be one of the above splicing rules, and this embodiment does not limit it.
[0091] Step S302: Play the music according to the initial music and record the start time.
[0092] It should be understood that after the initial music is generated, the music can be played automatically and the start time can be recorded, for example, the start time can be 10:10.
[0093] Step S303: Upon receiving a stop playback command input by the user, stop the music playback according to the stop playback command and record the end time.
[0094] Understandably, if a stop playback command is received from the user during music playback, the music playback can be stopped according to the stop playback command, and the end time can be recorded. For example, the end time can be 10:11.
[0095] Step S304: Determine the user's evaluation result of the initial music based on the start time and the end time.
[0096] It should be understood that after determining the start and end times, the playback duration can be calculated based on the start and end times, and the user's evaluation of the initial music can be determined based on the playback duration.
[0097] Furthermore, in order to obtain better evaluation results and make the detected evaluation results more accurate, step S304 includes:
[0098] The playback duration of the initial piece of music is determined based on the start time and the end time; the playback duration is compared with a preset duration threshold, and the user's level of liking for the initial piece of music is determined based on the comparison result; the user's evaluation result of the initial piece of music is determined based on the level of liking.
[0099] It should be understood that the playback duration of the initial piece of music can be calculated based on the start and end times. For example, if the start time is 10:10 and the end time is 10:11, the playback duration is 1 minute, and the preset duration threshold is 2 minutes. Comparing the playback duration with the preset duration threshold determines the user's evaluation of the initial piece of music. A playback duration greater than or equal to the preset duration threshold indicates a high level of user liking for the initial piece of music, while a playback duration less than the preset duration threshold indicates a low level of user liking for the initial piece of music.
[0100] Furthermore, since determining a user's liking for the initial piece of music solely based on playback duration may not be accurate, the evaluation result can also be determined by combining the user's music review comments. Before determining the user's evaluation result for the initial piece of music based on the degree of liking, the process further includes:
[0101] Receive the music evaluation statement input by the user;
[0102] Accordingly, determining the user's evaluation result for the initial piece of music based on the degree of liking includes:
[0103] Natural language processing is performed on the music evaluation statements to determine the evaluation sentiment words; the user's evaluation result of the initial music is determined based on the degree of liking and the evaluation sentiment words.
[0104] It should be understood that the system can also receive music evaluation statements input by the user, and perform natural language processing on the music evaluation statements to determine the evaluation sentiment words, and then further determine the user's degree of liking based on the evaluation sentiment words, thereby determining the user's evaluation result of the initial music.
[0105] In this embodiment, an initial piece of music is generated based on the chord group and a preset algorithm; the music is played according to the initial piece of music, and the start time is recorded; when a stop playback command is received from the user, the music playback is stopped according to the stop playback command, and the end time is recorded; the user's evaluation result of the initial piece of music is determined based on the start time and the end time, and then the initial piece of music is generated based on the chord group and the preset algorithm, and then the initial piece of music is played, and the evaluation result of the initial piece of music is determined based on the start time and end time of the music playback, and a target piece of music that meets the user's preference is generated based on the evaluation result, thereby generating a piece of music that has the user's emotional tendency and meets the user's preference.
[0106] In one embodiment, such as Figure 6 As shown, a third embodiment of the automatic music composition method based on emotional words of the present invention is proposed based on the first embodiment or the second embodiment. In this embodiment, the description is based on the first embodiment. Step S40 includes:
[0107] Step S401: Determine the degree of liking and the emotional words used for evaluation based on the evaluation results.
[0108] It should be understood that the evaluation results may include the degree of liking based on the playback duration, as well as the evaluation sentiment words determined by the user's input of music evaluation statements. Therefore, the degree of liking and evaluation sentiment words can be determined based on the evaluation results.
[0109] Step S402: Determine the weight adjustment value based on the degree of liking and the evaluation sentiment words.
[0110] Understandably, the weight adjustment value can be determined based on the degree of liking and the evaluative emotional words, and used for subsequent chord weight adjustments to obtain the target chord weight value.
[0111] Step S403: Adjust the chord weight value according to the weight adjustment value to obtain the target chord weight value.
[0112] Understandably, the chord weight values can be adjusted based on the weight adjustment value to obtain the target chord weight value, and then the target chord group can be determined based on the chord weight value, and a target piece of music that meets the user's preferences can be generated based on the target chord group.
[0113] Furthermore, in order to accurately generate target music that matches the user's preferences and personalize it to reflect the user's emotional characteristics, step S50 includes:
[0114] The corresponding target chord group is searched from the preset mapping dictionary based on the target chord weight value and the emotional words; a target melody that matches the user's preference is generated based on the target chord group.
[0115] It should be understood that after determining the target chord weight value, the target chord group can be determined based on the target chord weight value and the chords corresponding to the emotional words. Then, the above-mentioned music generation process is performed based on the target chord group to obtain the target music that meets the user's preferences.
[0116] In practical implementation, for example, when the chord weight of the emotional words initially input by the user is the initial chord weight value, assuming the user initially inputs "a sad and melancholic song," after natural language processing, it can be determined that the chord weight of sadness is 1, and the chord weight of melancholy is 1. Using a preset mapping dictionary of emotional words and chords, the corresponding chord groups for sadness and melancholy can be determined. Then, based on the chord groups and a preset algorithm provided by the Google open-source library, an initial piece of music is generated. The music is then played, and the playback duration is monitored. If the playback duration is less than a preset threshold, it indicates that the user may not be interested in the initial music, and the user's level of liking is determined to be low. Accordingly, the weight value of each chord is increased by 0.1. When a user inputs a music evaluation statement such as "Need more sorrowful music," natural language processing determines that the emotional word is "sad." Therefore, it is assumed that the user's acceptance of sadness is higher than average. Consequently, the chord weight value corresponding to sadness is increased by 1. Thus, the weight adjustment value for the chord weight value of sadness is increased by 0.2, and the weight adjustment value for the chord weight value of melancholy is increased by 0.1. Furthermore, the target chord weight value for sadness is determined to be 1.2, and the target chord weight value for melancholy is determined to be 1.1. This identifies the corresponding target chord group, and a target music piece that matches the user's preference is generated based on the target chord group.
[0117] Furthermore, the step of generating a target musical piece that matches the user's preferences based on the target chord group includes:
[0118] Based on the target chord group, a preset algorithm is used to determine the target melody, target accompaniment, and target rhythm; the target melody, target accompaniment, and target rhythm are matched and superimposed to generate a target musical phrase; the target musical phrase is spliced together according to preset rules to generate a target piece of music that meets the user's preferences.
[0119] Understandably, after determining the target chord group, a preset algorithm can be used to generate an adjusted target melody, target accompaniment, and corresponding target rhythm. This adjusted target melody, accompaniment, and rhythm are then matched and superimposed to generate the target musical phrase. Based on the defined musical structure, the target verse and target chorus are determined. Based on the adjusted target chord weights, a preset algorithm generates an adjusted target transition section. Finally, the target verse, target chorus, and target transition section are spliced together according to preset splicing rules to generate a target musical piece that meets the user's preferences. A schematic diagram of the musical piece can be found here. Figure 7 As shown
[0120] Optionally, in this embodiment, a caching mechanism can be set up on the server side. Audio paths are pre-generated for different chords in the chord library, and a hash method is used to map each generated audio path to a chord and store them on the server. When a music generation request is received from the terminal, the corresponding audio file is found directly based on the pre-stored mapping between audio paths and chords through the chord group. A transition section is then used to splice the files together to generate a complete piece of music, which is then returned to the client. Additionally, selected audio files can be marked so that when selecting audio based on chords in the next iteration, the system prioritizes audio files with fewer marks. If all audio files are selected a preset number of times, the server uses a model to regenerate some audio information and add it to the music library, while deleting several audio files with many marks. This ensures both speed in selecting audio based on chords and audio diversity.
[0121] Furthermore, the automatic composition method provided in this application can combine user preference information to generate a chord weight table corresponding to each user's preference information. This chord weight table represents the importance of different chords to the user. For new users, the chord weights are initialized using the commonly used chord weights of other users. When a user invokes the automatic composition function on the client, the server records the start and end times of the music playback. These times determine the playback duration and thus the user's level of liking for the music. A longer playback duration indicates higher liking, and a shorter duration indicates lower liking. If the user's liking is high, the server increases the chord weights used for that music; conversely, it decreases them. When chord weights are unstable, the server can determine the user's emotional information and preferentially select chords with higher weights based on that information, thereby generating a personalized piece of music with a suitable style based on the user's preferences.
[0122] In this embodiment, the degree of liking and the evaluation sentiment words are determined based on the evaluation results; a weight adjustment value is determined based on the degree of liking and the evaluation sentiment words; the chord weight value is adjusted based on the weight adjustment value to obtain the target chord weight value. Thus, the weight adjustment value is determined based on the user's evaluation results, and the target chord weight value is obtained based on the weight adjustment value, which is used to accurately generate the target music and improve the effect of music generation.
[0123] In one embodiment, such as Figure 8 As shown, based on the above embodiments, a fourth embodiment of the automatic music composition method based on emotional words of the present invention is proposed. In this embodiment, the description is based on the first embodiment. After step S50, the method further includes:
[0124] Step S601: Obtain the user information corresponding to the user, and generate identification information based on the user information.
[0125] Understandably, user information can also be obtained by reading the currently logged-in account, and identification information can be generated based on the user information.
[0126] Step S602: Generate a music identifier based on the identifier information, and add the music identifier to the target music.
[0127] Understandably, a music identifier can be generated based on the identification information, and the music identifier can be added to the target music. The music identifier can then be used to determine which user generated the music.
[0128] Step S603: Add the target music with the music tag added to the preset database.
[0129] It should be understood that target songs with added song tags can be added to a preset database. The preset database can be set on the server side and can store songs corresponding to multiple users.
[0130] Step S604: Upon receiving a random playback instruction, determine the current information based on the random playback instruction.
[0131] Understandably, when the system receives a random playback command from the user, it can determine the current information based on the random playback command.
[0132] Step S605: Search for the music to be played in the preset database based on the current information, and play the music according to the music to be played.
[0133] It should be understood that this step may specifically be as follows: determine the current user information based on the current information, and search for the target music identifier corresponding to the current user information; search for the music to be played that corresponds to the target music identifier from the preset database.
[0134] Understandably, the current user information can be determined based on the current information, and the target music identifier corresponding to the current user information can be found. Then, the music to be played corresponding to the target music identifier can be found from the preset database. Thus, when the user wants to play randomly, the previously generated music corresponding to the user can be played to achieve a better playback effect.
[0135] Furthermore, since users may have different moods at different times, in order to achieve a better random playback effect, before generating the identification information based on the user information, the process further includes:
[0136] Obtain the generation time of the target music piece;
[0137] Accordingly, generating identification information based on the user information includes:
[0138] Identification information is generated based on the user information and the generation time.
[0139] It should be understood that the generation time of each target piece of music can also be obtained, and identification information can be generated based on user information and generation time.
[0140] Further, the step of searching for the song to be played from the preset database based on the current information includes:
[0141] Based on the current information, determine the current user information and the current time; traverse the target music in the preset database and use the traversed target music as candidate music; determine the candidate music identifier corresponding to the candidate music, and determine the candidate user information and candidate generation time of the candidate music based on the candidate music identifier; when the candidate user information and the current user information are consistent, determine the candidate time range according to the preset time rules and the candidate generation time; determine whether the current time is within the candidate time range; if the current time is within the candidate time range, then use the candidate music as the music to be played.
[0142] It should be understood that, firstly, all target songs in the preset database can be traversed, and the traversed target songs are taken as candidate songs. Then, based on the candidate song identifier corresponding to the candidate song, the candidate user information and candidate generation time of the candidate song are determined. Then, when the candidate user information and the current user information are consistent, the candidate time range is determined according to the preset time rule and the candidate generation time. The preset time rule can be ±1 hour based on the candidate generation time. For example, when the candidate generation time is 8:00, the candidate time range determined according to the preset time rule is 7:00-8:00. Then, it can be determined whether the current time is within the candidate time range. If the current time is within the candidate time range, the candidate song is taken as the song to be played, thereby filtering out the songs that the user may be interested in for playback.
[0143] In this embodiment, user information corresponding to the user is obtained, and identification information is generated based on the user information; a music identifier is generated based on the identifier information, and the music identifier is added to the target music; the target music with the added music identifier is added to a preset database; when a random playback command is received, the current information is determined based on the random playback command; the music to be played is searched from the preset database based on the current information, and the music to be played is played. In this embodiment, when the user selects random playback, the music to be played that the user may be interested in can be played, which improves the user experience. Since these music to be played are also generated based on emotional words, the automatic music composition method in this application can have a wider range of applications.
[0144] Furthermore, this embodiment of the invention also proposes a storage medium storing an automatic music composition program based on emotion words. When the automatic music composition program based on emotion words is executed by a processor, it implements the steps of the automatic music composition method based on emotion words as described above.
[0145] Since this storage medium adopts all the technical solutions of all the above embodiments, it has at least all the beneficial effects brought about by the technical solutions of the above embodiments, which will not be repeated here.
[0146] In addition, refer to Figure 9 This invention also proposes an automatic music composition device based on emotional words, the automatic music composition device based on emotional words includes:
[0147] The sentiment word module 10 is used to extract sentiment words from the statement to be processed and determine the chord weight value corresponding to the sentiment word.
[0148] Chord group module 20 is used to find the corresponding chord group from a preset mapping dictionary based on the chord weight value and the emotion word.
[0149] The initial music module 30 is used to generate an initial music based on the chord group and detect the user's evaluation result of the initial music.
[0150] The weight adjustment module 40 is used to adjust the chord weight value according to the evaluation result to obtain the target chord weight value.
[0151] The target music module 50 is used to generate a target music that meets the user's preferences based on the target chord weight values.
[0152] In this embodiment, emotional words are extracted from the statement to be processed, and the chord weight values corresponding to the emotional words are determined. The corresponding chord groups are then searched from a preset mapping dictionary based on the chord weight values and the emotional words. An initial piece of music is generated based on the chord groups, and the user's evaluation of the initial piece is detected. The chord weight values are adjusted based on the evaluation results to obtain a target chord weight value. A target piece of music that matches the user's preferences is generated based on the target chord weight value. In this invention, chord groups are determined and an initial piece of music is generated using emotional words, and a target piece of music is generated based on the user's evaluation of the initial piece of music. This allows for the generation of music that reflects the user's emotional inclinations and preferences, thus personalizing the user's emotional characteristics.
[0153] Other embodiments or specific implementation methods of the automatic music composition device based on emotion words described in this invention can refer to the above-described method embodiments, and will not be repeated here.
[0154] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.
[0155] The sequence numbers of the above embodiments of the present invention are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0156] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product. The estimation machine software product is stored in an estimation machine readable storage medium (such as ROM / RAM, magnetic disk, optical disk) as described above, including several instructions to cause a smart device (which may be a mobile phone, estimation machine, automatic music composition device based on emotion words, air conditioner, or network automatic music composition device based on emotion words, etc.) to execute the methods described in the various embodiments of the present invention.
[0157] The above are merely preferred embodiments of the present invention and do not limit the scope of the patent. Any equivalent structural or procedural transformations made based on the description and drawings of the present invention, or direct or indirect applications in other related technical fields, are similarly included within the scope of patent protection of the present invention.
Claims
1. An automatic music composition method based on emotion-related words, characterized in that, The automatic music composition method based on emotion words includes the following steps: Extract sentiment words from the statement to be processed and determine the chord weight values corresponding to the sentiment words; The corresponding chord group is searched from a preset mapping dictionary based on the chord weight value and the emotion word; An initial piece of music is generated based on the chord groups, and the user's evaluation of the initial piece of music is detected. The chord weight values are adjusted based on the evaluation results to obtain the target chord weight values; Generate a target melody that matches the user's preferences based on the target chord weight values.
2. The automatic music composition method based on emotion words as described in claim 1, characterized in that, The step of extracting sentiment words from the statement to be processed and determining the chord weight values corresponding to the sentiment words includes: The process involves segmenting the statements to be processed into sentences, words, and parts of speech tags to obtain sentiment terms. The emotional words are vectorized to determine the chord weight values corresponding to the emotional words.
3. The automatic music composition method based on emotional words as described in claim 1, characterized in that, The process of generating an initial musical piece based on the chord groups and detecting the user's evaluation of the initial musical piece includes: An initial musical piece is generated based on the chord groups and the preset algorithm; Play the music according to the initial piece and record the start time; Upon receiving a stop playback command from the user, the music playback is stopped according to the command, and the end time is recorded. The user's evaluation of the initial piece of music is determined based on the start time and the end time.
4. The automatic music composition method based on emotional words as described in claim 3, characterized in that, The generation of the initial musical piece based on the chord group and the preset algorithm includes: Based on the chord group, a preset algorithm is used to determine the main melody and accompaniment; Identify the drum beat groups corresponding to the emotional words, and generate a rhythm based on the drum beat groups; The main melody, the accompaniment, and the rhythm are matched and superimposed to generate a musical phrase; The musical segments are spliced together according to preset rules to generate an initial piece of music.
5. The automatic music composition method based on emotion words as described in claim 4, characterized in that, Before splicing the musical segments according to preset rules to generate the initial piece of music, the process also includes: Based on the emotional words, historical transition segments are obtained from a preset music library, and the historical transition segments are the connection parts between the verse and the chorus; Determine the musical transition sections based on the aforementioned historical transition sections; Accordingly, the step of splicing the musical segments according to preset rules to generate an initial piece of music includes: Determine the song attributes of the musical segment, and determine the verse and chorus based on the song attributes; The initial music piece is generated by splicing together the transition section, the verse, and the chorus according to preset rules.
6. The automatic music composition method based on emotion words as described in claim 3, characterized in that, Determining the user's evaluation result of the initial piece of music based on the start time and the end time includes: The playback duration of the initial piece of music is determined based on the start time and the end time. The playback duration is compared with a preset duration threshold, and the user's level of liking for the initial music is determined based on the comparison result. The user's evaluation of the initial piece of music is determined based on the degree of liking.
7. The automatic music composition method based on emotion words as described in claim 6, characterized in that, Before determining the user's evaluation result of the initial piece of music based on the degree of liking, the method further includes: Receive the music evaluation statement input by the user; Accordingly, determining the user's evaluation result for the initial piece of music based on the degree of liking includes: Natural language processing is performed on the music evaluation statements to determine the evaluative emotion words; The user's evaluation of the initial piece of music is determined based on the degree of liking and the emotional words used in the evaluation.
8. The automatic music composition method based on emotional words as described in any one of claims 1 to 7, characterized in that, The step of adjusting the chord weight value based on the evaluation result to obtain the target chord weight value includes: The degree of liking and the emotional words used to evaluate it are determined based on the evaluation results. The weight adjustment value is determined based on the degree of liking and the emotional words used in the evaluation. The chord weight values are adjusted according to the weight adjustment values to obtain the target chord weight values.
9. The automatic music composition method based on emotional words as described in any one of claims 1 to 7, characterized in that, The step of generating a target melody that matches the user's preferences based on the target chord weight values includes: The corresponding target chord group is searched from the preset mapping dictionary based on the target chord weight value and the sentiment word; Based on the target chord group, generate a target musical piece that matches the user's preferences.
10. The automatic music composition method based on emotion words as described in claim 9, characterized in that, The process of generating a target melody that matches the user's preferences based on the target chord group includes: Based on the target chord group, a preset algorithm is used to determine the target melody, target accompaniment, and target rhythm; The target melody, the target accompaniment, and the target rhythm are matched and superimposed to generate the target musical phrase; The target musical segments are spliced together according to preset rules to generate a target musical piece that meets the user's preferences.
11. The automatic music composition method based on emotion words as described in any one of claims 1 to 7, characterized in that, After generating the target chord weight value that matches the user's preference, the process further includes: Obtain the user information corresponding to the user, and generate identification information based on the user information; A music identifier is generated based on the identifier information, and the music identifier is added to the target music. Add the target music with the music tag to the preset database; Upon receiving a random playback instruction, the current information is determined based on the random playback instruction; Based on the current information, the system searches for the music to be played in the preset database and then plays the music accordingly.
12. The automatic music composition method based on emotion words as described in claim 11, characterized in that, The step of searching for the song to be played from the preset database based on the current information includes: Based on the current information, determine the current user information and find the target music identifier corresponding to the current user information; Search the preset database for the song to be played that corresponds to the target song identifier.
13. The automatic music composition method based on emotion words as described in claim 11, characterized in that, Before generating the identification information based on the user information, the method further includes: Obtain the generation time of the target music piece; Accordingly, generating identification information based on the user information includes: Identification information is generated based on the user information and the generation time.
14. The automatic music composition method based on emotion words as described in claim 13, characterized in that, The step of searching for the song to be played from the preset database based on the current information includes: Determine the current user information and current time based on the current information; The target music in the preset database is traversed, and the traversed target music is used as candidate music; Determine the candidate music identifier corresponding to the candidate music, and determine the candidate user information and candidate generation time of the candidate music based on the candidate music identifier; The music to be played is determined based on the candidate user information, the candidate generation time, the current user information, and the current time.
15. The automatic music composition method based on emotion words as described in claim 14, characterized in that, The step of determining the music to be played based on the candidate user information, the candidate generation time, the current user information, and the current time includes: When the candidate user information and the current user information are consistent, the candidate time range is determined according to the preset time rules and the candidate generation time. Determine whether the current time is within the range of the candidate time; If the current time is within the selected time range, then the selected music will be used as the music to be played.
16. An automatic music composition device based on emotional words, characterized in that, The automatic music composition device based on emotion words includes: The sentiment word module is used to extract sentiment words from the statement to be processed and determine the chord weight value corresponding to the sentiment word; The chord group module is used to find the corresponding chord group from a preset mapping dictionary based on the chord weight value and the emotion word; The initial music module is used to generate an initial music based on the chord group and detect the user's evaluation result of the initial music; The weight adjustment module is used to adjust the chord weight value according to the evaluation result to obtain the target chord weight value; The target music module is used to generate target music that matches the user's preferences based on the target chord weight values.
17. The automatic music composition device based on emotional words as described in claim 16, characterized in that, The sentiment word module is also used to perform sentence segmentation, word segmentation, and part-of-speech tagging on the statement to be processed to obtain sentiment words; and to perform vectorization processing on the sentiment words to determine the chord weight values corresponding to the sentiment words.
18. The automatic music composition device based on emotion words as described in claim 16, characterized in that, The initial music module is further configured to generate an initial music based on the chord group and a preset algorithm; play the music according to the initial music and record the start time; stop the music playback according to the stop playback command input by the user and record the end time when the user inputs a stop playback command; and determine the user's evaluation result of the initial music based on the start time and the end time.
19. An automatic music composition device based on emotional words, characterized in that, The automatic composition device based on emotion words includes: a memory, a processor, and an automatic composition program based on emotion words stored in the memory and executable on the processor, wherein the automatic composition program based on emotion words is configured to implement the automatic composition method based on emotion words as described in any one of claims 1 to 15.
20. A storage medium, characterized in that, The storage medium stores an automatic music composition program based on emotion words, which, when executed by a processor, implements the steps of the automatic music composition method based on emotion words as described in any one of claims 1 to 15.