Chord generation method, computer equipment, computer readable storage medium and computer program product
By constructing the state transfer matrix under the emotional category and chord attributes, filtering and determining candidate chords, the problem of low reliability in chord generation in the prior art is solved, and more accurate expression of emotional and chord attributes is achieved.
Patent Information
- Application Number
- CN202510356963.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-25
- Publication Date
- 2025-06-24
AI Technical Summary
In the existing music generation technology, the chord generation method based on neural networks is less reliable and is affected by multiple factors such as emotion and chord attributes.
By constructing the state transfer matrix under the emotional category and chord attributes, the target state transfer matrix under the target emotional category is obtained, candidate chords that meet the starting chord attributes are selected, and subsequent chords are determined based on the observed transfer probability.
Improves reliability of chord generation, ensuring that chord sequences better reflect target emotional categories and chord attributes.
Smart Images

Figure CN120199209A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of music generation, and in particular, to a chord generation method, apparatus, computer device, computer-readable storage medium, and computer program product. Background Art
[0002] In related technologies, neural networks are usually used to learn the transition statistical probabilities of each chord in a song, and based on the transition statistical probabilities between the previous chord and each chord, the next chord of the previous chord is predicted. However, in music creation, chords are affected by multiple factors such as emotional factors and chord attribute factors, resulting in low reliability of the chords obtained based on neural networks. Summary of the Invention
[0003] Based on this, in view of the technical problem of low reliability of the obtained chords, it is necessary to provide a chord generation method, computer device, computer-readable storage medium, and computer program product that can improve the reliability of the obtained chords.
[0004] In a first aspect, this application provides a chord generation method, including:
[0005] Obtain a starting chord and a target emotion category; the starting chord is any one of a variety of preset chords, and each of the preset chords has a corresponding attribute value under each preset chord attribute; the target emotion category is any one of a variety of preset emotion categories, and the target emotion category is used to characterize the emotion represented by a chord sequence composed of the starting chord and the subsequent chords of the starting chord;
[0006] In state transition matrices respectively pre-constructed for a variety of emotion categories under each chord attribute, obtain target state transition matrices of the target emotion category under each chord attribute; wherein, the target state transition matrix is used to characterize the state transition probability between the attribute values of each preset chord under the corresponding chord attribute under the target emotion category;
[0007] Based on each of the target state transition matrices and the attribute values of the starting chord, screen out at least one of the preset chords from a variety of preset chords as candidate chords for the starting chord;
[0008] Obtain the observation transition probability of the starting chord transferring to each of the candidate chords, and based on the observation transition probabilities corresponding to each of the candidate chords, determine the subsequent chord of the starting chord among each of the candidate chords.
[0009] In one embodiment, the target state transition matrix includes the state transition probabilities of N rows and M columns. Each row corresponds to any one of a plurality of preset attribute value intervals, and each column corresponds to any one of the plurality of attribute value intervals. The state transition probability at the i-th row and j-th column in the target state transition matrix is used to represent the probability that the first preset chord transitions to the second preset chord under the target emotion category. The first preset chord is a preset chord among the plurality of preset chords, and the attribute value of the chord under the chord attribute falls into the attribute value interval corresponding to the i-th row. The second preset chord is a preset chord among the plurality of preset chords, and the attribute value of the chord under the corresponding chord attribute falls into the attribute value interval corresponding to the j-th column, where N≥i≥1 and M≥j≥1.
[0010] Selecting at least one of the preset chords from the multiple preset chords as a candidate chord for the starting chord based on each of the target state transition matrices and each attribute value of the starting chord includes:
[0011] For each chord attribute, determine the target state transition probability of the starting chord from the target state transition matrix corresponding to the chord attribute, and determine the attribute value interval corresponding to the column where the target state transition probability is located as the target attribute value interval of the starting chord under the target emotion category and the chord attribute. The target state transition probability is the maximum state transition probability among the state transition probabilities in the target state transition matrix that belong to the same row attribute value interval as the attribute value of the starting chord under the chord attribute.
[0012] Determine the attribute value interval corresponding to the column where the target state transition probability is located as the target attribute value interval of the starting chord under the target emotion category and the chord attribute.
[0013] Determine the preset chords among the multiple preset chords, whose attribute values under each chord attribute all correspond to and fall into each target attribute value interval of the starting chord, as one candidate chord of the starting chord.
[0014] In one embodiment, the method further includes the step of pre-constructing a state transition matrix for each chord attribute for multiple emotion categories respectively, and the step includes:
[0015] Obtain the emotion categories to which multiple songs belong, and under each emotion category, determine the transition frequencies of each preset chord in each of the songs under the emotion category.
[0016] Determine the attribute value interval in which each attribute value of each preset chord falls among a preset plurality of attribute value intervals based on the attribute values of each preset chord under each chord attribute;
[0017] For each emotion category and each chord attribute, based on the transition frequencies of each preset chord under the emotion category and the attribute value intervals in which the attribute values of each preset chord under the chord attribute fall, determine the state transition probabilities between the attribute value intervals, and based on the state transition probabilities between the attribute value intervals, construct the state transition matrix of the emotion category under the chord attribute.
[0018] In one embodiment, the obtaining the observed transition probability that the starting chord transitions to each candidate chord includes:
[0019] Obtain a first transition probability and a second transition probability that the starting chord transitions to each candidate chord; the first transition probability corresponding to each candidate chord is used to represent the probability that the starting chord transitions to the candidate chord when different emotion categories and different chord attributes are distinguished; the second transition probability corresponding to each candidate chord is used to represent the probability that the starting chord transitions to the candidate chord when different emotion categories and different chord attributes are not distinguished;
[0020] Perform a fusion process on the first transition probability and the second transition probability of each candidate chord to obtain the observed transition probability that the starting chord transitions to each candidate chord.
[0021] In one embodiment, the obtaining the first transition probability that the starting chord transitions to each candidate chord includes:
[0022] Based on the attribute values of the starting chord and the attribute values of each candidate chord, determine the distance between the starting chord and each candidate chord;
[0023] Based on the distance between the starting chord and each candidate chord, determine the first transition probability that the starting chord transitions to each candidate chord.
[0024] In one embodiment, the based on the distance between the starting chord and each candidate chord, determining the first transition probability that the starting chord transitions to each candidate chord includes:
[0025] Determine the sum of the distances corresponding to each candidate chord;
[0026] Based on the distance corresponding to each of the candidate chords and the total sum of the distances, obtain the first transition probability of the starting chord transitioning to each of the candidate chords.
[0027] In one embodiment, after determining the subsequent chord of the starting chord among the candidate chords, it further includes:
[0028] Take the subsequent chord as the new starting chord, and return to the step of screening at least one preset chord from multiple preset chords as the candidate chords of the starting chord based on each of the target state transition matrices and each of the attribute values of the starting chord, until the obtained subsequent chord meets the preset chord generation stop condition;
[0029] Form the chord sequence with the starting chord and each of the determined subsequent chords.
[0030] In one embodiment, the determining the subsequent chord of the starting chord among the candidate chords based on the observation transition probability corresponding to each of the candidate chords includes:
[0031] Based on the observation transition probability corresponding to each of the candidate chords, randomly determine any one of the candidate chords as the subsequent chord among the candidate chords.
[0032] In a second aspect, the present application also provides a computer device, including a memory and a processor, where the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:
[0033] Obtain a starting chord and a target emotion category; the starting chord is any one of multiple preset chords, and each preset chord has a corresponding attribute value under each preset chord attribute; the target emotion category is any one of multiple preset emotion categories, and the target emotion category is used to characterize the emotion represented by the chord sequence composed of the starting chord and the subsequent chord of the starting chord;
[0034] In the state transition matrices pre-constructed respectively for multiple emotion categories under each chord attribute, obtain the target state transition matrices of the target emotion category under each chord attribute; wherein, the target state transition matrix is used to characterize the state transition probability between the attribute values of each preset chord under the corresponding chord attribute under the target emotion category;
[0035] Based on each of the target state transition matrices and each of the attribute values of the starting chord, screen out at least one preset chord from multiple preset chords as the candidate chords of the starting chord;
[0036] Obtain the observed transition probabilities of the starting chord transferring to each of the candidate chords, and based on the observed transition probabilities corresponding to each of the candidate chords, determine the subsequent chord of the starting chord among the candidate chords.
[0037] In a third aspect, the present application further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the following steps are implemented:
[0038] Obtain a starting chord and a target emotion category; the starting chord is any one of a plurality of preset chords, and each of the preset chords has a corresponding attribute value under each of the preset chord attributes; the target emotion category is any one of a plurality of preset emotion categories, and the target emotion category is used to characterize the emotion represented by a chord sequence composed of the starting chord and the subsequent chord of the starting chord;
[0039] In the state transition matrices respectively pre-constructed for the plurality of emotion categories under each of the chord attributes, obtain the target state transition matrix of the target emotion category under each of the chord attributes; wherein, the target state transition matrix is used to characterize the state transition probabilities between the attribute values of the preset chords under the corresponding chord attributes under the target emotion category;
[0040] Based on each of the target state transition matrices and the attribute values of the starting chord, screen out at least one of the preset chords from the plurality of preset chords as the candidate chords of the starting chord;
[0041] Obtain the observed transition probabilities of the starting chord transferring to each of the candidate chords, and based on the observed transition probabilities corresponding to each of the candidate chords, determine the subsequent chord of the starting chord among the candidate chords.
[0042] In a fifth aspect, the present application further provides a computer program product, including a computer program. When the computer program is executed by a processor, the following steps are implemented:
[0043] Obtain a starting chord and a target emotion category; the starting chord is any one of a plurality of preset chords, and each of the preset chords has a corresponding attribute value under each of the preset chord attributes; the target emotion category is any one of a plurality of preset emotion categories, and the target emotion category is used to characterize the emotion represented by a chord sequence composed of the starting chord and the subsequent chord of the starting chord;
[0044] In the state transition matrices pre-constructed respectively for multiple emotion categories under each of the chord attributes, obtain the target state transition matrices of the target emotion category under each of the chord attributes; wherein, the target state transition matrix is used to characterize the state transition probability between the attribute values of the preset chords under the corresponding chord attributes under the target emotion category.
[0045] Based on each of the target state transition matrices and each of the attribute values of the starting chord, screen out at least one of the preset chords from the multiple preset chords as the candidate chords of the starting chord.
[0046] Obtain the observed transition probability of the starting chord transferring to each of the candidate chords, and based on the observed transition probability corresponding to each of the candidate chords, determine the subsequent chord of the starting chord among the candidate chords.
[0047] For the above chord generation method, computer device, computer-readable storage medium, and computer program product, first, obtain a starting chord and a target emotion category; the starting chord is any one of multiple preset chords, and each preset chord has corresponding attribute values under each of the preset chord attributes; the target emotion category is any one of multiple preset emotion categories, and the target emotion category is used to characterize the emotion represented by the chord sequence composed of the starting chord and the subsequent chord of the starting chord; then, in the state transition matrices pre-constructed respectively for multiple emotion categories under each chord attribute, obtain the target state transition matrices of the target emotion category under each chord attribute; wherein, the target state transition matrix is used to characterize the state transition probability between the attribute values of the preset chords under the corresponding chord attributes under the target emotion category; based on each of the target state transition matrices and each of the attribute values of the starting chord, screen out at least one of the preset chords from the multiple preset chords as the candidate chords of the starting chord; finally, obtain the observed transition probability of the starting chord transferring to each of the candidate chords, and based on the observed transition probability corresponding to each of the candidate chords, determine the subsequent chord of the starting chord among the candidate chords. In this way, based on each of the target state transition matrices characterizing the state transition probability between the attribute values of the preset chords under each chord attribute under the target emotion category, candidate chords of the starting chord can be screened out from the multiple preset chords, and then, based on the observed transition probability of the starting chord transferring to each of the candidate chords, the subsequent chord of the starting chord can be determined from the candidate chords, thereby realizing chord generation; for the chord generation method based on the above process, in the chord generation process, based on the state transition matrix, the influence of the emotion category and chord attribute on chord transition is fully considered, so the reliability of the obtained chords is improved. Description of the Drawings
[0048] To more clearly illustrate the technical solutions in the embodiments of the present application or the related art, the following will briefly introduce the drawings required for use in the description of the embodiments of the present application or the related art. Obviously, the drawings in the following description are only some embodiments of the present application. For those of ordinary skill in the art, without creative efforts, other related drawings can also be obtained based on these drawings.
[0049] Figure 1 It is a schematic flowchart of a chord generation method in an embodiment;
[0050] Figure 2 It is a schematic flowchart of the step of screening at least one preset chord from multiple preset chords as a candidate chord for the starting chord based on the target state transition matrix and the attribute values of the starting chord in an embodiment;
[0051] Figure 3 It is a schematic flowchart of the step of pre - constructing a state transition matrix for multiple emotion categories respectively under each chord attribute in an embodiment;
[0052] Figure 4 It is a schematic flowchart of the step of obtaining the observation transition probability of the starting chord transferring to each candidate chord in an embodiment;
[0053] Figure 5 It is a schematic flowchart of the step of obtaining the first transition probability of the starting chord transferring to each candidate chord in an embodiment;
[0054] Figure 6 It is a schematic flowchart of a chord generation method in another embodiment;
[0055] Figure 7 It is a schematic flowchart of chord generation based on the quantization mapping of emotion and chord in an embodiment;
[0056] Figure 8 It is a schematic diagram of the attribute value sequence of the chord sequence of a song in an embodiment;
[0057] Figure 9 It is a schematic diagram of chord generation based on the quantization mapping of emotion and chord in another embodiment;
[0058] Figure 10 It is a structural block diagram of a chord generation device in an embodiment;
[0059] Figure 11 It is an internal structure diagram of a computer device in an embodiment. Detailed implementation manners
[0060] To make the objectives, technical solutions, and advantages of this application clearer, the following further elaborates on this application in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely used to explain this application and are not used to limit this application.
[0061] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use, and processing of relevant data need to comply with relevant regulations.
[0062] In one embodiment, as Figure 1 shown, a chord generation method is provided. In this embodiment, it is exemplified that this method is applied to a server. It can be understood that this method can also be applied to a terminal, or to a system including a server and a terminal, and is implemented through the interaction between the server and the terminal; among them, the server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server providing cloud computing services; the terminal can be, but is not limited to, various personal computers, laptop computers, smartphones, tablet computers, etc. In this embodiment, the method includes the following steps S102 to step S108:
[0063] Step S102, obtain a starting chord and a target emotion category.
[0064] Among them, the starting chord is any one of multiple preset chords.
[0065] Among them, each preset chord has a corresponding attribute value under each preset chord attribute. In specific applications, the attribute value of a preset chord under a chord attribute is used to represent the score of this preset chord under this chord attribute; for example, the attribute value of chord 1 under "consonance degree" is 1, the attribute value under "positivity degree" is 2, the attribute value under "color brightness" is 2, the attribute value under "tension" is 4, and the attribute value under "stability" is 3. In actual applications, the attribute value is any value between.
[0066] In actual applications, the attribute value of each preset chord under each chord attribute can be obtained by scoring according to expert experience.
[0067] Among them, the preset chord attributes are at least one. In specific applications, the preset chord attributes are at least one of consonance degree, positivity degree, color brightness, tension, and stability. In actual applications, the chord attributes can be determined according to the expert's analysis experience of the chord attributes.
[0068] Among them, the target emotion category is any one of a variety of preset emotion categories. In specific applications, the variety of emotion categories are at least two of anger, excitement, boredom, melancholy, happiness, and anxiety. In practical applications, the emotion categories can be obtained from experts' summary of the emotional types that humans can mainly perceive from music.
[0069] Among them, the target emotion category is used to represent the emotion characterized by the chord sequence composed of the starting chord and the subsequent chords of the starting chord.
[0070] Among them, the subsequent chord is a chord that is temporally located after the starting chord.
[0071] Specifically, when the user needs to generate a chord, the user sends a chord generation instruction to the server; in response to the chord generation instruction, the server determines the starting chord and the target emotion category to which the emotion represented by the chord sequence expected to be generated by the user belongs.
[0072] In specific applications, the chord generation instruction can carry the chord information of the starting chord, such as the chord identifier; if the chord generation instruction carries the chord information of the starting chord, the server uses the preset chord that matches the carried chord information among the variety of preset chords as the starting chord, and if the chord generation instruction does not carry chord information, the server uses the default chord among the variety of preset chords as the starting chord.
[0073] In specific applications, the chord generation instruction also carries the chord generation requirement information of the user. The chord generation requirement information describes the user's requirements for the chord sequence to be generated. For example, the user expects to generate a chord sequence representing a certain emotion category; the server determines the emotion category that matches the carried chord generation requirement information among the variety of emotion categories as the target emotion category.
[0074] In practical applications, the chord generation requirement information can be text; the server parses the text based on a large language model to determine the emotion expressed by the text content and obtains the target emotion category; further, the content in the text can be a description of emotion, a description of a scene, or a description of a story plot.
[0075] Alternatively, the chord generation requirement information can directly indicate in the text the emotion that the user expects the chord sequence to be generated to be able to express, and this emotion is the target emotion category. For example, in practical applications, the server can also display emotion labels corresponding to each emotion category, and the chord generation requirement information is the emotion label selected by the user among the variety of emotion labels.
[0076] For example, the user inputs a specified starting chord and the corresponding emotional description to the server. Based on the large language model, the server determines the emotional category corresponding to the emotional description input by the user among multiple emotional categories, and obtains the emotional category of the chord sequence expected to be generated by the user.
[0077] Step S104, in the state transition matrices pre-constructed respectively for multiple emotional categories under each chord attribute, obtain the target state transition matrices of the target emotional category under each chord attribute.
[0078] Among them, the server presets multiple state transition matrices, and each state transition matrix corresponds to an emotional category and a chord attribute; each state transition matrix is used to represent the state transition probability between the attribute values of each preset chord under the chord attribute corresponding to (this state transition matrix) under the corresponding emotional category.
[0079] Among them, the target state transition matrix is used to represent the state transition probability between the attribute values of each preset chord under the chord attribute corresponding to (the target state transition matrix) under the target emotional category.
[0080] In specific applications, the transfer situations of each preset chord under different emotional categories and different chord attributes are different. The server pre-constructs multiple state transition matrices. For example, the emotional category of "anger" has corresponding state transition matrices respectively under "consonance degree", "positivity degree", "color brightness", "tension" and "stability". Among them, the state transition matrix of the emotional category of "anger" under the chord attribute of "consonance degree" is used to represent the state transition probability between the attribute values of each preset chord under the chord attribute of "consonance degree" under the emotional category of "anger".
[0081] Specifically, the server, based on the target emotional category and each chord attribute, obtains the target state transition matrix of this target emotional category under each chord attribute in the multiple pre-constructed state transition matrices.
[0082] For example, assume that the target emotional category is "excited", and each chord attribute includes "consonance degree", "positivity degree", "color brightness", "tension" and "stability". Then the server obtains the state transition matrices of the emotional category of "excited" under the chord attributes such as "consonance degree", "positivity degree", "color brightness", "tension" and "stability" as the target state transition matrices.
[0083] In S106, based on each target state transition matrix and the attribute values of the starting chord, screen at least one preset chord from multiple preset chords as the candidate chord of the starting chord.
[0084] Among them, the candidate chord is a preset chord that may become the subsequent chord.
[0085] Specifically, the server filters out at least one from multiple preset chords as the candidate chord of the starting chord based on the target state transition matrix of the target emotion category under each chord attribute and the attribute value of the starting chord under each chord attribute.
[0086] In a specific application, the server predicts the attribute value of the subsequent chord under each chord attribute based on each target state transition matrix and the attribute value of the starting chord under each chord attribute, and obtains a prediction result; then, the server determines the preset chords whose attribute values under each chord attribute match the prediction result among the multiple preset chords as the candidate chords.
[0087] For example, the server predicts the target attribute value to which the attribute value of the starting chord is most likely to transfer based on the state transition probability in the target state transition matrix, and obtains a prediction result.
[0088] Step S108, obtain the observed transition probability of the starting chord transferring to each candidate chord, and determine the subsequent chord of the starting chord among each candidate chord based on the observed transition probability corresponding to each candidate chord.
[0089] Specifically, the server calculates the observed transition probability of the starting chord transferring to each candidate chord based on the attribute value of the starting chord under each chord attribute, the attribute value of each candidate chord under each chord attribute, and the prior transition probability of the starting chord transferring to each candidate chord, and determines the subsequent chord of the starting chord among each candidate chord based on the observed transition probability of the starting chord transferring to each candidate chord.
[0090] Among them, the prior transition probability is the probability that the starting chord transfers to the candidate chord without distinguishing different emotion categories and different chord attributes.
[0091] In a specific application, the server determines the candidate chord with the largest corresponding observed transition probability as the subsequent chord of the starting chord.
[0092] In another specific application, the server randomly determines one among each candidate chord based on the observed transition probability corresponding to each candidate chord as the subsequent chord of the starting chord; among them, the probability that each candidate chord is randomly determined as the subsequent chord is its corresponding observed transition probability.
[0093] For example, assume that there are Chord 1, Chord 2, Chord 3, Chord 4, Chord 5, and Chord 6 in the chord library; the starting chord is Chord 1. Based on the state transition matrix, the candidate chords screened by the server are Chord 3, Chord 4, and Chord 6. Based on the observation transition probability, the subsequent chord determined by the server is Chord 4. Then, Chord 4 is the subsequent chord of Chord 1. That is, in terms of time sequence, the chord after Chord 1 is Chord 4.
[0094] In the above chord generation method, first, the server obtains the starting chord and the target emotion category; the starting chord is any one of multiple preset chords, and each preset chord has a corresponding attribute value under each preset chord attribute; the target emotion category is any one of multiple preset emotion categories, and the target emotion category is used to represent the emotion represented by the chord sequence composed of the starting chord and the subsequent chord of the starting chord. Then, the server obtains the target state transition matrix of the target emotion category under each chord attribute in the state transition matrices pre-constructed for multiple emotion categories under each chord attribute respectively; among them, the target state transition matrix is used to represent the state transition probability between the attribute values of each preset chord under the corresponding chord attribute under the target emotion category. Based on each target state transition matrix and the attribute values of the starting chord, at least one preset chord is screened out from multiple preset chords as the candidate chord of the starting chord. Finally, the server obtains the observation transition probability of the starting chord transferring to each candidate chord, and determines the subsequent chord of the starting chord among each candidate chord based on the observation transition probability corresponding to each candidate chord. In this way, based on each target state transition matrix representing the state transition probability between the attribute values of each preset chord under each chord attribute under the target emotion category, the candidate chords of the starting chord can be screened out from multiple preset chords. Then, based on the observation transition probability of the starting chord transferring to each candidate chord, the subsequent chord of the starting chord can be determined among each candidate chord, thus realizing chord generation. The chord generation method based on the above process fully considers the influence of the emotion category and chord attributes on chord transition based on the state transition matrix during the chord generation process, so the reliability of the obtained chords is improved.
[0095] In an exemplary embodiment, each state transition matrix includes state transition probabilities with N rows and M columns. Each row corresponds to any one of a plurality of preset attribute value intervals, and each column corresponds to any one of the plurality of attribute value intervals; the state transition probability at the i-th row and j-th column in each state transition matrix is used to represent the probability that a first preset chord transitions to a second preset chord under the (corresponding) sentiment category. The first preset chord is a preset chord among the plurality of preset chords, whose attribute value under the (corresponding) chord attribute falls within the attribute value interval corresponding to the i-th row, and the second preset chord is a preset chord among the plurality of preset chords, whose attribute value under the (corresponding) chord attribute falls within the attribute value interval corresponding to the j-th column, where N≥i≥1 and M≥j≥1.
[0096] Among them, the target state transition matrix includes state transition probabilities with N rows and M columns. Each row corresponds to any one of a plurality of preset attribute value intervals, and each column corresponds to any one of the plurality of attribute value intervals; the state transition probability at the i-th row and j-th column in the target state transition matrix is used to represent the probability that a first preset chord transitions to a second preset chord under the target sentiment category. The first preset chord is a preset chord among the plurality of preset chords, whose attribute value under the chord attribute falls within the attribute value interval corresponding to the i-th row, and the second preset chord is a preset chord among the plurality of preset chords, whose attribute value under the corresponding chord attribute falls within the attribute value interval corresponding to the j-th column, where N≥i≥1 and M≥j≥1.
[0097] In a specific application, the server presets a plurality of attribute value intervals. Further, the interval lengths of each attribute value interval are the same; furthermore, the interval length of each attribute value interval is 1 or 0.5; for example, assuming the attribute value is any value between and and and and , or, respectively, 、 、 、 、 、 、 、 、 and . In practical applications, the shorter the interval length, the higher the quantization granularity of the attribute value, and the higher the reliability of the generated chords, but the computational complexity will also increase accordingly.
[0098] As shown in Formula 1, it is a state transition matrix :
[0099] (Formula 1)
[0100] Assume that Formula 1 is the state transition matrix of the emotional category of "anger" under the chord attribute of "concordance degree"; referring to Formula 1, the row and the column state transition probability represents the probability that, under the emotional category of "anger" and under the chord attribute of "concordance degree", the attribute value falls into the preset chord corresponding to the attribute value interval of the row and transfers to the preset chord corresponding to the attribute value interval of the column; for example, referring to Formula 1, under the emotional category of "anger" and under the chord attribute of "concordance degree", the attribute value falls into the preset chord and transfers to the preset chord corresponding to the attribute value interval of with a transfer probability of 0.07.
[0101] As Figure 2 shown, the above step S106, based on each target state transition matrix and each attribute value of the starting chord, screens at least one preset chord from multiple preset chords as a candidate chord for the starting chord, specifically including the following steps:
[0102] Step S202: For each chord attribute, determine the target state transition probability of the starting chord from the target state transition matrix corresponding to the chord attribute, and determine the target attribute value interval of the starting chord under the target emotional category and chord attribute as the attribute value interval corresponding to the column where the target state transition probability is located.
[0103] Step S204: Determine a preset chord whose attribute values under each chord attribute all fall into each target attribute value interval of the starting chord as a candidate chord for the starting chord.
[0104] Among them, the target state transition probability is the maximum state transition probability among the state transition probabilities in the target state transition matrix that belong to the same row attribute value interval as the attribute value of the starting chord under the chord attribute.
[0105] For example, assume that the target state transition matrix is as shown in Formula 1, and assume that the attribute value of the starting chord under the chord attribute corresponding to this target state transition matrix is 0.5. Then the server can determine that this attribute value falls into the attribute value interval, and in Formula 1, the attribute value interval Corresponding to the first row, therefore, the target state transition probability corresponding to the starting chord is the maximum state transition probability 0.25 in the first row of Formula 1. Further, the target attribute value interval is the attribute value interval corresponding to the column where the state transition probability is 0.25. and .
[0106] Taking another example, assume that the attribute value of the starting chord under the chord attribute corresponding to the target state transition matrix is 4.2. Then the server can determine that this attribute value falls within the attribute value interval. And in Formula 1, the attribute value interval corresponds to the fifth row. Therefore, the target state transition probability corresponding to the starting chord is the maximum state transition probability 0.40 in the fifth row of Formula 1. Further, the target attribute value interval is the attribute value interval corresponding to the column where the state transition probability is 0.40, which is .
[0107] Specifically, for each chord attribute, the server first determines the attribute value interval in which the attribute value of the starting chord under this chord attribute falls among a preset plurality of attribute value intervals; then, the server searches for the target state transition matrix corresponding to this chord attribute, and in this target state transition matrix, determines the row corresponding to the attribute value interval in which the attribute value of the starting chord under this chord attribute falls, and takes the maximum state transition probability in this row as the target state transition probability of the starting chord under the target emotion category and the target attribute value interval; then, based on this target state transition matrix, the server determines the attribute value interval corresponding to the column where this target state transition probability is located, and determines it as the target attribute value interval of the starting chord under the target emotion category and the target attribute value interval; finally, the server takes the preset chords among all the preset chords, whose attribute values under each chord attribute all fall within the target attribute value interval of the starting chord under each chord attribute, as the candidate chords of the starting chord.
[0108] Taking an example, assume that the target attribute value intervals corresponding to the starting chord under "consonance degree", "positivity degree", "color brightness", "tension", and "stability" are respectively , , , and , then the server takes the preset chords among all the preset chords, whose attribute values under "consonance degree", "positivity degree", "color brightness", "tension", and "stability" respectively fall within , , , and , as the candidate chords of the starting chord.
[0109] In this embodiment, the server can determine, based on the target state transition matrix of the target emotion category under each chord attribute, the target attribute value intervals to which the attribute value intervals where the attribute values of the starting chord fall under the target emotion category are most likely to transition. Furthermore, candidate chords can be filtered out based on the target attribute value intervals.
[0110] In an exemplary embodiment, as Figure 3 shown, the chord generation method provided by the present application further specifically includes the following steps for pre - constructing state transition matrices for multiple emotion categories under each chord attribute respectively:
[0111] Step S302: Obtain the emotion categories to which multiple songs belong, and under each emotion category, determine the transition frequencies of each preset chord in each song under the emotion category.
[0112] Step S304: Based on the attribute values of each preset chord under each chord attribute, determine the attribute value intervals into which each attribute value of each preset chord falls among a preset number of attribute value intervals.
[0113] Step S306: For each emotion category and each chord attribute, based on the transition frequencies of each preset chord under the emotion category and the attribute value intervals into which the attribute values of each preset chord under the chord attribute fall, determine the state transition probabilities between the attribute value intervals, and based on the state transition probabilities between the attribute value intervals, construct the state transition matrix of the emotion category under the chord attribute.
[0114] Specifically, the server obtains multiple preset chords and determines the attribute values of each preset chord under each chord attribute, and then determines the attribute value intervals into which each attribute value of each preset chord falls; at the same time, the server obtains multiple songs and determines the emotion category to which each song belongs; then, under each emotion category, for each song under the emotion category, the server determines the chord sequence of the song and statistically calculates the transition frequencies of each preset chord in each song under the emotion category based on the chord sequences of the songs; next, for each chord attribute, the server determines the state transition probabilities between the attribute value intervals based on the above - statistically obtained transition frequencies and the attribute value intervals into which the attribute values of each preset chord under the chord attribute fall, and then constructs the state transition matrix of the emotion category under the chord attribute.
[0115] For example, for the emotion category "excited", the server determines the chord sequences of each song under the emotion category "excited", and based on the chord sequences of each song, counts the transition frequencies of each preset chord in each song under the emotion category "excited"; then, for the chord attribute "consonance degree", the server determines the state transition probabilities between each attribute value interval under the emotion category "excited" and the chord attribute "consonance degree" based on the transition frequencies of each preset chord in each song under the emotion category "excited" and the attribute value intervals in which the attribute values of each preset chord fall under the chord attribute "consonance degree", and then constructs a state transition matrix of the emotion category "excited" under the chord attribute "consonance degree". Similarly, state transition matrices of the emotion category "excited" under the chord attributes "positive degree", "color brightness", "tension", and "stability" are obtained.
[0116] In a specific application, the emotion categories can be preset by experts based on their experience. The server presets different emotion categories as emotion labels of different classification results, and then the server classifies the songs based on the emotion to determine the classification results of the songs, and further determines the emotion categories to which the songs belong.
[0117] In another specific application, the server can also first perform clustering processing on multiple songs based on the emotion to obtain multiple clustering results, and then analyze the emotions represented by each clustering result to obtain multiple emotion categories.
[0118] In this embodiment, for each emotion category, the server can construct a state transition matrix of the emotion category under each chord attribute based on the transition frequencies of each preset chord under the emotion category and the attribute value intervals in which the attribute values of each preset chord fall under each chord attribute.
[0119] In an exemplary embodiment, as Figure 4 shown, in the above step S108, obtaining the observed transition probabilities of the starting chord transferring to each candidate chord specifically includes the following steps:
[0120] Step S402, obtaining the first transition probability and the second transition probability of the starting chord transferring to each candidate chord.
[0121] Step S404, performing a fusion process on the first transition probability and the second transition probability of each candidate chord to obtain the observed transition probability of the starting chord transferring to each candidate chord.
[0122] Among them, the first transition probability corresponding to each candidate chord is used to represent the probability of the starting chord transferring to the candidate chord when different emotion categories and different chord attributes are distinguished; in a specific application, the first transition probability is determined based on the attribute values of the starting chord and the respective attribute values of each candidate chord.
[0123] Among them, the second transition probability corresponding to each candidate chord is used to represent the probability that the starting chord transitions to the candidate chord without distinguishing different emotion categories and different chord attributes; in specific applications, the second transition probability is the probability obtained by the server by statistically counting the transition frequencies between all preset chords under the condition of distinguishing different emotion categories and different chord attributes.
[0124] Specifically, the server first obtains the first transition probability that the starting chord transitions to each candidate chord, and the second transition probability that the starting chord transitions to each candidate chord; then, for each candidate chord, the server fuses the first transition probability and the second transition probability corresponding to the candidate chord to obtain the observed transition probability that the starting chord transitions to the candidate chord.
[0125] In specific applications, the server can add the first transition probability and the second transition probability to obtain the observed transition probability; or can fuse the first transition probability and the second transition probability by weighting to obtain the observed transition probability.
[0126] In practical applications, the server obtains the observed transition probability that the starting chord transitions to the candidate chord through Formula 2:
[0127] (Formula 2)
[0128] Among them, is the starting chord, is the candidate chord; is the observed transition probability that the starting chord transitions to the candidate chord; is the first transition probability that the starting chord transitions to the candidate chord; is the second transition probability that the starting chord transitions to the candidate chord; is the weight between.
[0129] In this embodiment, the server can determine the observed transition probability that the starting chord transitions to each candidate chord through the first transition probability that represents the starting chord transitions to each candidate chord under the condition of distinguishing different chord attributes and different emotion categories, and the second transition probability that represents the starting chord transitions to each candidate chord without distinguishing different chord attributes and different emotion categories.
[0130] In an exemplary embodiment, as Figure 5 shown, obtaining the first transition probability that the starting chord transitions to each candidate chord specifically includes the following steps:
[0131] Step S502: Determine the distance between the starting chord and each candidate chord based on the attribute values of the starting chord and the attribute values of each candidate chord.
[0132] Step S504: Determine the first transition probability of the starting chord transitioning to each candidate chord based on the distance between the starting chord and each candidate chord.
[0133] Specifically, the server obtains the attribute vector of the starting chord based on the attribute values of the starting chord under each chord attribute, and obtains the attribute vector of each candidate chord based on the attribute values of each candidate chord under each chord attribute; then, for each candidate chord, the server calculates the Euclidean distance between the starting chord and the candidate chord based on the attribute vector of the starting chord and the attribute vector of the candidate chord; next, the server determines the first transition probability of the starting chord transitioning to the candidate chord based on the Euclidean distance between the starting chord and each candidate chord.
[0134] In a specific application, the server determines the relative Euclidean distance corresponding to each candidate chord based on the Euclidean distance corresponding to each candidate chord, and further determines the first transition probability corresponding to each candidate chord.
[0135] In this embodiment, the server determines the first transition probability of the starting chord transitioning to each candidate chord based on the attribute values of the starting chord and the attribute values of each candidate chord.
[0136] In an exemplary embodiment, in the above step S502, determining the first transition probability of the starting chord transitioning to each candidate chord based on the distance between the starting chord and each candidate chord specifically includes the following: determining the sum of the distances corresponding to each candidate chord; obtaining the first transition probability of the starting chord transitioning to each candidate chord based on the distance corresponding to each candidate chord and the sum of the distances.
[0137] Specifically, the server determines the sum of the distances and the total sum of the distances corresponding to all candidate chords, and then for each candidate chord, calculates the ratio between the distance corresponding to the candidate chord and the total sum of the distances, to obtain the first transition probability of the starting chord transitioning to the candidate chord.
[0138] In a specific application, the server obtains the first transition probability of the starting chord transitioning to the candidate chord through formula 3:
[0139] (Formula 2)
[0140] Where, is the total number of candidate chords, is the th candidate chord; is the distance between the starting chord and the The distance between candidate chords.
[0141] In this embodiment, based on the distance corresponding to each candidate chord and the total distance of each distance, the server can determine the relative distance corresponding to each candidate chord, and further can obtain the first transition probability corresponding to each candidate chord.
[0142] In an exemplary embodiment, in step S108 above, after determining the subsequent chord of the starting chord among the candidate chords, the following specific content is further included: taking the subsequent chord as the new starting chord, and returning to the step of screening at least one preset chord from multiple preset chords as the candidate chord of the starting chord based on each target state transition matrix and each attribute value of the starting chord, until the obtained subsequent chord meets the preset chord generation stop condition; forming a chord sequence with the starting chord and the determined subsequent chords.
[0143] Among them, the preset chord generation stop condition can be the preset number of chords or the preset chord duration.
[0144] Specifically, after obtaining the subsequent chord of the starting chord, the server can take the currently obtained subsequent chord as the new starting chord, and return to step S106 to screen at least one preset chord from multiple preset chords as the candidate chord of the starting chord based on each target state transition matrix and each attribute value of the starting chord, so as to obtain the subsequent chord of the new starting chord again until the total number of the obtained subsequent chords reaches the preset number of chords, or the total duration of the obtained subsequent chords (and the starting chord) reaches the preset chord duration. Then, the server forms a chord sequence with the initial starting chord and the determined subsequent chords.
[0145] For example, the starting chord is chord 1, and the server determines the subsequent chord of chord 1, assumed to be chord 4; then, the server determines the subsequent chord of chord 4, assumed to be chord 5, and then the server determines the subsequent chord of chord 5... and so on, to obtain a chord sequence.
[0146] In this embodiment, by determining the subsequent chord of the starting chord as the new starting chord and determining the corresponding subsequent chord for the new starting chord, the server can generate a chord sequence of a certain length or an infinite length.
[0147] In an exemplary embodiment, in step S108 above, based on the observation transition probability corresponding to each candidate chord, determining the subsequent chord of the starting chord among the candidate chords specifically includes the following content: randomly determining any one candidate chord as the subsequent chord among the candidate chords based on the observation transition probability corresponding to each candidate chord.
[0148] Specifically, the server determines the observation transition probability corresponding to each candidate chord as the random probability that the candidate chord is randomly determined as the subsequent chord. Then, based on the random probability of each candidate chord, the server randomly determines any one of the candidate chords as the subsequent chord among the candidate chords.
[0149] For example, assume that the starting chord is Chord 1, and the candidate chords include Chord 2, Chord 3, and Chord 4; the observation transition probability from Chord 1 to Chord 2 is 70%, the observation transition probability from Chord 1 to Chord 3 is 20%, and the observation transition probability from Chord 1 to Chord 4 is 10%; then, the probability that the server randomly selects Chord 2 as the subsequent chord is 70%, the probability that it randomly selects Chord 3 as the subsequent chord is 20%, and the probability that it randomly selects Chord 4 as the subsequent chord is 10%.
[0150] In this embodiment, the server randomly determines one of the candidate chords as the subsequent chord based on the observation transition probability corresponding to each candidate chord, which can enrich the diversity of chord generation.
[0151] In an exemplary embodiment, the chord generation method provided by this application further includes the following: statistically analyzing the duration change of each preset chord under different emotion categories, and obtaining, under each emotion category, a duration feature used to characterize the duration relationship between the previous chord and the subsequent chord in terms of time sequence.
[0152] In the above step S108, after determining the subsequent chord of the starting chord among the candidate chords based on the observation transition probability corresponding to each candidate chord, it further specifically includes the following: adjusting the duration of the subsequent chord based on the duration feature between the starting chord and the subsequent chord under the emotion category.
[0153] Specifically, when the server statistically analyzes the transition frequency between each preset chord, it can also statistically analyze the duration change before and after the transition of each preset chord under each emotion category, obtain the duration feature between the previous chord and the subsequent chord in terms of time sequence under each emotion category, and then, after determining the subsequent chord, adjust the duration of the subsequent chord based on the corresponding duration feature. For example, assume that the duration of Chord 1 is one measure, and the target emotion category is "excited". Based on the duration change of each preset chord under the emotion category "excited", it is obtained that, under the emotion category "excited", the duration of the subsequent chord of Chord 1 should be half a measure. Then, after the server determines the subsequent chord of Chord 1, it will also adjust the duration of this subsequent chord to half a measure.
[0154] In this embodiment, by learning the duration change between chords, the server can generate subsequent chords that more conform to the emotion category, thereby improving the reliability of the obtained chords.
[0155] In an exemplary embodiment, asFigure 6 As shown, another chord generation method is provided. Taking the application of this method to a server as an example, it includes the following steps:
[0156] Step S602: Obtain multiple songs, determine the emotional category to which each song belongs, and under each emotional category, determine the transition frequency of each preset chord in each song under the emotional category.
[0157] Step S604: Obtain multiple preset chords, determine the attribute values of each preset chord under each chord attribute, and determine the attribute value interval in which each attribute value of each preset chord falls among multiple attribute value intervals.
[0158] Step S606: For each emotional category and each chord attribute, based on the transition frequency of each preset chord under the emotional category and the attribute value interval in which the attribute value of each preset chord under the chord attribute falls, determine the state transition probability between each attribute value interval, and based on the state transition probability between each attribute value interval, construct a state transition matrix of the emotional category under the chord attribute.
[0159] Step S608: Obtain the starting chord and the target emotional category, and obtain the target state transition matrix of the target emotional category under each chord attribute.
[0160] Step S610: For each chord attribute, based on the attribute value of the starting chord under the chord attribute, determine the target state transition probability of the starting chord under the target emotional category and the chord attribute from the target state transition matrix corresponding to the chord attribute.
[0161] Step S612: Determine the attribute value interval corresponding to the column where the target state transition probability is located as the target attribute value interval of the starting chord under the target emotional category and the chord attribute.
[0162] Step S614: Among multiple preset chords, determine the preset chords whose attribute values under each chord attribute all correspond to and fall within each target attribute value interval of the starting chord as a candidate chord of the starting chord.
[0163] Step S616: Obtain the first transition probability and the second transition probability of the starting chord transferring to each candidate chord, and obtain the first transition probability and the second transition probability of the starting chord transferring to each candidate chord.
[0164] Step S618: Based on the observed transition probability corresponding to each candidate chord, randomly determine any one candidate chord as the subsequent chord among each candidate chord.
[0165] Step S620: Use the subsequent chord as the new starting chord, and return to the step of determining the target state transition probability of the starting chord under the target emotion category and chord attribute from the target state transition matrix corresponding to the chord attribute based on the attribute value of the starting chord under the chord attribute for each chord attribute, until the obtained subsequent chord meets the preset chord generation stop condition, and form a chord sequence with the starting chord and the determined subsequent chords.
[0166] In this embodiment, on the one hand, for each emotion category, the server can construct a state transition matrix of the emotion category under each chord attribute based on the transition frequency of each preset chord under the emotion category and the attribute value interval in which the attribute value of each preset chord under each chord attribute falls; thus enabling the server to fully consider the influence of the emotion category and chord attribute on the chord based on the state transition matrix during the chord generation process, and therefore improving the reliability of the obtained chord. On the other hand, the server randomly determines one of the candidate chords as the subsequent chord based on the observed transition probability corresponding to each candidate chord, which can enrich the diversity of chord generation. On the further hand, the server can generate a chord sequence of a certain length or an infinite length by determining the subsequent chord of the starting chord as the new starting chord and determining the corresponding subsequent chord for the new starting chord.
[0167] To more clearly illustrate the chord generation method provided by the embodiments of the present application, the following uses a specific embodiment to specifically describe the chord generation method, but it should be understood that the embodiments of the present application are not limited thereto. As Figure 7 shown, in one exemplary embodiment, the present application also provides a chord generation method based on the quantization mapping of emotion and chords, which specifically includes the following steps:
[0168] 1. Attribute scoring of chords.
[0169] Chords are an indispensable part of musical structure, which are used to enrich the color and structure of music and provide support for melodies. Although there is a rough classification of the functional attributes of chords in harmony, different chords have different functions and colors in different musical scenarios, and their complex and multi-dimensional characteristics cannot be simply covered by the main-subordinate functional classification. To make the chord progression match the song mood, we need to quantify the characteristics of chords from multiple dimensions.
[0170] This embodiment summarizes five attributes of chords: consonance degree, positivity degree, color brightness, tension, and stability. This embodiment collects various existing chords and asks professional personnel with a musical background to score each chord under each attribute, and finally obtains the attribute value of each chord under each attribute by averaging the scores of all professional personnel, so as to construct a chord database.
[0171] 2. Build the connection between emotions and chords. In this step, the attribute values of chords under five attributes are used to represent the chord progression trend under a certain emotion.
[0172] In this embodiment, six common and relatively easy-to-distinguish song emotions are refined, namely: anger, excitement, boredom, melancholy, happiness, and anxiety.
[0173] Then, each song is collected for emotion marking. The specific implementation method is to use song keywords to assist manual discrimination to determine which of the above emotions the song belongs to.
[0174] For each song, in this embodiment, the chord sequence of the song is extracted based on the MIDI (Musical Instrument Digital Interface) dataset of the song, and based on the chord database constructed in step 1, the attribute values of each chord in the chord sequence under each attribute are determined, so as to obtain the attribute value sequence of the chord sequence of the song under each attribute; refer to Figure 8 For the schematic diagram of the attribute value sequence of the chord sequence of the song. Then, in this embodiment, the attribute value sequence of a specific emotion under each attribute is used as the training data of the hidden Markov chain, and thus the state transition matrix corresponding to the attribute change of a specific emotion under each attribute can be obtained.
[0175] Specifically, when constructing the state transition matrix, the attribute values also need to be quantified to obtain the corresponding quantified states; the quantization granularity can be controlled, for example, the quantization granularity is 1 or 0.5.
[0176] 3. Inference process.
[0177] When the user inputs an emotion description, in this embodiment, the large language model clusters the input emotion description into the above six emotions, and then uses the state transition matrix of the emotion to which the emotion description belongs under each attribute as the basis for generating the next determined chord.
[0178] Specifically, refer to Figure 9 For another schematic diagram of this embodiment, this embodiment first determines the quantified states of the starting chord under each attribute, then based on the five state transition matrices of the emotion to which the emotion description belongs, determines the corresponding quantified states of the next chord under each attribute, and then uses the corresponding quantified states of the next chord under each attribute as the screening conditions to search among the chords to obtain candidate chords, and then based on the observed transition probabilities corresponding to each candidate chord, obtains the next chord of the starting chord among the candidate chords, and then uses the next chord as the new starting chord, repeating the above operations to deduce the next chord to obtain a continuous chord sequence.
[0179] Among them, the observation transition probability is obtained based on the relative distance between the starting chord and each candidate chord and the inherent transition probability between the starting chord and each candidate chord.
[0180] For example, if the starting chord is Chord 1, and the chord database obtains its attribute value array as [2.5, 3.5, 4.6, 5, 1.2]. Assuming the quantization granularity used is 1, this array will be quantized into five states: [2 - 3, 3 - 4, 4 - 5, 4 - 5, 1 - 2]. According to the five-state transition matrix corresponding to the input emotion, the quantized state corresponding to the next chord under each attribute is obtained, assumed to be [1 - 2, 1 - 2, 3 - 4, 4 - 5, 1 - 2]. Then, using this range as a standard, a search is performed among the chords. Assuming that a total of four chords, Chord 1, Chord 2, Chord 3, and Chord 4, are found, and finally Chord 2 is obtained according to the observation transition probability. Then the chord following Chord 1 at the next time point is Chord 2. Then, the above operations are performed based on the quantized state of Chord 2 to deduce the next chord, thereby obtaining a continuous chord sequence.
[0181] In this embodiment, a chord sequence scheme with a specific emotion can be generated, ensuring naturalness and smoothness while maintaining the diversity of the chord sequence. At the same time, the inference time of this method is extremely short, which can meet the end-side implementation scenario.
[0182] It should be understood that although the steps in the flowcharts involved in the above-described embodiments are sequentially shown according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless there is a clear description in this article, the execution of these steps has no strict order limit, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-described embodiments may include multiple steps or multiple stages. These steps or stages are not necessarily executed at the same moment, but can be executed at different moments. The execution order of these steps or stages is not necessarily sequential, but can be executed alternately or in turn with at least a part of other steps or steps or stages in other steps.
[0183] Based on the same inventive concept, the embodiments of the present application also provide a chord generation device for implementing the above-mentioned chord generation method. The implementation solutions provided by this device for solving problems are similar to those described in the above method. Therefore, the specific limitations in one or more embodiments of the following chord generation devices can refer to the limitations on the chord generation method in the above text, and will not be repeated here.
[0184] In an exemplary embodiment, as Figure 10As shown, a chord generation device is provided, including: an information acquisition module 1002, a matrix acquisition module 1004, a first screening module 1006, and a second screening module 1008, where:
[0185] The information acquisition module 1002 is configured to acquire a starting chord and a target emotion category; the starting chord is any one of a plurality of preset chords, and each preset chord has a corresponding attribute value under each preset chord attribute; the target emotion category is any one of a plurality of preset emotion categories, and the target emotion category is used to characterize the emotion represented by a chord sequence composed of the starting chord and the subsequent chords of the starting chord.
[0186] The matrix acquisition module 1004 is configured to acquire a target state transition matrix of the target emotion category under each chord attribute in a state transition matrix pre-constructed for each emotion category under each chord attribute; wherein, the target state transition matrix is used to characterize the state transition probability between the attribute values of each preset chord under the corresponding chord attribute under the target emotion category.
[0187] The first screening module 1006 is configured to screen out at least one preset chord from a plurality of preset chords as a candidate chord for the starting chord based on each target state transition matrix and each attribute value of the starting chord.
[0188] The second screening module 1008 is configured to acquire the observation transition probability of the starting chord transferring to each candidate chord, and determine the subsequent chord of the starting chord among each candidate chord based on the observation transition probability corresponding to each candidate chord.
[0189] In an exemplary embodiment, the target state transition matrix includes state transition probabilities of N rows and M columns. Each row corresponds to any one of a plurality of preset attribute value intervals, and each column corresponds to any one of a plurality of attribute value intervals; the state transition probability of the i-th row and the j-th column in the target state transition matrix is used to characterize the probability of the first preset chord transferring to the second preset chord under the target emotion category. The first preset chord is a preset chord among a plurality of preset chords whose attribute value under the chord attribute falls into the attribute value interval corresponding to the i-th row, and the second preset chord is a preset chord among a plurality of preset chords whose attribute value under the corresponding chord attribute falls into the attribute value interval corresponding to the j-th column, where N≥i≥1 and M≥j≥1.
[0190] The first screening module 1006 is further configured to, for each chord attribute, determine the target state transition probability of the starting chord from the target state transition matrix corresponding to the chord attribute, and determine the attribute value interval corresponding to the column where the target state transition probability is located as the target attribute value interval of the starting chord under the target emotion category and chord attribute; the target state transition probability is the maximum state transition probability among the state transition probabilities in the same row attribute value interval as the attribute value of the starting chord under the chord attribute in the target state transition matrix; the preset chords among the multiple preset chords, whose attribute values under each chord attribute all correspond to fall into each target attribute value interval of the starting chord, are determined as a kind of candidate chord of the starting chord.
[0191] In an exemplary embodiment, the chord generation device further includes a matrix construction module, configured to obtain the emotion categories to which multiple songs belong, and determine the transfer frequencies of each preset chord in each song under the emotion category; based on the attribute values of each preset chord under each chord attribute, determine the attribute value interval in which each attribute value of each preset chord falls among a preset multiple attribute value intervals; for each emotion category and each chord attribute, based on the transfer frequencies of each preset chord under the emotion category and the attribute value intervals in which the attribute values of each preset chord under the chord attribute fall, determine the state transition probabilities between the attribute value intervals, and construct a state transition matrix of the emotion category under the chord attribute based on the state transition probabilities between the attribute value intervals.
[0192] In an exemplary embodiment, the second screening module 1008 is further configured to obtain the first transfer probability and the second transfer probability of the starting chord transferring to each candidate chord; the first transfer probability corresponding to each candidate chord is used to represent the probability that the starting chord transfers to the candidate chord when different emotion categories and different chord attributes are distinguished; the second transfer probability corresponding to each candidate chord is used to represent the probability that the starting chord transfers to the candidate chord when different emotion categories and different chord attributes are not distinguished; perform a fusion process on the first transfer probability and the second transfer probability of each candidate chord to obtain the observed transfer probability of the starting chord transferring to each candidate chord.
[0193] In an exemplary embodiment, the second screening module 1008 is further configured to determine the distance between the starting chord and each candidate chord based on the attribute values of the starting chord and the attribute values of each candidate chord; determine the first transfer probability of the starting chord transferring to each candidate chord based on the distance between the starting chord and each candidate chord.
[0194] In an exemplary embodiment, the second screening module 1008 is further configured to determine the total distance of the distances corresponding to each candidate chord; obtain the first transfer probability of the starting chord transferring to each candidate chord based on the distance corresponding to each candidate chord and the total distance.
[0195] In an exemplary embodiment, the second screening module 1008 is further configured to use the subsequent chord as a new starting chord, and return the step of screening at least one preset chord from a variety of preset chords as candidate chords for the starting chord based on the attribute values of each target state transition matrix and the starting chord, until the obtained subsequent chord meets the preset chord generation stop condition; and form a chord sequence with the starting chord and each determined subsequent chord.
[0196] In an exemplary embodiment, the second screening module 1008 is further configured to randomly determine any one of the candidate chords as the subsequent chord among the candidate chords based on the observation transition probability corresponding to each candidate chord.
[0197] Each module in the above chord generation device can be implemented in whole or in part by software, hardware, and their combination. Each of the above modules can be embedded in the processor in the computer device in hardware form or be independent of it, or can be stored in the memory in the computer device in software form, so that the processor can call and execute the operations corresponding to each of the above modules.
[0198] A computer device includes a memory and a processor. When the processor executes the computer program, the steps of the above method are implemented.
[0199] A computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the above method are implemented.
[0200] A computer program product includes a computer program, and when the computer program is executed by a processor, the steps of the above method are implemented.
[0201] Each module in the above chord generation device can be implemented in whole or in part by software, hardware, and their combination. Each of the above modules can be embedded in the processor in the computer device in hardware form or be independent of it, or can be stored in the memory in the computer device in software form, so that the processor can call and execute the operations corresponding to each of the above modules.
[0202] In an exemplary embodiment, a computer device is provided. The computer device can be a server, and its internal structure diagram can be as Figure 11As shown. The computer device includes a processor, a memory, an input / output interface (Input / Output, abbreviated as I / O), and a communication interface. Among them, the processor, the memory, and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store each chord and its transition data. The input / output interface of the computer device is used to exchange information between the processor and external devices. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, it implements a chord generation method.
[0203] Those skilled in the art can understand that Figure 11 the structure shown in is only a block diagram of some structures related to the solution of this application, and does not constitute a limitation on the computer device to which the solution of this application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine some components, or have different component arrangements.
[0204] In an exemplary embodiment, a computer device is further provided, including a memory and a processor. A computer program is stored in the memory, and when the processor executes the computer program, the steps in the above method embodiments are implemented.
[0205] In an exemplary embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by the processor, the steps in the above method embodiments are implemented.
[0206] In an exemplary embodiment, a computer program product is provided, including a computer program. When the computer program is executed by the processor, the steps in the above method embodiments are implemented.
[0207] Those of ordinary skill in the art can understand that all or part of the processes in the methods of the above embodiments can be completed by instructing relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above methods. Among them, any reference to a memory, database, or other medium used in the embodiments provided in the present application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM), etc. The databases involved in the embodiments provided in the present application can include at least one of relational databases and non-relational databases. Non-relational databases can include distributed databases based on blockchain, etc., without limitation. The processors involved in the embodiments provided in the present application can be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, data processing logics based on quantum computing, artificial intelligence (AI) processors, etc., without limitation.
[0208] The technical features of the above embodiments can be combined arbitrarily. For the sake of concise description, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, it should be considered to be within the scope recorded in the present application.
[0209] The above-described embodiments merely represent several implementation manners of the present application. The description thereof is relatively specific and detailed, but it should not be construed as a limitation to the patent scope of the present application. It should be noted that for those of ordinary skill in the art, without departing from the concept of the present application, several modifications and improvements can still be made, and these all fall within the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the appended claims.
Claims
1. A chord generation method, characterized in that: The method comprises: Acquire a starting chord and a target emotion category; the starting chord is any one of a plurality of preset chords, each of the preset chords having a corresponding attribute value under each preset chord attribute; the target emotion category is any one of a plurality of preset emotion categories, and the target emotion category is used to represent the emotion represented by a chord sequence consisting of the starting chord and subsequent chords of the starting chord; In the state transfer matrices pre-constructed for multiple emotion categories under each of the chord attributes, a target state transfer matrix of the target emotion category under each of the chord attributes is obtained; wherein the target state transfer matrix is used to represent the state transition probability between the attribute values of each of the preset chords under the corresponding chord attribute under the target emotion category; Based on each of the target state transfer matrices and each of the attribute values of the starting chord, at least one of the preset chords is selected from a plurality of the preset chords as a candidate chord of the starting chord; An observed transition probability of the starting chord to each of the candidate chords is obtained, and based on the observed transition probability corresponding to each of the candidate chords, the subsequent chord of the starting chord is determined from among the candidate chords.
2. The method according to claim 1, characterized in that The target state transition matrix includes N rows and M columns of the state transition probabilities, each row corresponds to any one of a plurality of preset attribute value intervals, and each column corresponds to any one of a plurality of attribute value intervals; The state transition probability of the i-th row and j-th column in the target state transition matrix is used to characterize the probability of the first preset chord transferring to the second preset chord under the target emotion category, the first preset chord is a preset chord among multiple preset chords, the attribute value under the chord attribute falls into the attribute value interval corresponding to the i-th row, and the second preset chord is a preset chord among multiple preset chords, the attribute value under the corresponding chord attribute falls into the attribute value interval corresponding to the j-th column, wherein N≥i≥1, M≥j≥1; The selecting at least one preset chord from a plurality of preset chords based on each of the target state transfer matrices and each of the attribute values of the starting chord as a candidate chord of the starting chord comprises: For each of the chord attributes, the target state transfer probability of the starting chord is determined from the target state transfer matrix corresponding to the chord attribute, and the attribute value interval corresponding to the column where the target state transfer probability is located is determined as the target attribute value interval of the starting chord under the target emotion category and the chord attribute; the target state transfer probability is the maximum state transfer probability among the state transfer probabilities in the target state transfer matrix that belong to the same row of attribute value intervals as the attribute value of the starting chord under the chord attribute; Among the plurality of preset chords, the preset chord whose attribute value under each chord attribute corresponds to and falls within each target attribute value interval of the starting chord is determined as one of the candidate chords of the starting chord.
3. The method according to claim 1, characterized in that The method further comprises the step of pre-constructing a state transfer matrix for each of the chord attributes for a plurality of emotion categories, the step comprising: Acquire the emotion categories to which the plurality of songs belong, and under each of the emotion categories, determine the transfer frequency of each of the preset chords in each of the songs under the emotion category; Based on the attribute value of each of the preset chords under each of the chord attributes, determining the attribute value interval into which each of the attribute values of each of the preset chords falls among a plurality of preset attribute value intervals; For each of the emotion categories and each of the chord attributes, based on the transition frequency of each of the preset chords under the emotion category and the attribute value interval into which the attribute value of each of the preset chords under the chord attribute falls, the state transition probability between each of the attribute value intervals is determined, and based on the state transition probability between each of the attribute value intervals, the state transfer matrix of the emotion category under the chord attribute is constructed.
4. The method according to claim 1, characterized in that The obtaining of observed transition probabilities of the starting chord to each of the candidate chords includes: Obtaining a first transition probability and a second transition probability of the starting chord transferring to each of the candidate chords; the first transition probability corresponding to each of the candidate chords is used to characterize the probability of the starting chord transferring to the candidate chord when different emotion categories and different chord attributes are distinguished; the second transition probability corresponding to each of the candidate chords is used to characterize the probability of the starting chord transferring to the candidate chord when different emotion categories and different chord attributes are not distinguished; The first transition probability and the second transition probability of each candidate chord are fused to obtain the observed transition probability of the starting chord transferring to each candidate chord.
5. The method according to claim 4, characterized in that The obtaining of a first transition probability of the starting chord to each of the candidate chords includes: Determining the distance between the starting chord and each of the candidate chords based on the attribute values of the starting chord and the attribute values of each of the candidate chords; The first transition probability of the starting chord to each of the candidate chords is determined based on the distance between the starting chord and each of the candidate chords.
6. The method according to claim 5, characterized in that The determining, based on the distance between the starting chord and each of the candidate chords, the first transition probability of the starting chord to each of the candidate chords comprises: Determine the sum of the distances corresponding to the candidate chords; Based on the distance corresponding to each candidate chord and the sum of the distances, the first transition probability of the starting chord transitioning to each candidate chord is obtained.
7. The method according to any one of claims 1 to 6, characterized in that: After determining the subsequent chord of the starting chord from each of the candidate chords, the method further includes: The following steps are as follows: taking the subsequent chord as the new starting chord, returning the attribute values based on the target state transfer matrices and the starting chord, and selecting at least one preset chord from the plurality of preset chords as a candidate chord for the starting chord, until the subsequent chord obtained satisfies a preset chord generation stop condition; The starting chord and the determined subsequent chords form the chord sequence.
8. The method according to any one of claims 1 to 6, characterized in that: The determining the subsequent chord of the starting chord from among the candidate chords based on the observed transition probabilities corresponding to the candidate chords includes: Based on the observed transition probabilities corresponding to the candidate chords, any one of the candidate chords is randomly determined as the subsequent chord among the candidate chords.
9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 8 are implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 8 are implemented.
11. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 8 are implemented.