Methods for generating rap lyrics and training models for rap melody generation; methods for training rap melody generation models
The rap lyrics and melody generation models, trained using deep learning methods, address the challenge of maintaining harmony and coherence in rap songs by generating coherent and rhythmically appropriate rap verses and melodies.
Patent Information
- Application Number
- TW113147896
- Authority / Receiving Office
- TW · TW
- Patent Type
- Patents
- Current Assignee / Owner
- Filing Date
- 2024-12-10
- Publication Date
- 2026-07-11
- Estimated Expiration
- 2044-12-09
AI Technical Summary
Maintaining harmony and coherence between melody and lyrics in rap songs, particularly when inserting rap verses between verses and choruses, remains a significant challenge.
A method for training a rap lyrics generation model using deep learning techniques, including feature embedding, encoding, decoding, and adjusting model parameters, and a rap melody generation model using preprocessing and loss value calculation to generate coherent and rhythmically appropriate rap lyrics and melodies.
Effectively generates rap lyrics and melodies that maintain harmony and coherence within songs, addressing the challenges of inserting rap verses, and ensuring rhythmic and structural consistency.
Smart Images

Figure IMG-2_DRAW_113147896-A0101-14-0001-1 
Figure IMG-2_DRAW_113147896-A0101-14-0002-2 
Figure IMG-2_DRAW_113147896-A0101-14-0003-3
Abstract
Description
Technical Field
[0001] This invention relates to a method for generating lyrics and a model training method thereon, as well as a method for training a melody generation model, particularly a method for generating rap lyrics and a model training method thereon, as well as a method for training a rap melody generation model. Prior Technology
[0002] For centuries, music has been a fundamental form of human emotion expression, captivating audiences and evoking resonance across cultures and eras. For those without formal training in literature or songwriting, composing songs and lyrics is a challenging task. Before composing a song, familiarity with musical elements such as notes, chords, beats, and rhythms is essential; these elements help in creating lyrics that suit the emotion, rhythm, melody, and number of words.
[0003] Rap music originated in the Bronx, New York in the 1970s, distinguishing itself with its unique style and performance. Its entertainment value and rich lyrical content spread rapidly, becoming a global phenomenon. Compared to the lyrics of regular songs, which typically express emotions within a limited number of words, rap songs must adhere to stricter formats and rhythmic requirements, inserting more words into a limited tempo to ensure listeners understand the message. Currently, popular songs are usually divided into a beginning and a middle section, often with rap inserted between them to ensure continuity and coherence.
[0004] However, maintaining harmony and coherence between melody and lyrics when inserting rap between verses and choruses remains a major challenge. Summary of the Invention
[0005] Therefore, the purpose of this invention is to provide a method for training a rap lyrics generation model to solve the above-mentioned problems.
[0006] Therefore, the present invention provides a rap lyrics generation model training method, wherein the rap lyrics generation model is used to generate rap lyrics for a song, and is implemented by an electronic device that stores multiple rap lyrics training data. The rap lyrics generation model training method includes a step (A), a step (B), a step (C), and a step (D).
[0007] In step (A), for each rap lyrics training data, the electronic device performs feature embedding based on the rap lyrics training data to obtain embedded data.
[0008] In step (B), for each embedded data, the electronic device uses an encoder of a deep learning model to encode the embedded data to generate encoded data.
[0009] In step (C), for each piece of encoded data, the electronic device uses a decoder of the deep learning model to decode the encoded data to obtain a decoding result.
[0010] In step (D), the electronic device adjusts the parameters of the deep learning model based on all the decoding results and repeats steps (B) to (C) until the deep learning model converges.
[0011] Another objective of this invention is to provide a method for training a rap melody generation model to solve the above-mentioned problems.
[0012] Therefore, the rap lyrics generation method of the present invention uses the above-mentioned sound recognition model establishment method to obtain the rap lyrics generation model, which is implemented by a user device. The user device stores a format setting data, lyrics before the insertion position, and lyrics after the insertion position. The rap lyrics insertion method includes a step (F), a step (G), a step (H), a step (I), and a step (J).
[0013] In step (F), the user device performs word segmentation based on the lyrics before and after the insertion position to obtain multiple words.
[0014] In this step (G), the user device calculates multiple weight information corresponding to the corresponding words.
[0015] In step (H), the user device selects multiple keywords from the words based on the weighted information.
[0016] In step (I), the user device generates multiple suggested words based on the keywords using a lyrics coherence model that generates related words based on the lyrics.
[0017] In step (J), the user device generates the rap lyrics using the rap lyrics generation model based on the suggested vocabulary and the format setting data.
[0018] Another objective of this invention is to provide a rap melody generation model training method to solve the above-mentioned problems. The rap melody generation model is used to generate a rap melody inserted into a song. It is implemented by an electronic device that stores multiple rap melody training data. Each rap melody training data includes a training melody. The rap melody generation model training method includes a step (A), a step (B), a step (C), and a step (D).
[0019] In step (A), for each rap melody training data, the electronic device preprocesses the rap melody training data to obtain preprocessed training data. The preprocessed training data includes multiple note feature data corresponding to multiple notes of the training melody of the rap melody training data. Each note feature data includes measure information indicating the measure in which the note is located, position information indicating the initial position of the note in the measure, track information indicating whether it contains a vocal track, rap information indicating whether the note is rap, chord information indicating the chord to which the note belongs, rhythm information indicating the rhythm of the note, pitch information indicating the pitch of the note, duration information indicating the duration of the note, and dynamics information indicating the dynamics of the note.
[0020] In step (B), the electronic device inputs all the preprocessed training data into a deep learning model to generate multiple output results corresponding to the same preprocessed training data.
[0021] In step (C), the electronic device calculates a loss value based on the preprocessed training data and the output results.
[0022] In step (D), the electronic device adjusts the deep learning model based on the loss value and repeats steps (B) to (C) until the deep learning model converges.
[0023] The advantages of this invention are: It provides an electronic device for generating rap lyrics for inserting into a song, and a user device for generating the inserted rap lyrics using the rap lyrics generation model based on suggested vocabulary and format settings. Furthermore, it provides an electronic device for generating a rap melody for inserting into a song, and a rap melody generation model for generating the rap melody. Simple Explanation of the Diagram
[0024] Other features and effects of the present invention will be clearly presented in the embodiments with reference to the drawings, wherein: Figure 1 is a block diagram illustrating an embodiment of the rap lyrics generation model training method of the present invention; Figure 2 is a flowchart to illustrate the sub-steps included in step 22 of Figure 1; Figure 3 is a flowchart to illustrate the sub-steps included in step 23 of Figure 1; Figure 4 is a flowchart to illustrate the sub-steps included in step 24 of Figure 1; Figure 5 is a flowchart illustrating an embodiment of the rap lyrics generation method of the present invention; Figure 6 is a flowchart illustrating an embodiment of the rap melody generation model training method of the present invention; and Figure 7 is a schematic diagram illustrating the first note feature data corresponding to the first note, the second note feature data corresponding to the second note, and the third note feature data corresponding to the third note. Implementation
[0025] Before the invention is described in detail, it should be noted that similar elements are represented by the same numbers in the following description.
[0026] Referring to Figure 1, an embodiment of the rap lyrics generation model training method of the present invention is used to generate rap lyrics for a song. This is implemented by an electronic device (not shown) that stores multiple sets of rap lyrics training data. Each set of rap lyrics training data includes a training lyric. The electronic device may be, for example, a server, a computer, or an embedded system. The steps included in this embodiment will be described below.
[0027] In step 21, for each rap lyrics training data, the electronic device reverses the training lyrics of the rap lyrics training data so that the order of the training lyrics changes from right to left, as shown in Table 1. Location 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 Normal sorting city city drop answer , Small lane drop answer , Sink silent drop answer . Reverse sort . answer drop silent Sink , answer drop lane Small , answer drop city city Table 1
[0028] It is important to note that the model is trained from left to right, while the rhyme occurs at the end of each line. By reversing the training lyrics, you can first generate the sentence endings and then focus only on the first word of the reversed sentence to control the rhythm. It is worth noting that in this embodiment, each training lyric in each piece of rap lyric training data is combined with some symbols to inform the model when the data begins, ends, and is segmented. For example, the symbol "[bos]" is used to indicate the beginning of the data sequence, "[eos]" is used to indicate the end of the data sequence, and "[S]" is used to indicate sentence segmentation, in order to improve the accuracy and cohesion of sentence structure, as shown in Table 2. [bos] [S] . answer drop silent Sink [S] , answer drop lane Small [S] , answer drop city city [eos] Table 2
[0029] In step 22, for each rap lyrics training data, the electronic device performs feature embedding based on the rap lyrics training data to obtain embedded data.
[0030] Referring to Figure 2, step 22 includes sub-steps 221 to 226.
[0031] In sub-step 221, for each rap lyrics training data, the electronic device generates a vowel vector information based on the vowel of each word in the training lyrics of the rap lyrics training data.
[0032] It is worth noting that in this embodiment, the Chinese vowel group is processed using the "pinyin" system. For example, "python-pinyin" is used to convert each Chinese character into the corresponding vowel group embedding, as shown in Table 3. [bos] [S] . a i ou en [S] , a i ang iao [S] , a i i eng [eos] Table 3
[0033] In sub-step 222, for each rap lyrics training data, the electronic device generates word vector information based on each word of the training lyrics in the rap lyrics training data.
[0034] In sub-step 223, for each rap lyrics training data, the electronic device generates a sentence position vector information based on the position of each word and each punctuation mark in the training lyrics within the sentence.
[0035] It is worth noting that in this embodiment, Ii represents the position of the token in the sentence. For example, I0 corresponds to punctuation marks, and I1 corresponds to rhyming words, as shown in Table 4. [bos] [S] I0 I1 I2 I3 I4 [S] I0 I1 I2 I3 I4 [S] I0 I1 I2 I3 I4 [eos] Table 4
[0036] In sub-step 224, for each rap lyrics training data, the electronic device generates a paragraph position vector information based on the paragraph position of each word and each punctuation mark in the training lyrics of the rap lyrics training data.
[0037] It is worth noting that in this embodiment, Si represents the i-th paragraph of the entire sequence for each character and each punctuation mark, as shown in Table 5. [bos] [S] S0 S0 S0 S0 S0 [S] S1 S1 S1 S1 S1 [S] S2 S2 S2 S2 S2 [eos] Table 5
[0038] In sub-step 225, for each rap lyrics training data, the electronic device generates a global position vector information based on the global position of each word and each punctuation mark in the training lyrics of the rap lyrics training data.
[0039] It is worth noting that in this embodiment, Gi represents the i-th position of the entire sequence, as shown in Table 6. G0 G1 G2 G3 G4 G5 G6 G7 G8 G9 G10 G11 G12 G13 G14 G15 G16 G17 G18 G19 Table 6
[0040] In sub-step 226, for each rap lyrics training data, the electronic device generates a format vector information based on the format of each word and each punctuation mark of the training lyrics in the rap lyrics training data. The format vector information has multiple format tags.
[0041] It is worth noting that in this embodiment, the format markers are represented by Ri, for example, R2 represents rhyming characters, R1 represents punctuation marks, and R0 represents regular characters, as shown in Table 7. [bos] [S] R1 R2 R0 R0 R0 [S] R1 R2 R0 R0 R0 [S] R1 R2 R0 R0 R0 [eos] Table 7
[0042] Each embedded data includes the vowel vector information, the word vector information, the sentence position vector information, the paragraph position vector information, the global position vector information, and the format vector information.
[0043] In step 23, for each embedded data, the electronic device uses an encoder of a deep learning model to encode the embedded data to generate encoded data.
[0044] It is worth noting that this deep learning model is, for example, an auto-regressive model based on a transformer architecture.
[0045] Referring to Figure 3, step 23 includes sub-steps 231 and 232, which illustrate that the encoder encodes using a masking strategy in Bidirectional Encoder Representations from Transformers (BERT).
[0046] In step 231, for each embedded data, the electronic device randomly changes one part of the format tags of the format vector information of the embedded data according to the word vector information of the embedded data, and leaves the other part of the format tags of the format vector information of the embedded data unchanged, as shown in Table 8. [bos] [S] R1 answer R0 R0 R0 [S] R1 drop R0 R0 R0 [S] R1 R2 R0 R0 city [eos] Table 8
[0047] In step 232, for each embedded data, the electronic device generates the encoded data based on the vowel vector information, word vector information, sentence position vector information, paragraph position vector information, global position vector information, and format vector information of the embedded data.
[0048] In step 24, for each piece of encoded data, the electronic device uses a decoder of the deep learning model to decode the encoded data to obtain a decoding result.
[0049] Referring to Figure 4, step 24 includes sub-steps 241 to 244, which explain how the decoding result is obtained by applying the Top-K Sampling method.
[0050] In sub-step 241, for each piece of encoded data, the electronic device calculates multiple normalized scores corresponding to the same output marker based on the probability of sentence-end rhyme and the repetition of rhymes of the multiple output markers of the encoded data.
[0051] It is worth noting that the normalized score corresponding to the i-th output label xi in the t-th row As shown in the following formula: , in, To output the score of label xit in row t, For the i-th output tag xit, the final consonant of the t-th line, The set of final consonants of the last character from line 1 to line t-1, i.e. , Let be a first multiplicative factor, which is defined as follows: if the coda of an output tag matches the set of codas, then the first multiplicative factor is . If no matching exists, the first multiplication factor is 1. The final consonant of the last character in line t-1. Let be a second multiplication factor. If the final consonant of an output token matches the final consonant of the last word in line t-1, then the second multiplication factor is . If no matching exists, the second multiplication factor is 1. The set of single characters, which is one of the last characters of the first row to the (t-1)th row. , A third multiplication factor is defined as follows: if an output tag matches the set of words, then the third multiplication factor is... If no matching exists, the third multiplication factor is 1. , N is the number of output markers xi.
[0052] In sub-step 242, for each piece of encoded data, the electronic device selects multiple candidate output tags from the output tags based on the normalization scores. Specifically, the electronic device selects the top K output tags with the corresponding normalization scores as candidate output tags, where K is any integer greater than 1.
[0053] In sub-step 243, for each encoded data, the electronic device randomly selects a target tag from the candidate output tags and repeats sub-steps 241-242 until the entire sequence is obtained, i.e., the decoding result is obtained.
[0054] In step 25, the electronic device adjusts the parameters of the deep learning model based on all the decoding results, and repeats steps 22 to 24 until the deep learning model converges. The deep learning model is the rap lyrics generation model.
[0055] Referring to Figure 5, an embodiment of the rap lyrics generation method of the present invention is applicable to generating a rap melody inserted into a song. This is implemented by a user device (not shown), which stores the rap lyrics generation model, format setting data, lyrics before the insertion position, and lyrics after the insertion position. The user device may be, for example, a smartphone, tablet, or computer. In other embodiments, the user device does not store the rap lyrics generation model but is communicatively connected to a server (not shown) that stores the rap lyrics generation model. The steps included in this embodiment will be described below.
[0056] In step 31, the user device performs word segmentation based on the lyrics before and after the insertion position to obtain multiple words.
[0057] It is worth noting that, in this embodiment, the user device uses, for example, the Pkuseg tool proposed by Ruixuan Luo et al. for word segmentation.
[0058] In step 32, the user device calculates multiple weight values corresponding to the equivalent words.
[0059] It is worth noting that, in this embodiment, the user device uses, for example, tf-idf (term frequency–inverse document frequency) to calculate the weight information. Each weight information includes a tf value and an idf value. The tf value represents the frequency of the word in all documents, and the idf value is determined by the number of documents containing the word.
[0060] In step 33, the user device selects multiple keywords from the words based on the weighted information.
[0061] It is important to note that this step is a filtering process to remove irrelevant and meaningless words, such as particles and auxiliary verbs.
[0062] In step 34, the user device generates multiple suggested words based on the keywords using a lyrics coherence model that generates related words based on the lyrics.
[0063] It is worth noting that, in this embodiment, the lyrics coherence model is, for example, a word embedding model trained using a Wiki corpus, which utilizes the semantic relationships between words in the embedding space to generate more related words.
[0064] In step 35, the user device generates the rap lyrics using the rap lyrics generation model based on the suggested vocabulary and the format setting data.
[0065] It is worth noting that in this embodiment, the format setting data, for example, sets the number of lines of lyrics to be inserted, the number of characters in each line, and the number of clauses in each line. For example, the format setting data 4,4,4,(3,5) indicates that 4 lines of lyrics are generated, where each of the first to third lines includes 4 characters, and the fourth line includes two clauses, which consist of 3 characters and 5 characters respectively.
[0066] Referring to Figure 6, an embodiment of the rap melody generation model training method of the present invention is used to generate a rap melody inserted into a song. This is implemented by an electronic device (not shown) that stores multiple sets of rap melody training data. Each set of rap lyric training data includes a training melody. The electronic device may be, for example, a server, a computer, or an embedded system. The steps included in this embodiment will be described below.
[0067] In step 41, for each rap melody training data, the electronic device preprocesses the rap melody training data to obtain preprocessed training data. The preprocessed training data includes multiple note feature data corresponding to multiple notes of the training melody of the rap melody training data. Each note feature data includes measure information indicating the measure in which the note is located, position information indicating the initial position of the note in the measure, track information indicating whether it contains a vocal track, rap information indicating whether the note is rap, chord information indicating the chord to which the note belongs, rhythm information indicating the rhythm of the note, pitch information indicating the pitch of the note, duration information indicating the duration of the note, and dynamics information indicating the dynamics of the note, as shown in Table 9. Musical note characteristics data Vocabulary numerical values Section Information 16 1,2,…,16 Location Information 16 0,1,…,15 Audio track information 2 0,1 Rap News 2 0,1 Chord Information 60 1,2,…,60 Rhythm Information 137 28,30,…,211 Pitch Information 256 0,1,…,255 Pitch Length Information 16 1,2,…,16 Strength Information 33 0,4,…,128 Table 9
[0068] It is worth noting that in this embodiment, the measure information is described by a decreasing numerical sequence, with the first measure represented as 16, the second as 15, and so on. The position information divides a single measure into 16 units, with values from 0 to 15 representing the starting position of the note within the measure. The track information is 0 for accompaniment and 1 for vocals. The rap information is 0 for no rap and 1 for rap, representing vocals. The chord information includes 12 different chords and 5 chord types, resulting in a total of 60 different chord labels. The rhythm information is the rhythm of the entire piece, selecting 137 different rhythms from rhythms 28 to 211. The pitch information, based on Musical Instrument Digital Interface (MIDI), includes music data from 0 (C-1) to 127 (G9), with 128-255 being reserved values. This intensity information selects 33 different intensities from intensity 0 to 128.
[0069] Referring to Figure 7, for example, a preprocessed training dataset includes first note feature data corresponding to a first note 51, second note feature data corresponding to a second note 52, and third note feature data corresponding to a third note 53. There are two measures remaining for the first note 51 and the second note 52, therefore the measure information for their feature data is 2. There is one measure remaining for the third note 53, therefore the measure information for its feature data is 1. The positions of the first note 51 and the third note 53 are both at the beginning of a measure, therefore the position information for their feature data is 0. Using a sixteenth note as a unit, the second note 52 is after a half note, therefore the position information for its feature data is 8. The first note 51, the second note 52, and the third note 53 are all accompaniment, therefore the track information for their feature data is 0. The first note 51, the second note 52, and the third note 53 are not rap, so their corresponding rap information is 0. The first note 51 and the second note 52 are the 25th chord, and the third note 53 is the 27th chord, so the chord information for the first note 51 and the second note 52 is 25, and the chord information for the third note 53 is 27. The rhythm is marked as 88 in the upper left corner of the diagram, so the rhythm information for all notes 51, 52, and 53 is set to 88. The first note is C5, the second note 52 is D5, and the third note is E5, so the pitch information for the first note 51 is 78, the pitch information for the second note 52 is 79, and the pitch information for the third note 53 is 80. The first note 51 and the second note 52 are half notes, and the third note 53 is a whole note. Therefore, the duration information for the first note 51 and the second note 52 is 8, and the duration information for the third note 53 is 16. The dynamics of the first note 51 and the second note 52 are 60, and the dynamics of the third note 53 are 70. Therefore, the dynamics information for the first note 51 and the second note 52 is 60, and the dynamics information for the third note 53 is 70.
[0070] In step 42, the electronic device inputs all the preprocessed training data into a deep learning model to generate multiple output results corresponding to the same preprocessed training data.
[0071] It should be noted that in this embodiment, the deep learning model is the XLNet model. For each note feature data of each preprocessed training data, the electronic device uses the measure information, the position information, the track information, the rap information, and the chord information as a query stream input (Query Stream Input), and uses the measure information, the position information, the track information, the rap information, the chord information, the rhythm information, the pitch information, the note length information, and the dynamics information as a content stream input (Content Stream Input) to generate an output result corresponding to the note feature data.
[0072] In step 43, the electronic device calculates a loss value based on the preprocessed training data and the output results.
[0073] It should be noted that in this embodiment, the loss value is calculated by the following formula: , where is the previous rap melody of the insertion position, is the next rap melody of the insertion position, are the output results, and each output result includes multiple tokens. The i-th token t i is obtained according to the following formula: , where IsRap indicates that it is rap according to the rap information, is the probability of generating the i-th token t i under the conditions of the previous rap melody of the insertion position, the next rap melody of the insertion position, all the previously generated tokens t < i, and the indication of rap according to the rap information.
[0074] In step 44, the electronic device adjusts the deep learning model according to the loss value and repeats steps 42-43 until the deep learning model converges. The deep learning model is the rap melody generation model.
[0075] In summary, the rap lyrics generation method and its model training method, as well as the rap melody generation model training method of the present invention, utilize an electronic device to embed, encode, and decode features from rap lyrics training data. The parameters of the deep learning model are adjusted based on all decoding results until the deep learning model converges, thereby obtaining a rap lyrics generation model for generating rap lyrics inserted into the song. Furthermore, the user device obtains keywords from the lyrics before and after the insertion position, and uses the lyrics coherence model to generate suggested keywords. Based on these suggested keywords and the format setting data, the rap lyrics generation model is used to generate the inserted rap lyrics. In addition, the electronic device preprocesses the rap melody training data and adjusts the deep learning model based on the preprocessed training data until the deep learning model converges, thereby obtaining a rap melody generation model for generating the rap melody inserted into the song. Therefore, the present invention effectively achieves its objectives.
[0076] However, the above description is merely an embodiment of the present invention and should not be construed as limiting the scope of the present invention. Any simple equivalent changes and modifications made in accordance with the scope of the patent application and the contents of the patent specification of the present invention shall still fall within the scope of the patent of the present invention.
[0077] Steps 21-25 Steps 221-226 231, 232: Steps Steps 241-243 Steps 31-35 Steps 41-44 51: First Note 52: Second Note 53: Third Note
Claims
1. A method for training a rap lyrics generation model, the rap lyrics generation model being used to generate rap lyrics inserted into a song, implemented by an electronic device storing multiple training data sets of rap lyrics, each training data set including a training lyric, the method comprising the following steps: (A) for each training data set of rap lyrics, performing feature embedding based on each word, each phrase, and each punctuation mark of the training lyric in the training data set to obtain an embedding data set including multiple vectors; (B) for each embedding data set, using an encoder of a deep learning model to encode based on the vectors in the embedding data set to generate an encoded data set; (C) for each encoded data set, using a decoder of the deep learning model to decode based on the rhyme probability and rhyme repetition of multiple output markers in the encoded data set to obtain a decoding result; and (D) adjusting the parameters of the deep learning model based on all decoding results, and repeating steps (B) to (C) until the deep learning model converges.
2. The rap lyrics generation model training method as described in claim 1 further includes the following steps before step (A): (E) For each rap lyrics training data, the training lyrics of the rap lyrics training data are reversed so that the order of the training lyrics is changed from right to left.
3. The training method for the rap lyrics generation model as described in claim 1, wherein, Step (A) includes the following sub-steps: (A-1) For each rap lyrics training data, generate a vowel vector information based on the vowel of each word in the training lyrics of the rap lyrics training data; (A-2) For each rap lyrics training data, generate a word vector information based on each word in the training lyrics of the rap lyrics training data; (A-3) For each rap lyrics training data, generate a sentence position vector information based on the position of each word and each punctuation mark in the sentence of the training lyrics of the rap lyrics training data; (A-4) For each rap lyrics training data, generate a paragraph position vector information based on the paragraph position of each word and each punctuation mark in the training lyrics of the rap lyrics training data; (A-5) For each rap lyrics training data, generate a global position vector information based on the global position of each character in the training lyrics of the rap lyrics training data; and (A-6) For each rap lyrics training data, generate a format vector information based on the format of each word and each punctuation mark in the training lyrics of the rap lyrics training data. Each embedded data includes the vowel vector information, the word vector information, the sentence position vector information, the paragraph position vector information, the global position vector information, and the format vector information.
4. The training method for the rap lyrics generation model as described in claim 3, wherein, The format vector information has multiple format tags, and step (B) includes the following sub-steps: (B-1) For each embedded data, based on the word vector information of the embedded data, randomly change one part of the format tags of the format vector information of the embedded data, and leave the other part of the format tags of the format vector information of the embedded data unchanged; and (B-2) For each embedded data, generate the encoded data based on the vowel vector information, the word vector information, the sentence position vector information, the paragraph position vector information, the global position vector information, and the format vector information of the embedded data.
5. The training method for the rap lyrics generation model as described in claim 1, wherein, Step (C) includes the following sub-steps: (C-1) For each coded data, calculate multiple normalization scores corresponding to the output markers based on the probability of rhyming at the end of the sentence and the repetition of rhymes; (C-2) For each coded data, select multiple candidate output markers from the output markers based on the normalization scores; (C-3) For each coded data, randomly select a target marker from the candidate output markers; and (C-4) For each coded data, the electronic device determines whether the entire sequence has been obtained. If it determines that the entire sequence has not been obtained, repeat sub-steps (C-1) to (C-3) until the entire sequence is obtained.
6. The training method for the rap lyrics generation model as described in claim 5, wherein, In step (C-1), the normalized score corresponding to the i-th output tag xit in row t is as follows: , where is the score of the output tag xit in row t, is the coda of the i-th output tag xit in row t, is the set of codas of the last word from row 1 to row (t-1), is a first multiplication factor, if the coda of an output tag matches the coda of the set of codas, the first multiplication factor is , if no match exists, the first multiplication factor is 1, is the coda of the last word in row (t-1), is a second multiplication factor, if the coda of an output tag matches the coda of the last word in row (t-1), the second multiplication factor is , if no match exists, the second multiplication factor is 1, is the set of words of the last word from row 1 to row (t-1), is a third multiplication factor, if the output tag matches the set of words, the third multiplication factor is , if no match exists, the third multiplication factor is 1, , , N is the number of output tags xit.
7. A rap lyrics generation method for a rap lyrics generation model derived from the training method of any one of claims 1 to 6, implemented by a user device, the user device storing format setting data, lyrics before the insertion position, and lyrics after the insertion position, the rap lyrics insertion method comprising the following steps: (F) performing word segmentation based on the lyrics before the insertion position and the lyrics after the insertion position to obtain multiple words; (G) calculating multiple weight information corresponding to each of the words; (H) selecting multiple keywords from the words based on the weight information; (I) generating multiple suggested words based on the keywords using a lyrics coherence model for generating related words based on lyrics; and (J) generating the rap lyrics insertion based on the suggested words and the format setting data using the rap lyrics generation model.
8. A training method for a rap melody generation model, the rap melody generation model being used to generate a rap melody inserted into a song, implemented by an electronic device, the electronic device storing multiple rap melody training data, each rap melody training data including a training melody, the rap melody generation model training method comprising the following steps: (A) For each rap melody training data, the rap melody training data is preprocessed to obtain preprocessed training data, the preprocessed training data including multiple note feature data corresponding to multiple notes of the training melody of the rap melody training data, each note feature data including measure information indicating the measure in which the note is located, position information indicating the initial position of the note in the measure, track information indicating whether a vocal track is included, rap information indicating whether the note is rap, chord information indicating the chord to which the note belongs, rhythm information indicating the rhythm of the note, pitch information indicating the pitch of the note, duration information indicating the duration of the note, and dynamic information indicating the dynamics of the note. (B) Input all the preprocessed training data into a deep learning model to generate multiple outputs corresponding to the preprocessed training data; (C) Calculate a loss value based on the preprocessed training data and the outputs; and (D) Adjust the deep learning model based on the loss value and repeat steps (B) to (C) until the deep learning model converges.
9. The training method for the rap melody generation model as described in claim 8, wherein, In step (B), the deep learning model is the XLNet model. For each note feature data of each preprocessed training data, the measure information, position information, track information, rap information, and chord information are used as a query stream input, and the measure information, position information, track information, rap information, chord information, rhythm information, pitch information, duration information, and dynamics information are used as a content stream input to generate an output result corresponding to the note feature data.
10. The rap melody generation model training method as described in claim 8, wherein, In step (C), the loss value is calculated using the following formula: , where is the rap melody before the insertion position, is the rap melody after the insertion position, and is the output result. Each output result includes multiple tags, and the i-th tag ti is obtained according to the following formula: , where IsRap is the rap information indicating that it is rap, and is the probability of generating the i-th tag ti under the condition that the rap information indicates that it is rap based on the rap melody before the insertion position, the rap melody after the insertion position, all previously generated tags t < i, and the rap information indicating that it is rap.