Music emotion recognition method, device, equipment and medium based on contextual features

Through the deep belief network model and feature pyramid technology, combined with audio and text features, the deficiencies in local and global feature extraction in music emotion recognition are solved, the accuracy and efficiency of music emotion recognition are improved, and the generalization ability of the model is enhanced.

CN118349922BActive Publication Date: 2024-09-03XIAMEN UNIV OF TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410783596.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-06-18
Publication Date
2024-09-03
Estimated Expiration
2044-06-18

AI Technical Summary

Technical Problem

Existing technology cannot accurately capture the local and global characteristics of music, and cannot identify different levels of details of music, resulting in low accuracy and low efficiency in music emotion classification.

Method used

A deep belief network (DBN) model is used to fuse audio and text features. Through feature pyramid and contextual feature fusion, the model is corrected for feature extraction accuracy at different resolutions and solves the problem of emotional consistency between clips.

Benefits of technology

It improves the detail and efficiency of music emotion recognition, enhances the generalization ability of the model, can capture the detailed features of different levels of music, and improves the accuracy of emotion classification and recognition.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118349922B
    Figure CN118349922B
Patent Text Reader

Abstract

The present invention provides a music emotion recognition method, device, equipment and medium based on contextual features, which relates to the field of artificial intelligence technology. The method of the present invention processes and extracts features of a music sample data set, and then uses a deep belief network DBN model to train and learn local features of music to obtain DBN fusion features; constructs a feature pyramid to improve the accuracy of the model's feature extraction at different resolutions, and obtains a multi-scale fusion DBN model; then combines the features of the previous and next music clips at a certain time interval, calculates the contextual feature value difference, and based on the feature value difference, performs contextual feature fusion between adjacent clips to correct the model's understanding of emotional consistency, and finally obtains a music emotion recognition model. The method of the present invention can capture detailed features of music at different levels, and improves the efficiency of music feature extraction and emotion classification and recognition.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a music emotion recognition method, device, equipment and medium based on contextual features. Background Art

[0002] With the rapid development of Internet media technology, people's demand for music information is increasing. Especially in application scenarios such as film soundtracks and advertising production, accurately capturing and analyzing the emotional information contained in the audio (such as excitement, happiness, sadness, anger, etc.) is crucial to improving user experience.

[0003] Traditional music classification methods based on text or labels are difficult to accurately express the emotional information conveyed by music. There are also many research results based on deep learning algorithms for feature extraction and sentiment analysis of audio signals, but they are all based on the analysis of local features of music, with little consideration of the global features of music and the features between contextual segments, unable to capture the details of music at different levels, and the accuracy and efficiency of music sentiment classification are also low.

[0004] In view of this, the applicant filed this application after studying the existing technology. Summary of the invention

[0005] The present invention aims to provide a music emotion recognition method, device, equipment and medium based on contextual features to solve the problem that existing methods are unable to recognize music from local and global features and cannot accurately capture music details at different levels.

[0006] In order to solve the above technical problems, the present invention is implemented through the following technical solutions:

[0007] A music emotion recognition method based on contextual features, comprising:

[0008] 1. A music emotion recognition method based on contextual features, characterized by comprising:

[0009] S1, obtaining a sample data set, wherein the sample data set includes audio files and lyrics texts classified by different emotion labels, and the different emotion labels include excitement, happiness, sadness and anger;

[0010] S2, preprocessing the sample data set, extracting audio features from the audio file, and extracting text features from the lyrics text;

[0011] S3, inputting the audio features and the text features into a deep belief network (DBN) model for feature fusion training, until the energy function of the deep belief network (DBN) model reaches global minimization, and obtaining a DBN fusion feature value; wherein the DBN fusion feature value is the optimal weight and bias of the energy function;

[0012] S4, according to the DBN fusion feature value, the audio feature and the text feature, according to the set different resolution scales, extract features of different scales, and perform weighted fusion to obtain a feature pyramid to capture features of different scales in the sample; and input the feature vector of each layer of the feature pyramid into the deep belief network DBN model for training in turn to correct the accuracy of feature extraction of the DBN model at different resolutions, until the training of all feature maps of the feature pyramid is completed to obtain a multi-scale fusion DBN model;

[0013] S5, performing sliding window extraction on each segment of the audio file and the lyrics text according to the set time step, inputting the multi-scale fusion DBN model to obtain multi-scale fusion feature values, weightedly fusing the multi-scale fusion feature values ​​in each segment to obtain context features; calculating the feature value difference between adjacent segments according to the context features; judging whether the multi-scale fusion feature value of the current segment is fused with the multi-scale fusion feature value of the adjacent segment according to the feature value difference, updating the fusion feature value of the current segment to solve the problem of emotional consistency between segments, until the sliding window completes the fusion of context features of all segments, and obtaining a pyramid model based on context features;

[0014] S6, evaluating the pyramid model based on contextual features, and when the evaluation score exceeds a set threshold, obtaining an evaluated music emotion recognition model;

[0015] S7, inputting the music data into the music emotion recognition model to obtain the emotion label of the music data.

[0016] The present invention also provides a music emotion recognition device based on contextual features, comprising:

[0017] A sample data set construction unit is used to obtain a sample data set, wherein the sample data set includes audio files and lyrics texts classified by different emotion labels, and the different emotion labels include excitement, happiness, sadness and anger;

[0018] A feature extraction unit, used to pre-process the sample data set, extract audio features from the audio file, and extract text features from the lyrics text;

[0019] A DBN feature fusion unit is used to obtain a DBN fusion feature value, input the audio feature and the text feature into a deep belief network DBN model for feature fusion training, until the energy function of the deep belief network DBN model reaches global minimization, and obtain a DBN fusion feature value; wherein the DBN fusion feature value is the optimal weight and bias of the energy function;

[0020] A feature pyramid unit is used to obtain a multi-scale fusion feature value, extract features of different scales according to the DBN fusion feature value, the audio feature and the text feature, and perform weighted fusion to obtain a feature pyramid to capture features of different scales in the sample; and input the feature vectors of each layer of the feature pyramid into the deep belief network DBN model for training in turn to correct the accuracy of feature extraction of the DBN model at different resolutions, until the training of all feature maps of the feature pyramid is completed to obtain a DBN model;

[0021] The context feature supplement unit is used to obtain a music emotion recognition model with context weighted fusion, perform sliding window extraction on each segment of the audio file and the lyrics text according to a set time step, input the multi-scale fusion DBN model, obtain multi-scale fusion feature values, and weightedly fuse the multi-scale fusion feature values ​​in each segment to obtain context features; calculate the feature value difference between adjacent segments based on the context features; determine whether the multi-scale fusion feature value of the current segment is fused with the multi-scale fusion feature value of the adjacent segment based on the feature value difference, and update the fusion feature value of the current segment to solve the problem of emotional consistency between segments, until the sliding window completes the fusion of context features of all segments, and obtains a pyramid model based on context features;

[0022] The model evaluation unit is used to evaluate the pyramid model based on contextual features, and when the evaluation score exceeds a set threshold, an evaluated music emotion recognition model is obtained.

[0023] The emotion recognition unit is used to input the music data into the music emotion recognition model to obtain the emotion label of the music data.

[0024] The present invention also provides a music emotion recognition device based on contextual features, including a processor and a memory, wherein the memory stores a computer program, and the computer program can be executed by the processor to implement a music emotion recognition method based on contextual features as described above.

[0025] The present invention also provides a computer-readable storage medium, on which computer-readable instructions are stored. When the computer-readable instructions are executed by a processor of a device where the computer-readable storage medium is located, the method for music emotion recognition based on contextual features as described above is implemented.

[0026] In summary, compared with the prior art, the present invention has the following beneficial effects:

[0027] After data processing and feature extraction of a music sample data set, the present invention uses a deep belief network DBN model to learn the local features of music, uses a feature pyramid to correct the accuracy of feature extraction of the DBN model at different resolutions, and comprehensively analyzes different levels of information of music to capture local and global information in the sample, thereby improving the level of detail in emotion recognition; combined with the contextual features of the music, the notes, lyrics and emotions of the previous and next music clips are integrated to correct the model's understanding of emotional consistency, enhance the model's generalization ability, and solve the problem of music emotional consistency. The method of the present invention can capture the detailed features of music at different levels, and improve the efficiency of music feature extraction and emotion classification and recognition. The method can be applied to multiple scenarios such as music recommendation systems, intelligent music players, and online education, and has broad market application prospects. BRIEF DESCRIPTION OF THE DRAWINGS

[0028] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.

[0029] Figure 1 A structural diagram of a music emotion recognition method based on contextual features provided in Example 1 of the present invention.

[0030] Figure 2 A flowchart of a method for music emotion recognition based on contextual features provided in Example 1 of the present invention.

[0031] Figure 3 This is a flowchart of music feature extraction provided in Example 1 of the present invention.

[0032] Figure 4 A flowchart of deep belief network feature fusion provided in Example 1 of the present invention.

[0033] Figure 5 This is a flowchart of constructing a feature pyramid provided in the first embodiment of the present invention.

[0034] Figure 6A flowchart of context feature supplementation provided in the first embodiment of the present invention.

[0035] Figure 7 A schematic diagram of a music emotion recognition device based on contextual features provided in Embodiment 2 of the present invention.

[0036] The present invention is further described in detail below in conjunction with the accompanying drawings and specific embodiments. DETAILED DESCRIPTION

[0037] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention. Therefore, the following detailed description of the embodiments of the present invention provided in the drawings is not intended to limit the scope of the invention claimed for protection, but merely represents the selected embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.

[0038] Embodiment 1

[0039] Embodiment 1 of the present invention provides a context-based music emotion recognition method, which can be implemented by a context-based music emotion recognition device (hereinafter referred to as emotion recognition device), and in particular, executed by one or more processors in the emotion recognition device.

[0040] In this embodiment, the emotion recognition device may be an electronic device equipped with a processor, the processor having a computer program of the music emotion recognition method based on contextual features and the computer program can be executed, such as a computer, a smart phone, a smart tablet, etc.

[0041] Most existing music emotion recognition methods rely on manual labeling and similarity analysis, and there is no fully automated and highly accurate method. The present invention provides a feature pyramid music emotion recognition method and device based on contextual features. The method combines local features of music with global contextual features, uses feature pyramids to capture music details at different levels, and achieves efficient emotion classification through a deep learning network.

[0042] like Figure 1 and Figure 2 As shown, a music emotion recognition method based on contextual features includes steps S1 to S7.

[0043] S1, obtaining a sample data set, wherein the sample data set includes audio files and lyrics texts classified by different emotion tags, and the different emotion tags include excitement, happiness, sadness, and anger.

[0044] In this embodiment, a music sample data set containing different emotion labels (excited, happy, sad, angry) is constructed, and the number of samples is not less than 10,000. The sample data set includes audio files and lyrics texts so that audio features and text features can be extracted. There are no less than 1,000 samples for each emotion, and each music sample is no less than 1 minute long and has a complete music beginning and end.

[0045] S2, preprocessing the sample data set, extracting audio features through the audio file, and extracting text features through the lyrics text.

[0046] In this embodiment, the preprocessed data is divided into a training set and a test set, and evenly distributed according to different emotional labels, such as excitement, happiness, sadness, and anger. 9,000 copies are taken as training sets and 1,000 copies are taken as test sets, so as to evaluate the performance of the model after training the model.

[0047] like Figure 3 As shown in the figure, multi-level feature extraction is performed on the training set to extract acoustic features from the audio file, including pitch features, rhythm features, and intensity features, etc. At the same time, text features are extracted from the lyrics text, including word frequency features, part-of-speech features, etc. The above features together constitute the feature vector space of the music sample.

[0048] Furthermore, extracting the audio features includes:

[0049] Pitch feature: Pitch detection uses a spectrum analysis method and adopts the YIN algorithm to estimate the audio signal of the audio file to obtain a pitch feature value;

[0050] Rhythm features: extracting the audio file through a beat tracking algorithm to identify repeated patterns and beats to obtain rhythm feature values;

[0051] Intensity feature: Calculate the amplitude envelope of the audio signal of the audio file to obtain an intensity feature value.

[0052] The text features include word frequency features and part-of-speech features, and the steps of extracting the text features include:

[0053] Calculate the number of times each word appears in the lyrics text using a statistical method to obtain a word frequency feature;

[0054] A natural semantic understanding algorithm is used to identify the grammatical role of each word in the sentence of the lyrics text to obtain part-of-speech features.

[0055] S3, inputting the audio features and the text features into a deep belief network DBN model for feature fusion training, until the energy function of the deep belief network DBN model reaches global minimization, and obtaining DBN fusion feature values; wherein the DBN fusion feature values ​​are the optimal weights and biases of the energy function.

[0056] Preferably, a deep belief network (DBN) model is used to fuse audio features and text features together, so that the model can understand the auditory attributes and text content of the music at the same time to more accurately identify emotions and build a music emotion recognition classifier.

[0057] like Figure 4 As shown, the deep belief network DBN model is composed of multiple restricted Boltzmann machine layers for learning representations between features. In this embodiment, for fast calculation, the restricted Boltzmann machine layer is set to 3 layers.

[0058] The energy function of the restricted Boltzmann machine is a mathematical model used to describe the state of a system. It is used to describe the energy of the system under a given state.

[0059] When the deep belief network DBN learns features, the energy of the system in a given state is described by the energy function of the restricted Boltzmann machine (RBN), and the expression of the energy function of the restricted Boltzmann machine is:

[0060] ;

[0061] in, and Respectively represent the neuron states of the visible layer and the hidden layer of the deep belief network DBN model, V and H respectively represent the number of visible layers and hidden layers of the deep belief network DBN model, Is the visible layer unit i and hidden layer units j The weight between Represents the visible layer unit i The neuronal state, Represents the hidden layer unit j The neuronal state, and Visible layer units i and hidden layer units j The bias term of

[0062] The learning goal of the restricted Boltzmann machine (RBN) is to generate the optimal weights through training , Bias and , the optimal condition is to minimize the energy function.

[0063] In this embodiment, the energy function is calculated using the joint probability distribution of the states. When the energy function is globally minimized, the optimal weight is obtained. , Bias and , to represent the complex relationship between audio, lyrics and emotional features; among them, the state The joint probability distribution of is expressed as:

[0064] ;

[0065] Here, Z is a normalization factor to ensure that the sum of the probabilities of all possible states is 1.

[0066] Then, the audio features and the text features are input into the deep belief network DBN model for layer-by-layer training. In each layer, the model learns the high-level representation of the input features and passes it to the next layer. After multiple iterations of training, when the calculated energy function reaches global minimization, the output fusion feature is the complex relationship between audio, lyrics and emotional features, and the current DBN model and DBN fusion feature value are saved.

[0067] S4, according to the DBN fusion feature value, the audio feature and the text feature, according to the set different resolution scales, features of different scales are extracted, and weighted fusion is performed to obtain a feature pyramid to capture features of different scales in the sample; and the feature vectors of each layer of the feature pyramid are sequentially input into the deep belief network DBN model for training to correct the accuracy of feature extraction of the DBN model at different resolutions, until the training of all features of the feature pyramid is completed to obtain a multi-scale fusion DBN model.

[0068] In this embodiment, features at different scales are fused to capture local and global information in the sample to correct the accuracy of feature extraction at different resolutions by the deep belief network DBN model.

[0069] Furthermore, if Figure 5 As shown, the S4 specifically includes:

[0070] S41, extracting features of different scales according to the audio features and the text features and various set resolution scales.

[0071] In this embodiment, the different resolution scales are set to 1 second, 2 seconds, 4 seconds, and 8 seconds. Other different numbers of scales may also be set according to actual needs.

[0072] S42, according to the DBN fusion feature value, weighting the features of different scales to obtain feature pyramids arranged at different scales; each layer of the feature pyramid represents a feature of one scale.

[0073] In this embodiment, the fused features are arranged according to different scales to form a feature pyramid.

[0074] S43, inputting the feature vectors of each layer in the feature pyramid into the deep belief network DBN model for training respectively, so as to correct the accuracy of feature extraction of the deep belief network DBN model at different resolutions, supplement the DBN fusion feature value, until the feature training of all scales in the feature pyramid is completed, and a multi-scale fusion DBN model and pyramid features are obtained.

[0075] In this embodiment, the feature vector of each layer in the feature pyramid is input into the deep belief network DBN model for training until the construction of the 4-layer pyramid is completed, and the modified deep belief network DBN model, that is, the multi-scale fusion DBN model, and the 4-layer pyramid feature matrix are stored.

[0076] S5, performing sliding window extraction on each segment of the audio file and the lyrics text according to the set time step, inputting the multi-scale fusion DBN model to obtain multi-scale fusion feature values, weightedly fusion the multi-scale fusion feature values ​​in each segment to obtain context features; calculating the feature value difference between adjacent segments according to the context features; judging whether the multi-scale fusion feature value of the current segment is fused with the multi-scale fusion feature value of the adjacent segment according to the feature value difference, updating the fusion feature value of the current segment to solve the problem of emotional consistency between segments, until the sliding window completes the fusion of context features of all segments, and obtaining a pyramid model based on context features.

[0077] like Figure 6 As shown, in this embodiment, the set time step is usually 500ms, and the set time step is the step of the sliding window set based on the original audio file. The extracted multi-scale fusion feature value is combined with the pyramid feature matrix in step S4. The context feature is obtained by weighted fusion of the multi-scale fusion feature values ​​in each segment.

[0078] Further, when determining whether the multi-scale fusion feature value of the current segment is to be fused with the multi-scale fusion feature value of an adjacent segment, the adjacent segment includes a previous segment and a subsequent segment;

[0079] If the difference between the feature values ​​of the previous segment and the current segment exceeds the threshold (indicating that the emotions of the two segments are quite different), the context feature of the previous segment is discarded, and only the current feature value is saved without fusion; otherwise, the multi-scale fusion feature value of the current segment is weightedly fused with the multi-scale fusion feature value of the previous segment, and the fused multi-scale fusion feature value is updated and saved, that is, the context weighted feature value;

[0080] If the difference between the feature values ​​of the subsequent segment and the current segment exceeds the threshold, the context feature of the subsequent segment is discarded, and only the current feature value is saved without fusion; otherwise, the multi-scale fusion feature value of the current segment is weightedly fused with the multi-scale fusion feature value of the subsequent segment, and the fused multi-scale fusion feature value, that is, the context weighted feature value, is updated and saved.

[0081] In this embodiment, the threshold is set to 50%. When processing the current segment, the contextual features of the segment are used as supplementary features to enhance the model's understanding of emotions, and adjacent segments with large emotional differences from the current segment are discarded to solve the problem of emotional consistency.

[0082] Then, the next sliding window calculation is performed until the context feature fusion of all fragments is completed, and a pyramid model based on context features and context weighted feature values ​​are obtained.

[0083] S6, evaluating the pyramid model based on contextual features, and when the evaluation score exceeds a set threshold, obtaining an evaluated music emotion recognition model.

[0084] In this embodiment, the test set data is used to evaluate the performance of the pyramid model based on contextual features. The precision, recall and F1 score are calculated. When the evaluation score exceeds the set threshold, the model is confirmed to be a stable music emotion recognition model, otherwise the model is retrained.

[0085] The calculation expression of the F1 evaluation score is:

[0086] ;

[0087] The evaluation score F1 represents the harmonic mean of precision and recall, with a maximum value of 1 and a minimum value of 0. The larger the F1 value, the better the model performance.

[0088] , represents the precision rate, x represents the current model number, n represents the number of individuals in the test set that are truly positive and predicted to be positive, and N represents the number of individuals in the test set that are predicted to be positive by the model;

[0089] R , represents the recall rate, and M represents the number of truly positive individuals in the test set.

[0090] In this embodiment, the method of the present invention is tested and evaluated by precision, recall and F1 score. If the precision is greater than 70%, the sample recognition is more accurate. The F1 score is the harmonic mean of the precision and recall. If the F1 score is greater than 0.7, the method of the present invention has good generalization ability and stability.

[0091] As shown in Table 1, the method proposed in the present invention performs well in both recognition accuracy and model stability. The method can recognize a variety of emotions expressed by music, such as excitement, happiness, sadness, and anger, and is an effective music emotion recognition technology.

[0092] Table 1: Algorithm test results

[0093]

[0094] Then, save the evaluated music emotion recognition model and feature value library so that the model can be loaded and the features can be matched during music recognition.

[0095] S7, inputting the music data into the evaluated music emotion recognition model to obtain the emotion label of the music data.

[0096] In summary, compared with the prior art, the present invention has the following beneficial effects:

[0097] (1) After performing data processing and feature extraction on a music sample data set, the present invention adopts a deep belief network (DBN) model to learn the local features of music, uses a feature pyramid to correct the accuracy of feature extraction at different resolutions by the DBN model, and comprehensively analyzes different levels of information in the music to capture local and global information in the sample, thereby improving the level of detail in emotion recognition.

[0098] (2) The contextual features of the music are combined with the notes, lyrics, and emotions of the previous and next music clips to enhance the model’s understanding of emotions and the generalization ability of the model, while also solving the problem of emotional consistency in music.

[0099] (3) The method of the present invention can capture the detailed features of music at different levels, thereby improving the accuracy of music feature extraction and emotion classification and recognition.

[0100] Embodiment 2

[0101] like Figure 7 As shown, the second embodiment of the present invention further provides a music emotion recognition device based on contextual features, comprising:

[0102] A sample data set construction unit is used to obtain a sample data set, wherein the sample data set includes audio files and lyrics texts classified by different emotion labels, and the different emotion labels include excitement, happiness, sadness and anger;

[0103] A feature extraction unit, used to pre-process the sample data set, extract audio features from the audio file, and extract text features from the lyrics text;

[0104] A DBN feature fusion unit is used to obtain a DBN fusion feature value, input the audio feature and the text feature into a deep belief network DBN model for feature fusion training, until the energy function of the deep belief network DBN model reaches global minimization, and obtain a DBN fusion feature value; wherein the DBN fusion feature value is the optimal weight and bias of the energy function;

[0105] A feature pyramid unit is used to obtain a multi-scale fusion feature value, extract features of different scales according to the DBN fusion feature value, the audio feature and the text feature, and perform weighted fusion to obtain a feature pyramid to capture features of different scales in the sample; and input the feature vectors of each layer of the feature pyramid into the deep belief network DBN model for training in turn to correct the accuracy of feature extraction of the DBN model at different resolutions, until the training of all feature maps of the feature pyramid is completed to obtain a DBN model;

[0106] The context feature supplement unit is used to obtain a music emotion recognition model with context weighted fusion, perform sliding window extraction on each segment of the audio file and the lyrics text according to a set time step, input the multi-scale fusion DBN model, obtain multi-scale fusion feature values, and weightedly fuse the multi-scale fusion feature values ​​in each segment to obtain context features; calculate the feature value difference between adjacent segments based on the context features; determine whether the multi-scale fusion feature value of the current segment is fused with the multi-scale fusion feature value of the adjacent segment based on the feature value difference, and update the fusion feature value of the current segment to solve the problem of emotion consistency between segments, until the sliding window completes the fusion of context features of all segments, and finally obtains the music emotion recognition model;

[0107] A model evaluation unit, used to evaluate the music emotion recognition model, and when the evaluation score exceeds a set threshold, an evaluated music emotion recognition model is obtained;

[0108] The emotion recognition unit is used to input the music data into the music emotion recognition model to obtain the emotion label of the music data.

[0109] Embodiment 3

[0110] The third embodiment of the present invention also provides a music emotion recognition device based on contextual features, which includes a memory and a processor, wherein the memory stores a computer program, and the computer program can be executed by the processor to implement the music emotion recognition method based on contextual features as described above.

[0111] Embodiment 4

[0112] The fourth embodiment of the present invention also provides a computer-readable storage medium, on which computer-readable instructions are stored. When the computer-readable instructions are executed by a processor of a device where the computer-readable storage medium is located, the music emotion recognition method based on contextual features as described above is implemented.

[0113] In several embodiments provided in the embodiments of the present invention, it should be understood that the disclosed apparatus and method can also be implemented in other ways. The apparatus and method embodiments described above are merely schematic. For example, the flowcharts in the accompanying drawings show the possible architecture, functions and operations of the apparatus, method and computer program product according to multiple embodiments of the present invention. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of a code, and the module, program segment or a part of the code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flow chart, and the combination of boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.

[0114] In addition, the functional modules in the various embodiments of the present invention may be integrated together to form an independent part, or each module may exist independently, or two or more modules may be integrated to form an independent part.

[0115] If the function is implemented in the form of a software function module 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 invention is essentially or the part that contributes to the prior art or the part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions to enable a computer device (which can be a personal computer, electronic device, or network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program code. It should be noted that in this article, the term "include", "include" or any other variant thereof is intended to cover non-exclusive inclusion, so that the process, method, article or device including a series of elements includes not only those elements, but also includes other elements that are not explicitly listed, or also includes elements inherent to such process, method, article or device. Without more constraints, an element defined by the phrase "comprising a..." does not exclude the existence of other identical elements in the process, method, article or apparatus comprising the element.

[0116] The terms used in the embodiments of the present invention are only for the purpose of describing specific embodiments, and are not intended to limit the present invention. The singular forms "a", "said" and "the" used in the embodiments of the present invention and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings.

[0117] It should be understood that the term "and / or" used in this article is only a description of the association relationship of associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the associated objects before and after are in an "or" relationship.

[0118] The word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining" or "in response to detecting", depending on the context. Similarly, the phrases "if it is determined" or "if (stated condition or event) is detected" may be interpreted as "when it is determined" or "in response to determining" or "when detecting (stated condition or event)" or "in response to detecting (stated condition or event)", depending on the context.

[0119] The "first\second" mentioned in the embodiments is only to distinguish similar objects, and does not represent a specific order for the objects. It is understandable that the "first\second" can be interchanged with the specific order or sequence where permitted. It should be understood that the objects distinguished by "first\second" can be interchanged where appropriate, so that the embodiments described herein can be implemented in an order other than those illustrated or described herein.

[0120] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A music emotion recognition method based on contextual features, characterized in that: include: S1, obtaining a sample data set, wherein the sample data set includes audio files and lyrics texts classified by different emotion labels, and the different emotion labels include excitement, happiness, sadness and anger; S2, preprocessing the sample data set, extracting audio features from the audio files of the sample data set, and extracting text features from the lyrics text of the sample data set; S3, inputting the audio features and the text features into a deep belief network (DBN) model for feature fusion training, until the energy function of the deep belief network (DBN) model reaches global minimization, and obtaining a DBN fusion feature value; wherein the DBN fusion feature value is the optimal weight and bias of the energy function; S4, according to the DBN fusion feature value, the audio feature and the text feature, according to the set different resolution scales, extract features of different scales, and perform weighted fusion to obtain a feature pyramid to capture features of different scales in the sample; and input the feature vector of each layer of the feature pyramid into the deep belief network DBN model for training in turn to correct the accuracy of feature extraction of the DBN model at different resolutions, until the training of all features of the feature pyramid is completed to obtain a multi-scale fusion DBN model; wherein, S4 specifically includes: S41, extracting features of different scales according to the audio features and the text features and at different set time scales; S42, weighting the features of different scales according to the DBN fusion feature value to obtain a feature pyramid arranged at different scales; each layer of the feature pyramid represents a feature of one scale; S43, inputting the feature vectors of each layer in the feature pyramid into the deep belief network DBN model for training, so as to correct the accuracy of feature extraction of the deep belief network DBN model at different resolutions, supplement the DBN fusion feature value, until the features of all scales in the feature pyramid are completed, and a multi-scale fusion DBN model and a pyramid feature matrix are obtained; S5, performing sliding window extraction on each segment of the audio file and the lyrics text according to the set time step, inputting the multi-scale fusion DBN model to obtain multi-scale fusion feature values, weightedly fusing the multi-scale fusion feature values ​​in each segment to obtain context features; calculating the feature value difference between adjacent segments according to the context features; judging whether the multi-scale fusion feature value of the current segment is fused with the multi-scale fusion feature value of the adjacent segment according to the feature value difference, updating the fusion feature value of the current segment to solve the problem of emotional consistency between segments, until the sliding window completes the fusion of context features of all segments, and obtaining a pyramid model based on context features; S6, evaluating the pyramid model based on contextual features, when the evaluation score exceeds the set threshold, obtaining an evaluated music emotion recognition model; wherein the evaluation calculation expression is: ; The evaluation score F1 represents the harmonic mean of precision and recall, with a maximum value of 1 and a minimum value of 0. The larger the F1 value, the better the model performance. , represents the precision rate, x represents the current model number, n represents the number of individuals in the test set that are truly positive and predicted to be positive, and N represents the number of individuals in the test set that are predicted to be positive by the model; R , represents the recall rate, M represents the number of truly positive individuals in the test set; S7, inputting the music data into the evaluated music emotion recognition model to obtain the emotion label of the music data.

2. A music emotion recognition method based on contextual features according to claim 1, characterized in that The audio features include pitch features, rhythm features and intensity features, and the steps of extracting the audio features include: The YIN algorithm is used to estimate the audio signal of the audio file to obtain a pitch feature value; Performing pattern and beat recognition on the audio file by using a beat tracking algorithm to extract rhythm feature values; The intensity feature value is obtained by calculating the amplitude envelope of the audio signal of the audio file.

3. A music emotion recognition method based on contextual features according to claim 2, characterized in that ,The text features include word frequency features and part-of-speech features, and the steps of extracting the text features include: Calculate the number of times each word appears in the lyrics text using a statistical method to obtain a word frequency feature; A natural semantic understanding algorithm is used to identify the grammatical role of each word in the sentence of the lyrics text to obtain part-of-speech features.

4. The method for music emotion recognition based on contextual features according to claim 3 is characterized in that ,The deep belief network DBN model is composed of multiple restricted Boltzmann machine layers for learning the representation between features, and S3 specifically includes: S31, when learning features, the deep belief network DBN describes the energy of the system under a given state through the energy function of the restricted Boltzmann machine, and the expression of the energy function of the restricted Boltzmann machine is: ; in, and Respectively represent the neuron states of the visible layer and the hidden layer of the deep belief network DBN model, V and H respectively represent the number of visible layers and hidden layers of the deep belief network DBN model, Is the visible layer unit i and hidden layer units j The weight between Represents the visible layer unit i The neuronal state, Represents the hidden layer unit j The neuronal state, and Visible layer units i and hidden layer units j The bias term of S32, using the joint probability distribution of the state to calculate the energy function, when the energy function is globally minimized, the optimal weight is obtained , Bias and , to represent the complex relationship between audio, lyrics and emotional features; among them, the state The joint probability distribution of is expressed as: ; in, Z is a normalization factor to ensure that the sum of the probabilities of all possible states is 1.

5. A music emotion recognition method based on contextual features according to claim 4, characterized in that ,In S5, when judging whether the multi-scale fusion feature value of the current segment is fused with the multi-scale fusion feature value of the adjacent segment, the adjacent segment includes the previous segment and the next segment; If the difference between the feature values ​​of the previous segment and the current segment exceeds the threshold, the context feature of the previous segment is discarded, and only the current feature value is saved without fusion; otherwise, the multi-scale fusion feature value of the current segment is weightedly fused with the multi-scale fusion feature value of the previous segment, and the fused multi-scale fusion feature value is updated and saved; If the difference between the feature values ​​of the subsequent segment and the current segment exceeds the threshold, the context feature of the subsequent segment is discarded, and only the current feature value is saved without fusion; otherwise, the multi-scale fusion feature value of the current segment is weightedly fused with the multi-scale fusion feature value of the subsequent segment, and the fused multi-scale fusion feature value is updated and saved.

6. A music emotion recognition device based on contextual features, characterized in that: include: A sample data set construction unit is used to obtain a sample data set, wherein the sample data set includes audio files and lyrics texts classified by different emotion labels, and the different emotion labels include excitement, happiness, sadness and anger; A feature extraction unit, used to pre-process the sample data set, extract audio features from the audio file, and extract text features from the lyrics text; A DBN feature fusion unit is used to obtain a DBN fusion feature value, input the audio feature and the text feature into a deep belief network DBN model for feature fusion training, until the energy function of the deep belief network DBN model reaches global minimization, and obtain a DBN fusion feature value; wherein the DBN fusion feature value is the optimal weight and bias of the energy function; The feature pyramid unit is used to obtain a multi-scale fusion feature value, and according to the DBN fusion feature value, the audio feature and the text feature, according to the set different resolution scales, extract features of different scales, and perform weighted fusion to obtain a feature pyramid to capture features of different scales in the sample; and the feature vectors of each layer of the feature pyramid are sequentially input into the deep belief network DBN model for training to correct the accuracy of feature extraction of the DBN model at different resolutions, until the training of all feature maps of the feature pyramid is completed to obtain a multi-scale fusion DBN model; wherein the feature pyramid unit specifically includes: S41, extracting features of different scales according to the audio features and the text features and at different set time scales; S42, weighting the features of different scales according to the DBN fusion feature value to obtain a feature pyramid arranged at different scales; each layer of the feature pyramid represents a feature of one scale; S43, inputting the feature vectors of each layer in the feature pyramid into the deep belief network DBN model for training, so as to correct the accuracy of feature extraction of the deep belief network DBN model at different resolutions, supplement the DBN fusion feature value, until the features of all scales in the feature pyramid are completed, and a multi-scale fusion DBN model and a pyramid feature matrix are obtained; The context feature supplement unit is used to obtain a music emotion recognition model with context weighted fusion, perform sliding window extraction on each segment of the audio file and the lyrics text according to a set time step, input the multi-scale fusion DBN model, obtain multi-scale fusion feature values, and weightedly fuse the multi-scale fusion feature values ​​in each segment to obtain context features; calculate the feature value difference between adjacent segments based on the context features; determine whether the multi-scale fusion feature value of the current segment is fused with the multi-scale fusion feature value of the adjacent segment based on the feature value difference, and update the fusion feature value of the current segment to solve the problem of emotional consistency between segments, until the sliding window completes the fusion of context features of all segments, and obtains a pyramid model based on context features; The model evaluation unit is used to evaluate the pyramid model based on contextual features. When the evaluation score exceeds a set threshold, an evaluated music emotion recognition model is obtained. The evaluation calculation expression is: ; The evaluation score F1 represents the harmonic mean of precision and recall, with a maximum value of 1 and a minimum value of 0. The larger the F1 value, the better the model performance. , represents the precision rate, x represents the current model number, n represents the number of individuals in the test set that are truly positive and predicted to be positive, and N represents the number of individuals in the test set that are predicted to be positive by the model; R , represents the recall rate, M represents the number of truly positive individuals in the test set; The emotion recognition unit is used to input the music data into the music emotion recognition model to obtain the emotion label of the music data.

7. A music emotion recognition device based on contextual features, characterized in that: It comprises a processor and a memory, wherein the memory stores a computer program, and the computer program can be executed by the processor to implement a music emotion recognition method based on contextual features as described in any one of claims 1-5.

8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-readable instructions, and when the computer-readable instructions are executed by a processor of a device where the computer-readable storage medium is located, a music emotion recognition method based on contextual features as described in any one of claims 1 to 5 is implemented.