Audio file generation method, terminal device and medium

By constructing and training a neural network model to generate audio files, the problem of low efficiency in music creation is solved, and efficient music creation is achieved. The generated audio files possess musicality and musicality.

CN109326270BActive Publication Date: 2024-10-18PING AN TECH (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN201811085971.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2018-09-18
Publication Date
2024-10-18
Estimated Expiration
2038-09-18

AI Technical Summary

Technical Problem

The creation efficiency of musical works in the current technology is relatively low, mainly relying on manual creation, which takes a long time.

Method used

By constructing and training a neural network model, audio files are generated using audio training samples. This process includes obtaining audio training samples, constructing a Long Short-Term Memory (LSTM) network model and a multi-layer neural network model, detecting the user-inputted sound names and generating key-value pair sequences, and finally generating audio files.

Benefits of technology

It improves the efficiency of music creation, generates audio files with a certain degree of musicality, meets users' music creation needs, reduces repetition, and improves the creation effect.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN109326270B_ABST
    Figure CN109326270B_ABST
Patent Text Reader

Abstract

The present invention is applicable to the field of artificial intelligence technology, and provides a method for generating an audio file, a terminal device, and a medium, the method comprising: obtaining a plurality of audio training samples; constructing and training a neural network model according to the audio training samples; detecting a plurality of note names input by a user for constructing a target audio waveform, and determining a code value corresponding to each of the note names; processing each determined code value through a neural network model to obtain a first key-value pair sequence including a plurality of key-value pairs arranged in sequence; and generating an audio file based on the first key-value pair sequence. The present invention realizes the automatic generation of audio files through a neural network model, so that users no longer need to spend a long period of time to think and create, thereby improving the creation efficiency of music works; because the output audio file can have musical rationality to a certain extent, it meets the actual music creation needs of users and achieves a better music creation effect.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of artificial intelligence technology, and in particular relates to a method for generating an audio file, a terminal device and a computer-readable storage medium. Background Art

[0002] With the continuous improvement of material living standards, music has occupied an increasingly important position in people's daily lives. Therefore, more and more people have begun to devote themselves to music creation.

[0003] However, in the prior art, various musical works are mainly created manually, and the creation of musical works depends on creative inspiration and the musical theory level of the creator. Therefore, in most cases, it often takes a long time to create a musical work, resulting in a relatively low creation efficiency. Summary of the invention

[0004] In view of this, an embodiment of the present invention provides a method for generating an audio file, a terminal device, and a computer-readable storage medium to solve the problem of low efficiency in creating music works in the prior art.

[0005] A first aspect of an embodiment of the present invention provides a method for generating an audio file, comprising:

[0006] Obtain multiple audio training samples;

[0007] Constructing and training a neural network model based on the audio training samples;

[0008] Detecting multiple note names input by a user for constructing a target audio waveform, and determining a code value corresponding to each of the note names;

[0009] The determined encoding values ​​are processed by the neural network model to obtain a first key-value pair sequence including a plurality of key-value pairs arranged in sequence; each of the key-value pairs includes a key name and a key value, the key name indicates the encoding value corresponding to the note name, and the key value indicates the duration of the note;

[0010] An audio file is generated based on the first key-value pair sequence.

[0011] A second aspect of an embodiment of the present invention provides a terminal device, including a memory and a processor, wherein the memory stores a computer program that can be run on the processor, and when the processor executes the computer program, the following steps are implemented:

[0012] Obtain multiple audio training samples;

[0013] Constructing and training a neural network model based on the audio training samples;

[0014] Detecting multiple note names input by a user for constructing a target audio waveform, and determining a code value corresponding to each of the note names;

[0015] The determined encoding values ​​are processed by the neural network model to obtain a first key-value pair sequence including a plurality of key-value pairs arranged in sequence; each of the key-value pairs includes a key name and a key value, the key name indicates the encoding value corresponding to the note name, and the key value indicates the duration of the note;

[0016] An audio file is generated based on the first key-value pair sequence.

[0017] A third aspect of an embodiment of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the following steps are implemented:

[0018] Obtain multiple audio training samples;

[0019] Constructing and training a neural network model based on the audio training samples;

[0020] Detecting multiple note names input by a user for constructing a target audio waveform, and determining a code value corresponding to each of the note names;

[0021] The determined encoding values ​​are processed by the neural network model to obtain a first key-value pair sequence including a plurality of key-value pairs arranged in sequence; each of the key-value pairs includes a key name and a key value, the key name indicates the encoding value corresponding to the note name, and the key value indicates the duration of the note;

[0022] An audio file is generated based on the first key-value pair sequence.

[0023] In the embodiment of the present invention, the automatic generation of audio files is realized through a neural network model, so that users no longer need to spend a long period of time to think and create, thereby improving the creation efficiency of musical works; because the training samples of the neural network model are audio training samples that have been created in advance, and the output key-value pair sequence is related to multiple note names input by the user, it is guaranteed that the key-value pair sequence output by the neural network model can have certain music melody characteristics after executing the encoding conversion; by using the key-value pair sequence to generate the corresponding audio file, the audio data contained in the audio file can have musical rationality to a certain extent, thereby also meeting the actual music creation needs of the user and achieving a better music creation effect. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0025] Figure 1 is a flow chart of an implementation of a method for generating an audio file provided by an embodiment of the present invention;

[0026] Figure 2 is a specific implementation flow chart of the method S101 for generating an audio file provided in an embodiment of the present invention;

[0027] Figure 3 This is a specific implementation process of the audio file generation method S105 provided in an embodiment of the present invention;

[0028] Figure 4 This is a specific implementation process of the audio file generation method S1052 provided in an embodiment of the present invention;

[0029] Figure 5 is a structural block diagram of a device for generating an audio file provided by an embodiment of the present invention;

[0030] Figure 6 It is a schematic diagram of a terminal device provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0031] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present invention. However, it should be clear to those skilled in the art that the present invention may be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present invention.

[0032] In order to illustrate the technical solution of the present invention, a specific embodiment is provided below for illustration.

[0033] Figure 1 The implementation process of the method for generating an audio file provided by an embodiment of the present invention is shown, and the method flow includes steps S101 to S105. The specific implementation principle of each step is as follows:

[0034] S101: Acquire multiple audio training samples.

[0035] In the embodiment of the present invention, the audio training sample is a digitized melody in a currently created audio file, that is, formatted data corresponding to multiple notes that appear continuously in the audio file and conform to music theory. The above audio file can be, for example, a Musical Instrument Digital Interface (MIDI) file. Among them, the MIDI file can be obtained according to the control instructions issued by the music composer in tools such as a MIDI keyboard or a score recorder.

[0036] For example, in a MIDI keyboard, if the touch instructions issued by the music composer on each key in sequence are detected, the notes corresponding to each key are recorded according to the touch order of each key, and the formatted data corresponding to each note that appears in sequence is saved in a MIDI file. The MIDI file transmitted by the above MIDI keyboard can be received through the preset numeric keyboard docking interface.

[0037] In the embodiment of the present invention, the formatted data corresponding to the note is specifically data represented in a key-value pair format. The key-value pair includes a key name and a key value. The key name represents the code value corresponding to the note, and the key value represents the duration of the note.

[0038] As an implementation example of the present invention, since there are usually only 88 musical notes, by storing the code values ​​corresponding to each note in a preset comparison table, when any note is detected, the corresponding code value can be found from the comparison table. For example, for a sixteenth note with a pitch of D3, its corresponding key-value pair is (4, 1).

[0039] In addition to the above-mentioned acquisition of various audio training samples based on the received midi file, as an embodiment of the present invention, Figure 2 The specific implementation process of the method S101 for generating an audio file provided by an embodiment of the present invention is shown, and is described in detail as follows:

[0040] S1011: Acquire multiple sampled notes in an existing audio signal.

[0041] In the embodiment of the present invention, various audio pickups are used to capture any audio signal, and multiple notes contained in the audio signal are identified through a preset sampling frequency. For the convenience of distinction, the notes identified in this process are called sampled notes.

[0042] S1012: Determine the encoding value corresponding to each of the sampled notes according to the MIDI pitch of the sampled notes, and record the note duration of each of the sampled notes in units of preset duration.

[0043] According to the note name of each sampled note, the MIDI pitch corresponding to the note name is determined in the preset correspondence table of note names and MIDI pitches. For example, if there is a sampled note "C4", its corresponding MIDI pitch is 60.

[0044] In the embodiment of the present invention, a pre-selected note is used as a reference object. The difference between the sampled note and the initial code value is determined according to the difference between the MIDI pitch of the sampled note and the MIDI pitch of the reference object; and the code value corresponding to the sampled note is calculated according to the sum of the initial code value and the difference.

[0045] For example, if the note "C3" is pre-selected as the reference object and its MIDI pitch is 48, it means that the encoding operation of the note is performed starting from MIDI pitch 48. The initial encoding value in the embodiment of the present invention is 2. Therefore, if the sampled note is "C#3", the difference between its MIDI pitch 49 and the MIDI pitch 48 of the reference object is 1, so the encoding value corresponding to the sampled note is determined to be the sum of the initial encoding value 2 and the difference 1, that is, the encoding value corresponding to the sampled note "C#3" is 3. If the sampled note is "C3", the difference between its MIDI pitch and the MIDI pitch of the reference object is 0, so the encoding value corresponding to the sampled note is determined to be the initial encoding value 2.

[0046] In particular, the code value corresponding to the rest is 0.

[0047] In the embodiment of the present invention, the multiple value of the beat continuation duration of each sampled note relative to the preset duration is determined with the preset duration as a unit, and the multiple value is output as the note duration corresponding to the sampled note.

[0048] For example, taking the beat duration of a sixteenth note as a unit, if the sampled note "C3" is an eighth note, its beat duration is two unit durations, so the corresponding note duration is 2.

[0049] S1013: Based on each of the sampled notes and the corresponding encoding value and the note duration, a long short-term memory network LSTM model is trained.

[0050] After the code value and note duration of each sampled note are identified through the above steps S1011 and S1012, a key-value pair corresponding to the sampled note is generated. The key-value pair corresponding to each sampled note and the source audio signal of the sampled note are used as training samples to construct and train a long short-term memory network (LSTM) model, so that the trained LSTM model can be used to extract the key-value pair information matched by the audio signal.

[0051] The network of the above LSTM model is a single-layer network, which contains 100 neurons. The model is trained by iterating the input of a preset number of multiple existing audio signals and key-value pairs, using the Adam gradient descent algorithm, and clipping the gradients whose sum of the Euclidean distance L2 norm (L2norm) is greater than 5 to avoid gradient explosion in the LSTM model.

[0052] S1014: Input the multi-channel audio signals collected in real time into the LSTM model, and obtain multiple audio training samples output by the LSTM model.

[0053] As an implementation example of the present invention, the above-mentioned acquisition of the multi-channel audio signals collected in real time at the current moment includes: acquiring a plurality of completed music files; playing each music file separately, and collecting multiple audio signals therein.

[0054] As another implementation example of the present invention, when a music composer plays music in real time, an audio pickup is used to collect audio signals.

[0055] The currently collected audio signal is input into the trained LSTM model, so that after the LSTM model processes each audio signal, it outputs a key-value pair corresponding to the audio signal, and uses the key-value pair as an audio training sample for subsequent training of other neural network models.

[0056] In the embodiment of the present invention, by obtaining multiple sampled notes in an existing audio signal and generating key-value pairs matching the notes, the LSTM model is trained with the audio signal and the key-value pairs, which ensures that when the audio signal collected in real time is detected, the key-value pair data satisfying the preset format can be automatically output through the trained LSTM model, thereby achieving the effect of automatic generation of audio training samples and improving the efficiency of obtaining audio training samples.

[0057] S102: Constructing and training a neural network model based on the audio training samples.

[0058] In an embodiment of the present invention, a neural network model is constructed and trained based on the multiple audio training samples obtained as described above, so that the trained neural network model can be used to detect each input note name and output a key-value pair sequence after automatic creation is completed.

[0059] Specifically, the above training process includes:

[0060] Pre-build a multi-layer neural network model. The multi-layer neural network model can be a Deep-Q-learning reinforcement learning model based on a three-layer network structure. The Deep-Q-learning reinforcement learning model includes a cascaded recurrent neural network (Note Recurrent Neural Network, Note RNN) and a reinforcement learning network; the reinforcement learning network includes a target Q value network (Target Q Network), a Q network (Q Network) and a reward recurrent neural network (RewardRNN).

[0061] In the embodiment of the present invention, various preset parameters contained in the Note RNN are obtained, and based on the preset parameters, the Target Q Network and the Q Network are initialized. Among them, the Reward RNN is a direct copy of the Note RNN, that is, the two have the same network structure and parameters.

[0062] After completing the initialization processing operations on each layer of the cascade network, adjust the various model parameters of the Deep-Q-learning reinforcement learning model until the optimal Q value appears in the Deep-Q-learning reinforcement learning model, and stop adjusting. According to the following formula, determine the model π value corresponding to the optimal Q value when it is detected:

[0063]

[0064] Among them, s t is the encoding value output by the neural network model corresponding to time t, a t is the encoding value corresponding to time t+1 output by the neural network model, r is the feedback value, π * is the optimal key-value pair sequence.

[0065] In the embodiment of the present invention, a pre-established loss function is obtained. The loss function may be, for example:

[0066]

[0067]

[0068] Among them, the above π is the encoding value output by the neural network model; θ- and θ are both preset parameters of Target Q Network, γ is the discount coefficient, and c is a preset constant value, which is used to represent the influence weight of music theory factors on the system feedback value.

[0069] By using the stochastic gradient descent method, the Q value corresponding to the minimum output value of the above loss function is calculated, and the Q value is determined as the optimal Q value of the Deep-Q-learning reinforcement learning model.

[0070] Preferably, the discount coefficient γ is 0.5, and the preset constant value c is 0.5.

[0071] The embodiment of the present invention adjusts the various model parameters of the neural network model based on the above-mentioned loss function, thereby ensuring that the neural network model after training can output key-value pair data that is consistent with music theory and has higher randomness, thereby reducing the repetitiveness of music creation works and achieving better music creation effects.

[0072] S103: Detect multiple note names input by the user for constructing a target audio waveform, and determine a coding value corresponding to each of the note names.

[0073] In an embodiment of the present invention, a user is requested to input multiple note names for constructing a target audio waveform, so as to determine them as the respective tonic notes in the audio file to be generated, or the tonality of the audio file to be generated is determined based on the multiple note names. For example, if it is detected that the note names input by the user are C, E, and G, then the tonality of the audio file to be generated can be determined to be C.

[0074] According to the preset comparison table of note names and code values, the code value corresponding to each note name input by the user is determined.

[0075] S104: Processing each of the determined coding values ​​through the neural network model to obtain a first key-value pair sequence including a plurality of key-value pairs arranged in sequence; each of the key-value pairs includes a key name and a key value, the key name represents the coding value corresponding to the note name, and the key value represents the duration of the note.

[0076] S105: Generate an audio file based on the first key-value pair sequence.

[0077] In the embodiment of the present invention, the neural network model trained in step S102 is used to process each determined code value to output a first key-value pair sequence, wherein the first key-value pair sequence includes a plurality of key-value pairs arranged in sequence.

[0078] Since each key-value pair contains a key name for representing a coding value and a key value for representing a note duration, by creating an audio file based on the first key-value pair sequence, it is ensured that when the audio file is played, the audio signals matching the note names corresponding to each key-value pair can be played in sequence, and the playback duration of the audio signal is the note duration corresponding to the key-value pair.

[0079] In the embodiment of the present invention, the automatic generation of audio files is realized through a neural network model, so that users no longer need to spend a long period of time to think and create, thereby improving the creation efficiency of musical works; because the training samples of the neural network model are audio training samples that have been created in advance, and the output key-value pair sequence is related to multiple note names input by the user, it is guaranteed that the key-value pair sequence output by the neural network model can have certain music melody characteristics after executing the encoding conversion; by using the key-value pair sequence to generate the corresponding audio file, the audio data contained in the audio file can have musical rationality to a certain extent, thereby also meeting the actual music creation needs of the user and achieving a better music creation effect.

[0080] As an embodiment of the present invention, Figure 3 The specific implementation process of the method S105 for generating an audio file provided by an embodiment of the present invention is shown, and is described in detail as follows:

[0081] S1051: Convert each of the key-value pairs in the first key-value pair sequence, and output each of the note names matching the key-value pairs.

[0082] For each key-value pair in the first key-value pair sequence, the key name and key value contained in the key-value pair are parsed out, and the note name corresponding to the key name parsed out above is output according to the comparison relationship table between the key name and the note name.

[0083] S1052: Determine whether each of the note names meets a preset audio construction condition.

[0084] In the embodiment of the present invention, a preset audio construction condition is loaded. The audio construction condition is used to indicate the conditions that each note name contained in a melody that satisfies music theory needs to meet.

[0085] The above-mentioned audio construction conditions include but are not limited to: 1) the melody tonality associated with each parsed note name is the same as the tonality associated with the target audio waveform determined in step S103; 2) the note name corresponding to the first key value in the first key-value pair sequence is the same as the note name corresponding to the last key value; 3) among the output note names, the two note names with the highest pitch and the lowest pitch are detected respectively; the pitch interval between the above two note names is less than an octave; 4) the note names sequentially associated with the first key-value pair sequence are the same as the note names sequentially input by the user.

[0086] Exemplarily, if in the above S103, the note names input by the user are C1, E1 and G1 respectively, then the melody tonality associated with the note names C1, E1 and G1 is C; if the note names output in sequence through the above S1051 are C2, E2 and G3 respectively, then the melody tonality associated with the note names C2, E2 and G3 is C. Therefore, the tonality associated with the target audio waveform determined in step S103 is the same as the melody tonality associated with each note name parsed in step S1051, so the above audio construction condition 1) is met.

[0087] In the above example, since the note name corresponding to the first key value in the first key-value pair sequence is C2, and the note name corresponding to the last key value is G3, and since the note name C2 is not the same as the note name G3, it can be known that in the audio file generated based on the first key-value pair sequence, the starting note and the ending note are not the same, which does not satisfy conventional music theory, and therefore does not satisfy the above audio construction condition 2).

[0088] Furthermore, the note names associated in sequence with the first key-value pair sequence are C2, E2 and G3, which are different from the note names C1, E1 and G1 input in sequence by the user. This indicates that the automatically generated audio file does not contain the phrase melody specified by the user, and therefore does not meet the above-mentioned audio construction condition 4).

[0089] As an embodiment of the present invention, Figure 4 The specific implementation process of the method S1052 for generating an audio file provided by an embodiment of the present invention is shown, and is described in detail as follows:

[0090] S10521: Add at least one key-value pair matching the pause signal to the header of the first key-value pair sequence to obtain a second key-value pair sequence.

[0091] In the embodiment of the present invention, the first key-value pair sequence described in the neural network model is subjected to a delay process, that is, at least one key-value pair matching the rest signal is added to the head of the first key-value pair sequence, so that the monophonic melody originally generated based on the first key-value pair sequence is shifted back by a specified number of beat durations. Specifically, if the number of key-value pairs added that match the rest signal is N (N is an integer greater than zero), the monophonic melody originally generated based on the first key-value pair sequence is shifted back by N beat durations.

[0092] For the sake of easy distinction, the key-value pair sequence obtained after performing the key-value pair adding operation on the first key-value pair sequence is the second key-value pair sequence.

[0093] S10522: Calculate the autocorrelation coefficient of the first key-value pair sequence using a preset formula.

[0094] In the embodiment of the present invention, the autocorrelation coefficient of the first key-value pair sequence output by the neural network model is calculated by a preset formula. The autocorrelation coefficient is used to indicate the degree of syllable repetition of the melody.

[0095] The above preset formulas include:

[0096]

[0097] Among them, r(Sequence1, Sequence2) represents the autocorrelation coefficient of the first key-value pair sequence, Sequence1 and Sequence2 represent the first key-value pair sequence and the second key-value pair sequence respectively; Cov() is the covariance function, and Var() is the variance function.

[0098] S10523: Determine whether each of the note names corresponding to the first key-value pair sequence meets a preset audio construction condition according to a magnitude relationship between the autocorrelation coefficient and a preset threshold.

[0099] Determine whether the calculated autocorrelation coefficient is greater than a preset threshold value. If the judgment result is yes, it is determined that each note name corresponding to the first key-value pair sequence does not meet the preset audio construction condition; if the judgment result is no, it is determined that each note name corresponding to the first key-value pair sequence meets the preset audio construction condition.

[0100] Preferably, the above preset threshold is 0.15.

[0101] In an embodiment of the present invention, a second key-value pair sequence is generated by delaying the first key-value pair sequence, and the autocorrelation coefficient of the first key-value pair sequence is obtained based on the operation processing of the first key-value pair sequence and the second key-value pair sequence. Only when the autocorrelation coefficient is less than or equal to a preset threshold value, the audio construction condition is determined to be satisfied, thereby avoiding the first key-value pair sequence output by the neural network model having a high degree of autocorrelation. This also ensures that when an audio file is subsequently generated based on the first key-value pair sequence with a lower degree of autocorrelation, there will be no problem of excessive syllable repetition, thereby reducing repeated sounds in the automatically generated audio file and achieving a better music creation effect.

[0102] Preferably, the audio construction condition may include one or more of the above-mentioned embodiments, which are not limited here. When the audio construction condition is multiple of the above-mentioned embodiments, it is necessary to determine whether each of the parsed note names in S1051 satisfies each of the audio construction conditions.

[0103] If all the note names parsed in S1051 meet the currently loaded audio construction conditions, execute step S1053; otherwise, execute step S1054.

[0104] S1053: If each of the note names satisfies the preset audio construction conditions, an audio file based on each of the key-value pairs is generated.

[0105] S1054: If each of the note names does not satisfy the preset audio construction conditions, then return to execute the operation of processing each of the coding values ​​determined by the neural network model to obtain a first key-value pair sequence including a plurality of key-value pairs arranged in sequence.

[0106] If the note names parsed in S1051 do not meet any of the currently loaded audio construction conditions, it means that the audio file generated based on the first key-value pair sequence may not have high musicality. Therefore, the process returns to step S104 so that the neural network model can recalculate the coding values ​​corresponding to the note names input by the user to output another key-value pair sequence again.

[0107] In the embodiment of the present invention, the automatic generation of audio files is achieved through a neural network model, so that users no longer need to spend a long period of time thinking and creating, thereby improving the efficiency of creating music works; because the key-value pair sequence output by the neural network model will be filtered and processed based on the preset audio construction conditions, it is ensured that the audio files automatically generated by the entire creation system can meet the musicality and the actual creation needs of users to a certain extent.

[0108] It should be understood that the order of execution of the steps in the above embodiment does not necessarily mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiment of the present invention.

[0109] Corresponding to the method for generating an audio file provided in an embodiment of the present invention, Figure 5 The structure block diagram of the device for generating an audio file provided by an embodiment of the present invention is shown. For the convenience of description, only the parts related to the present embodiment are shown.

[0110] Reference Figure 5 , the device comprises:

[0111] The acquisition unit 51 is used to acquire a plurality of audio training samples.

[0112] The training unit 52 is used to construct and train a neural network model according to the audio training samples.

[0113] The detection unit 53 is used to detect multiple note names input by the user for constructing the target audio waveform, and determine the encoding value corresponding to each of the note names.

[0114] The processing unit 54 is used to process each of the determined coding values ​​through the neural network model to obtain a first key-value pair sequence including a plurality of key-value pairs arranged in sequence; each of the key-value pairs includes a key name and a key value, the key name represents the coding value corresponding to the note name, and the key value represents the duration of the note.

[0115] The generating unit 55 is configured to generate an audio file based on the first key-value pair sequence.

[0116] Optionally, the generating unit 55 includes:

[0117] The conversion subunit is used to convert each of the key-value pairs in the first key-value pair sequence and output each of the note names matching the key-value pairs.

[0118] The judging subunit is used to judge whether each of the note names meets the preset audio construction conditions.

[0119] A generating subunit is used to generate an audio file based on each of the key-value pairs if each of the note names meets a preset audio construction condition.

[0120] The return subunit is used to return to execute the operation of processing each of the coding values ​​determined by the neural network model to obtain a first key-value pair sequence including a plurality of key-value pairs arranged in sequence if each of the note names does not meet the preset audio construction conditions.

[0121] Optionally, the judging subunit is specifically used for:

[0122] Add at least one key-value pair matching the pause signal to the head of the first key-value pair sequence to obtain a second key-value pair sequence;

[0123] The autocorrelation coefficient of the first key-value pair sequence is calculated by a preset formula, wherein the preset formula includes:

[0124]

[0125] Determining whether each of the note names corresponding to the first key-value pair sequence meets a preset audio construction condition according to a magnitude relationship between the autocorrelation coefficient and a preset threshold;

[0126] Among them, the r(Sequence1, Sequence2) represents the autocorrelation coefficient, the Sequence1 and Sequence2 represent the first key-value pair sequence and the second key-value pair sequence respectively; the Cov() is the covariance function, and Var() is the variance function.

[0127] Optionally, the training unit 52 includes:

[0128] A construction subunit is used to construct a multi-layer neural network model, wherein the neural network model includes a cascaded recurrent neural network and a reinforcement learning network; the reinforcement learning network includes a target Q value network, a Q network, and an incentive recurrent neural network.

[0129] The first acquisition subunit is used to acquire various preset parameters included in the recurrent neural network, and initialize the target Q value network and the Q network based on the preset parameters.

[0130] The adjusting subunit is used to adjust various model parameters in the neural network model until an optimal Q value of the neural network model is detected.

[0131] Optionally, the acquiring unit 51 includes:

[0132] The second acquisition subunit is used to acquire multiple sampled notes from the existing audio signal.

[0133] The determination subunit is used to determine the encoding value corresponding to each of the sampled notes according to the musical instrument digital interface MIDI pitch of the sampled notes, and record the note duration of each of the sampled notes in units of preset duration.

[0134] The training subunit is used to train a long short-term memory network LSTM model based on each of the sampled notes and the corresponding encoding values ​​and the note duration.

[0135] The third acquisition subunit is used to input the multi-channel audio signals collected in real time into the LSTM model to obtain multiple audio training samples output by the LSTM model.

[0136] Figure 6 Schematic diagram of a terminal device provided by an embodiment of the present invention. Figure 6 As shown, the terminal device 6 of this embodiment includes: a processor 60, a memory 61, and a computer program 62 stored in the memory 61 and executable on the processor 60, such as a program for generating an audio file. When the processor 60 executes the computer program 62, the steps in the above-mentioned various audio file generation method embodiments are implemented, such as Figure 1 Alternatively, when the processor 60 executes the computer program 62, the functions of each module / unit in the above-mentioned device embodiments are realized, for example, Figure 5 The functions of the units 51 to 55 are shown.

[0137] Exemplarily, the computer program 62 may be divided into one or more modules / units, which are stored in the memory 61 and executed by the processor 60 to implement the present invention. The one or more modules / units may be a series of computer program instruction segments capable of implementing specific functions, which are used to describe the execution process of the computer program 62 in the terminal device 6.

[0138] The terminal device 6 may be a computing device such as a desktop computer, a notebook, a PDA, or a cloud server. The terminal device may include, but is not limited to, a processor 60 and a memory 61. Those skilled in the art will appreciate that Figure 6 It is only an example of the terminal device 6 and does not constitute a limitation on the terminal device 6. It may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, the terminal device may also include input and output devices, network access devices, buses, etc.

[0139] The processor 60 may be a central processing unit (CPU), other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.

[0140] The memory 61 may be an internal storage unit of the terminal device 6, such as a hard disk or memory of the terminal device 6. The memory 61 may also be an external storage device of the terminal device 6, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the terminal device 6. Further, the memory 61 may also include both an internal storage unit and an external storage device of the terminal device 6. The memory 61 is used to store the computer program and other programs and data required by the terminal device. The memory 61 may also be used to temporarily store data that has been output or is to be output.

[0141] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0142] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, ROM), random access memory (Random Access Memory, RAM), disk or optical disk and other media that can store program codes.

[0143] As described above, the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application.

Claims

1. A method for generating an audio file, characterized in that: include: Obtain multiple audio training samples; Constructing and training a neural network model based on the audio training samples; Detecting multiple note names input by a user for constructing a target audio waveform, and determining a code value corresponding to each of the note names; The determined encoding values ​​are processed by the neural network model to obtain a first key-value pair sequence including a plurality of key-value pairs arranged in sequence; each of the key-value pairs includes a key name and a key value, the key name indicates the encoding value corresponding to the note name, and the key value indicates the duration of the note; Generating an audio file based on the first key-value pair sequence, comprising: converting each of the key-value pairs in the first key-value pair sequence, and outputting each of the note names matching the key-value pairs; Determine whether each of the note names matching the key-value pairs meets the preset audio construction conditions; if each of the note names matching the key-value pairs meets the preset audio construction conditions, generate an audio file based on each of the key-value pairs; if each of the note names matching the key-value pairs does not meet the preset audio construction conditions, return to execute the operation of processing each of the code values ​​determined by the neural network model to obtain a first key-value pair sequence including a plurality of key-value pairs arranged in sequence.

2. The method for generating an audio file according to claim 1, wherein: The step of judging whether each of the note names matching the key-value pair meets a preset audio construction condition includes: Add at least one key-value pair matching the pause signal to the head of the first key-value pair sequence to obtain a second key-value pair sequence; The autocorrelation coefficient of the first key-value pair sequence is calculated by a preset formula, wherein the preset formula includes: Determining whether each of the note names corresponding to the first key-value pair sequence meets a preset audio construction condition according to a magnitude relationship between the autocorrelation coefficient and a preset threshold; Among them, the represents the autocorrelation coefficient, Sequence1 and Sequence2 represent the first key-value pair sequence and the second key-value pair sequence respectively; Cov() is the covariance function, and Var() is the variance function.

3. The method for generating an audio file according to claim 1, wherein: The step of constructing and training a neural network model according to the audio training sample comprises: Constructing a multi-layer neural network model, wherein the neural network model includes a cascaded recurrent neural network and a reinforcement learning network; the reinforcement learning network includes a target Q value network, a Q network, and an incentive recurrent neural network; Acquire various preset parameters included in the recurrent neural network, and initialize the target Q value network and the Q network based on the preset parameters; Adjust various model parameters in the neural network model until an optimal Q value of the neural network model is detected.

4. The method for generating an audio file according to claim 1, wherein: The obtaining of multiple audio training samples comprises: Get multiple sampled notes from an existing audio signal; Determine the code value corresponding to each of the sampled notes according to the MIDI pitch of the sampled notes, and record the note duration of each of the sampled notes in units of a preset duration; Based on each of the sampled notes and the corresponding encoding values ​​and the note duration, a long short-term memory network LSTM model is trained; The multi-channel audio signals collected in real time are input into the LSTM model to obtain multiple audio training samples output by the LSTM model.

5. A terminal device, comprising a memory and a processor, wherein the memory stores a computer program that can be run on the processor, characterized in that: When the processor executes the computer program, the following steps are implemented: Obtain multiple audio training samples; Constructing and training a neural network model based on the audio training samples; Detecting multiple note names input by a user for constructing a target audio waveform, and determining a code value corresponding to each of the note names; The determined encoding values ​​are processed by the neural network model to obtain a first key-value pair sequence including a plurality of key-value pairs arranged in sequence; each of the key-value pairs includes a key name and a key value, the key name indicates the encoding value corresponding to the note name, and the key value indicates the duration of the note; Generating an audio file based on the first key-value pair sequence, comprising: converting each of the key-value pairs in the first key-value pair sequence, and outputting each of the note names matching the key-value pairs; Determine whether each of the note names matching the key-value pairs meets the preset audio construction conditions; if each of the note names matching the key-value pairs meets the preset audio construction conditions, generate an audio file based on each of the key-value pairs; if each of the note names matching the key-value pairs does not meet the preset audio construction conditions, return to execute the operation of processing each of the code values ​​determined by the neural network model to obtain a first key-value pair sequence including a plurality of key-value pairs arranged in sequence.

6. The terminal device according to claim 5, characterized in that: The step of judging whether each of the note names matching the key-value pair meets a preset audio construction condition specifically includes: Add at least one key-value pair matching the pause signal to the head of the first key-value pair sequence to obtain a second key-value pair sequence; The autocorrelation coefficient of the first key-value pair sequence is calculated by a preset formula, wherein the preset formula includes: Determining whether each of the note names corresponding to the first key-value pair sequence meets a preset audio construction condition according to a magnitude relationship between the autocorrelation coefficient and a preset threshold; Among them, the represents the autocorrelation coefficient, Sequence1 and Sequence2 represent the first key-value pair sequence and the second key-value pair sequence respectively; Cov() is the covariance function, and Var() is the variance function.

7. The terminal device according to claim 5, characterized in that: The obtaining of multiple audio training samples comprises: Get multiple sampled notes from an existing audio signal; Determine the code value corresponding to each of the sampled notes according to the MIDI pitch of the sampled notes, and record the note duration of each of the sampled notes in units of a preset duration; Based on each of the sampled notes and the corresponding encoding values ​​and the note duration, a long short-term memory network LSTM model is trained; The multi-channel audio signals collected in real time are input into the LSTM model to obtain multiple audio training samples output by the LSTM model.

8. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 4 are implemented.