Chord generation model training method, chord generation method, device and equipment

The neural network model predicts chord sequences and functional sequences, and combines the loss value to determine the chord generation model, which solves the problem of low chord harmony in existing chord generation methods and improves the matching between chords and melody.

CN114970651BActive Publication Date: 2024-10-29BEIJING DAJIA INTERNET INFORMATION TECH CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202110217833.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-02-26
Publication Date
2024-10-29
Estimated Expiration
2041-02-26

AI Technical Summary

Technical Problem

In existing chord generation methods, the generated chords have a low degree of harmony and cannot effectively match the melody.

Method used

By obtaining a set of sample sequences, including melody, tonality, chord sequences and function sequences, use the neural network model to predict the complete chord sequence and function sequence, and determine the model based on the loss value. If the loss value is less than the threshold, it will be generated as a chord Model.

Benefits of technology

The degree of harmony of the chords is improved, and the matching between the chords and the melody is enhanced by considering the influence of the chord function sequence.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114970651B_ABST
    Figure CN114970651B_ABST
Patent Text Reader

Abstract

The present disclosure relates to a training method, a chord generation method, and a device for a chord generation model. The training method for the chord generation model includes: obtaining a sample sequence set; including: a sample melody sequence and a sample tonality sequence, a sample chord sequence, and a sample chord function sequence; inputting the sample sequence set into a neural network model to be trained; the neural network model is used to predict a complete chord sequence and a chord function sequence according to a sample melody sequence, a sample tonality sequence, a sample chord sequence, and a partial sequence position in a sample chord function sequence in the sample sequence set, and output a predicted chord sequence and a predicted chord function sequence; based on the predicted chord sequence and the sample chord sequence, the predicted chord function sequence and the sample chord function sequence, determine the loss value of the current neural network model; if it is less than a preset loss threshold, use the current neural network model as a chord generation model. The present disclosure can improve the harmony of the obtained chords.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the technical field of audio processing, and in particular to a training method for a chord generation model, a chord generation method, a device, an electronic device, and a storage medium. Background Art

[0002] With the development of audio processing technology, a method of generating music by matching melody with chords has emerged. Based on the set melody, appropriate chords can be matched to make the generated music harmonious and pleasant.

[0003] In the related art, the matching of chords and melodies is mostly generated by artificially defined rules, such as artificially defining the rules of melody matching with chords, summarizing chord grammar, or statistically matching the probability of chords relative to melody sounds in the collected audio data. However, the current chord generation method generates chords with low harmony. Summary of the invention

[0004] The present disclosure provides a training method for a chord generation model, a chord generation method, a device, an electronic device, and a storage medium, so as to at least solve the problem that the generated chords in the related art have a low degree of harmony. The technical solution of the present disclosure is as follows:

[0005] In a first aspect, a training method for a chord generation model is provided, comprising:

[0006] Acquire a sample sequence set; the sample sequence set includes: a sample melody sequence and a sample tonality sequence corresponding to a sample melody, a sample chord sequence and a sample chord function sequence corresponding to a sample chord; the sample chord is the chord corresponding to the sample melody; the sample chord function sequence is used to identify the chord function corresponding to the sample chord sequence;

[0007] The sample sequence set is input into a neural network model to be trained; the neural network model is used to predict a complete chord sequence and a complete chord function sequence according to a sample melody sequence, a sample tonality sequence, a partial sequence position in a sample chord sequence, and a partial sequence position in a sample chord function sequence in the sample sequence set, and output a predicted chord sequence and a predicted chord function sequence;

[0008] Determine a loss value of a current neural network model based on the predicted chord sequence and the sample chord sequence, and the predicted chord function sequence and the sample chord function sequence;

[0009] If the loss value is less than a preset loss threshold, the current neural network model is used as a chord generation model.

[0010] In an optional embodiment, the part of the sequence bits is the sequence bits except the last bit;

[0011] The neural network model includes a sequence bit masking layer for performing last bit masking processing on the sample chord sequence and the sample chord function sequence in the input sample sequence set to obtain partial sequence bits in the sample chord sequence and partial sequence bits in the sample chord function sequence.

[0012] In an optional embodiment, the predicting of a complete chord sequence and a complete chord function sequence includes: predicting the last bit of the sample chord sequence and the last bit of the sample chord function sequence based on the sample melody sequence, the sample tonality sequence, and some sequence bits in the sample chord sequence and some sequence bits in the sample chord function sequence; combining some sequence bits in the sample chord sequence with the last bit of the sample chord sequence to obtain the predicted chord sequence, and combining some sequence bits in the sample chord function sequence with the last bit of the sample chord function sequence to obtain the predicted chord function sequence.

[0013] In an optional embodiment, the sample tonality sequence includes: a sample tonic sequence and a sample mode sequence; the predicting the last bit of the sample chord sequence and the last bit of the sample chord function sequence based on the sample melody sequence, the sample tonality sequence, and some sequence bits in the sample chord sequence and some sequence bits in the sample chord function sequence includes: superimposing the sample melody sequence, the sample tonic sequence and the sample mode sequence to obtain a first sample coding sequence; superimposing some sequence bits in the sample chord sequence and some sequence bits in the sample chord function sequence to obtain a second sample coding sequence; generating a corresponding attention vector based on the first sample coding sequence and the second sample coding sequence, decoding the attention vector using the neural network model to obtain the last bit of the sample chord sequence and the last bit of the sample chord function sequence.

[0014] In an optional embodiment, the neural network model includes a first prediction layer and a second prediction layer; the inputting the sample sequence set into the neural network model to be trained includes: inputting the sample melody sequence, the sample tonality sequence, and part of the sequence bits in the sample chord function sequence into the first prediction layer, the first prediction layer is used to predict a complete chord function sequence based on the sample melody sequence, the sample tonality sequence, and part of the sequence bits in the sample chord function sequence, and output the predicted chord function sequence; inputting the predicted chord function sequence and part of the sequence bits in the sample chord sequence into the second prediction layer; the second prediction layer is used to predict a complete chord sequence based on the predicted chord function sequence and part of the sequence bits in the sample chord sequence, and output the predicted chord sequence.

[0015] In an optional embodiment, determining the loss value of the chord generation model includes: obtaining a first loss value between the predicted chord sequence and the sample chord sequence, and obtaining a second loss value between the predicted chord function sequence and the sample chord function sequence; using the sum of the first loss value and the second loss value as the loss value of the chord matching model; or if the first loss value is less than a preset first threshold, and the second loss value is less than a preset second threshold, using the current neural network model as the chord generation model.

[0016] In a second aspect, a chord generation method is provided, comprising:

[0017] For a melody of a chord to be generated, obtaining a melody sequence and a tonality sequence corresponding to the melody;

[0018] Inputting the melody sequence and the tonality sequence into a trained chord generation model, and obtaining a chord sequence corresponding to the melody through the chord generation model; the chord generation model is obtained by the chord generation model training method as described in the first aspect;

[0019] The chord to be generated is generated according to the chord sequence.

[0020] In an optional embodiment, obtaining the melody sequence and tonal sequence corresponding to the melody includes: obtaining the melody characteristics and tonal characteristics of the melody; sampling the melody characteristics and tonal characteristics at a preset sampling frequency to obtain the melody sequence and tonal sequence.

[0021] In a third aspect, a training device for a chord generation model is provided, comprising:

[0022] The sample sequence acquisition unit is configured to execute acquisition of a sample sequence set; the sample sequence set includes: a sample melody sequence and a sample tonality sequence corresponding to a sample melody, a sample chord sequence and a sample chord function sequence corresponding to a sample chord; the sample chord is the chord corresponding to the sample melody; the sample chord function sequence is used to identify the chord function corresponding to the sample chord sequence;

[0023] A network model training unit is configured to execute inputting the sample sequence set into a neural network model to be trained; the neural network model is used to predict a complete chord sequence and a complete chord function sequence according to a sample melody sequence, a sample tonality sequence, a partial sequence position in a sample chord sequence, and a partial sequence position in a sample chord function sequence in the sample sequence set, and output a predicted chord sequence and a predicted chord function sequence;

[0024] A model loss determination unit, configured to determine a loss value of a current neural network model based on the predicted chord sequence and the sample chord sequence, and the predicted chord function sequence and the sample chord function sequence;

[0025] The prediction model acquisition unit is configured to execute, if the loss value is less than a preset loss threshold, using the current neural network model as a chord generation model.

[0026] In an optional embodiment, the partial sequence bits are sequence bits excluding the last bit; the neural network model includes a sequence bit masking layer for performing last bit masking processing on the sample chord sequence and the sample chord function sequence in the input sample sequence set to obtain partial sequence bits in the sample chord sequence and partial sequence bits in the sample chord function sequence.

[0027] In an optional embodiment, the network model training unit is further configured to predict the last bit of the sample chord sequence and the last bit of the sample chord function sequence based on the sample melody sequence, the sample tonality sequence, and some sequence bits in the sample chord sequence and some sequence bits in the sample chord function sequence; combine some sequence bits in the sample chord sequence with the last bit of the sample chord sequence to obtain the predicted chord sequence, and combine some sequence bits in the sample chord function sequence with the last bit of the sample chord function sequence to obtain the predicted chord function sequence.

[0028] In an optional embodiment, the sample tonality sequence includes: a sample tonic sequence and a sample mode sequence; the network model training unit is further configured to execute superposition of the sample melody sequence, the sample tonic sequence and the sample mode sequence to obtain a first sample coding sequence; superposition of some sequence bits in the sample chord sequence and some sequence bits in the sample chord function sequence to obtain a second sample coding sequence; based on the first sample coding sequence and the second sample coding sequence, a corresponding attention vector is generated, and the attention vector is decoded using the neural network model to obtain the last bit of the sample chord sequence and the last bit of the sample chord function sequence.

[0029] In an optional embodiment, the neural network model includes a first prediction layer and a second prediction layer; the network model training unit is further configured to execute inputting the sample melody sequence, the sample tonality sequence, and partial sequence bits in the sample chord function sequence into the first prediction layer, the first prediction layer is used to predict a complete chord function sequence based on the sample melody sequence, the sample tonality sequence, and partial sequence bits in the sample chord function sequence, and output the predicted chord function sequence; inputting the predicted chord function sequence and partial sequence bits in the sample chord sequence into the second prediction layer; the second prediction layer is used to predict a complete chord sequence based on the predicted chord function sequence and partial sequence bits in the sample chord sequence, and output the predicted chord sequence.

[0030] In an optional embodiment, the model loss determination unit is further configured to execute the acquisition of a first loss value between the predicted chord sequence and the sample chord sequence, and the acquisition of a second loss value between the predicted chord function sequence and the sample chord function sequence; using the sum of the first loss value and the second loss value as the loss value of the chord matching model; or is configured to execute if the first loss value is less than a preset first threshold, and the second loss value is less than a preset second threshold, using the current neural network model as the chord generation model.

[0031] In a fourth aspect, a chord generating device is provided, comprising:

[0032] A melody sequence acquisition unit is configured to execute a melody for a chord to be generated, and acquire a melody sequence and a tonality sequence corresponding to the melody;

[0033] a chord sequence acquisition unit, configured to input the melody sequence and the tonality sequence into a trained chord generation model, and obtain a chord sequence corresponding to the melody through the chord generation model; the chord generation model is obtained by the chord generation model training method as described in the first aspect;

[0034] The chord generation unit is configured to generate the to-be-generated chord according to the chord sequence.

[0035] In an optional embodiment, the melody sequence acquisition unit is further configured to execute acquisition of the melody characteristics and the tonality characteristics of the melody; and to sample the melody characteristics and the tonality characteristics at a preset sampling frequency to obtain the melody sequence and the tonality sequence.

[0036] In a fifth aspect, an electronic device is provided, comprising: a processor; and a memory for storing instructions executable by the processor; wherein the processor is configured to execute the instructions to implement the training method of the chord generation model as described in the first aspect, or the chord generation method as described in the second aspect.

[0037] In a sixth aspect, a computer-readable storage medium is provided. When the instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the training method of the chord generation model as described in the first aspect, or the chord generation method as described in the second aspect.

[0038] In a seventh aspect, a computer program product is provided, comprising a computer program, wherein when the computer program is executed by a processor, the training method for the chord generation model as described in the first aspect, or the chord generation method as described in the second aspect is implemented.

[0039] The technical solution provided by the embodiments of the present disclosure brings at least the following beneficial effects:

[0040] By obtaining a sample sequence set; the sample sequence set includes: a sample melody sequence and a sample tonality sequence corresponding to the sample melody, a sample chord sequence and a sample chord function sequence corresponding to the sample chord; the sample chord is the chord corresponding to the sample melody; the sample chord function sequence is used to identify the chord function corresponding to the sample chord sequence; the sample sequence set is input into the neural network model to be trained; the neural network model is used to predict the complete chord sequence and the complete chord function sequence according to the sample melody sequence, the sample tonality sequence, the partial sequence bits in the sample chord sequence and the partial sequence bits in the sample chord function sequence in the sample sequence set, and output the predicted chord sequence and the predicted chord function sequence; based on the predicted chord sequence and the sample chord sequence, and the predicted chord function sequence and the sample chord function sequence, determine the loss value of the current neural network model; if the loss value is less than the preset loss threshold, use the current neural network model as a chord generation model. The chord generation model provided by the present disclosure considers the influence of the chord function sequence in addition to the chord sequence itself during the training process, and can improve the harmony of the obtained chords when the chords are obtained through the chord generation model.

[0041] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS

[0042] The drawings herein are incorporated into and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the description are used to explain the principles of the present disclosure, and do not constitute improper limitations on the present disclosure.

[0043] Figure 1 The figure is a flowchart of a method for training a chord generation model according to an exemplary embodiment.

[0044] Figure 2 is a flowchart showing a method of predicting a complete chord sequence and a chord function sequence according to an exemplary embodiment.

[0045] Figure 3 The figure is a flowchart showing the end of the prediction of a chord sequence and a chord function sequence according to an exemplary embodiment.

[0046] Figure 4 The figure is a flowchart of outputting a predicted chord sequence and a predicted chord function sequence according to an exemplary embodiment.

[0047] Figure 5 The figure is a flow chart of a chord generating method according to an exemplary embodiment.

[0048] Figure 6 is a flow chart of a chord generating method according to another exemplary embodiment.

[0049] Figure 7 It is a schematic diagram of the structure of a sequential neural network according to an exemplary embodiment.

[0050] Figure 8 It is a block diagram of a training device for a chord generation model according to an exemplary embodiment.

[0051] Fig. 9 It is a block diagram of a chord generating device according to an exemplary embodiment.

[0052] Fig.10 The figure is a diagram showing the internal structure of an electronic device according to an exemplary embodiment. DETAILED DESCRIPTION

[0053] In order to enable ordinary persons in the art to better understand the technical solutions of the present disclosure, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the accompanying drawings.

[0054] It should be noted that the terms "first", "second", etc. in the specification and claims of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present disclosure described herein can be implemented in an order other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.

[0055] Figure 1 is a flow chart of a method for training a chord generation model according to an exemplary embodiment. Figure 1 As shown, the training method of the chord generation model is used in the terminal, including the following steps.

[0056] In step S101, the terminal obtains a sample sequence set; the sample sequence set includes: a sample melody sequence and a sample tonality sequence corresponding to the sample melody, a sample chord sequence and a sample chord function sequence corresponding to the sample chord; the sample chord is the chord corresponding to the sample melody; the sample chord function sequence is used to identify the chord function corresponding to the sample chord sequence.

[0057] The terminal may be, but is not limited to, various personal computers, laptops, smart phones, tablet computers, and portable wearable devices, and the sample sequence set may be a set of sample sequences for training a chord generation model, which may include a sample melody sequence and a sample tonality sequence corresponding to a sample melody, and a sample chord sequence and a sample chord function sequence corresponding to a sample chord. The sample melody and sample chord may be obtained by the terminal by reading a preset chord data set, and the chord data set may store a variety of melody files and pre-made chord files corresponding to the melody files, as sample melodies and sample chords, respectively.

[0058] Specifically, the terminal can obtain the stored sample melodies and sample chords through a preset chord data set, and extract the corresponding melody sequence and tonality sequence based on the sample melody, and extract the corresponding chord sequence and chord function sequence based on the sample chord. The chord function sequence is mainly used to identify the function of the chord. For example, the chord functions of different chords can be divided into main chords, dominant chords, and subdominant chords. The method for extracting the sample chord function sequence is that the user identifies the chord sequence according to different chord functions through the terminal. After obtaining the melody sequence and tonality sequence extracted from the sample melody, and the chord sequence and chord function sequence extracted from the sample chord, the terminal can store the obtained sequences to form a sample sequence set.

[0059] In step S102, the terminal inputs the sample sequence set into the neural network model to be trained; the neural network model is used to predict a complete chord sequence and a complete chord function sequence based on the sample melody sequence, the sample tonality sequence, the partial sequence positions in the sample chord sequence, and the partial sequence positions in the sample chord function sequence in the sample sequence set, and output the predicted chord sequence and the predicted chord function sequence.

[0060] The partial sequence bits in the sample chord sequence refer to a portion of the sequence bits in the complete sample chord sequence, while the partial sequence bits in the sample chord function sequence refer to a portion of the sequence bits in the complete sample function chord sequence. Since the sample chord sequence and the sample function chord sequence input to the neural network model may include multiple sequence bits, the terminal can extract any number of sequence bits from the sample chord sequence and the sample function chord sequence of multiple sequence bits as the partial sequence bits in the sample chord sequence and the partial sequence bits in the sample chord function sequence. The provided neural network model is mainly used to predict the corresponding chord sequence and chord function sequence based on the partial sequence bits and the input sample melody sequence and the sample tonality sequence, that is, the predicted chord sequence and the predicted chord function sequence are used as the output of the neural network model.

[0061] For example, the input complete sample chord sequence may include 3 sequence bits, which may be sequence bit A, sequence bit B and sequence bit C. After the terminal inputs the complete sample chord sequence into the neural network model, the sequence bits of the complete sample chord sequence may be extracted, which may be to extract only the first two sequence bits of the complete sample chord sequence, i.e., sequence bit A and sequence bit B, as partial sequence bits in the sample chord sequence. Afterwards, the terminal may use the sample melody sequence, the sample tonality sequence, and the partial sequence bits in the obtained sample chord sequence, i.e., sequence bit A and sequence bit B, to predict the complete chord sequence, i.e., to predict the last bit of the chord sequence, thereby obtaining the final predicted chord sequence. The prediction principle of the predicted chord function sequence is similar to the principle of obtaining the predicted chord sequence, by extracting partial sequence bits of the sample chord function sequence, and using the obtained partial sequence bits as well as the sample melody sequence and the sample tonality sequence to predict the complete chord function sequence as the predicted chord function sequence.

[0062] In step S103, the terminal determines the loss value of the current neural network model based on the predicted chord sequence and the sample chord sequence, and the predicted chord function sequence and the sample chord function sequence;

[0063] In step S104, if the loss value is less than a preset loss threshold, the terminal uses the current neural network model as a chord generation model.

[0064] Since the predicted chord sequence and the predicted chord function sequence output by the neural network model may not be the correct sample chord sequence and the sample chord function sequence, the terminal can respectively determine the loss value of the current neural network model based on the difference loss between the predicted chord sequence and the sample chord sequence, and based on the difference loss between the predicted chord function sequence and the sample chord function sequence. The difference loss can be the proportion of the incorrectly predicted chord sequence or chord function sequence to the total chord sequence or chord function sequence. The terminal can determine the loss value of the current neural network model based on the two difference losses obtained. If the loss value is less than a loss threshold preset by the terminal, the terminal can use the currently used neural network model as the final chord generation model. If the loss value is greater than the set loss threshold, the terminal needs to further train the neural network model until the loss value obtained is less than the set loss threshold.

[0065] In the training method of the chord generation model, the terminal obtains a sample sequence set; the sample sequence set includes: a sample melody sequence and a sample tonality sequence corresponding to the sample melody, a sample chord sequence and a sample chord function sequence corresponding to the sample chord; the sample chord is the chord corresponding to the sample melody; the sample chord function sequence is used to identify the chord function corresponding to the sample chord sequence; the sample sequence set is input into the neural network model to be trained; the neural network model is used to predict the complete chord sequence and the complete chord function sequence according to the sample melody sequence, the sample tonality sequence, the partial sequence bits in the sample chord sequence and the partial sequence bits in the sample chord function sequence in the sample sequence set, and output the predicted chord sequence and the predicted chord function sequence; based on the predicted chord sequence and the sample chord sequence, and the predicted chord function sequence and the sample chord function sequence, determine the loss value of the current neural network model; if the loss value is less than the preset loss threshold, use the current neural network model as the chord generation model. The chord generation model provided by the present disclosure considers the influence of the chord function sequence in addition to the chord sequence itself during the training process, and can improve the harmony of the obtained chord when the chord is obtained through the chord generation model.

[0066] In an exemplary embodiment, some sequence bits are sequence bits except the last bit; the neural network model includes a sequence bit masking layer, which is used to perform last bit masking processing on the sample chord sequence and the sample chord function sequence in the input sample sequence set to obtain some sequence bits in the sample chord sequence and some sequence bits in the sample chord function sequence.

[0067] In this embodiment, partial sequence bits refer to the sequence bits other than the last sequence bit in the sequence, that is, the last bit. The neural network model provided in this embodiment carries a sequence bit masking layer for masking the last sequence bit of the input sample chord sequence and the sample chord function sequence. After the terminal inputs the sample sequence set into the neural network model, the neural network model can use the sequence bit masking layer to mask the last sequence bit of the sample chord sequence and the sample chord function sequence in the input sample sequence set, thereby obtaining partial sequence bits in the above-mentioned sample chord sequence and partial sequence bits in the sample chord function sequence.

[0068] Furthermore, if Figure 2 As shown, step S102 may further include:

[0069] In step S201, the terminal predicts the last position of the chord sequence and the last position of the sample chord function sequence based on the sample melody sequence, the sample tonality sequence, and some sequence positions in the sample chord sequence and some sequence positions in the sample chord function sequence.

[0070] After the neural network model obtains part of the sequence bits in the sample chord sequence and part of the sequence bits in the sample chord function sequence through the sequence bit masking layer, the terminal can use the sample melody sequence and the sample tonality sequence input into the neural network model, and part of the sequence bits in the sample chord sequence and part of the sequence bits in the sample chord function sequence to predict the last bits of the sample chord sequence and the sample chord function sequence respectively.

[0071] In step S202, the terminal combines some sequence bits in the sample chord sequence with the last bit of the sample chord sequence to obtain a predicted chord sequence, and combines some sequence bits in the sample chord function sequence with the last bit of the sample chord function sequence to obtain a predicted chord function sequence.

[0072] After the terminal obtains the prediction results of the last bits of the sample chord sequence and the sample chord function sequence in step S201, the terminal can combine the prediction results with some sequence bits in the sample chord sequence and some sequence bits in the sample chord function sequence, so as to obtain the predicted chord sequence and the predicted chord function sequence respectively.

[0073] For example, for a sample chord sequence including sequence bit A, sequence bit B, and sequence bit C, the terminal can use part of the sequence bits in the sample chord sequence, i.e., sequence bit A and sequence bit B, as well as the sample melody sequence and the sample tonality sequence to predict the last bit of the sample chord sequence, and the prediction result may be sequence bit D. After that, the terminal can combine part of the sequence bits in the sample chord sequence and the last bit of the predicted sample chord sequence, i.e., form a chord sequence of sequence bit A, sequence bit B, and sequence bit D as the predicted chord sequence. Similarly, the last bit of the sample chord function sequence can be predicted in the same way, and part of the sequence bits in the sample chord function sequence and the last bit of the predicted sample chord function sequence can be combined to obtain the final predicted chord function sequence.

[0074] Furthermore, the sample tonality sequence may include: a sample tonic sequence and a sample mode sequence; Figure 3 As shown, step S201 can be further implemented by the following steps:

[0075] In step S301, the terminal superimposes a sample melody sequence, a sample tonic sequence, and a sample mode sequence to obtain a first sample coding sequence.

[0076] Among them, tonality refers to the general term for the tonic and mode category of the key, which can include the tonic height and the mode category, so the tonality sequence is generally composed of the tonic sequence and the mode sequence. After the terminal inputs the sample sequence set into the neural network model, the neural network model can extract the corresponding sample tonic sequence and sample mode sequence from the input sample tonality sequence, and then superimpose the sample tonic sequence and the sample mode sequence with the sample melody sequence to form a coding sequence corresponding to the sample melody as the first sample coding sequence.

[0077] In step S302, the terminal superimposes part of the sequence bits in the sample chord sequence and part of the sequence bits in the sample chord function sequence to obtain a second sample coding sequence.

[0078] Similarly, the terminal may also superimpose some sequence bits in the sample chord sequence obtained through the sequence bit masking layer of the neural network model and some sequence bits in the sample chord function sequence, so as to obtain a coding sequence corresponding to the sample chord as a second sample coding sequence.

[0079] In step S303, the terminal generates a corresponding attention vector based on the first sample coding sequence and the second sample coding sequence, and decodes the attention vector using a neural network model to obtain the last bit of the sample chord sequence and the last bit of the sample chord function sequence.

[0080] Among them, the attention vector is mainly used to solve the structural problem of the melody by paying attention to the information before and after the sequence. Therefore, in this embodiment, a serialization model including an attention mechanism is adopted as a neural network model. The neural network model can convert the input melody-related sequence into a chord-related sequence in a manner similar to machine translation. The attention vector used in the translation process is composed of the first sample coding sequence obtained in step S301 and the second sample coding sequence in step S302.

[0081] Specifically, the terminal can combine the first sample coding sequence with the second sample coding sequence to generate an attention vector for decoding processing, and then use the decoder of the neural network model to decode the obtained attention vector to obtain the last bit of the sample chord sequence and the last bit of the sample chord function sequence, respectively.

[0082] In the above embodiment, the terminal can mask the last bit of the sample chord sequence and the sample chord function sequence through a sequence bit masking layer, and can use part of the sequence bits in the sample chord sequence and part of the sequence bits in the sample chord function sequence obtained after the masking process as a part of the attention vector formed by the model input. When decoding, the attention vector formed by the part of the sequence bits of the sample chord sequence and the sample chord function sequence can be considered to achieve the prediction of the last bit, which can solve the structural problem of long melodies and improve the structural neatness of the generated chords, thereby improving the matching degree between the chords and the melody generated by the chord generation model.

[0083] In an exemplary embodiment, the neural network model includes a first prediction layer and a second prediction layer; Figure 4 As shown, step S102 may further include:

[0084] In step S401, the terminal inputs a portion of sequence bits in a sample melody sequence, a sample tonality sequence, and a sample chord function sequence into a first prediction layer, and the first prediction layer is used to predict a complete chord function sequence based on the portion of sequence bits in the sample melody sequence, the sample tonality sequence, and the sample chord function sequence, and output a predicted chord function sequence.

[0085] In this embodiment, the neural network model can be composed of two prediction layers, namely a first prediction layer and a second prediction layer, which can be used to predict and output a predicted chord function sequence and a predicted chord sequence, respectively. Specifically, after the terminal obtains the sample sequence set in step S101, it can first input the sample melody sequence, the sample tonality sequence, and part of the sequence positions of the sample chord function sequence in the sample sequence set into the first prediction layer, and predict the complete chord function sequence through the first prediction layer, thereby obtaining a predicted chord function sequence and outputting the predicted chord function sequence.

[0086] In step S402, the terminal inputs the predicted chord function sequence and part of the sequence bits in the sample chord sequence into the second prediction layer; the second prediction layer is used to predict the complete chord sequence based on the predicted chord function sequence and part of the sequence bits in the sample chord sequence, and output the predicted chord sequence.

[0087] After the terminal obtains the predicted chord function sequence in step S401, the terminal can input the obtained predicted chord function sequence and part of the sequence bits in the sample chord sequence into the second prediction layer, and predict the complete chord sequence through the second prediction layer, thereby obtaining the predicted chord sequence and outputting the predicted chord sequence.

[0088] In this embodiment, the neural network model used may include two prediction layers, wherein the first prediction layer is used to obtain a predicted chord function sequence based on an input sample melody sequence and a sample tonality sequence, and the second prediction layer may obtain a predicted chord sequence based on the predicted chord function sequence. This embodiment predicts the predicted chord sequence by predicting the chord function sequence, and may further consider the influence of the chord function sequence on the chord sequence, thereby further improving the harmony of the obtained chords when obtaining chords through the chord generation model.

[0089] In an exemplary embodiment, step S103 may further include: the terminal obtains a first loss value of the predicted chord sequence and the sample chord sequence, and obtains a second loss value of the predicted chord function sequence and the sample chord function sequence; and uses the sum of the first loss value and the second loss value as the loss value of the chord matching model.

[0090] Among them, the first loss value refers to the loss value between the predicted chord sequence obtained by the neural network model and the sample chord sequence, and the second loss value refers to the loss value between the predicted chord function sequence obtained by the neural network model and the sample chord function sequence. Specifically, the terminal can calculate the first loss value and the second loss value respectively, and sum the obtained first loss value and the second loss value, and use the sum of the obtained first loss value and the second loss value as the loss value of the neural network model currently used. Only when the loss value is less than the pre-set loss threshold, the terminal will use the current neural network model as the chord generation model.

[0091] In addition, after obtaining the first loss value and the second loss value, the terminal can also compare the first loss value and the second loss value with two pre-set loss thresholds respectively. Only when the first loss value is less than the pre-set first threshold and the second loss value is also less than the pre-set second threshold, the terminal will use the current neural network model as a chord generation model.

[0092] In this embodiment, the loss value of the neural network model is determined by calculating the first loss value of the predicted chord sequence and the sample chord sequence and the second loss value of the predicted chord function sequence and the sample chord function sequence, respectively. At the same time, the first loss value and the first threshold value, and the second loss value and the second threshold value can also be compared respectively. Only when the first loss value is less than the preset first threshold value, and the second loss value is less than the preset second threshold value, the terminal will use the current neural network model as the chord generation model, which can simultaneously ensure the accuracy of the obtained chord sequence and the chord function sequence, thereby further improving the accuracy of the obtained chord generation model. The neural network model obtained by this implementation can ensure through the loss value that when the neural network model is used as a chord generation model to predict chords, the obtained chord sequence will be constrained by the chord function sequence at the same time, thereby further improving the harmony of the obtained chords.

[0093] Figure 5 is a flow chart of a chord generation method according to an exemplary embodiment. Figure 5 As shown, chord generation is used in the terminal, including the following steps.

[0094] In step S501, the terminal obtains a melody sequence and a tonality sequence corresponding to the melody of the chord to be generated.

[0095] The chord to be generated refers to the chord that needs to be generated by the chord generation model, and the chord can be used to match the corresponding melody. When the terminal obtains a melody that needs to generate a chord, it can first extract a melody sequence and a tonality sequence corresponding to the melody according to the melody.

[0096] In step S502, the terminal inputs the melody sequence and the tonality sequence into the trained chord generation model, and obtains the chord sequence corresponding to the melody through the chord generation model; the chord generation model is obtained by the chord generation model training method as described in any of the above embodiments;

[0097] In step S503, the terminal generates a chord to be generated according to the chord sequence.

[0098] Specifically, after obtaining the melody sequence and tonal sequence of the melody in step S501, the terminal can input the obtained melody sequence and tonal sequence into the chord generation model obtained in advance by the chord generation model training method used in the above embodiment, and the model outputs a chord sequence corresponding to the input melody sequence and tonal sequence. Finally, the terminal can generate the chords to be generated corresponding to the melody based on the obtained chord sequence.

[0099] In the above chord generation method, the terminal obtains a melody sequence and a tonality sequence corresponding to the melody of the chord to be generated; inputs the melody sequence and the tonality sequence into a trained chord generation model, and obtains the chord sequence corresponding to the melody through the chord generation model; the chord generation model is obtained through the chord generation model training method as described in any of the above embodiments; and the chord to be generated is generated according to the chord sequence. In the chord generation method provided by the present disclosure, the terminal can generate corresponding chords through the chord generation model obtained by the chord generation model training method as described in any of the above embodiments. Because the chord generation model considers the influence of the chord function sequence in addition to the chord sequence itself during the training process, the harmony of the obtained chords can be improved when the chords are obtained through the chord generation model.

[0100] In an exemplary embodiment, step S501 may further include: the terminal obtains the melody characteristics and the tonality characteristics of the melody; and samples the melody characteristics and the tonality characteristics according to a preset sampling frequency to obtain a melody sequence and a tonality sequence.

[0101] Specifically, after the terminal obtains the melody that needs to generate chords, it can extract the corresponding melody, tonic and mode based on the melody, and use the tonic and mode as the tonal features of the melody. After that, sampling can be performed, for example, sampling each beat in each 4 / 4 measure, to obtain a melody sequence and a tonal sequence respectively.

[0102] In this embodiment, the terminal can obtain the melody sequence and tonality sequence corresponding to the melody by sampling. By serializing the melody, the matching degree of the chord sequence and the melody sequence can be improved. When generating music, the harmony of the generated music can be further improved by sequence matching.

[0103] In an exemplary embodiment, a chord generation method is also provided, such as Figure 6 As shown, Figure 6 The invention is a flow chart of a chord generation method according to an exemplary embodiment. The chord generation is used in a terminal and includes the following steps.

[0104] In step S601, the terminal obtains a sample sequence set; the sample sequence set includes: a sample melody sequence corresponding to the sample melody, a sample tonic sequence and a sample mode sequence, a sample chord sequence corresponding to the sample chord and a sample chord function sequence; the sample chord is the chord corresponding to the sample melody; the sample chord function sequence is used to identify the chord function corresponding to the sample chord sequence;

[0105] In step S602, the terminal inputs the sample sequence set into the neural network model to be trained; the neural network model includes a sequence bit masking layer, which is used to perform a last bit masking process on the sample chord sequence and the sample chord function sequence in the input sample sequence set to obtain a part of the sequence bits in the sample chord sequence and a part of the sequence bits in the sample chord function sequence;

[0106] In step S603, the terminal superimposes the sample melody sequence, the sample tonic sequence and the sample mode sequence to obtain a first sample coding sequence; superimposes part of the sequence bits in the sample chord sequence and part of the sequence bits in the sample chord function sequence to obtain a second sample coding sequence;

[0107] In step S604, the terminal generates a corresponding attention vector based on the first sample coding sequence and the second sample coding sequence, and decodes the attention vector using a neural network model to obtain the last bit of the sample chord sequence and the last bit of the sample chord function sequence;

[0108] In step S605, the terminal combines part of the sequence bits in the sample chord sequence with the last bit of the sample chord sequence to obtain a predicted chord sequence, and combines part of the sequence bits in the sample chord function sequence with the last bit of the sample chord function sequence to obtain a predicted chord function sequence;

[0109] In step S606, the terminal obtains a first loss value of the predicted chord sequence and the sample chord sequence, and obtains a second loss value of the predicted chord function sequence and the sample chord function sequence; and uses the sum of the first loss value and the second loss value as the loss value of the chord matching model;

[0110] In step S607, if the loss value is less than the preset loss threshold, the terminal uses the current neural network model as the chord generation model;

[0111] In step S608, the terminal obtains the melody characteristics and the tonality characteristics of the melody; samples the melody characteristics and the tonality characteristics according to a preset sampling frequency to obtain a melody sequence and a tonality sequence;

[0112] In step S609, the terminal inputs the melody sequence and the tonality sequence into the trained chord generation model, obtains the chord sequence corresponding to the melody through the chord generation model, and generates the chord to be generated according to the chord sequence.

[0113] In the above chord generation method, in addition to considering the chord sequence itself, the terminal also considers the influence of the chord function sequence during the training of the chord generation model, and can improve the harmony of the obtained chords when obtaining the chords through the chord generation model. In addition, the terminal can mask the last bit of the sample chord sequence and the sample chord function sequence through the sequence bit masking layer, and can also use part of the sequence bits in the sample chord sequence and part of the sequence bits in the sample chord function sequence obtained after the masking process as part of the model input to form an attention vector. When decoding, the attention vector formed by considering part of the sequence bits of the sample chord sequence and the sample chord function sequence can be used to predict the last bit, which can solve the structural problem of long-term melody, make the matching chord structure neat, and improve the matching degree of the generated chord and melody. Finally. The terminal can obtain the melody sequence and tonality sequence corresponding to the melody by sampling, and can improve the matching degree of the chord sequence and the melody sequence by serializing the melody. When generating music, the harmony of the generated music can be further improved by sequence matching.

[0114] In an exemplary embodiment, a chord generation method is also provided. The method can combine tonality and chord functions and use a sequence neural network to generate chords. The network structure of the sequence neural network used can be as follows: Figure 7 As shown, the method may include the following steps:

[0115] 1. Training corpus preparation: Prepare training and test sets: including information: tonality, melody pitch (e.g. C4), chord symbol (e.g. Dm). For MIDI and Music XML file formats, use the music21 toolkit to extract sequences.

[0116] Sequencing: Sampling is performed on each beat of each 4 / 4 measure, that is, four tokens per measure, and the maximum length of the model is 240. The sequences include: tonality sequence, including tonic sequence and mode sequence; chord function sequence, which marks the chord progressions of tonic (T), dominant (D), subdominant (SD), and non-tonic (N), and generates chord function sequence. The final sequences used are: tonic sequence, mode sequence, melody sequence, chord sequence, and function sequence.

[0117] 2. Model training: Based on the transformer model, add the superposition of the tonic sequence, mode sequence, and melody sequence representation to the encoder input, and then output the superposition of the chord sequence and function sequence in the decoder. Train the end-to-end melody and chord model. During training, the loss function is the sum of the output chord and output function losses.

[0118] 3. Model reasoning: Given a melody, tonic, and tonality sequence, concatenate them to generate a coding sequence. Input the coding sequence into the model, and based on the previous prediction results, cyclically predict two sequences: chord sequence and chord function sequence. Combine the melody and chords to generate a complete piece of music.

[0119] This embodiment uses the Transformer model, a serialization model that includes an attention mechanism, and serializes the melody and chords, analogous to translation, to complete the task of matching melody with chords. This model can effectively solve the melody structural problem by paying attention to the information before and after the sequence, so that the structure of the matching chord sequence is neat and consistent with the development of the melody phrase. At the same time, the tonality information and chord function information are extracted into a sequence, which improves the harmony of the generated matching chord sequence.

[0120] It should be understood that although Figure 1-6 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, Figure 1-6 At least part of the steps may include multiple steps or multiple stages. These steps or stages are not necessarily performed at the same time, but can be performed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed in turn or alternately with other steps or at least part of the steps or stages in other steps.

[0121] Figure 8 FIG. 1 is a block diagram of a training device for a chord generation model according to an exemplary embodiment. Figure 8 The device includes a sample sequence acquisition unit 801, a network model training unit 802, a model loss determination unit 803 and a prediction model acquisition unit 804.

[0122] The sample sequence acquisition unit 801 is configured to execute acquisition of a sample sequence set; the sample sequence set includes: a sample melody sequence and a sample tonality sequence corresponding to the sample melody, a sample chord sequence and a sample chord function sequence corresponding to the sample chord; the sample chord is the chord corresponding to the sample melody; the sample chord function sequence is used to identify the chord function corresponding to the sample chord sequence;

[0123] The network model training unit 802 is configured to execute inputting the sample sequence set into the neural network model to be trained; the neural network model is used to predict the complete chord sequence and the complete chord function sequence according to the sample melody sequence, the sample tonality sequence, the partial sequence bits in the sample chord sequence, and the partial sequence bits in the sample chord function sequence in the sample sequence set, and output the predicted chord sequence and the predicted chord function sequence;

[0124] The model loss determination unit 803 is configured to determine the loss value of the current neural network model based on the predicted chord sequence and the sample chord sequence, and the predicted chord function sequence and the sample chord function sequence;

[0125] The prediction model acquisition unit 804 is configured to execute if the loss value is less than a preset loss threshold, using the current neural network model as a chord generation model.

[0126] In an exemplary embodiment, some sequence bits are sequence bits except the last bit; the neural network model includes a sequence bit masking layer, which is used to perform last bit masking processing on the sample chord sequence and the sample chord function sequence in the input sample sequence set to obtain some sequence bits in the sample chord sequence and some sequence bits in the sample chord function sequence.

[0127] In an exemplary embodiment, the network model training unit 802 is further configured to predict the last bit of the sample chord sequence and the last bit of the sample chord function sequence based on the sample melody sequence, the sample tonality sequence, and some sequence bits in the sample chord sequence and some sequence bits in the sample chord function sequence; combine some sequence bits in the sample chord sequence with the last bit of the sample chord sequence to obtain a predicted chord sequence, and combine some sequence bits in the sample chord function sequence with the last bit of the sample chord function sequence to obtain a predicted chord function sequence.

[0128] In an exemplary embodiment, the sample tonality sequence includes: a sample tonic sequence and a sample mode sequence; the network model training unit 802 is further configured to perform superposition of the sample melody sequence, the sample tonic sequence and the sample mode sequence to obtain a first sample coding sequence; superposition of some sequence bits in the sample chord sequence and some sequence bits in the sample chord function sequence to obtain a second sample coding sequence; based on the first sample coding sequence and the second sample coding sequence, a corresponding attention vector is generated, and the attention vector is decoded using a neural network model to obtain the last bit of the sample chord sequence and the last bit of the sample chord function sequence.

[0129] In an exemplary embodiment, the neural network model includes a first prediction layer and a second prediction layer; the network model training unit 802 is further configured to execute inputting a sample melody sequence, a sample tonality sequence, and a partial sequence bit in a sample chord function sequence into the first prediction layer, the first prediction layer is used to predict a complete chord function sequence based on the sample melody sequence, the sample tonality sequence, and the partial sequence bit in the sample chord function sequence, and output the predicted chord function sequence; inputting the predicted chord function sequence and the partial sequence bit in the sample chord sequence into the second prediction layer; the second prediction layer is used to predict a complete chord sequence based on the predicted chord function sequence and the partial sequence bit in the sample chord sequence, and output the predicted chord sequence.

[0130] In an exemplary embodiment, the model loss determination unit 803 is further configured to execute the acquisition of a first loss value between a predicted chord sequence and a sample chord sequence, and the acquisition of a second loss value between a predicted chord function sequence and a sample chord function sequence; using the sum of the first loss value and the second loss value as the loss value of the chord matching model; or is configured to execute if the first loss value is less than a preset first threshold, and the second loss value is less than a preset second threshold, then using the current neural network model as a chord generation model.

[0131] Fig. 9 is a block diagram of a chord generating device according to an exemplary embodiment. Fig. 9 The device includes a melody sequence acquisition unit 901, a chord sequence acquisition unit 902 and a chord generation unit 903.

[0132] A melody sequence acquisition unit 901 is configured to execute a melody for a chord to be generated, and acquire a melody sequence and a tonality sequence corresponding to the melody;

[0133] The chord sequence acquisition unit 902 is configured to input the melody sequence and the tonality sequence into a trained chord generation model, and obtain the chord sequence corresponding to the melody through the chord generation model; the chord generation model is obtained by the chord generation model training method as described in any of the above embodiments;

[0134] The chord generation unit 903 is configured to generate a chord to be generated according to the chord sequence.

[0135] In an exemplary embodiment, the melody sequence acquisition unit 901 is further configured to acquire the melody features and tonality features of the melody; sample the melody features and tonality features at a preset sampling frequency to obtain the melody sequence and tonality sequence.

[0136] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.

[0137] Fig.10 1 is a block diagram of a device 1000 for training a chord generation model or for generating chords according to an exemplary embodiment. For example, the device 1000 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, etc.

[0138] Reference Fig.10 , device 1000 may include one or more of the following components: a processing component 1002 , a memory 1004 , a power component 1006 , a multimedia component 1008 , an audio component 1010 , an input / output (I / O) interface 1012 , a sensor component 1014 , and a communication component 1016 .

[0139] The processing component 1002 generally controls the overall operation of the device 1000, such as operations associated with display, phone calls, data communications, camera operations, and recording operations. The processing component 1002 may include one or more processors 1020 to execute instructions to complete all or part of the steps of the above-mentioned method. In addition, the processing component 1002 may include one or more modules to facilitate the interaction between the processing component 1002 and other components. For example, the processing component 1002 may include a multimedia module to facilitate the interaction between the multimedia component 1008 and the processing component 1002.

[0140] The memory 1004 is configured to store various types of data to support operations on the device 1000. Examples of such data include instructions for any application or method operating on the device 1000, contact data, phone book data, messages, pictures, videos, etc. The memory 1004 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk, or optical disk.

[0141] The power supply component 1006 provides power to the various components of the device 1000. The power supply component 1006 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power for the device 1000.

[0142] The multimedia component 1008 includes a screen that provides an output interface between the device 1000 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundaries of the touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 1008 includes a front camera and / or a rear camera. When the device 1000 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera may receive external multimedia data. Each front camera and the rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.

[0143] The audio component 1010 is configured to output and / or input audio signals. For example, the audio component 1010 includes a microphone (MIC), and when the device 1000 is in an operating mode, such as a call mode, a recording mode, and a speech recognition mode, the microphone is configured to receive an external audio signal. The received audio signal can be further stored in the memory 1004 or sent via the communication component 1016. In some embodiments, the audio component 1010 also includes a speaker for outputting audio signals.

[0144] I / O interface 1012 provides an interface between processing component 1002 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include but are not limited to: home button, volume button, start button, and lock button.

[0145] The sensor assembly 1014 includes one or more sensors for providing various aspects of status assessment for the device 1000. For example, the sensor assembly 1014 can detect the open / closed state of the device 1000, the relative positioning of components, such as the display and keypad of the device 1000, and the sensor assembly 1014 can also detect the position change of the device 1000 or a component of the device 1000, the presence or absence of user contact with the device 1000, the orientation or acceleration / deceleration of the device 1000, and the temperature change of the device 1000. The sensor assembly 1014 may include a proximity sensor configured to detect the presence of nearby objects without any physical contact. The sensor assembly 1014 may also include an optical sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 1014 may also include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.

[0146] The communication component 1016 is configured to facilitate wired or wireless communication between the device 1000 and other devices. The device 1000 can access a wireless network based on a communication standard, such as WiFi, a carrier network (such as 2G, 3G, 4G or 5G), or a combination thereof. In an exemplary embodiment, the communication component 1016 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 1016 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.

[0147] In an exemplary embodiment, the device 1000 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to perform the above methods.

[0148] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 1004 including instructions, and the instructions can be executed by the processor 1020 of the device 1000 to perform the above method. For example, the non-transitory computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.

[0149] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. The present disclosure is intended to cover any variations, uses or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The description and examples are to be considered exemplary only, and the true scope and spirit of the present disclosure are indicated by the following claims.

[0150] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.

Claims

1. A training method for a chord generation model, characterized in that: include: Get a sample sequence set; The sample sequence set includes: a sample melody sequence and a sample tonality sequence corresponding to a sample melody, a sample chord sequence and a sample chord function sequence corresponding to a sample chord; the sample chord is the chord corresponding to the sample melody; the sample chord function sequence is used to identify the chord function corresponding to the sample chord sequence; the chord function includes: at least one of a tonic chord, a dominant chord and a subdominant chord; The sample sequence set is input into a neural network model to be trained; the neural network model is used to predict a complete chord sequence and a complete chord function sequence according to a sample melody sequence, a sample tonality sequence, a partial sequence position in a sample chord sequence, and a partial sequence position in a sample chord function sequence in the sample sequence set, and output a predicted chord sequence and a predicted chord function sequence; Determine a loss value of a current neural network model based on the predicted chord sequence and the sample chord sequence, and the predicted chord function sequence and the sample chord function sequence; If the loss value is less than a preset loss threshold, the current neural network model is used as a chord generation model; The partial sequence bits are sequence bits except the last bit; the neural network model includes a sequence bit masking layer, which is used to perform last bit masking processing on the sample chord sequence and the sample chord function sequence in the input sample sequence set to obtain partial sequence bits in the sample chord sequence and partial sequence bits in the sample chord function sequence; The predicted complete chord sequence and complete chord function sequence include: Based on the sample melody sequence, the sample tonality sequence, and some sequence positions in the sample chord sequence and some sequence positions in the sample chord function sequence, predict the end position of the sample chord sequence and the end position of the sample chord function sequence; The predicted chord sequence is obtained by combining some sequence bits in the sample chord sequence with the last bit of the sample chord sequence, and the predicted chord function sequence is obtained by combining some sequence bits in the sample chord function sequence with the last bit of the sample chord function sequence.

2. The method according to claim 1, characterized in that The sample tonality sequence includes: a sample tonic sequence and a sample mode sequence; The predicting of the last position of the sample chord sequence and the last position of the sample chord function sequence based on the sample melody sequence, the sample tonality sequence, and some sequence positions in the sample chord sequence and some sequence positions in the sample chord function sequence comprises: Superimposing the sample melody sequence, the sample tonic sequence and the sample mode sequence to obtain a first sample coding sequence; Superimposing some sequence bits in the sample chord sequence and some sequence bits in the sample chord function sequence to obtain a second sample coding sequence; A corresponding attention vector is generated based on the first sample coding sequence and the second sample coding sequence, and the attention vector is decoded using the neural network model to obtain the last bit of the sample chord sequence and the last bit of the sample chord function sequence.

3. The method according to claim 1, characterized in that The neural network model includes a first prediction layer and a second prediction layer; the step of inputting the sample sequence set into the neural network model to be trained includes: Inputting the sample melody sequence, the sample tonality sequence, and part of the sequence bits in the sample chord function sequence into the first prediction layer, the first prediction layer being used to predict a complete chord function sequence based on the sample melody sequence, the sample tonality sequence, and part of the sequence bits in the sample chord function sequence, and outputting the predicted chord function sequence; The predicted chord function sequence and part of the sequence bits in the sample chord sequence are input into the second prediction layer; the second prediction layer is used to predict a complete chord sequence based on the predicted chord function sequence and part of the sequence bits in the sample chord sequence, and output the predicted chord sequence.

4. The method according to any one of claims 1 to 3, characterized in that: Determining the loss value of the current neural network model includes: Obtaining a first loss value between the predicted chord sequence and the sample chord sequence, and obtaining a second loss value between the predicted chord function sequence and the sample chord function sequence; Taking the sum of the first loss value and the second loss value as the loss value of the current neural network model; or If the first loss value is less than a preset first threshold value, and the second loss value is less than a preset second threshold value, the current neural network model is used as the chord generation model.

5. A chord generation method, characterized in that: include: For a melody of a chord to be generated, obtaining a melody sequence and a tonality sequence corresponding to the melody; Inputting the melody sequence and the tonality sequence into a trained chord generation model, and obtaining a chord sequence corresponding to the melody through the chord generation model; the chord generation model is obtained by the chord generation model training method according to any one of claims 1 to 4; The chord to be generated is generated according to the chord sequence.

6. The method according to claim 5, characterized in that The obtaining of a melody sequence and a tonality sequence corresponding to the melody includes: Acquiring melodic features and tonality features of the melody; The melody feature and the tonality feature are sampled according to a preset sampling frequency to obtain the melody sequence and the tonality sequence.

7. A training device for a chord generation model, characterized in that: include: A sample sequence acquisition unit, configured to execute acquisition of a sample sequence set; The sample sequence set includes: a sample melody sequence and a sample tonality sequence corresponding to a sample melody, a sample chord sequence and a sample chord function sequence corresponding to a sample chord; the sample chord is the chord corresponding to the sample melody; the sample chord function sequence is used to identify the chord function corresponding to the sample chord sequence; the chord function includes: at least one of a tonic chord, a dominant chord and a subdominant chord; A network model training unit is configured to execute inputting the sample sequence set into a neural network model to be trained; the neural network model is used to predict a complete chord sequence and a complete chord function sequence according to a sample melody sequence, a sample tonality sequence, a partial sequence position in a sample chord sequence, and a partial sequence position in a sample chord function sequence in the sample sequence set, and output a predicted chord sequence and a predicted chord function sequence; A model loss determination unit, configured to determine a loss value of a current neural network model based on the predicted chord sequence and the sample chord sequence, and the predicted chord function sequence and the sample chord function sequence; A prediction model acquisition unit, configured to execute, if the loss value is less than a preset loss threshold, using the current neural network model as a chord generation model; The partial sequence bits are sequence bits except the last bit; the neural network model includes a sequence bit masking layer, which is used to perform last bit masking processing on the sample chord sequence and the sample chord function sequence in the input sample sequence set to obtain partial sequence bits in the sample chord sequence and partial sequence bits in the sample chord function sequence; The network model training unit is further configured to predict the last bit of the sample chord sequence and the last bit of the sample chord function sequence based on the sample melody sequence, the sample tonality sequence, and some sequence bits in the sample chord sequence and some sequence bits in the sample chord function sequence; combine some sequence bits in the sample chord sequence with the last bit of the sample chord sequence to obtain the predicted chord sequence, and combine some sequence bits in the sample chord function sequence with the last bit of the sample chord function sequence to obtain the predicted chord function sequence.

8. The device according to claim 7, characterized in that The sample tonality sequence includes: a sample tonic sequence and a sample mode sequence; the network model training unit is further configured to execute superposition of the sample melody sequence, the sample tonic sequence and the sample mode sequence to obtain a first sample coding sequence; superposition of part of the sequence bits in the sample chord sequence and part of the sequence bits in the sample chord function sequence to obtain a second sample coding sequence; based on the first sample coding sequence and the second sample coding sequence, a corresponding attention vector is generated, and the attention vector is decoded using the neural network model to obtain the last bit of the sample chord sequence and the last bit of the sample chord function sequence.

9. The device according to claim 7, characterized in that The neural network model includes a first prediction layer and a second prediction layer; the network model training unit is further configured to input the sample melody sequence, the sample tonality sequence, and part of the sequence bits in the sample chord function sequence into the first prediction layer, the first prediction layer is used to predict a complete chord function sequence based on the sample melody sequence, the sample tonality sequence, and part of the sequence bits in the sample chord function sequence, and output the predicted chord function sequence; input the predicted chord function sequence and part of the sequence bits in the sample chord sequence into the second prediction layer; the second prediction layer is used to predict a complete chord sequence based on the predicted chord function sequence and part of the sequence bits in the sample chord sequence, and output the predicted chord sequence.

10. The device according to any one of claims 7 to 9, characterized in that The model loss determination unit is further configured to execute the acquisition of a first loss value for the predicted chord sequence and the sample chord sequence, and the acquisition of a second loss value for the predicted chord function sequence and the sample chord function sequence; using the sum of the first loss value and the second loss value as the loss value of the current neural network model; or is configured to execute if the first loss value is less than a preset first threshold, and the second loss value is less than a preset second threshold, using the current neural network model as the chord generation model.

11. A chord generating device, characterized in that: include: A melody sequence acquisition unit is configured to execute a melody for a chord to be generated, and acquire a melody sequence and a tonality sequence corresponding to the melody; a chord sequence acquisition unit, configured to input the melody sequence and the tonality sequence into a trained chord generation model, and obtain a chord sequence corresponding to the melody through the chord generation model; the chord generation model is obtained by the chord generation model training method according to any one of claims 1 to 4; The chord generation unit is configured to generate the to-be-generated chord according to the chord sequence.

12. The device according to claim 11, characterized in that The melody sequence acquisition unit is further configured to acquire the melody feature and the tonality feature of the melody; The melody feature and the tonality feature are sampled according to a preset sampling frequency to obtain the melody sequence and the tonality sequence.

13. An electronic device, characterized in that: include: processor; a memory for storing instructions executable by the processor; The processor is configured to execute the instructions to implement the training method of the chord generation model as described in any one of claims 1 to 4, or the chord generation method as described in any one of claims 5 to 6.

14. A computer-readable storage medium, characterized in that: When the instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the training method for a chord generation model as described in any one of claims 1 to 4, or the chord generation method as described in any one of claims 5 to 6.

15. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the training method for a chord generation model as claimed in any one of claims 1 to 4 or the chord generation method as claimed in any one of claims 5 to 6 is implemented.

Citation Information

Patent Citations

  • Method and device for constructing chord conversion vector and computer readable storage medium

    CN109935222A

  • Chord generation method based on deep learning

    CN110264987A

  • Method and system for generating chord based on melody

    CN116863893A

  • Song generation method, apparatus, electronic device, and storage medium

    WO2023245389A1