CN109448697B - Poem melody generation method, electronic device and computer readable storage medium - Google Patents

Poem melody generation method, electronic device and computer readable storage medium Download PDF

Info

Publication number
CN109448697B
CN109448697B CN201811168589.0A CN201811168589A CN109448697B CN 109448697 B CN109448697 B CN 109448697B CN 201811168589 A CN201811168589 A CN 201811168589A CN 109448697 B CN109448697 B CN 109448697B
Authority
CN
China
Prior art keywords
pitch
matrix
melody
sample
sequence
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201811168589.0A
Other languages
Chinese (zh)
Other versions
CN109448697A (en
Inventor
梅亚琦
朱照华
刘奡智
王健宗
肖京
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ping An Technology Shenzhen Co Ltd
Original Assignee
Ping An Technology Shenzhen Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Ping An Technology Shenzhen Co Ltd filed Critical Ping An Technology Shenzhen Co Ltd
Priority to CN201811168589.0A priority Critical patent/CN109448697B/en
Publication of CN109448697A publication Critical patent/CN109448697A/en
Application granted granted Critical
Publication of CN109448697B publication Critical patent/CN109448697B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G10MUSICAL INSTRUMENTS; ACOUSTICS
    • G10LSPEECH ANALYSIS TECHNIQUES OR SPEECH SYNTHESIS; SPEECH RECOGNITION; SPEECH OR VOICE PROCESSING TECHNIQUES; SPEECH OR AUDIO CODING OR DECODING
    • G10L13/00Speech synthesis; Text to speech systems
    • G10L13/06Elementary speech units used in speech synthesisers; Concatenation rules
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/12Computing arrangements based on biological models using genetic models
    • G06N3/126Evolutionary algorithms, e.g. genetic algorithms or genetic programming
    • GPHYSICS
    • G10MUSICAL INSTRUMENTS; ACOUSTICS
    • G10HELECTROPHONIC MUSICAL INSTRUMENTS; INSTRUMENTS IN WHICH THE TONES ARE GENERATED BY ELECTROMECHANICAL MEANS OR ELECTRONIC GENERATORS, OR IN WHICH THE TONES ARE SYNTHESISED FROM A DATA STORE
    • G10H1/00Details of electrophonic musical instruments
    • G10H1/0033Recording/reproducing or transmission of music for electrophonic musical instruments
    • GPHYSICS
    • G10MUSICAL INSTRUMENTS; ACOUSTICS
    • G10LSPEECH ANALYSIS TECHNIQUES OR SPEECH SYNTHESIS; SPEECH RECOGNITION; SPEECH OR VOICE PROCESSING TECHNIQUES; SPEECH OR AUDIO CODING OR DECODING
    • G10L13/00Speech synthesis; Text to speech systems
    • G10L13/08Text analysis or generation of parameters for speech synthesis out of text, e.g. grapheme to phoneme translation, prosody generation or stress or intonation determination
    • G10L13/10Prosody rules derived from text; Stress or intonation
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D30/00Reducing energy consumption in communication networks
    • Y02D30/70Reducing energy consumption in communication networks in wireless communication networks

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Health & Medical Sciences (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Computational Linguistics (AREA)
  • Biophysics (AREA)
  • Acoustics & Sound (AREA)
  • Multimedia (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Bioinformatics & Cheminformatics (AREA)
  • Bioinformatics & Computational Biology (AREA)
  • Human Computer Interaction (AREA)
  • Evolutionary Biology (AREA)
  • Theoretical Computer Science (AREA)
  • Genetics & Genomics (AREA)
  • Artificial Intelligence (AREA)
  • Biomedical Technology (AREA)
  • Data Mining & Analysis (AREA)
  • Evolutionary Computation (AREA)
  • General Health & Medical Sciences (AREA)
  • Molecular Biology (AREA)
  • Computing Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Mathematical Physics (AREA)
  • Software Systems (AREA)
  • Physiology (AREA)
  • Auxiliary Devices For Music (AREA)

Abstract

The invention relates to big data analysis, and provides a poetry melody generation method, an electronic device and a computer readable storage medium, comprising the following steps: constructing a sample music library for storing poetry samples and match samples; extracting poetry sample structural features to form a sample structural feature matrix; extracting the pitch of the score sample to form a sample pitch matrix; constructing a first probability matrix of the corresponding relation between the structural features and the pitch and a second probability matrix of the transfer relation between adjacent pitches; constructing a new poetry characteristic matrix without matching music; generating a new poetry pitch sequence through the first probability matrix and the second probability matrix according to the structural feature matrix; randomly selecting a score sample section, and sequentially extracting note time values of the score sample section to obtain a new poetry time value sequence; constructing an initial melody sequence of the new poetry through the pitch sequence and the time value sequence of the new poetry; and selecting a melody sequence of a match sample corresponding to the poetry sample with the highest structural feature matching degree, and performing genetic exchange operation on the melody sequence and the initial melody sequence to obtain a final melody of the new poetry.

Description

Poem melody generation method, electronic device and computer readable storage medium
Technical Field
The present invention relates to the field of algorithmic composing technologies, and in particular, to a poetry melody generating method, an electronic device, and a computer readable storage medium.
Background
The poetry is a representation of the essence inheritance of Chinese culture, is used for expressing various emotions of poetry, the artistic value of the ancient poetry is not only represented by the literature value of the poetry, but also has extremely high artistic value in the singing mode of the ancient poetry, however, the evolution mode of Chinese makes the modern Chinese incapable of accurately re-engraving the singing of the ancient poetry, so that the singing mode of the ancient poetry is a mission for promoting Chinese culture.
At present, development of algorithm composition is very rapid, the algorithm composition means that a regular program is used, a probability program is adopted or a computer is used for automatically generating song melody, a method for generating the song melody according to tone characteristics is adopted in a representative method, and if a poetry adopts modern Chinese tone characteristics to generate the music melody, the structural characteristics of the poetry are not considered, so that certain limitation exists in matching generated music with the poetry, for example, transition between two adjacent characters of the poetry is gentle, and the transition of the melody is sharp, and the mood of the poetry cannot be reflected.
Disclosure of Invention
In view of the foregoing, it is an object of the present invention to provide a poetry melody generating method, an electronic device and a computer readable storage medium that combine a poetry structural feature and a tone feature.
In order to achieve the above object, the present invention provides an electronic device including a memory including a poetry melody generation program and a processor executing the poetry melody generation program, the poetry melody generation program including:
the music library construction module is used for constructing a sample music library and storing poetry samples and corresponding match samples thereof;
the first feature extraction module is used for extracting structural features of the poetry samples to form a sample structural feature matrix, wherein the structural features comprise one or more of a rule, a rhyme part, an tone final and a part of speech;
the sample pitch matrix construction module is used for extracting the pitch of the score sample and forming a sample pitch matrix corresponding to the sample structure feature matrix;
the probability matrix construction module is used for obtaining the probability of the corresponding relation between the structural features and the pitches and the probability of the transition relation between the adjacent pitches according to the structural features of each word in the sample structural feature matrix and the corresponding pitches and adjacent pitches in the sample pitch matrix, and respectively constructing a first probability matrix and a second probability matrix;
the second feature extraction module is used for extracting the structural features of new poems which are not matched with the new poems and constructing a structural feature matrix of the new poems;
the pitch sequence generation module is used for generating a pitch sequence of the new poem through the first probability matrix and the second probability matrix according to the structural feature matrix of the new poem;
the timing sequence generation module randomly selects a score sample section from score samples of the sample music library, and sequentially extracts the time values of notes in the score sample section to obtain a time value sequence S of a new poem;
the initial melody sequence generating module constructs an initial melody sequence T of the new poem through a pitch sequence Y and a time value sequence S of the new poem, wherein the number of segments of the initial melody sequence is o 3 All elements in Y and S are traversed to construct notes, and the generated notes are sequentially arranged to obtain an initial melody sequence T;
the final melody generation module is used for selecting o of a match sample corresponding to a poem sample with highest matching degree of structural features of new poems from a sample music library 3 And performing exchange operation in a genetic algorithm on the segment melody sequence and the initial melody sequence T to obtain a final melody T' of the new poem.
In addition, in order to achieve the above object, the present invention further provides a poetry melody generating method, including:
constructing a sample music library for storing poetry samples and corresponding score samples thereof;
extracting structural features of poetry samples to form a sample structural feature matrix, wherein the structural features comprise one or more of rhythms, rhyme parts, tone vowels and part of speech;
extracting the pitch of the score sample to form a sample pitch matrix corresponding to the sample structure feature matrix;
according to the structural feature of each word in the sample structural feature matrix and the corresponding pitch and adjacent pitch in the sample pitch matrix, obtaining the probability of the corresponding relation between the structural feature and the pitch and the probability of the transition relation between the adjacent pitches, and respectively forming a first probability matrix and a second probability matrix;
extracting structural features of new poems which are not matched with music, and constructing a structural feature matrix of the new poems;
generating a pitch sequence of the new poem through the first probability matrix and the second probability matrix according to the structural feature matrix of the new poem;
randomly selecting a score sample section from score samples of a sample music library, and sequentially extracting the time values of notes in the score sample section to obtain a time value sequence S of new poetry;
constructing an initial melody sequence T of the new poem through a pitch sequence Y and a duration sequence S of the new poem, wherein the number of segments of the initial melody sequence is o 3 Wherein, all elements in Y and S are traversed respectively to construct notes, and then the generated notes are sequentially arranged to obtain T;
selecting a matching sample o corresponding to a poem sample with highest matching degree between structural features of new poems and structural features of new poems from a sample music library 3 And performing exchange operation in a genetic algorithm on the segment melody sequence and the initial melody sequence T to obtain a final melody T' of the new poem.
Preferably, the step of generating the pitch sequence of the new poetry includes:
selecting a pitch with highest probability corresponding to a first element of a structural feature matrix of the new poem from the first probability matrix as the pitch of the first element;
selecting a pitch with highest probability of a pitch transfer relation with the first element from the second probability matrix as a pitch of the second element;
repeating the steps to obtain the pitch of all elements of the structural feature matrix of the new poem, and generating a pitch sequence matrix of the new poem.
Preferably, the step of generating the pitch sequence of the new poetry includes:
selecting the former o with highest probability corresponding to the first element of the structural feature matrix of the new poem from the first probability matrix 1 Pitch from o 1 Randomly selecting one pitch from the pitches as a first pitch p 1
Selecting, from the second probability matrix, the first o having the highest probability of being related to the first pitch transition according to the first pitch 2 Pitch from o 2 Randomly selecting one pitch from the pitches as a second pitch p 2
And repeating the previous operation until the pitches corresponding to all elements in the lattice matrix of the new poetry are obtained, and generating a pitch sequence Y of the new poetry without matching.
Preferably, the method for generating the final melody T' of the new poetry includes:
o is selected from matching music samples corresponding to poetry samples with highest matching degree 3 The segment melody sequence and the initial melody sequence T are taken together as a candidate melody sequence;
randomly selecting n exchange points in the initial melody sequence T by taking the musical bars as units;
randomly distributing the exchange points to the joints of different music sections;
and (3) keeping the content before the first exchange point in the initial melody sequence T unchanged, randomly selecting a melody from the designated intervals in the candidate melody for exchange with the melody sequence at the corresponding position in the T for each exchange interval after the exchange point until the exchange ending condition of the genetic algorithm is met, and taking the finally obtained melody T' as a final melody.
In addition, in order to achieve the above object, the present invention also provides a computer-readable storage medium including a poetry melody generation program therein, which when executed by a processor, implements the steps of the above-described poetry melody generation method.
According to the poetry melody generation method, the electronic device and the computer readable storage medium, the poetry and the melody correlation are considered, and meanwhile, the structural characteristics of the poetry are considered, so that the finally generated music melody can be well matched with the tone characteristics and the structural characteristics of the poetry, and the matching degree of the melody and the poetry is improved.
In addition, the related operation in the genetic algorithm is introduced while the original matching melody music characteristics are maintained, so that the finally generated melody has diversity without monotonous.
Drawings
Other objects and attainments together with a more complete understanding of the invention will become apparent and appreciated by referring to the following description taken in conjunction with the accompanying drawings. In the drawings:
FIG. 1 is a schematic view of an application environment of a method for generating a poetry melody according to a preferred embodiment of the invention;
FIG. 2 is a block diagram illustrating a preferred embodiment of the poetry melody generating process of FIG. 1;
FIG. 3 is a flowchart of a poetry melody generating method according to a preferred embodiment of the present invention;
FIG. 4 is a flowchart illustrating another embodiment of the poetry melody generating method according to the present invention;
fig. 5a-5c are schematic views illustrating an embodiment of the poetry melody generating method according to the present invention.
The same reference numerals will be used throughout the drawings to refer to similar or corresponding features or functions.
Detailed Description
It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the scope of the invention.
Specific embodiments of the present invention will be described in detail below with reference to the accompanying drawings.
The invention provides a poetry melody generation method which is applied to an electronic device 1. Referring to fig. 1, an application environment of a preferred embodiment of the poetry melody generating method of the present invention is shown.
In this embodiment, the electronic apparatus 1 may be a terminal device having an operation function, such as a server, a mobile phone, a tablet computer, a portable computer, or a desktop computer.
The electronic device 1 comprises a memory 11, a processor 12, a network interface 13 and a communication bus 14.
The memory 11 includes at least one type of readable storage medium. The at least one type of readable storage medium may be a non-volatile storage medium such as a flash memory, a hard disk, a multimedia card, a card memory 11, etc. In some embodiments, the readable storage medium may be an internal storage unit of the electronic device 1, such as a hard disk of the electronic device 1. In other embodiments, the readable storage medium may also be an external memory 11 of the electronic device 1, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash Card (Flash Card) or the like, which are provided on the electronic device 1.
In the present embodiment, the readable storage medium of the memory 11 is generally used for storing the poetry melody generating program 10, the sample music library, and the like installed in the electronic device 1. The memory 11 may also be used for temporarily storing data that has been output or is to be output.
The processor 12 may in some embodiments be a central processing unit (Central Processing Unit, CPU), microprocessor or other data processing chip for running program codes or processing data stored in the memory 11, such as the poetry melody generating program 10 or the like.
The network interface 13 may optionally comprise a standard wired interface, a wireless interface (e.g. WI-FI interface), typically used to establish a communication connection between the electronic apparatus 1 and other electronic devices.
The communication bus 14 is used to enable connected communication between these components.
Fig. 1 shows only an electronic device 1 with components 11-14, but it is understood that not all shown components are required to be implemented, and that more or fewer components may be implemented instead.
Optionally, the electronic apparatus 1 may further comprise a user interface, which may comprise an input unit such as a Keyboard (Keyboard), a voice input device such as a microphone or the like with voice recognition function, a voice output device such as a sound box, a headset or the like, and optionally a standard wired interface, a wireless interface.
Optionally, the electronic device 1 may also comprise a display, which may also be referred to as a display screen or display unit.
In some embodiments, the display may be an LED display, a liquid crystal display, a touch-control liquid crystal display, an Organic Light-Emitting Diode (OLED) touch device, or the like. The display is used for displaying information processed in the electronic device 1 and for displaying a visualized user interface.
Optionally, the electronic device 1 further comprises a touch sensor. The area provided by the touch sensor for the user to perform a touch operation is referred to as a touch area. Further, the touch sensors described herein may be resistive touch sensors, capacitive touch sensors, and the like. The touch sensor may include not only a contact type touch sensor but also a proximity type touch sensor. Furthermore, the touch sensor may be a single sensor or may be a plurality of sensors arranged in an array, for example.
Optionally, the electronic device 1 may further include logic gates, sensors, audio circuits, etc., which are not described herein.
In the embodiment of the apparatus shown in fig. 1, an operating system, and a poem melody generation program 10 may be included in a memory 11 as a kind of computer storage medium; the processor 12 implements the following steps when executing the poem melody generation program 10 stored in the memory 11:
constructing a sample music library for storing poetry samples and corresponding score samples thereof;
extracting structural features of poetry samples to form a sample structural feature matrix;
extracting the pitch of the score sample to form a sample pitch matrix corresponding to the sample structure feature matrix;
according to the structural feature of each word in the sample structural feature matrix and the corresponding pitch and adjacent pitch in the sample pitch matrix, obtaining the probability of the corresponding relation between the structural feature and the pitch and the probability of the transition relation between the adjacent pitches, and respectively forming a first probability matrix and a second probability matrix;
extracting structural features of new poems which are not matched with music, and constructing a structural feature matrix of the new poems;
generating a pitch sequence of the new poem through the first probability matrix and the second probability matrix according to the structural feature matrix of the new poem;
randomly selecting a score sample segment from score samples of a sample music library, and sequentially extracting the duration d of notes in the score sample segment i Obtaining a sequence of time values S of new poems;
constructing an initial melody sequence T of the new poem through a pitch sequence Y and a duration sequence S of the new poem, wherein the number of segments of the initial melody sequence is o 3 Wherein, all elements in Y and S are traversed respectively to construct notes, and then the generated notes are sequentially arranged to obtain T;
selecting a matching sample o corresponding to a poem sample with highest matching degree between structural features of new poems and structural features of new poems from a sample music library 3 And performing exchange operation in a genetic algorithm on the segment melody sequence and the initial melody sequence T to obtain a final melody T' of the new poem.
In other embodiments, the poetry melody generating program 10 can be further divided into one or more modules, which are stored in the memory 11 and executed by the processor 12 to accomplish the present invention. The invention may refer to a series of computer program instruction segments capable of performing a specified function. Referring to fig. 2, a functional block diagram of a preferred embodiment of the poetry melody generating program 10 in fig. 1 is shown. The poetry melody generation program 10 can be divided into:
the music library construction module 110 is used for constructing a sample music library for storing poetry samples and corresponding match samples thereof;
the first feature extraction module 120 extracts structural features of the poetry sample to form a sample structural feature matrix, where the structural features include one or more of a rule, a rhyme part, an tone final and a part of speech;
the sample pitch matrix construction module 130 extracts the pitches of the score samples to form a sample pitch matrix corresponding to the sample structural feature matrix;
the probability matrix construction module 140 is used for respectively constructing a first probability matrix and a second probability matrix according to the structural feature of each word in the sample structural feature matrix and the corresponding pitch and adjacent pitch in the corresponding sample pitch matrix to obtain the probability of the corresponding relation between the structural feature and the pitch and the probability of the transition relation between the adjacent pitches;
the second feature extraction module 150 extracts the structural features of the new poetry which are not matched, and constructs a structural feature matrix of the new poetry;
the pitch sequence generating module 160 generates a pitch sequence of the new poem according to the structural feature matrix of the new poem through the first probability matrix and the second probability matrix;
the time sequence generating module 170 randomly selects a score sample segment from the score samples of the sample music library, and sequentially extracts the duration d of the notes in the score sample segment i Obtaining a sequence of time values S of new poems;
the initial melody sequence generating module 180 constructs an initial melody sequence T of the new poem by using the pitch sequence Y and the duration sequence S of the new poem, wherein the number of segments of the initial melody sequence is o 3 Wherein, all elements in Y and S are traversed respectively to construct notes, and then the generated notes are sequentially arranged to obtain T;
the final melody generating module 190 selects o of the score sample corresponding to the poetry sample with the highest matching degree between the structural features of the new poetry and the structural features of the new poetry from the sample music library 3 And performing exchange operation in a genetic algorithm on the segment melody sequence and the initial melody sequence T to obtain a final melody T' of the new poem.
Preferably, the final melody generation module 190 includes:
candidate melody sequence obtaining module 191, selecting o from matching score samples corresponding to poem samples with highest matching degree 3 The segment melody sequence and T are taken together as a candidate melody sequence;
the exchange module 192 performs an exchange operation in a genetic algorithm on the initial melody sequence T through the candidate melody sequence to obtain a final melody T' of the new poetry, including:
the exchange point selecting unit 1921 randomly selects n exchange points in the initial melody sequence T by taking the musical measure as a unit, and randomly selects n exchange points in the initial melody sequence T by taking the musical measure as a unit, wherein n e [1, b-1], b is the number of measures contained in the melody sequence T;
a switching point allocation unit 1922 for randomly allocating switching points to the joints of different music sections;
a melody exchange unit 1923 for keeping the content before the first exchange point in T unchanged, and randomly selecting a melody from the designated interval in the candidate melody for exchange with the melody sequence at the corresponding position in T for each exchange interval (including the last exchange point to the end of the melody) after the exchange point (if the melody in T is randomly selected, not processing);
the judging unit 1924 judges whether the exchange ending condition (for example, the current exchange algebra is larger than the set maximum exchange algebra or the fitness value after the continuous exchange is smaller than the set value) of the genetic algorithm is satisfied, if the exchange ending condition is not satisfied, it sends a signal to the melody exchange unit, and if the exchange ending condition is satisfied, it takes the finally obtained melody T' as the final melody.
In one embodiment of the present invention,
the first feature extraction module 120 extracts the patterns of the poetry sample, wherein the patterns of the first sound and the second sound are flat, and the patterns of the third sound and the fourth sound are cramped, so as to form a pattern matrix;
the probability matrix construction module 140 includes:
the system comprises a rule pitch relation obtaining unit, a rule pitch relation matrix and a rule matching unit, wherein the rule pitch relation obtaining unit is used for constructing a rule pitch relation matrix according to a rule matrix of a poem sample and a pitch matrix of a match sample corresponding to the poem sample, elements in the rule pitch relation matrix are relation pairs, and each rule element in the rule matrix is constructed with a pitch element at a corresponding position in the pitch matrix;
the first probability obtaining unit obtains a first probability of a corresponding relation between pitch and a grid according to elements in a grid pitch relation matrix to form a first probability matrix D, wherein the first probability of the corresponding relation between pitch and the grid is obtained by dividing the number of times of occurrence of relation pairs with the same pitch and grid by the number of times of occurrence of all relation pairs containing the pitch;
a pitch transfer relation obtaining unit for obtaining the pitch transfer relation of adjacent notes according to the pitch matrix of the score sample, and constructing a transfer relation matrix, wherein the elements of the transfer relation matrix are pitch pairs formed by the pitches of the adjacent two notes;
and the second probability obtaining unit obtains the second probability of the transition relation between the pitches of adjacent notes according to the transition relation matrix of the poetry sample, and forms a second probability matrix E, wherein the second probability of the transition from the first pitch to the second pitch of the pitch pair is obtained by dividing the occurrence times of the pitch pair by the occurrence times of all the pitch pairs when the first pitch of the pitch pair is the first element.
In addition, the invention also provides a poetry melody generation method. Referring to fig. 3, a flowchart of a poetry melody generating method according to a preferred embodiment of the invention is shown. The method may be performed by an apparatus, which may be implemented in software and/or hardware.
In this embodiment, the poetry melody generating method includes:
step S1, a sample music library is constructed and used for storing poetry samples and corresponding match samples;
step S2, extracting structural features of a poetry sample to form a sample structural feature matrix, wherein the structural features comprise: one or more of the rhythms, rhyme portions, tone vowels, and parts of speech, but the invention is not limited thereto, and may include, for example, the positions of the above-described structural features;
s3, extracting the pitch of the score sample to form a sample pitch matrix corresponding to the sample structure feature matrix;
step S4, according to the structural feature of each word in the sample structural feature matrix and the corresponding pitch and adjacent pitch in the sample pitch matrix, obtaining the probability of the corresponding relation between the structural feature and the pitch and the probability of the transition relation between the adjacent pitches, respectively forming a first probability matrix and a second probability matrix, wherein each word corresponds to one or more notes and has one or more pitches;
s5, extracting structural features of new poems which are not matched with the poems, and constructing a structural feature matrix of the new poems;
step S6, generating a pitch sequence of the new poetry through the first probability matrix and the second probability matrix according to the structural feature matrix of the new poetry, for example, sequentially determining the pitches corresponding to all elements in the structural feature matrix of the new poetry, selecting the pitch with the highest probability corresponding to the first element of the structural feature matrix of the new poetry from the first probability matrix as the pitch of the first element, then selecting the pitch with the highest probability of the pitch transfer relation with the first element from the second probability matrix as the pitch of the second element, and analogically obtaining the pitches of all elements;
step S7, randomly selecting a score sample segment from score samples of the sample music library, and sequentially extracting the duration d of notes in the score sample segment i Obtaining a sequence S of the time value of the new poetry, wherein the sequence length of the score sample section and the integer multiple of the sequence length of the pitch sequence of the new poetry;
step S8, constructing an initial melody sequence T of the new poem through a pitch sequence Y and a time value sequence S of the new poem, wherein the number of segments of the initial melody sequence is o 3 Specifically, all elements in Y and S are traversed respectively to construct notes, and then the generated notes are sequentially arranged to obtain T;
step S9, selecting a matching sample o corresponding to the poetry sample with the highest matching degree between the structural features of the new poetry and the structural features of the new poetry from the sample music library 3 And performing exchange operation in a genetic algorithm on the segment melody sequence and the initial melody sequence T to obtain a final melody T' of the new poem.
In a preferred embodiment of the present invention, the structural feature is a pattern, and the poem melody generating method using the poem pattern as a driving source is as shown in fig. 4, and includes:
step S10, a sample music library is constructed for storing poetry samples and corresponding match samples thereof, e.g., a= { a 1 ,a 2 ,…,a LA The } is poetry content, L A For poetry length, the note t of the score sample can pass through a binary group<p,d>Expressed, where p E [48,95 ]]Representing the pitch of a note in the MIDI format, d represents the duration of the note, i.e. the note duration;
step S20, a sample processing step, namely, according to the rules of each word in a plurality of poems in a poem sample and the corresponding pitch and adjacent pitches in a match sample, obtaining the probability of the corresponding relation between the rules and the pitch and the probability of the transition relation between the adjacent pitches, respectively forming a first probability matrix (marked as D (48 multiplied by 1)) and a second probability matrix (marked as E (48 multiplied by 48)), wherein the rules of one sound and two sounds are flat, and the rules of three sounds and four sounds are zebra;
step S30, extracting the grid characteristics of new poems which are not matched, and constructing a grid matrix of the new poems;
step S40, generating a pitch sequence of the new poem through the first probability matrix and the second probability matrix according to the lattice matrix of the new poem;
step S50, randomly selecting a score from the sample music library, and sequentially extracting the duration d of the notes in the score i Obtaining a sequence S of the time value of the new poetry, wherein the sequence length of the score sample section and the integer multiple of the sequence length of the pitch sequence of the new poetry;
step S60, constructing an initial melody sequence T of the new poem through the pitch sequence Y and the time value sequence S of the new poem, wherein the number of segments of the initial melody sequence is o 3 Specifically, all elements in Y and S are traversed to construct notes, and then the generated notes are sequentially arranged to obtain T.
Step S70, selecting a matching sample o corresponding to the poetry sample with the highest degree of matching between the pattern and the new poetry in the sample music library 3 And performing exchange operation in a genetic algorithm on the segment melody sequence and the initial melody sequence T to obtain a final melody T' of the new poem.
In step S20, it includes:
generating a lattice matrix of each poem sample according to the pinyin tone;
constructing a pitch matrix of notes of each score sample;
constructing a grid pitch relation matrix according to a grid matrix of the poem sample and a pitch matrix of a match sample corresponding to the poem sample, wherein elements in the grid pitch relation matrix are relation pairs, and each grid element in the grid matrix is constructed with a pitch element at a corresponding position in the pitch matrix;
obtaining a first probability of a corresponding relation between a pitch and a grid according to elements in a grid pitch relation matrix, and forming a first probability matrix D, wherein the first probability of the corresponding relation between the pitch and the grid is obtained by dividing the number of times of occurrence of all relation pairs containing the pitch by the number of times of occurrence of all relation pairs containing the pitch;
obtaining the pitch transfer relation of adjacent notes according to the pitch matrix of the score sample, and constructing a transfer relation matrix, wherein the elements of the transfer relation matrix are pitch pairs formed by the pitches of the adjacent two notes;
and obtaining a second probability of the transfer relation between the pitches of adjacent notes according to the transfer relation matrix of the poetry sample, and forming a second probability matrix E, wherein the second probability of the transfer from the first pitch to the second pitch of the pitch pair is obtained by dividing the occurrence times of the pitch pair by the occurrence times of all the pitch pairs when the first pitch of the pitch pair is the first element.
In step S40, it includes:
a first pitch generation step of selecting a former o with highest probability of corresponding relation with a first element in a lattice matrix of new poem from a first probability matrix according to the lattice of the first element in the lattice matrix 1 Pitch from o 1 Randomly selecting one pitch from the pitches as an initial pitch p 1 ,p 1 ∈[48,95]Wherein o 1 Can be specified by the user, o in default 1 =2;
A second pitch generation step of selecting, from the second probability matrix, a former o having the highest probability of the transition relation with the first pitch based on the first pitch 2 Pitch from o 2 Randomly selecting one pitch from the pitches as a second pitch p 2 Wherein o 1 And o 2 May be the same or different;
and repeating the previous operation until the pitches corresponding to all elements in the lattice matrix of the new poetry are obtained, and generating a pitch sequence Y of the new poetry without matching.
In the above method for generating the pitch sequence Y, the lattice matrix of the whole poem is exemplified, but the present invention is not limited thereto, and the pitch sequence of each sentence may be generated in units of poems.
In step S70, it includes:
taking the melody sequence as a population, taking each musical measure in the melody sequence as each individual of the population, and taking each note in the musical measure as each gene of the individual;
determining fitness of each individual in the initial melody sequence T of new poems, e.g. according to the individual of the initial melody sequence T and o selected from the matching score samples corresponding to the poem sample with highest matching degree 3 Taking the inverse of root mean square error of a plurality of genes of a corresponding individual of the segment melody sequence as the fitness of the individual;
judging whether the fitness of individuals in the new poetry initial melody sequence T all reach a set threshold value;
if the individual fitness which does not reach the set threshold value exists, exchanging the individual with the minimum fitness in the new poetry initial melody sequence T, and repeating the steps until the fitness of all the individuals in the new poetry melody sequence reaches the set threshold value.
The embodiment of the computer readable storage medium of the present invention is substantially the same as the embodiment of the poetry melody generating method and the embodiment of the electronic device, and will not be repeated here.
In one embodiment of the present invention, the new poetry is: the relationship of the patterns of the Chinese characters, qianlijiang, and Qianlijiang is' flat, zepe, baidi, qianlijiang, and Qianlike, one day, is designated o 1 =o 2 The initial melody sequence generated from the music library by this rhythm is shown in fig. 5a =1; o of match sample corresponding to poem sample with highest degree of matching of new poem obtained from music library 3 The melody segment sequence is shown in FIG. 5b, and the matching degree between the melody segment sequence and the initial melody sequence is 86%; the final melody obtained after the genetic algorithm exchange operation is shown in fig. 5 c.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, apparatus, article, or method that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, apparatus, article, or method. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, apparatus, article or method that comprises the element.
The foregoing embodiment numbers of the present invention are merely for the purpose of description, and do not represent the advantages or disadvantages of the embodiments. From the above description of the embodiments, it will be clear to those skilled in the art that the above-described embodiment method may be implemented by means of software plus a necessary general hardware platform, but of course may also be implemented by means of hardware, but in many cases the former is a preferred embodiment. Based on such understanding, the technical solution of the present invention may be embodied essentially or in a part contributing to the prior art in the form of a software product stored in a storage medium (e.g. ROM/RAM, magnetic disk, optical disk) as described above, comprising instructions for causing a terminal device (which may be a mobile phone, a computer, a server, or a network device, etc.) to perform the method according to the embodiments of the present invention.
The foregoing description is only of the preferred embodiments of the present invention, and is not intended to limit the scope of the invention, but rather is intended to cover any equivalents of the structures or equivalent processes disclosed herein or in the alternative, which may be employed directly or indirectly in other related arts.

Claims (10)

1. A poetry melody generation method applied to an electronic device, the method comprising:
constructing a sample music library for storing poetry samples and corresponding score samples thereof;
extracting structural features of poetry samples to form a sample structural feature matrix, wherein the structural features comprise one or more of rhythms, rhyme parts, tone vowels and part of speech;
extracting the pitch of the score sample to form a sample pitch matrix corresponding to the sample structure feature matrix;
according to the structural feature of each word in the sample structural feature matrix and the corresponding pitch and adjacent pitch in the sample pitch matrix, obtaining the probability of the corresponding relation between the structural feature and the pitch and the probability of the transition relation between the adjacent pitches, and respectively forming a first probability matrix and a second probability matrix;
extracting structural features of new poems which are not matched with music, and constructing a structural feature matrix of the new poems;
generating a pitch sequence Y of the new poetry through the first probability matrix and the second probability matrix according to the structural feature matrix of the new poetry;
randomly selecting a score sample section from score samples of a sample music library, and sequentially extracting the time values of notes in the score sample section to obtain a time value sequence S of new poetry;
constructing an initial melody sequence T of the new poem through a pitch sequence Y and a duration sequence S of the new poem, wherein the number of segments of the initial melody sequence is o 3 All elements in Y and S are traversed to construct notes, and the generated notes are sequentially arranged to obtain an initial melody sequence T;
selecting a matching sample o corresponding to a poem sample with highest matching degree between structural features of new poems and structural features of new poems from a sample music library 3 And performing exchange operation in a genetic algorithm on the segment melody sequence and the initial melody sequence T to obtain a final melody T' of the new poem.
2. The poem melody generation method according to claim 1, wherein the new poem pitch sequence Y generation step includes:
selecting a pitch with highest probability corresponding to a first element of a structural feature matrix of the new poem from the first probability matrix as the pitch of the first element;
selecting a pitch with highest probability of a pitch transfer relation with the first element from the second probability matrix as a pitch of the second element;
repeating the steps to obtain the pitch of all elements of the structural feature matrix of the new poem, and generating a pitch sequence Y of the new poem.
3. The poem melody generation method according to claim 1, wherein the new poem pitch sequence Y generation step includes:
selecting the former o with highest probability corresponding to the first element of the structural feature matrix of the new poem from the first probability matrix 1 Pitch from o 1 Randomly selecting one pitch from the pitches as a first pitch p 1
Selecting, from the second probability matrix, the first o having the highest probability of being related to the first pitch transition according to the first pitch 2 Pitch from o 2 Randomly selecting one pitch from the pitches as a second pitch p 2
And repeating the previous operation until the pitches corresponding to all elements in the lattice matrix of the new poem are obtained, and generating a pitch sequence Y of the new poem.
4. The poetry melody generation method according to claim 1, wherein the final melody T' generation method of the new poem includes:
o is selected from matching music samples corresponding to poetry samples with highest matching degree 3 The segment melody sequence and the initial melody sequence T are taken together as a candidate melody sequence;
randomly selecting n exchange points in the initial melody sequence T by taking the musical bars as units;
randomly distributing the exchange points to the joints of different music sections;
and keeping the content before the first exchange point in the initial melody sequence T unchanged, randomly selecting a melody from the designated intervals in the candidate melody for exchange with the melody sequence at the corresponding position in the initial melody sequence T for each exchange interval after the exchange point until the exchange ending condition of the genetic algorithm is met, and taking the finally obtained melody T' as a final melody.
5. The poetry melody generation method of claim 4, wherein the final melody T' generation method of the new poem includes:
taking the melody sequence as a population, taking each musical measure in the melody sequence as each individual of the population, and taking each note in the musical measure as each gene of the individual;
determining the fitness of each individual in the new poetry initial melody sequence T;
judging whether the fitness of individuals in the new poetry initial melody sequence T all reach a set threshold value;
if the individual fitness which does not reach the set threshold value exists, exchanging the individual with the minimum fitness in the new poetry initial melody sequence T, and repeating the steps until the fitness of all the individuals in the new poetry melody sequence reaches the set threshold value.
6. The poetry melody generation method of claim 1, wherein the structural feature is a lattice, the structural feature matrix is a lattice matrix, the first and second lattices are flat, the third and fourth lattices are zebra, and the first and second probability matrices are formed by:
generating a lattice matrix of each poem sample according to the pinyin tone;
constructing a pitch matrix of notes of each score sample;
constructing a grid pitch relation matrix according to a grid matrix of the poem sample and a pitch matrix of a match sample corresponding to the poem sample, wherein elements in the grid pitch relation matrix are relation pairs, and each grid element in the grid matrix is constructed with a pitch element at a corresponding position in the pitch matrix;
obtaining a first probability of a corresponding relation between a pitch and a grid according to elements in a grid pitch relation matrix, and forming a first probability matrix, wherein the first probability of the corresponding relation between the pitch and the grid is obtained by dividing the number of times of occurrence of all relation pairs containing the pitch by the number of times of occurrence of all relation pairs with the same pitch;
obtaining the pitch transfer relation of adjacent notes according to the pitch matrix of the score sample, and constructing a transfer relation matrix, wherein the elements of the transfer relation matrix are pitch pairs formed by the pitches of the adjacent two notes;
and obtaining a second probability of the transfer relation between the pitches of adjacent notes according to the transfer relation matrix of the poetry sample, and forming a second probability matrix, wherein the second probability of the transfer from the first pitch to the second pitch of the pitch pair is obtained by dividing the occurrence times of the pitch pair by the occurrence times of all the pitch pairs when the first pitch of the pitch pair is the first element.
7. An electronic device, comprising a memory and a processor, wherein the memory includes a poetry melody generation program, and the processor executes the poetry melody generation program, the poetry melody generation program comprising:
the music library construction module is used for constructing a sample music library and storing poetry samples and corresponding match samples thereof;
the first feature extraction module is used for extracting structural features of the poetry samples to form a sample structural feature matrix, wherein the structural features comprise one or more of a rule, a rhyme part, an tone final and a part of speech;
the sample pitch matrix construction module is used for extracting the pitch of the score sample and forming a sample pitch matrix corresponding to the sample structure feature matrix;
the probability matrix construction module is used for obtaining the probability of the corresponding relation between the structural features and the pitches and the probability of the transition relation between the adjacent pitches according to the structural features of each word in the sample structural feature matrix and the corresponding pitches and adjacent pitches in the sample pitch matrix, and respectively constructing a first probability matrix and a second probability matrix;
the second feature extraction module is used for extracting the structural features of new poems which are not matched with the new poems and constructing a structural feature matrix of the new poems;
the pitch sequence generating module generates a pitch sequence Y of the new poem through the first probability matrix and the second probability matrix according to the structural feature matrix of the new poem;
the timing sequence generation module randomly selects a score sample section from score samples of the sample music library, and sequentially extracts the time values of notes in the score sample section to obtain a time value sequence S of a new poem;
the initial melody sequence generating module constructs an initial melody sequence T of the new poem through a pitch sequence Y and a time value sequence S of the new poem, wherein the number of segments of the initial melody sequence is o 3 All elements in Y and S are traversed to construct notes, and the generated notes are sequentially arranged to obtain an initial melody sequence T;
the final melody generation module is used for selecting o of a match sample corresponding to a poem sample with highest matching degree of structural features of new poems from a sample music library 3 And performing exchange operation in a genetic algorithm on the segment melody sequence and the initial melody sequence T to obtain a final melody T' of the new poem.
8. The electronic device of claim 7, wherein the final melody generation module comprises:
the candidate melody sequence obtaining module is used for selecting o from matching music samples corresponding to poetry samples with highest matching degree 3 The segment melody sequence and the initial melody sequence T are taken together as a candidate melody sequence;
the exchange module performs an exchange operation in a genetic algorithm on the initial melody sequence T through the candidate melody sequence to obtain a final melody T' of the new poetry, including:
the exchange point selecting unit randomly selects n exchange points in the initial melody sequence T by taking the bar as a unit;
the exchange point distribution unit is used for randomly distributing the exchange points to the joints of different music sections;
the melody exchange unit keeps the content before the first exchange point in the initial melody sequence T unchanged, randomly selects a melody from the designated interval in the candidate melody for exchange with the melody sequence at the corresponding position in the T for each exchange interval after the exchange point;
and the judging unit judges whether the exchange ending condition of the genetic algorithm is met, if the exchange ending condition is not met, the judging unit sends a signal to the melody exchange unit, and if the exchange ending condition is met, the finally obtained melody T' is taken as a final melody.
9. The electronic device of claim 7, wherein the first feature extraction module extracts a pattern of a poem sample, the patterns of one and two are flat, the patterns of three and four are zep, and forms a pattern matrix, and the probability matrix construction module comprises:
the system comprises a rule pitch relation obtaining unit, a rule pitch relation matrix and a rule matching unit, wherein the rule pitch relation obtaining unit is used for constructing a rule pitch relation matrix according to a rule matrix of a poem sample and a pitch matrix of a match sample corresponding to the poem sample, elements in the rule pitch relation matrix are relation pairs, and each rule element in the rule matrix is constructed with a pitch element at a corresponding position in the pitch matrix;
the first probability obtaining unit obtains first probability of corresponding relation between pitch and grid according to elements in the relation matrix of the pitch of the grid, and forms a first probability matrix, wherein the first probability of the corresponding relation between the pitch and the grid is obtained by dividing the number of times of occurrence of relation pairs with the same pitch and grid by the number of times of occurrence of all relation pairs containing the pitch;
a pitch transfer relation obtaining unit for obtaining the pitch transfer relation of adjacent notes according to the pitch matrix of the score sample, and constructing a transfer relation matrix, wherein the elements of the transfer relation matrix are pitch pairs formed by the pitches of the adjacent two notes;
and the second probability obtaining unit obtains the second probability of the transition relation between the pitches of adjacent notes according to the transition relation matrix of the poetry sample, and forms a second probability matrix, wherein the second probability of the transition from the first pitch to the second pitch of the pitch pair is obtained by dividing the occurrence times of the pitch pair by the occurrence times of all the pitch pairs when the first pitch of the pitch pair is the first element.
10. A computer-readable storage medium, wherein a poetry melody generation program is included in the computer-readable storage medium, which when executed by a processor, implements the steps of the poetry melody generation method according to any one of claims 1 to 6.
CN201811168589.0A 2018-10-08 2018-10-08 Poem melody generation method, electronic device and computer readable storage medium Active CN109448697B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811168589.0A CN109448697B (en) 2018-10-08 2018-10-08 Poem melody generation method, electronic device and computer readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811168589.0A CN109448697B (en) 2018-10-08 2018-10-08 Poem melody generation method, electronic device and computer readable storage medium

Publications (2)

Publication Number Publication Date
CN109448697A CN109448697A (en) 2019-03-08
CN109448697B true CN109448697B (en) 2023-06-02

Family

ID=65544952

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811168589.0A Active CN109448697B (en) 2018-10-08 2018-10-08 Poem melody generation method, electronic device and computer readable storage medium

Country Status (1)

Country Link
CN (1) CN109448697B (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113689835A (en) * 2020-05-18 2021-11-23 微软技术许可有限责任公司 Automatic music generation
CN112309435B (en) * 2020-10-30 2024-06-07 北京有竹居网络技术有限公司 Main melody generation method and device, electronic equipment and storage medium
CN112863465B (en) * 2021-01-27 2023-05-23 中山大学 Context information-based music generation method, device and storage medium

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
FR2785438A1 (en) * 1998-09-24 2000-05-05 Baron Rene Louis MUSIC GENERATION METHOD AND DEVICE
CN1275770A (en) * 2000-05-08 2000-12-06 董光熙 Kara OK chanting disc
CN101916240B (en) * 2010-07-08 2012-06-13 福州博远无线网络科技有限公司 Method for generating new musical melody based on known lyric and musical melody
US9620092B2 (en) * 2012-12-21 2017-04-11 The Hong Kong University Of Science And Technology Composition using correlation between melody and lyrics
CN106156005B (en) * 2016-07-06 2019-04-02 天津大学 Based on visual classic poetry characteristic analysis method
CN107894850A (en) * 2016-10-04 2018-04-10 张知强 The note coding of Chinese-English words and its musical-product and coding method rule

Also Published As

Publication number Publication date
CN109448697A (en) 2019-03-08

Similar Documents

Publication Publication Date Title
CN109448697B (en) Poem melody generation method, electronic device and computer readable storage medium
US9110817B2 (en) Method for creating a markov process that generates sequences
Yadav et al. Statistical analysis of the Indus script using n-grams
JP6772213B2 (en) Question answering device, question answering method and program
CN110600057B (en) Method and system for comparing performance sound information with music score information
CN112528637A (en) Text processing model training method and device, computer equipment and storage medium
US12027145B2 (en) Systems, devices, and methods for computer-generated musical compositions
CN111694937A (en) Interviewing method and device based on artificial intelligence, computer equipment and storage medium
CN111862937A (en) Singing voice synthesis method, singing voice synthesis device and computer readable storage medium
CN114547267A (en) Intelligent question-answering model generation method and device, computing equipment and storage medium
CN106875929A (en) A kind of music rhythm method for transformation and system
Leonardi A generalization of the PST algorithm: modeling the sparse nature of protein sequences
CN113140230A (en) Method, device and equipment for determining pitch value of note and storage medium
CN112989109A (en) Music structure analysis method, electronic equipment and storage medium
US10431191B2 (en) Method and apparatus for analyzing characteristics of music information
CN115687935A (en) Post-processing method, device and equipment for voice recognition and storage medium
CN114974423A (en) Model training method and device based on reinforcement learning, electronic equipment and medium
CN115238092A (en) Entity relationship extraction method, device, equipment and storage medium
CN113094490B (en) Session interaction method and device, electronic equipment and storage medium
CN115130464A (en) Entity detection model training method, entity detection method and computer equipment
CN105683873A (en) Fault-tolerant input method editor
Buonamente et al. Simulating music with associative self-organizing maps
JP7375096B2 (en) Distributed representation generation system, distributed representation generation method, and distributed representation generation program
JP7198492B2 (en) Personality output device, personality output method, personality output program, word evaluation value generation device, word evaluation value generation method, and word evaluation value generation program
JP2006260073A (en) Genetic relation extraction program, genetic relation extraction method and genetic relation extraction device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant