Melody generation method and apparatus, and storage medium and computer device

By using pitch prediction models and masking rules in melody generation, the problem of difficulty in balancing the diversity and time complexity of melody generation in the existing technology is solved, and diversified and efficient generation of melody is achieved.

WO2024192864A1PCT designated stage expired Publication Date: 2024-09-26GUANGZHOU QUYAN NETWORK TECH CO LTD

Patent Information

Application Number
PCT/CN2023/093777
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2023-03-17
Filing Date
2023-05-12
Publication Date
2024-09-26

AI Technical Summary

Technical Problem

Existing technology cannot take into account diverse melodies and low time complexity. Existing automatic composition methods often have repetitive problems or require the use of complex neural network models when generating melody, resulting in high time complexity.

Method used

By receiving custom lyric text, the initial lyric melody is generated and masked by applying preset masking rules. The pitch prediction model based on the mask language model is used to generate the final melody, reducing the amount of model parameters and reducing time complexity.

Benefits of technology

It achieves diversified generation of melodies, while reducing the time complexity and parameter amount of the neural network model, and improving the efficiency of melody generation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2023093777_26092024_PF_FP
    Figure CN2023093777_26092024_PF_FP
Patent Text Reader

Abstract

A melody generation method and apparatus (500), and a storage medium and a computer device (900), which relate to the technical field of artificial intelligence. The method comprises: when a custom lyrics text is received, acquiring text information of the custom lyrics text (S102); according to the text information and a pre-generated first original melody, generating an initial lyrics melody corresponding to the custom lyrics text, wherein the initial lyrics melody comprises a plurality of pieces of pitch information (S104); masking some of the pieces of pitch information in the initial lyrics melody according to a preset masking rule, so as to obtain a target masked melody (S106); and inputting the target masked melody into a pitch prediction model, and according to pitch prediction information output by the pitch prediction model, generating a final lyrics melody corresponding to the custom lyrics text, wherein the pitch prediction model is a neural network model that has been subjected to model pre-training on the basis of a masked language model (S108). Both diversified melodies and relatively low time complexity can be taken into consideration.
Need to check novelty before this filing date? Find Prior Art

Description

Melody generation method, device, storage medium and computer equipment

[0001] This application claims priority to the Chinese patent application filed with the China Patent Office on March 17, 2023, with application number 202310265882.3 and invention name “Melody Generation Method, Device, Storage Medium and Computer Equipment”, the entire contents of which are incorporated by reference into this application. Technical Field

[0002] The present application relates to the field of artificial intelligence technology, and in particular to a melody generation method, apparatus, storage medium, and computer equipment. Background Art

[0003] With the continuous development of artificial intelligence and neural network technologies, artificial intelligence and neural network technologies have been applied to the field of music to automatically generate corresponding lyrics and melodies based on custom lyrics input by users, thereby realizing automatic composition functions.

[0004] Currently, existing technologies generally implement automatic composition through two methods. One method directly applies user-entered custom lyrics to existing lyric melodies. Specifically, multiple lyric melodies are pre-determined, and after the user enters the custom lyrics, one of the lyric melodies is selected as the custom lyric melody. As you can see, after a certain number of melodies are generated, the automatically generated melodies will become repetitive, making this approach incapable of producing diverse melodies.

[0005] Another implementation involves data annotation of multiple existing music clips. This annotation information binds together information such as the lyrics, rhythm, duration, accompaniment chords, and melody. Using the annotations corresponding to each music clip as training data, a neural network model is trained to produce a trained neural network model. In this way, when custom lyrics are input into the trained neural network model, the trained neural network model automatically outputs the rhythm and melody corresponding to the custom lyrics.

[0006] While this approach can output diverse melodies, it requires a complex, multi-dimensional representation of the data, making it time-consuming and challenging to label. Furthermore, this multi-dimensional representation increases the size of the neural network model's vocabulary. Consequently, existing techniques require complex neural network models with large parameter counts and high time complexity.

[0007] In summary, the existing technology cannot take into account both diverse melodies and low time complexity.

[0008] Summary of the Invention

[0009] The purpose of this application is to solve at least one of the above-mentioned technical deficiencies, especially the technical defect in the prior art that it is impossible to take into account both diverse melodies and low time complexity.

[0010] In a first aspect, an embodiment of the present application provides a melody generation method, the method comprising:

[0011] Upon receiving the custom lyrics text, obtaining text information of the custom lyrics text;

[0012] Generating an initial lyrics melody corresponding to the custom lyrics text according to the text information and a pre-generated first original melody; the initial lyrics melody includes a plurality of pitch information;

[0013] Masking part of the pitch information of the initial lyrics melody according to a preset masking rule to obtain a target masked melody;

[0014] The target masked melody is input into a pitch prediction model, and a final lyric melody corresponding to the custom lyric text is generated based on the pitch prediction information output by the pitch prediction model; wherein the pitch prediction model is a neural network model pre-trained based on a masked language model.

[0015] In a second aspect, an embodiment of the present application provides a melody generation device, the device comprising:

[0016] A text acquisition module, configured to acquire text information of the custom lyrics text when receiving the custom lyrics text;

[0017] A first lyrics melody generation module is configured to generate an initial lyrics melody corresponding to the custom lyrics text based on the text information and a pre-generated first original melody; the initial lyrics melody includes a plurality of pitch information;

[0018] a masking module configured to mask part of the pitch information of the initial lyrics melody according to a preset masking rule to obtain a target masked melody;

[0019] The second lyrics melody generation module is configured to input the target mask melody into a pitch prediction model, and generate a final lyrics melody corresponding to the custom lyrics text based on the pitch prediction information output by the pitch prediction model; wherein the pitch prediction model is a neural network model that is pre-trained based on a mask language model.

[0020] In a third aspect, an embodiment of the present application provides a storage medium storing computer-readable instructions. When the computer-readable instructions are executed by one or more processors, the one or more processors execute the steps of the melody generation method described in any of the above embodiments.

[0021] In a fourth aspect, an embodiment of the present application provides a computer device, the computer device comprising: one or more processors, and a memory;

[0022] The memory stores computer-readable instructions, and when the one or more processors execute the computer-readable instructions, the steps of the melody generation method described in any one of the above embodiments are performed.

[0023] In the melody generation model, device, storage medium and computer device of the present application, the computer device can generate an initial lyrics melody based on the text information of the custom lyrics text and the preset first original melody, and mask part of the pitch information in the initial lyrics melody according to the preset masking rules to obtain a masked melody, and input the masked melody into the pitch prediction model. Since the pitch prediction model is a neural network model that performs model pre-training based on the masked language model, the pitch prediction model can predict the pitch information of each masked symbol in combination with the context information of each masked symbol, and output the pitch prediction information, so that the computer device can generate the final lyrics melody based on the pitch prediction information. In this way, the computer device can use a limited number of original melodies as the basis for composition, and use masking and model prediction methods to adjust the melody, thereby generating diversified melodies. At the same time, since the pitch prediction model predicts the pitch information of each masked symbol based on the masked melody, the size of the vocabulary of the pitch prediction model is related to the number of pitches. Since the order of magnitude of pitch is limited, the pitch prediction model has a low vocabulary and a small number of model parameters, which can reduce the time complexity of the model and thus take into account both diverse melodies and low time complexity. BRIEF DESCRIPTION OF THE DRAWINGS

[0024] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0025] FIG1 is a schematic flow chart of a melody generation method according to an embodiment;

[0026] FIG2 is a flowchart illustrating the steps of masking part of the pitch information of the initial lyrics melody according to a preset masking rule to obtain a target masked melody in one embodiment;

[0027] FIG3 is a flowchart illustrating the steps of inputting a target mask melody into a pitch prediction model and generating a final lyric melody based on the target reasoning method and pitch prediction information in one embodiment;

[0028] FIG4 is a flow chart showing steps for generating lyrics rhythm information corresponding to a custom lyrics text based on text information in one embodiment;

[0029] FIG5 is a schematic structural diagram of a melody generating device according to an embodiment;

[0030] FIG6 is a schematic diagram of the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION

[0031] The following will be combined with the drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.

[0032] In some embodiments, the melody generation method provided herein can be applied to any computer device with data processing capabilities, including, but not limited to, various personal computers, laptops, smartphones, tablets, IoT devices, and portable wearable devices. IoT devices can include smart speakers, smart TVs, smart air conditioners, and smart car devices. Portable wearable devices can include smart watches, smart bracelets, and head-mounted devices.

[0033] In one embodiment, the present application provides a melody generation method that can be applied to a computer device. As shown in FIG1 , the melody generation method herein may include the following steps:

[0034] S102: When receiving the custom lyrics text, obtain text information of the custom lyrics text.

[0035] The custom lyric text may be user-written lyric text. From a literary perspective, the custom lyric text can be considered a collection of one or more sentences. The text information described herein can be used to reflect the literary composition of the custom lyric text. For example, the text information may include any one or any combination of information such as the text size, total word count, number of original sentences, and the number of words in each original sentence of the custom lyric text.

[0036] Upon receiving custom lyrics text, the computer device may obtain text information of the custom lyrics text. It is understood that the computer device may process the custom lyrics text in a corresponding manner based on the information type of the text information to achieve the acquisition of the text information. For example, when the text information includes the number of original sentences of the custom lyrics text, the computer device may segment the custom lyrics text according to a preset segmentation rule and determine the number of original sentences based on the segmentation results. For another example, when the text information includes the number of words corresponding to each original sentence, the computer device may use a word counting method to count the number of words in each original sentence.

[0037] S104: Generate an initial lyrics melody corresponding to the custom lyrics text according to the text information and the pre-generated first original melody; the initial lyrics melody includes a plurality of pitch information.

[0038] Specifically, the first original melody can be a lyric melody extracted from a sample song, wherein the sample song can be a song that has been historically created by the computer device. That is, the computer device can pre-extract the lyric melody of the sample song and use it as the first original melody. When receiving the custom lyrics text, the computer device can generate an initial lyrics melody corresponding to the custom lyrics text based on the text information and the pre-extracted first original melody, so that the initial lyrics melody includes multiple pitch information. Each pitch information can be used to indicate the height of the sound, such as "1" / "do", "2" / "rei". Exemplarily, the computer device can adjust the arrangement order of each pitch information in the first original melody according to the total number of words in the custom lyrics text to obtain the initial lyrics melody.

[0039] S106: Masking part of the pitch information of the initial lyrics melody according to a preset masking rule to obtain a target masked melody.

[0040] Specifically, after obtaining the initial lyrics melody, the computer device can replace part of the pitch information in the initial lyrics melody with a mask symbol according to a preset masking rule to obtain a target masked melody. The target masked melody includes one or more pitch information and one or more masking symbols. For example, if the initial lyrics melody is [52, 60, 55, 52, 55, 57, 60, 57], then its corresponding target masked melody can be ['52', '60', '[mask]', '52', '55', '[mask]', '60', '[mask]'], where [mask] is a masking symbol.

[0041] It is understood that the specific content of the masking rules can be determined based on actual circumstances, and this embodiment does not specifically limit this. For example, the masking rule can be to mask the initial lyrics melody according to a preset ratio threshold, so that the proportion of masking symbols in the initial lyrics melody is not less than the preset ratio threshold. For another example, the masking rule can be to determine whether each pitch information in the initial lyrics melody has a musical conflict according to a preset musical conflict detection rule, and replace the pitch information with a masking symbol if there is a musical conflict.

[0042] S108: Input the target masked melody into the pitch prediction model, and generate the final lyrics melody corresponding to the custom lyrics text based on the pitch prediction information output by the pitch prediction model; wherein the pitch prediction model is a neural network model pre-trained based on the masked language model.

[0043] Specifically, the masking process of the initial lyric melody can be considered the process of adding noise to the initial lyric melody, and the target masked melody can be considered the initial lyric melody after the noise has been added. A computer device can perform pitch prediction based on the target masked melody to determine the pitch information corresponding to each masking symbol in the target masked melody, thereby achieving denoising. After determining the pitch information corresponding to each masking symbol, the final lyric melody corresponding to the custom lyric text can be obtained.

[0044] During the pitch prediction process, the computer device can input the target masked melody into the pitch prediction model. Since the pitch prediction model is a neural network model pre-trained based on the Masked Language Model (MLM), the pitch prediction model can combine the contextual information of the target masked melody (i.e., the individual pitch information in the target masked melody) to achieve pitch prediction and output the pitch prediction information, so that the computer device can determine the pitch corresponding to each masked symbol based on the pitch prediction information, thereby obtaining the final lyrics melody.

[0045] It can be understood that the model selection and / or specific model structure of the pitch prediction model can be determined based on actual conditions. This article does not impose any specific restrictions on this. It only requires that the pitch prediction model is a neural network model that is pre-trained based on a masked language model.

[0046] In one example, the pitch prediction model can be a BERT (Bidirectional Encoder Representation from Transformers) model. Furthermore, since the pitch prediction model predicts the pitch information of each mask symbol based on the mask melody, the size of the vocabulary of the pitch prediction model is associated with the number of pitches. Since the order of magnitude of pitches is limited, the vocabulary of the pitch prediction model is relatively low. In this case, the pitch prediction model can be implemented by only setting up a 4-layer encoder and a 128-dimensional transformer feedforward. Compared with the prior art solution of using a 12-layer encoder, a 12-layer decoder and a 1024-dimensional transformer feedforward, the model parameter amount of the present application is greatly reduced.

[0047] In the present application, a computer device can generate an initial lyrics melody based on the text information of the custom lyrics text and a preset first original melody, and mask part of the pitch information in the initial lyrics melody according to a preset masking rule to obtain a masked melody, and input the masked melody into a pitch prediction model. Since the pitch prediction model is a neural network model that performs model pre-training based on a masked language model, the pitch prediction model can predict the pitch information of each masked symbol in combination with the contextual information of each masked symbol, and output the pitch prediction information, so that the computer device can generate the final lyrics melody based on the pitch prediction information. In this way, the computer device can use a limited number of original melodies as the basis for composition, and use masking and model prediction methods to adjust the melody, thereby generating diversified melodies. At the same time, since the pitch prediction model predicts the pitch information of each masked symbol based on the masked melody, the size of the vocabulary of the pitch prediction model is related to the number of pitches. Since the order of magnitude of pitch is limited, the pitch prediction model has a low vocabulary and a small number of model parameters, which can reduce the time complexity of the model and thus take into account both diverse melodies and low time complexity.

[0048] In one embodiment, as shown in FIG2 , the step of masking part of the pitch information of the initial lyrics melody according to a preset masking rule to obtain a target masked melody includes:

[0049] S202: Obtain the accompaniment melody corresponding to the custom lyrics text;

[0050] S204: judging whether each pitch information of the initial lyrics melody conforms to music theory according to the accompaniment melody and preset music theory rules;

[0051] S206: Masking pitch information in the initial lyrics melody that does not conform to music theory to obtain a first masked melody;

[0052] S208: Generate a target mask melody based on the first mask melody.

[0053] The song melody may include an accompaniment melody and a lyric melody. If the lyric melody and the accompaniment melody do not match well, the listener may experience a sense of jarring when listening to the song. To make the lyric melody automatically generated by the computer more reasonable and improve the matching between the lyric melody and the accompaniment melody, in this embodiment, the computer device can mask the initial lyric melody according to the accompaniment melody corresponding to the custom lyric text and preset musical theory rules, thereby replacing the unmusical pitch information in the initial lyric melody with masking symbols.

[0054] Specifically, the computer device can obtain the accompaniment melody corresponding to the customized lyrics text. In one embodiment, the computer device can determine the corresponding accompaniment melody based on the received style tag, for example, by instantly generating the accompaniment melody based on the style tag or selecting an accompaniment melody corresponding to the style tag from a plurality of preset accompaniment melodies based on the style tag.

[0055] When the accompaniment melody is obtained, the computer device can judge whether each pitch information of the initial lyrics melody conforms to music theory based on the accompaniment melody and preset music theory rules, and replace the mask symbol with each pitch information in the initial lyrics melody that does not conform to music theory, and obtain the first mask melody.

[0056] It is understood that the specific content of the music theory rules can be determined based on actual circumstances and is not specifically limited herein. In one example, the accompaniment melody may include multiple chords. The music theory rules may be used to determine whether each pitch information of the initial lyrics melody is an out-of-tune note and whether it is a avoided note that conflicts with the chords of the accompaniment melody. Each out-of-tune note and avoided note in the initial lyrics melody is replaced with a mask symbol to obtain a first masked melody.

[0057] After the first mask melody is generated, the computer device may obtain a target mask melody based on the first mask melody. For example, the computer device may directly use the first mask melody as the target mask melody, or adjust the first mask melody and use the adjusted first mask melody as the target mask melody.

[0058] In one embodiment, the step of generating a target mask melody based on the first mask melody includes:

[0059] Calculating the masking ratio of the first masked melody;

[0060] If the masking ratio of the first masked melody is less than the preset ratio threshold, the pitch information of the first masked melody is randomly masked according to the preset ratio threshold to obtain a target masked melody; wherein the masking ratio of the target masked melody is greater than or equal to the preset ratio threshold.

[0061] The masking ratio of the first masked melody refers to the ratio of the total number of masking symbols to the total number of pitches, and the total number of pitches refers to the sum of the total number of masking symbols and the total number of pitch information in the first masked melody. For example, when the first masked melody is ['52','60','[mask]','52','55','[mask]','60','57'], the total number of pitches is 8 and the total number of masking symbols is 2, then the masking ratio of the first masked melody is 25%.

[0062] The computer device can compare the mask ratio of the first mask melody with a preset ratio threshold to determine whether the mask ratio of the first mask melody is less than the preset ratio threshold. When the mask ratio of the first mask melody is less than the preset ratio threshold, the number of mask symbols in the first mask melody is limited. If the first mask melody is directly input into the pitch prediction model for pitch prediction, and the final lyrics melody is obtained accordingly, then under the limitation of the number of mask symbols, the diversity of the final lyrics melody is also limited. Therefore, in order to further enhance the diversity of lyrics melody, when the mask ratio of the first mask melody is less than the preset ratio threshold, the computer device can randomly mask the various pitch information of the first mask melody, so that the mask ratio of the first mask melody after random masking is greater than or equal to the preset ratio threshold, and the first mask melody after random masking is used as the target mask melody.

[0063] It is understood that the specific value of the preset ratio threshold can be determined according to actual conditions, and this document does not impose any specific restrictions on this. In one example, the preset ratio threshold can be greater than or equal to 12%.

[0064] In one embodiment, the step of generating a target mask melody based on the first mask melody includes: calculating a masking ratio of the first mask melody; and if the masking ratio of the first mask melody is greater than or equal to a preset ratio threshold, using the first mask melody as the target mask melody.

[0065] The description of the masking ratio and the preset ratio threshold for the first masked melody can be found in the above embodiment and will not be repeated here. When the masking ratio of the first masked melody is greater than or equal to the preset ratio threshold, it indicates that the number of masking symbols in the first masked melody is sufficient. Therefore, the first masked melody can be directly used as the target masked melody without the need for random masking. This further improves the efficiency of melody generation.

[0066] In one embodiment, the step of inputting the target mask melody into a pitch prediction model and generating a final lyric melody corresponding to the custom lyric text based on the pitch prediction information output by the pitch prediction model includes:

[0067] Selecting a target pitch inference method from among the multiple pitch inference methods based on the preset multiple pitch inference methods and the selection probability corresponding to each pitch inference method;

[0068] The target mask melody is input into the pitch prediction model, and the final lyric melody is generated based on the target reasoning method and pitch prediction information.

[0069] Among them, the pitch inference method can be a method of inferring the pitch information corresponding to each mask symbol based on the pitch prediction information.

[0070] Specifically, the computer device can select a pitch inference method from a plurality of different pitch inference methods as the target inference method based on the selection probability of each pitch inference method, and infer the pitch information corresponding to each mask symbol in the target mask melody according to the target inference method and the pitch prediction information output by the pitch prediction model to obtain the final lyrics melody.

[0071] In this embodiment, the computer device can randomly select a target inference method from a variety of different pitch inference methods, and generate the final lyrics melody accordingly, which can further enrich the diversity of the melody.

[0072] In one embodiment, the pitch prediction information includes the predicted pitch probabilities corresponding to each mask symbol in the target mask melody. That is, one mask symbol corresponds to multiple predicted pitch probabilities, and the pitch information corresponding to each predicted pitch probability is different. For example, when the vocabulary of the pitch prediction model includes the seven pitches of do, rei, mi, fa, so, la, and si, after the target mask melody ['mi', '[mask]', 'do'] is input into the pitch prediction model, the pitch prediction information output by the pitch prediction model can be [0.3, 0.2, 0.2, 0.25, 0.01, 0.02, 0.02]. Among them, 0.3 is the predicted probability corresponding to do, 0.2 is the predicted probability corresponding to rei and mi respectively, 0.25 is the predicted probability corresponding to fa, and so on.

[0073] As shown in FIG3 , the target mask melody is input into the pitch prediction model, and the steps of generating the final lyrics melody according to the target reasoning method and pitch prediction information include:

[0074] S302: When the target inference mode is a one-shot inference mode, the target mask melody is input into a pitch prediction model to obtain pitch prediction information;

[0075] S304: For each mask symbol in the target mask melody, determine a target probability threshold, select a target pitch probability from each predicted pitch probabilities corresponding to the mask symbol based on the target probability threshold, and use the pitch information corresponding to the target pitch probability as the pitch information corresponding to the mask symbol, wherein the target pitch probability is greater than or equal to the target probability threshold;

[0076] S306: Fill the pitch information corresponding to each mask symbol into the target mask melody to obtain the final lyrics melody.

[0077] The one-shot inference method determines the pitch information corresponding to each mask symbol in the target mask melody at once. Each time the target mask melody is input into the pitch prediction model, the model outputs the predicted pitch probabilities corresponding to each mask symbol. When the target inference method is one-shot, the computer device infers the pitch information corresponding to each mask symbol based on the predicted pitch probabilities output by the pitch prediction model at that time.

[0078] Specifically, after the target mask melody is input into the pitch prediction model, the pitch prediction model will output the predicted pitch probabilities corresponding to each mask symbol respectively. For each mask symbol, the computer device can determine the target probability threshold corresponding to the mask symbol, and select a predicted pitch probability greater than or equal to the target probability threshold from the various predicted pitch probabilities corresponding to the mask symbol as the target pitch probability, and use the pitch information corresponding to the target pitch probability as the pitch information corresponding to the mask symbol. For example, in the aforementioned example of ['mi','[mask]','do'], if the target probability threshold corresponding to the mask symbol is 0.22, the computer device will select "do" or "fa" as the pitch information corresponding to the mask symbol.

[0079] In one embodiment, the computer device may use the maximum predicted pitch probability that is greater than or equal to the target probability threshold as the target pitch probability, and use the pitch information corresponding to the maximum predicted pitch probability as the pitch information corresponding to the mask symbol.

[0080] It should be noted that the target probability threshold described herein can be pre-set or dynamically generated (for example, by using the mean of the predicted pitch probabilities corresponding to the same mask symbol as the target probability threshold corresponding to that mask symbol), and this is not specifically limited herein. Furthermore, the target probability threshold corresponding to each mask symbol can be the same or different.

[0081] The computer device can fill the pitch information corresponding to each mask symbol into the corresponding position of the target mask melody according to the position of each mask symbol in the target mask melody to replace each mask symbol in the target mask melody and obtain the final lyrics melody.

[0082] In this embodiment, by determining the pitch information corresponding to each mask symbol in the target mask melody at one time, the time for generating the final lyrics melody can be shortened, thereby further improving the melody generation efficiency.

[0083] In one embodiment, the step of selecting the target pitch probability from the predicted pitch probabilities corresponding to the mask symbol according to a preset probability threshold includes:

[0084] Among the predicted pitch probabilities corresponding to the mask symbol, each predicted pitch probability that is greater than or equal to a preset probability threshold is used as a candidate pitch probability;

[0085] The target pitch probability is randomly selected from each candidate pitch probability.

[0086] Specifically, for each mask symbol, if there are at least two predicted pitch probabilities greater than or equal to the target probability threshold among the predicted pitch probabilities corresponding to the mask symbol, the computer device can randomly select one as the target pitch probability from the predicted pitch probabilities greater than or equal to the target probability threshold. For example, in the aforementioned example of ['mi', '[mask]', 'do'], when the target probability threshold corresponding to the mask symbol is 0.22, the computer device can randomly select 0.3 or 0.25 as the target pitch probability, that is, the computer device can randomly select "do" or "fa" as the pitch information corresponding to the mask symbol. In this way, the diversity of the melody can be further increased while ensuring that the melody of the lyrics is reasonable.

[0087] In one embodiment, the pitch prediction information includes the predicted pitch probabilities corresponding to each mask symbol in the target mask melody. Detailed descriptions of the pitch prediction information can be found in the above embodiments and will not be repeated here.

[0088] The steps of inputting the target mask melody into the pitch prediction model and generating the final lyrics melody based on the target reasoning method and pitch prediction information include:

[0089] When the target inference mode is a multiple inference mode and the target masked melody includes at least one mask symbol, the target masked melody is input into the pitch prediction model to obtain pitch prediction information, and according to a preset probability threshold, N target pitch probabilities are selected from the pitch prediction information most recently output by the pitch prediction model, and based on the positions of the mask symbols corresponding to the N target pitch probabilities, the pitch information corresponding to the N target pitch probabilities is respectively filled into the target masked melody to update the target masked melody, until the updated target masked melody does not include the mask symbol and the final lyrics melody is obtained;

[0090] The probability of each target pitch is greater than or equal to a preset probability threshold, and N is a preset positive integer and is less than the number of initial mask symbols of the target mask melody.

[0091] Specifically, the multiple inference method refers to a method in which the pitch information corresponding to each mask symbol is determined multiple times, and the current pitch information determination needs to be based on the pitch information determined previously. Because the multiple inference method requires the pitch information corresponding to each mask symbol to be determined multiple times, and the previous determination results need to serve as the basis for the current determination process, the multiple inference method needs to update the target mask melody based on the pitch information determined each time, and use the updated target mask melody for the current inference. The initial number of mask symbols of the target mask melody refers to the maximum number of mask symbols of the target mask melody before the target mask melody is updated at least once. For example, the target mask melody obtained in step S106 has a total of 4 mask symbols. During the inference process, the pitch information corresponding to 2 mask symbols is inferred each time and the target mask melody is updated accordingly, so that the number of mask symbols of the target mask melody decreases by 2 after each update. In this example, the initial number of mask symbols of the target mask melody is 4.

[0092] When the target inference method is multiple inference, if the target mask melody includes at least one mask symbol, it indicates that the target mask melody has not been predicted. Therefore, whenever the target inference method is multiple inference and the target mask melody includes at least one mask symbol, the computer device will input the target mask melody into the pitch prediction model, so that the pitch prediction model predicts the target mask melody input and outputs the pitch prediction information for that time, so that the computer device can perform the current inference based on the current pitch prediction information.

[0093] During the current reasoning process, the computer device can determine the target probability threshold and select N predicted pitch probabilities greater than or equal to the target probability threshold from the current pitch prediction information as the target pitch probability. After determining the N target pitch probabilities, the computer device can fill the pitch information corresponding to the N target pitch probabilities into the target mask melody according to the mask symbol positions corresponding to the N target pitch probabilities (i.e., the positions of the mask symbols in the target mask melody) to achieve the update of the target mask melody. If the updated target mask melody does not include the mask symbol, the updated target mask melody can be used as the final lyrics melody. If the updated target mask melody also includes at least one mask symbol, the next reasoning is performed with reference to the above process.

[0094] It can be understood that N can be any positive integer less than the number of initial mask symbols. For ease of explanation, some embodiments of this document are described as an example of N being 1. For example, when the target mask melody obtained in step S106 has a total of 4 mask symbols, the computer device can determine the pitch information corresponding to each mask symbol one by one, and fill the pitch information into the target mask melody every time the pitch information corresponding to a mask symbol is determined, and then the updated target mask melody is re-input into the pitch prediction model, so that the pitch prediction model can perform pitch prediction based on the pitch information already determined and the pitch information obtained by later reasoning and prediction, and perform the current reasoning. After performing 4 reasonings, the computer device can determine the pitch information corresponding to the 4 mask symbols and obtain the final lyrics melody.

[0095] It should be noted that the target probability threshold described herein can be pre-set or dynamically generated (for example, by using the mean of the predicted pitch probabilities outputted in the same inference process as the target probability threshold for that inference process), and this is not specifically limited in this article. Furthermore, the target probability threshold for each inference process can be the same or different.

[0096] In this embodiment, by imitating human composing thinking, the pitch information with a higher probability is first determined, and then the pitch information corresponding to the remaining mask symbols is determined based on the pitch information that has been determined and the pitch information obtained by later reasoning and prediction, thereby improving the rationality of the melody of the final lyrics melody and improving the matching degree between the lyrics melody and the accompaniment melody.

[0097] In one embodiment, the step of generating an initial lyrics melody corresponding to the custom lyrics text based on the text information and a pre-generated first original melody includes:

[0098] Based on the text information, generate lyrics rhythm information corresponding to the custom lyrics text;

[0099] randomly selecting a second original melody that matches the rhythm information of the lyrics from a plurality of pre-generated second original melodies as the first original melody;

[0100] An initial lyrics melody is generated based on the first original melody.

[0101] Specifically, each second original melody can be a lyric melody extracted from a sample song. In one embodiment, the computer device can process each MIDI (Musical Instrument Digital Interface) data in the pop909 dataset to obtain multiple second original melodies whose lengths and formats meet preset requirements. For example, each second original melody can include 1 to 22 phrases, and each phrase includes at least 3 pitch information.

[0102] The computer device can randomly select a second original melody that matches the rhythmic information of the lyrics from a plurality of second original melodies based on the rhythmic information of the lyrics corresponding to the text information generator of the custom lyrics text as the first original melody. In other words, if at least two second original melodies match the rhythmic information of the lyrics, the computer device can randomly select one of the matching second original melodies as the first original melody and generate the initial lyrics melody based on it. This can further increase the diversity of melody generation.

[0103] In one embodiment, the text information includes the number of input sentences and the number of characters in the custom lyrics text. When entering the custom lyrics text, the user may use special characters (including, but not limited to, punctuation marks or spaces) to divide the custom lyrics text into multiple input sentences. The number of input sentences herein refers to the number of sentences at the time the user enters the custom lyrics text. For example, if the custom lyrics text entered by the user is "It is dusk, and I am alone in sorrow, and the wind and rain are even more severe," the number of input sentences may be 2.

[0104] As shown in FIG4 , the steps of generating lyrics rhythm information corresponding to the custom lyrics text based on the text information include:

[0105] S402: Determine whether the custom lyrics text meets the preset composition sentence rules based on the number of input sentences and the number of words in the text;

[0106] S404: If the composition sentence rule is not satisfied, segment the custom lyrics text according to the composition sentence rule to obtain individual composition sentences;

[0107] S406: If the composition phrase rule is satisfied, each input phrase of the custom lyrics text is used as a composition phrase;

[0108] S408: Filtering a plurality of pre-generated original rhythm information according to the phrase information of each composition phrase to obtain reference rhythm information, and generating lyrics rhythm information based on the reference rhythm information.

[0109] Specifically, the multiple original rhythm information can all be rhythm information extracted from sample songs. In one embodiment, the computer device can obtain rhythm information corresponding to multiple sample songs through intelligent music transcription, where each original rhythm information can include rhythm information with a granularity of a single sentence or a single paragraph (or multiple sentences). Furthermore, each rhythm information can include the song structure type, word segmentation, length combination, and singing time corresponding to each word of the lyrics within the sentence (or paragraph).

[0110] The computer device can determine whether the custom lyrics text needs to be re-segmented based on the number of input sentences, the number of words in the text, and the preset composition sentence rules. If necessary, the custom lyrics text is re-segmented according to the preset composition sentence rules to obtain individual composition sentences. In this case, the number of composition sentences can be the same as or different from the number of input sentences. If re-segmentation is not required, the individual composition sentences can be determined according to the user's sentence segmentation method, that is, each input sentence can be used as a composition sentence.

[0111] After determining each composition phrase, the computer device may select one or more pieces of original rhythm information from the plurality of original rhythm information as reference rhythm information based on the phrase information of each composition phrase, and generate lyrics rhythm information for the customized lyrics text based on the reference rhythm information. The phrase information may be a set of factors to be considered when composing the music for the composition phrase, such as the number of words in the composition phrase and the word segmentation.

[0112] In this embodiment, whether the custom lyrics text meets the preset composition sentence rules is determined based on the number of input sentences and the number of text words, and each composition sentence is determined accordingly. The baseline rhythm information used to generate the lyrics rhythm information is determined based on the sentence information of each composition sentence. In this way, the problem of failure to match or inaccurate matching results due to improper sentence segmentation can be avoided, so that reasonable lyrics rhythm information can be automatically generated.

[0113] In one embodiment, the sentence information of the composition sentence includes the song structure type corresponding to the composition sentence. The song structure type may be, but is not limited to, a verse, a chorus, a bridge, or a pre-chorus.

[0114] The step of screening multiple pre-generated original rhythm information according to the sentence information of each composition sentence to obtain the benchmark rhythm information includes: screening multiple original rhythm information based on each song structure type and the number of composition sentences corresponding to each song structure type to obtain the benchmark rhythm information.

[0115] Specifically, based on the song structure type corresponding to each composition phrase, the computer device can calculate which type of song structure needs to be arranged and the number of composition phrases corresponding to each song structure type that needs to be arranged. This allows the computer device to perform data screening from multiple original rhythm information based on the statistical information and obtain benchmark rhythm information. For example, if all composition phrases include six verses and five choruses, the benchmark rhythm information may include the original rhythm information of the six verses and the original rhythm information of the five choruses. In this way, more reasonable benchmark rhythm information can be obtained to improve the quality of subsequent composition.

[0116] In one embodiment, the reference tempo information includes at least one piece of original phrase tempo information, which refers to the tempo information of a single phrase extracted from a sample song. Furthermore, each piece of original phrase tempo information may include the song structure type, word segmentation, length and shortness of the lyrics within the sentence, and the duration of each word.

[0117] The steps of generating lyric rhythm information based on the reference rhythm information include: for each composition sentence, determining the original sentence rhythm information that matches the arrangement order of the composition sentence in the reference rhythm information as the target rhythm information, performing word segmentation processing on the composition sentence, and adjusting the target rhythm information based on the word segmentation result to obtain the lyric rhythm information corresponding to the composition sentence.

[0118] Specifically, when the reference tempo information includes multiple pieces of original phrase tempo information, each piece of original phrase tempo information may be arranged in a certain order. For each composition phrase, the computer device may use the original phrase tempo information in the reference tempo information that matches the composition phrase in the order of arrangement among all composition phrases as the target tempo information. For example, when the reference tempo information includes a first original phrase tempo, a second original phrase tempo, and a third original phrase tempo arranged in sequence, if the current composition phrase is the second composition phrase, the computer device may use the second original phrase tempo as the target tempo information corresponding to the current composition phrase.

[0119] For each composition sentence, after determining the target rhythm information corresponding to the composition sentence, the computer device can adjust the target rhythm information according to the text segmentation result of the composition sentence, and use the target rhythm information as a development basis to generate the lyrics rhythm information corresponding to the composition sentence.

[0120] In one example, a computer device can construct a lyric rhythm melody corresponding to a composition phrase based on the text segmentation results of the composition phrase, the text length and part of speech of each segmentation, and the text segmentation results corresponding to the original phrase rhythm information, the text length and part of speech of each segmentation.

[0121] Furthermore, after obtaining the lyrics rhythm information corresponding to each composition phrase, the computer device can also adjust the lyrics rhythm information according to the rhythm information of the custom lyrics text, so that the adjusted lyrics rhythm information has the effect of rhythm repetition and echo, thereby improving the rationality of the lyrics rhythm.

[0122] In this embodiment, the lyrics rhythm information corresponding to the composition phrase is generated by combining the word segmentation results of the composition phrase, thereby making the lyrics rhythm information more intelligent and reasonable.

[0123] In one embodiment, the first original melody includes at least one first original phrase melody, which refers to the melody information of a single phrase extracted from a sample song. The initial lyrics melody includes initial phrase melodies corresponding to each composition phrase, which refers to the lyrics melody corresponding to a single composition phrase.

[0124] The step of generating an initial lyrics melody based on a first original melody includes: for each composition phrase, determining a first original phrase melody in the first original melody that matches the arrangement order of the composition phrase as a reference melody, and generating the initial phrase melody of the composition phrase based on the number of phrase words in the composition phrase, the number of pitches of the reference melody, and the various pitch information of the reference melody.

[0125] Among them, the number of pitches of the reference melody refers to the total number of pitch information contained in the reference melody. For example, when the reference melody is "1234", the reference melody includes four pitch information "1" (do), "2" (rei), "3" (mi), and "4" (fa), so its number of pitches is 4.

[0126] Specifically, when the first original melody includes multiple first original phrase melodies, the first original phrase melodies may be arranged in a certain order. For each composition phrase, the computer device may select a first original phrase melody in the first original melody that matches the composition phrase in the overall composition phrase order as the reference melody.

[0127] Since the number of words in a composition phrase is associated with the number of pitches in the final lyrics melody corresponding to the composition phrase, the computer device can determine the number of pitches that the final lyrics melody corresponding to the composition phrase needs to include based on the number of words in the composition phrase, and judge whether the pitch information included in the baseline melody is sufficient based on the number of pitches that the final lyrics melody needs to include and the number of pitches of the baseline melody, and generate the initial phrase melody of the composition phrase based on the judgment result and the various pitch information of the baseline melody.

[0128] In this embodiment, the computer device can adjust the reference melody based on the number of pitches to be determined in the composition phrase and the number of pitches of the reference melody to obtain the initial lyrics melody corresponding to the composition phrase, so that the computer device can use a limited number of original melodies as the basis for composition, thereby generating diversified melodies.

[0129] In one embodiment, the step of generating the initial phrase melody of the composition phrase according to the number of phrase words of the composition phrase, the number of pitches of the reference melody, and the pitch information of the reference melody includes:

[0130] If the number of words in the composition phrase is greater than the number of pitches in the reference melody, the composition phrase is segmented to obtain individual segmented texts, and the segmented text corresponding to each pitch information in the reference melody is determined according to a preset melody filling rule;

[0131] Determining melody information of each second segmented word text according to the text position of each first segmented word text in the composition phrase and the pitch information corresponding to each first segmented word text, so as to obtain an initial segmented word melody of the composition phrase;

[0132] The first segmented text is a segmented text with corresponding pitch information, the second segmented text is a segmented text without corresponding pitch information, and the melody information of each second segmented text is pitch information or a mask symbol.

[0133] Specifically, for each compositional phrase, if the number of words in the compositional phrase is greater than the number of pitches in the baseline melody, this indicates that the number of pitches required for the final lyrics melody corresponding to the compositional phrase is greater than the number of pitches in the baseline melody. Therefore, simply trimming or redistributing the individual pitch information of the baseline melody is insufficient. In this case, the computer device can determine the segmented text corresponding to each pitch information in the baseline melody based on the word segmentation of the compositional phrase and the preset melody filling rules. Furthermore, the melody filling rules herein can be rules for melody distribution based on word segmentation, melody direction, and / or vowel pronunciation.

[0134] Since the number of words in the composition phrase is greater than the number of pitches in the reference melody, after determining the segmented text corresponding to each pitch information in the reference melody, a portion of the segmented text corresponds to the pitch information (this portion of the segmented text is the first segmented text described in this article), and the other portion of the segmented text does not correspond to the pitch information (this portion of the segmented text is the second segmented text described in this article). The computer device can determine the approximate melody direction of the composition phrase based on the pitch information of each first segmented text and the text position of each first segmented text in the composition phrase, and determine the melody information of each second segmented text accordingly. The melody information of each second segmented text can be pitch information or a mask symbol. In one example, the computer device can determine the melody information of each second segmented text based on a preset melody determination rule or a probabilistic statistical model.

[0135] Through the method described in this embodiment, the computer device can develop diverse melodies based on the reference melody as the basis for composition, so as to further improve the diversity of the melody.

[0136] In one embodiment, the step of generating the initial phrase melody of the composition phrase according to the number of phrase words of the composition phrase, the number of pitches of the reference melody, and the pitch information of each reference melody includes:

[0137] If the number of words in the composition phrase is less than the number of pitches in the reference melody, then according to the number of words in the composition phrase and a preset melody clipping rule, the pitch information of the reference melody is clipped so that the number of pitches of the clipped reference melody is equal to the number of words in the composition phrase;

[0138] The trimmed reference melody is used as the initial phrase melody of the composition phrase.

[0139] Specifically, for each compositional phrase, if the number of words in the compositional phrase is less than the number of pitches in the reference melody, this indicates that the number of pitches required for the final lyric melody corresponding to the compositional phrase is less than the number of pitches in the reference melody. In this case, the computer device can trim the individual pitch information contained in the reference melody according to a preset melody trimming rule to trim the reference melody to the same length as the compositional phrase. For example, if the number of words in the compositional phrase is 8 and the corresponding reference melody is [52, 60, 57, 55, 52, 52, 55, 57, 60, 57, 55, 57], then the trimmed reference melody can be [52, 60, 55, 52, 55, 57, 60, 57].

[0140] After obtaining the trimmed baseline melody, the computer device can use the trimmed baseline melody as a basis for composing to develop a variety of melodies. This can shorten the time it takes to generate the initial lyrics melody, and further shorten the time it takes to generate the final lyrics melody, further improving the efficiency of melody generation.

[0141] In one embodiment, the process of obtaining the pitch prediction model includes:

[0142] Obtaining pre-generated second original melodies;

[0143] masking each of the second original melodies using a plurality of masking methods to obtain each second masked melodies;

[0144] Using each second mask melody and the second original melody corresponding to each second mask melody as a training set, the initial prediction model is trained until the training is completed and the pitch prediction model is obtained; wherein the initial prediction model is used for model pre-training according to the mask language model.

[0145] The detailed description of the second original melody can be found in the above embodiment, which will not be repeated here.

[0146] Specifically, when generating a training set for obtaining a pitch prediction model, the computer device may mask the second original melody using a variety of different masking methods, and obtain multiple second masked melodies based on the masking results. In other words, for any two second masked melodies, their masking methods may be the same or different.

[0147] It is understood that the specific masking method can be determined according to the actual situation, and this document does not impose any specific restrictions on this. In one example, the computer device can use random masking at a token (word) granularity and random masking at a phrase granularity. For example, the second original melody may be [64 64 64 64 62 62 62], [64 67 64 67 67], [64 64 55 55 52 55 55 57 57 60 60 60 60 62]], where “,” is a phrase separator. Then, after random masking at the token granularity, the masked result may be [64[mask][mask]64 62 62 62], [64 67[mask]67 67], [64 64 [mask]55 52[mask]55 57[mask]60 60 60 60 62]. After random masking at the phrase granularity, the masked results can be [[mask][mask][mask][mask][mask][mask][mask]],[64 67 64 67 67],[64 64 55 55 52 55 55 57 57 60 60 60 60 62].

[0148] After obtaining each second masked melody, the computer device can use the second masked melody and the second original melody used to generate the second masked melody as a set of training data, and generate training data corresponding to each second masked melody to obtain a training set including each set of training data. The training set is then used to train the initial prediction model, so that the initial prediction model can be pre-trained based on the masked language model, and a pitch prediction model is obtained upon completion of the training.

[0149] In this embodiment, the computer device uses multiple different masking methods to generate a training set, so that the training set can simulate noisy data generated by different noisy processes. Since the pitch prediction model is trained using the training set, the pitch prediction model can have a better prediction effect.

[0150] In one embodiment, each second original melody includes at least one second original phrase melody, wherein the second original phrase melody refers to melody information of a single phrase extracted from a sample song.

[0151] The steps of masking each second original melody using multiple masking methods to obtain each second masked melody include:

[0152] Masking each second original melody using a plurality of masking methods to obtain each third masked melody;

[0153] For each third mask melody, the second original phrase melody that does not contain a mask symbol in the third mask melody is used as the target phrase melody, and each pitch information of the target phrase melody is shuffled to obtain a second mask melody.

[0154] Specifically, after masking the second original melody, the masked result is a third masked melody. In the third masked melody, some of the second original phrasing melodies have masking symbols, while other parts do not. The computer device uses the second original phrasing melodies without masking symbols as target phrasing melodies, adjusts the arrangement order of each pitch information in the target phrasing melodies, and uses each of the adjusted second original phrasing melodies as the second masked melody.

[0155] For example, when the second original melody is [64 64 64 64 62 62 62],[64 67 64 67 67],[64 64 55 55 52 55 55 57 57 60 60 60 60 62]], and the result of random masking is [[mask][mask][mask][mask][mask][mask][mask]],[64 67 64 67 67],[64 64 55 55 52 55 55 57 57 60 60 60 60 62]], the second masked melody can be [[mask][mask][mask][mask][mask][mask]],[67 64 67 67 64],[55 52 55 64 64 55 55 57 60 60 60 60 62 57].

[0156] In this embodiment, by adjusting the order of the pitch information in the second original phrase melody, which does not contain the mask symbol, the loss values ​​of all tokens are returned during model training to serve as the basis for updating model parameters, rather than updating model parameters based solely on the loss values ​​of masked tokens. This optimizes the prediction performance of the pitch prediction model and further increases the diversity of lyrics melodies.

[0157] The melody generation device provided in an embodiment of the present application is described below. The melody generation device described below and the melody generation method described above can refer to each other.

[0158] In one embodiment, the present application provides a melody generation device 500. As shown in FIG5 , the device 500 may include:

[0159] The text acquisition module 510 is configured to acquire text information of the custom lyrics text when receiving the custom lyrics text;

[0160] The first lyrics melody generating module 520 is configured to generate an initial lyrics melody corresponding to the custom lyrics text based on the text information and the pre-generated first original melody; the initial lyrics melody includes multiple pitch information;

[0161] a masking module 530 configured to mask part of the pitch information of the initial lyrics melody according to a preset masking rule to obtain a target masked melody;

[0162] The second lyrics melody generation module 540 is configured to input the target mask melody into the pitch prediction model, and generate the final lyrics melody corresponding to the custom lyrics text based on the pitch prediction information output by the pitch prediction model; wherein the pitch prediction model is a neural network model that is pre-trained based on the mask language model.

[0163] In one embodiment, the masking module 530 includes an accompaniment acquisition unit, a music theory judgment unit, a first masking unit, and a target masked melody generation unit. The accompaniment acquisition unit is configured to acquire an accompaniment melody corresponding to the custom lyrics text. The music theory judgment unit is configured to determine whether each pitch information of the initial lyrics melody conforms to music theory based on the accompaniment melody and preset music theory rules. The first masking unit is configured to mask the pitch information in the initial lyrics melody that does not conform to music theory to obtain a first masked melody. The target masked melody generation unit is configured to generate a target masked melody based on the first masked melody.

[0164] In one embodiment, the target masked melody generation unit includes a masking ratio calculation unit and a random masking unit. The masking ratio calculation unit is configured to calculate the masking ratio of a first masked melody. The random masking unit is configured to, if the masking ratio of the first masked melody is less than a preset ratio threshold, randomly mask each pitch information of the first masked melody according to the preset ratio threshold to obtain a target masked melody. The masking ratio of the target masked melody is greater than or equal to the preset ratio threshold.

[0165] In one embodiment, the target mask melody generation unit includes a mask ratio calculation unit and a first melody determination unit. The mask ratio calculation unit is configured to calculate the mask ratio of the first mask melody. The first melody determination unit is configured to use the first mask melody as the target mask melody if the mask ratio of the first mask melody is greater than or equal to a preset ratio threshold.

[0166] In one embodiment, the second lyric melody generation module 540 includes an inference method selection unit and a final lyric melody generation unit. The inference method selection unit is configured to select a target pitch inference method from a plurality of preset pitch inference methods and the corresponding selection probability of each pitch inference method. The final lyric melody generation unit is configured to input the target mask melody into a pitch prediction model and generate a final lyric melody based on the target inference method and the pitch prediction information.

[0167] In one embodiment, the pitch prediction information includes predicted pitch probabilities corresponding to each mask symbol in the target mask melody.

[0168] The final lyrics melody generation unit includes a pitch prediction information acquisition unit, a first pitch determination unit and a melody filling unit. Among them, the pitch prediction information acquisition unit is configured to input the target mask melody into the pitch prediction model when the target reasoning method is a one-time reasoning method to obtain pitch prediction information. The first pitch determination unit is configured to determine the target probability threshold for each mask symbol in the target mask melody, and according to the target probability threshold, select the target pitch probability from each predicted pitch probabilities corresponding to the mask symbol, and use the pitch information corresponding to the target pitch probability as the pitch information corresponding to the mask symbol, wherein the target pitch probability is greater than or equal to the target probability threshold. The melody filling unit is configured to fill the pitch information corresponding to each mask symbol into the target mask melody respectively to obtain the final lyrics melody.

[0169] In one embodiment, the first pitch determination unit includes a candidate pitch probability selection unit and a random selection unit. The candidate pitch probability selection unit is configured to select, from among the predicted pitch probabilities corresponding to the mask symbol, predicted pitch probabilities that are greater than or equal to a target probability threshold as candidate pitch probabilities. The random selection unit is configured to randomly select a target pitch probability from among the candidate pitch probabilities.

[0170] In one embodiment, the pitch prediction information includes predicted pitch probabilities corresponding to each mask symbol in the target mask melody.

[0171] The final lyrics melody generation unit includes a second pitch determination unit. The second pitch determination unit is configured to, when the target inference mode is multiple inference mode and the target mask melody includes at least one mask symbol, input the target mask melody into the pitch prediction model to obtain pitch prediction information and determine a target probability threshold. Based on the target probability threshold, N target pitch probabilities are selected from the pitch prediction information most recently output by the pitch prediction model, and based on the positions of the mask symbols corresponding to the N target pitch probabilities, the pitch information corresponding to the N target pitch probabilities is respectively filled into the target mask melody to update the target mask melody until the updated target mask melody does not include the mask symbol and the final lyrics melody is obtained; wherein each target pitch probability is greater than or equal to the target probability threshold, and N is a preset positive integer and less than the initial number of mask symbols of the target mask melody.

[0172] In one embodiment, the first lyric melody generation module 520 includes a lyric rhythm generation unit, a first original melody selection unit, and an initial lyric melody generation unit. The lyric rhythm generation unit is configured to generate lyric rhythm information corresponding to the custom lyric text based on text information. The first original melody selection unit is configured to randomly select a second original melody that matches the lyric rhythm information from a plurality of pre-generated second original melodies as the first original melody. The initial lyric melody generation unit is configured to generate an initial lyric melody based on the first original melody.

[0173] In one embodiment, the text information includes the number of input sentences and the number of words in the custom lyrics text.

[0174] The lyric rhythm generation unit includes a composition sentence rule determination unit, a first composition sentence determination unit, a second composition sentence determination unit, and a reference rhythm acquisition unit. The composition sentence rule determination unit is configured to determine whether the custom lyric text meets the preset composition sentence rules based on the number of input sentences and the number of words in the text. The first composition sentence determination unit is configured to segment the custom lyric text according to the composition sentence rules to obtain individual composition sentences if the composition sentence rules are not met. The second composition sentence determination unit is configured to use each input sentence of the custom lyric text as each composition sentence if the composition sentence rules are met. The reference rhythm acquisition unit is configured to screen multiple pre-generated original rhythm information based on the sentence information of each composition sentence to obtain reference rhythm information, and generate lyric rhythm information based on the reference rhythm information.

[0175] In one embodiment, the sentence information of the composition sentence includes the song structure type corresponding to the composition sentence. The reference rhythm acquisition unit includes a screening unit. The screening unit is configured to screen the plurality of original rhythm information based on each song structure type and the number of composition sentences corresponding to each song structure type to obtain the reference rhythm information.

[0176] In one embodiment, the reference tempo information includes at least one original phrase tempo information. The reference tempo acquisition unit includes a tempo adjustment unit. The tempo adjustment unit is configured to, for each composition phrase, determine, in the reference tempo information, the original phrase tempo information that matches the arrangement order of the composition phrase as target tempo information, perform word segmentation on the composition phrase, and adjust the target tempo information based on the word segmentation result to obtain lyrics tempo information corresponding to the composition phrase.

[0177] In one embodiment, the first original melody includes at least one first original phrase melody, and the initial lyrics melody includes an initial phrase melody corresponding to each composition phrase. The reference rhythm acquisition unit includes a melody adjustment unit. The melody adjustment unit is configured to, for each composition phrase, determine a first original phrase melody in the first original melody that matches the arrangement order of the composition phrase as a reference melody, and generate an initial phrase melody for the composition phrase based on the number of phrase words in the composition phrase, the number of pitches in the reference melody, and information about the individual pitches of the reference melody.

[0178] In one embodiment, the melody adjustment unit includes a third pitch determination module and a second melody determination module. The third pitch determination module is configured to perform word segmentation processing on the composition phrase to obtain each word segmentation text if the number of words in the composition phrase is greater than the number of pitches of the reference melody, and determine the word segmentation text corresponding to each pitch information in the reference melody according to the preset melody filling rules. The second melody determination module is configured to determine the melody information of each second word segmentation text based on the text position of each first word segmentation text in the composition phrase and the pitch information corresponding to each first word segmentation text, so as to obtain the initial word segmentation melody of the composition phrase; wherein the first word segmentation text is a word segmentation text that has corresponding pitch information, the second word segmentation text is a word segmentation text that does not have corresponding pitch information, and the melody information of each second word segmentation text is pitch information or a mask symbol.

[0179] In one embodiment, the melody adjustment unit includes a melody clipping unit and an initial phrase melody determination unit. The melody clipping unit is configured to clip the pitch information of the reference melody according to the number of phrases of the composition phrase and a preset melody clipping rule if the number of phrases of the composition phrase is less than the number of pitches of the reference melody, so that the number of pitches of the clipped reference melody is equal to the number of phrases of the composition phrase. The initial phrase melody determination unit is configured to use the clipped reference melody as the initial phrase melody of the composition phrase.

[0180] In one embodiment, the melody generation module of the present application further includes a second original melody acquisition module, a second masked melody acquisition module, and a model training module. The second original melody acquisition module is configured to acquire pre-generated second original melodies. The second masked melody acquisition module is configured to mask each second original melody using a plurality of masking methods and obtain each second masked melody. The model training module is configured to perform model training on the initial prediction model using each second masked melody and the second original melody corresponding to each second masked melody as a training set until the training is completed and a pitch prediction model is obtained; the initial prediction model is configured to perform model pre-training based on a masked language model.

[0181] In one embodiment, each second original melody includes at least one second original phrase melody. The second mask melody acquisition module includes a second masking unit and a scrambling unit. The second masking unit is configured to mask each second original melody using multiple masking methods to obtain each third masked melody. The scrambling unit is configured to, for each third masked melody, use the second original phrase melody that does not contain a masking symbol in the third masked melody as the target phrase melody, and scramble the pitch information of the target phrase melody to obtain the second masked melody.

[0182] In one embodiment, the present application further provides a storage medium storing computer-readable instructions. When the computer-readable instructions are executed by one or more processors, the one or more processors execute the steps of the melody generation method in any embodiment.

[0183] In one embodiment, the present application further provides a computer device having computer-readable instructions stored therein. When the computer-readable instructions are executed by one or more processors, the one or more processors execute the steps of the melody generation method in any embodiment.

[0184] Schematically, Figure 6 illustrates the internal structure of a computer device provided in an embodiment of the present application. In one example, the computer device can be a server. Referring to Figure 6 , computer device 900 includes a processing component 902, which further includes one or more processors, and memory resources represented by memory 901 for storing instructions executable by processing component 902, such as applications. The applications stored in memory 901 can include one or more modules, each corresponding to a set of instructions. Furthermore, processing component 902 is configured to execute the instructions to perform the steps of the melody generation method described in any of the above embodiments.

[0185] The computer device 900 may further include a power supply component 903 configured to perform power management of the computer device 900, a wired or wireless network interface 904 configured to connect the computer device 900 to a network, and an input / output (I / O) interface 905. The computer device 900 may operate based on an operating system stored in the memory 901, such as Windows Server™, Mac OS X™, Unix™, Linux™, Free BSD™, or the like.

[0186] Those skilled in the art will understand that the internal structure of the computer device shown in the present application is merely a block diagram of a partial structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different component arrangement.

[0187] Finally, it should be noted that, in this article, relational terms such as first and second are merely used to distinguish one entity or operation from another, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprise," "include," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, article, or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. Without further restriction, an element defined by the phrase "comprising a..." does not exclude the presence of other identical elements in the process, method, article, or device comprising the element. Herein, "one," "said," "the," and "its" may also include plural forms unless the context clearly indicates otherwise. A plurality refers to at least two, such as 2, 3, 5, or 8. "And / or" includes any and all combinations of the relevant listed items.

[0188] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The various embodiments can be combined as needed, and the same or similar parts can be referenced to each other.

[0189] The above description of the disclosed embodiments is intended to enable one skilled in the art to implement or use the present application. Various modifications to these embodiments will be readily apparent to one skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application is not limited to the embodiments shown herein, but is intended to conform to the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A melody generation method, characterized in that: The method comprises: When receiving the custom lyrics text, obtaining text information of the custom lyrics text; Generating an initial lyrics melody corresponding to the custom lyrics text according to the text information and a pre-generated first original melody; the initial lyrics melody includes a plurality of pitch information; Masking part of the pitch information of the initial lyrics melody according to a preset masking rule to obtain a target masked melody; The target masked melody is input into a pitch prediction model, and a final lyric melody corresponding to the custom lyric text is generated according to the pitch prediction information output by the pitch prediction model; wherein the pitch prediction model is a neural network model pre-trained based on a masked language model.

2. The melody generation method according to claim 1, characterized in that: The step of masking part of the pitch information of the initial lyrics melody according to a preset masking rule to obtain a target masked melody includes: Obtain the accompaniment melody corresponding to the custom lyrics text; According to the accompaniment melody and preset music theory rules, determining whether each pitch information of the initial lyrics melody conforms to music theory; Masking the pitch information in the initial lyrics melody that does not conform to music theory to obtain a first masked melody; The target mask melody is generated based on the first mask melody.

3. The melody generation method according to claim 2, characterized in that: The step of generating the target mask melody based on the first mask melody comprises: calculating a masking ratio of the first masking melody; If the masking ratio of the first mask melody is less than a preset ratio threshold, randomly masking each pitch information of the first mask melody according to the preset ratio threshold to obtain the target mask melody; Wherein, the masking ratio of the target mask melody is greater than or equal to the preset ratio threshold.

4. The melody generation method according to claim 2, characterized in that: The step of generating the target mask melody based on the first mask melody comprises: calculating a masking ratio of the first masking melody; If the masking ratio of the first mask melody is greater than or equal to a preset ratio threshold, the first mask melody is used as the target mask melody.

5. The melody generation method according to claim 1, characterized in that: The step of inputting the target mask melody into the pitch prediction model and generating the final lyrics melody corresponding to the custom lyrics text according to the pitch prediction information output by the pitch prediction model includes: According to a plurality of preset pitch inference methods and a selection probability corresponding to each of the pitch inference methods, a target inference method is selected from the plurality of pitch inference methods; The target mask melody is input into the pitch prediction model, and the final lyrics melody is generated according to the target reasoning method and the pitch prediction information.

6. The melody generation method according to claim 5, characterized in that: The pitch prediction information includes each predicted pitch probability corresponding to each mask symbol in the target mask melody; The step of inputting the target mask melody into the pitch prediction model and generating the final lyrics melody according to the target reasoning method and the pitch prediction information comprises: When the target reasoning mode is a one-time reasoning mode, inputting the target mask melody into the pitch prediction model to obtain the pitch prediction information; For each mask symbol in the target mask melody, determine a target probability threshold, select a target pitch probability from each of the predicted pitch probabilities corresponding to the mask symbol according to the target probability threshold, and use the pitch information corresponding to the target pitch probability as the pitch information corresponding to the mask symbol, wherein the target pitch probability is greater than or equal to the target probability threshold; The pitch information corresponding to each mask symbol is respectively filled into the target mask melody to obtain the final lyrics melody.

7. The melody generation method according to claim 6, characterized in that: The step of selecting a target pitch probability from each of the predicted pitch probabilities corresponding to the mask symbol according to the target probability threshold comprises: Among the predicted pitch probabilities corresponding to the mask symbol, each predicted pitch probability that is greater than or equal to the target probability threshold is used as a candidate pitch probability; The target pitch probability is randomly selected from each of the candidate pitch probabilities.

8. The melody generation method according to claim 5, characterized in that: The pitch prediction information includes each predicted pitch probability corresponding to each mask symbol in the target mask melody; The step of inputting the target mask melody into the pitch prediction model and generating the final lyrics melody according to the target reasoning method and the pitch prediction information comprises: When the target reasoning mode is a multiple reasoning mode, and the target mask melody includes at least one mask symbol, the target mask melody is input into the pitch prediction model to obtain the pitch prediction information, and a target probability threshold is determined, and according to the target probability threshold, N target pitch probabilities are selected from the pitch prediction information most recently output by the pitch prediction model, and based on the mask symbol positions corresponding to the N target pitch probabilities, the pitch information corresponding to the N target pitch probabilities is respectively filled into the target mask melody to update the target mask melody, until the updated target mask melody does not include a mask symbol and the final lyrics melody is obtained; Wherein, each of the target pitch probabilities is greater than or equal to the target probability threshold, and N is a preset positive integer and is less than the number of initial mask symbols of the target mask melody.

9. The melody generation method according to any one of claims 1 to 8, characterized in that: The step of generating an initial lyrics melody corresponding to the custom lyrics text according to the text information and the pre-generated first original melody includes: Based on the text information, generate lyrics rhythm information corresponding to the custom lyrics text; randomly selecting a second original melody matching the lyrics rhythm information from among a plurality of pre-generated second original melodies as the first original melody; The initial lyrics melody is generated according to the first original melody.

10. The melody generation method according to claim 9, characterized in that: The text information includes the number of input sentences and the number of words in the custom lyrics text; The step of generating lyrics rhythm information corresponding to the custom lyrics text based on the text information includes: According to the number of input sentences and the number of words in the text, determining whether the custom lyrics text meets the preset composition sentence rules; If the composition sentence rule is not satisfied, the custom lyrics text is segmented according to the composition sentence rule to obtain each composition sentence; If the composition sentence rule is satisfied, each input sentence of the custom lyrics text is used as each composition sentence; According to the sentence information of each of the composition sentences, a plurality of pre-generated original rhythm information are screened to obtain reference rhythm information, and the lyrics rhythm information is generated based on the reference rhythm information.

11. The melody generation method according to claim 10, characterized in that: The sentence information of the composition sentence includes the song structure type corresponding to the composition sentence; The step of screening the pre-generated multiple original rhythm information according to the phrase information of each of the composition phrases to obtain the reference rhythm information comprises: Based on each of the song structure types and the number of composition phrases corresponding to each of the song structure types, multiple original rhythm information are screened to obtain the benchmark rhythm information.

12. The melody generation method according to claim 10, characterized in that: The reference rhythm information includes at least one original sentence rhythm information; The step of generating the lyrics rhythm information based on the reference rhythm information comprises: For each of the composition sentences, the original sentence rhythm information that matches the arrangement order of the composition sentence is determined in the benchmark rhythm information as the target rhythm information, and the composition sentence is segmented, and the target rhythm information is adjusted based on the result of the segmentation to obtain the lyrics rhythm information corresponding to the composition sentence.

13. The melody generation method according to claim 10, characterized in that: The first original melody includes at least one first original phrase melody, and the initial lyrics melody includes initial phrase melodies corresponding to each of the composition phrases; The step of generating the initial lyrics melody according to the first original melody comprises: For each of the composition phrases, a first original phrase melody matching the arrangement order of the composition phrase is determined in the first original melody as a reference melody, and an initial phrase melody of the composition phrase is generated according to the number of phrase words in the composition phrase, the number of pitches of the reference melody and the individual pitch information of the reference melody.

14. The melody generation method according to claim 13, characterized in that: The step of generating the initial phrase melody of the composition phrase according to the number of phrase words of the composition phrase, the number of pitches of the reference melody and each pitch information of the reference melody comprises: If the number of words in the composition phrase is greater than the number of pitches in the reference melody, the composition phrase is segmented to obtain each segmented text, and the segmented text corresponding to each pitch information in the reference melody is determined according to a preset melody filling rule; Determine the melody information of each of the second segmented word texts according to the text position of each of the first segmented word texts in the composition phrase and the pitch information corresponding to each of the first segmented word texts, so as to obtain the initial segmented word melody of the composition phrase; Among them, the first segmented text is a segmented text with corresponding pitch information, the second segmented text is a segmented text without corresponding pitch information, and the melody information of each of the second segmented texts is pitch information or a mask symbol.

15. The melody generation method according to claim 13, characterized in that: The step of generating the initial phrase melody of the composition phrase according to the number of phrase words of the composition phrase, the number of pitches of the reference melody and each pitch information of the reference melody comprises: If the number of words in the composition phrase is less than the number of pitches of the reference melody, the pitch information of the reference melody is clipped according to the number of words in the composition phrase and a preset melody clipping rule, so that the number of pitches of the clipped reference melody is equal to the number of words in the composition phrase; The trimmed reference melody is used as the initial phrase melody of the composition phrase.

16. The melody generation method according to any one of claims 1 to 8, characterized in that: The process of obtaining the pitch prediction model includes: Acquire each pre-generated second original melody; Using a plurality of masking methods to mask each of the second original melodies, and obtaining each second masked melodies; Using each of the second masked melodies and the second original melody corresponding to each of the second masked melodies as a training set, the initial prediction model is trained until the training is completed and the pitch prediction model is obtained; wherein the initial prediction model is used for model pre-training according to the masked language model.

17. The melody generation method according to claim 16, characterized in that: Each of the second original melodies includes at least one second original phrased melody; The step of masking each of the second original melodies using a plurality of masking methods to obtain each of the second masked melodies comprises: Using a plurality of the masking methods to mask each of the second original melodies to obtain each third masked melodies; For each of the third masked melody, the second original phrase melody that does not contain a mask symbol in the third masked melody is used as a target phrase melody, and each pitch information of the target phrase melody is shuffled to obtain a second masked melody.

18. A melody generating device, characterized in that: The device comprises: A text acquisition module, configured to acquire text information of the custom lyrics text when receiving the custom lyrics text; A first lyrics melody generating module is configured to generate an initial lyrics melody corresponding to the custom lyrics text according to the text information and a pre-generated first original melody; the initial lyrics melody includes a plurality of pitch information; A masking module, configured to mask part of the pitch information of the initial lyrics melody according to a preset masking rule to obtain a target masked melody; The second lyrics melody generation module is configured to input the target masked melody into a pitch prediction model, and generate a final lyrics melody corresponding to the custom lyrics text according to the pitch prediction information output by the pitch prediction model; wherein the pitch prediction model is a neural network model that is pre-trained based on a masked language model.

19. A storage medium, characterized in that: The storage medium stores computer-readable instructions, and when the computer-readable instructions are executed by one or more processors, the one or more processors execute the steps of the melody generation method according to any one of claims 1 to 18.

20. A computer device, characterized in that: include: one or more processors, and memory; The memory stores computer-readable instructions, and when the computer-readable instructions are executed by the one or more processors, the steps of the melody generation method according to any one of claims 1 to 18 are performed.

Citation Information

Patent Citations

  • Singing synthesis method and device, computer device and storage medium

    CN113555001A

  • Method and device for automatically composing chorus from japanese lyrics

    JP2014170146A

  • System, QR tag, method, program and server for managing historical information of seafood using blockchain and IoT technology

    KR1020220131810A

  • Music composition automation including song structure

    US20120312145A1

  • Method and apparatus for computer-aided variation of music and other sequences, including variation by chaotic mapping

    US9286876B1

Cited By

  • Music generation model training method and music generation method

    CN120472869A