A method for automatically collecting and processing music emotion database
Through the method of automatically collecting and processing music emotion databases, the problem of inefficient emotion classification retrieval in the existing technology is solved, and an efficient music emotion database is built, which realizes the label generation and similarity calculation of massive music data, and supports real-time recommendation. Improved the performance of the music recommendation system.
Patent Information
- Application Number
- CN202210205546.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-02
- Publication Date
- 2024-12-27
- Estimated Expiration
- 2042-03-02
AI Technical Summary
The existing music database is still in the exploration stage in emotional classification retrieval. Most of the tags in commercial software are added manually, which is difficult to meet the analysis needs of massive music data. The results of academic research are difficult to apply, resulting in inefficiency of the emotional recommendation system.
Using the method of automatically collecting and processing music emotions databases, by building a stable network data acquisition system, using PhantomJS+Selenium to simulate browser behavior to capture web page data, perform data cleaning and label generation, calculate music similarity, and provide multiple database interfaces , including JSON, MongoDB and MySQL, uses Spark distributed computing framework and Python for data processing.
A large music database with emotional tags and music similarity was built, which improved the comprehensiveness and label applicability of the database, achieved dynamic updates and real-time recommendations, and had high commercial value.
Smart Images

Figure CN114896357B_ABST
Abstract
Description
Technical Field
[0001] The invention relates to a method for automatically collecting and processing a music emotion database, and belongs to the field of data mining and machine learning. Background Art
[0002] Tag-based recommendation is the current mainstream music recommendation method. Its advantage is that the query speed of the tag index query is extremely fast, which meets the needs of most commercial recommendation systems. Secondly, the tag features are easier to connect with user behavior data and personal information to form a feature matrix for analysis, which meets the requirements of using existing machine learning methods for data processing. The complexity of music data itself determines that multimodal processing is required in music classification related tasks. However, in actual application scenarios, complex analysis methods cannot meet user needs when facing massive music data.
[0003] The current music database is still in the exploratory stage for emotion classification and retrieval. The music tags in commercial music software are mostly added manually, and the classification method is relatively rough. Academic research on music emotion classification mostly uses small music data sets, and related research results on audio are difficult to apply in the analysis of massive music data.
[0004] In summary, building a fully automatic method for collecting and processing music emotion libraries can not only save a lot of manpower costs and solve the label selection problem of massive music data, but also study and analyze user behavior and music emotions, and further promote the development of emotion-based music recommendation. Summary of the invention
[0005] The purpose of the present invention is to provide a method for automatically collecting and processing a music emotion database to construct a large music database with emotion tags and music similarities, and provide a variety of database interfaces. This method can automatically collect and process network music data, and improve the comprehensiveness of the music emotion database and the applicability of labels.
[0006] The present invention adopts the following technical solutions to solve the above technical problems:
[0007] The present invention provides a method for automatically collecting and processing a music emotion database, and the specific steps are as follows:
[0008] Step 1: Build a stable network data collection system
[0009] 1.1. Each time the collection system is started, it first obtains the public proxy IP in the network, tests and screens the obtained IP, and builds a proxy IP pool;
[0010] 1.2, set the frequency of single IP access, clear invalid IPs in time, randomly select IPs and access at random times;
[0011] 1.3. For web pages that use ajax to dynamically load content, use PhantomJS+Selenium to simulate browser behavior and capture pages rendered by js;
[0012] 1.4, using the user's music playlist as the collection entry, obtain all music-related information in the current playlist;
[0013] 1.5, data cleaning, de-duplication, special symbols, synonym replacement, etc. of the collected data, and process it into music text data and user behavior data;
[0014] Step 2: Generate music tags and sort them
[0015] 2.1, based on the data processed in 1.5, analyze and filter tags from the music's own tags and the name of the playlist the music is in;
[0016] 2.2. The music’s own labels are retained, and all music playlists are further processed, including word segmentation, stop word removal, word frequency statistics and sorting, etc., low-frequency keywords are removed, and emotional labels are screened out based on the emotional vocabulary;
[0017] 2.3, Music tag generation, emotional tags retain the top two tags with the highest frequency, and remove tags with conflicting emotions, such as fear and relaxation, only the one with the highest frequency is taken, and other tags are music tags and non-overlapping high-frequency keywords;
[0018] 2.4, perform weighted calculation on the user behavior data of the music, such as the number of plays, number of favorites, number of subscriptions, etc., to obtain a numerical representation that can be used to present the popularity of the music, i.e., the initial score, and classify and sort each tag based on the numerical value;
[0019] Step 3: Music similarity calculation
[0020] 3.1, the music tags are processed into feature vectors using the TF-IDF method, and the value of the non-appearing tags is 0, generating a music feature matrix;
[0021] 3.2, calculate the cosine similarity of the feature matrix, design a corresponding data calculation model to solve the problem of excessive data calculation, and use a distributed data processing platform for calculation and processing;
[0022] 3.3, similarity sorting, keep the music with similarity greater than or equal to 0.6, remove the music without similar music, and then sort according to popularity;
[0023] Step 4, multiple data format reading and writing interfaces, as follows:
[0024] 4.1, the general transmission format JSON is used for storage. The processed data is mainly divided into three parts: basic music information data, user-music related information data and music similarity matrix data. These data can all be saved in JSON format for easy transmission. At the same time, most databases and data applications can directly read and convert them.
[0025] 4.2, MongoDB database storage interface, which has the function of directly processing JSON data and storing it in MongoDB, and also provides corresponding add, delete, modify and query functions;
[0026] 4.2, MySQL database storage interface, which has the function of directly processing JSON data and storing it in MySQL, and also provides corresponding add, delete, modify and query functions;
[0027] As a further optimization solution of the present invention, the software environment of the method is Spark distributed computing framework, Scala development environment and Python 3.6 with data analysis and processing package installed.
[0028] As a further optimization solution of the present invention, the data file formats of the collection and processing processes are both in JSON format.
[0029] As a further optimization scheme of the present invention, in order to ensure the accuracy of the labels, the music labels in 2.2 ultimately need to be manually reviewed.
[0030] Compared with the prior art, the present invention adopts the above technical solution and has the following technical effects: constructing a large music database with emotional tags and music similarity, and providing multiple database interfaces. This method can automatically collect and process network music data, improve the comprehensiveness of the music emotional database and the applicability of the tags, and provide rich and comprehensive data materials for the data set production in the field of music recommendation research. The database constructed by this method has a dynamic update function, can regularly collect music data from the network and process and update it, the database has extremely high timeliness, can be directly used as a back-end database for real-time music recommendation, and has high commercial value in the field of music recommendation. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] Figure 1 A schematic diagram of a method for automatically collecting and processing a music emotion database;
[0032] Figure 2 This is an example of online music data collection, where (a) is the user playlist list of NetEase Cloud Music, (b) is all the category tags of NetEase Cloud Music, and (c) is the playlist information page of NetEase Cloud Music;
[0033] Figure 3 Complete music ids and tags for partial processing;
[0034] Figure 4 This is a flowchart for collecting online music data;
[0035] Figure 5 The flowchart of data analysis and processing is shown in Figure 2. DETAILED DESCRIPTION
[0036] In order to enable those skilled in the art to better understand the technical solutions in the embodiments of the present invention and to make the above-mentioned purposes, features and advantages of the embodiments of the present invention more obvious and understandable, the technical solutions in the embodiments of the present invention are further described in detail below with reference to the accompanying drawings.
[0037] Embodiment 1: A method for automatically collecting and processing a music emotion database, the specific steps are as follows:
[0038] Step 1: Build a stable network data collection system
[0039] 1.1. Each time the collection system is started, it first obtains the public proxy IP in the network, tests and screens the obtained IP, and builds a proxy IP pool;
[0040] 1.2, set the frequency of single IP access, clear invalid IPs in time, randomly select IPs and access at random times;
[0041] 1.3. For web pages that use ajax to dynamically load content, use PhantomJS+Selenium to simulate browser behavior and capture pages rendered by js;
[0042] 1.4, using the user's music playlist as the collection entry, obtain all music-related information in the current playlist;
[0043] 1.5, data cleaning, de-duplication, special symbols, synonym replacement, etc. of the collected data, and process it into music text data and user behavior data;
[0044] Step 2: Generate music tags and sort them
[0045] 2.1, based on the data processed in 1.5, analyze and filter tags from the music's own tags and the name of the playlist the music is in;
[0046] 2.2. The music’s own labels are retained, and all music playlists are further processed, including word segmentation, stop word removal, word frequency statistics and sorting, etc., low-frequency keywords are removed, and emotional labels are screened out based on the emotional vocabulary;
[0047] 2.3, Music tag generation, emotional tags retain the top two tags with the highest frequency, and remove tags with conflicting emotions, such as fear and relaxation, only the one with the highest frequency is taken, and other tags are music tags and non-overlapping high-frequency keywords;
[0048] 2.4, perform weighted calculation on the user behavior data of the music, such as the number of plays, number of favorites, number of subscriptions, etc., to obtain a numerical representation that can be used to present the popularity of the music, i.e., the initial score, and classify and sort each tag based on the numerical value;
[0049] Step 3: Music similarity calculation
[0050] 3.1, the music tags are processed into feature vectors using the TF-IDF method, and the value of the non-appearing tags is 0, generating a music feature matrix;
[0051] 3.2, calculate the cosine similarity of the feature matrix, design a corresponding data calculation model to solve the problem of excessive data calculation, and use a distributed data processing platform for calculation and processing;
[0052] 3.3, similarity sorting, keep the music with similarity greater than or equal to 0.6, remove the music without similar music, and then sort according to popularity;
[0053] Step 4, multiple data format reading and writing interfaces, as follows:
[0054] 4.1, the general transmission format JSON is used for storage. The processed data is mainly divided into three parts: basic music information data, user-music related information data and music similarity matrix data. These data can all be saved in JSON format for easy transmission. At the same time, most databases and data applications can directly read and convert them.
[0055] 4.2, MongoDB database storage interface, which has the function of directly processing JSON data and storing it in MongoDB, and also provides corresponding add, delete, modify and query functions;
[0056] 4.2, MySQL database storage interface, has the function of directly processing JSON data and storing it in MySQL, and also provides corresponding add, delete, modify and query functions. The software environment of this method is Spark distributed computing framework, Scala development environment and Python3.6 with data analysis and processing package installed. The data file format of the collection and processing process is JSON format. To ensure the accuracy of the label, the music label in 2.2 finally needs manual review. Specific embodiment:
[0058] The schematic diagram of the method for automatically collecting and processing the music emotion database proposed by the present invention is as follows: Figure 1 As shown in the figure. This figure mainly consists of two parts: network music data collection and data analysis and processing. The upper part is the first part and the lower part is the second part. Figure 1As can be seen in the figure, the core of the first part is the data collection mechanism, which mainly responds to the anti-crawler mechanism and provides efficient and stable data collection functions. The collected data is used as the material for the second part. After data cleaning, it is divided into user behavior data and music text data, which are used for music classification and sorting and label generation respectively. Finally, after similarity calculation, it is merged to build a music emotion database.
[0059] Figure 2 This is an example of online music data collection, where (a) is a user playlist list of NetEase Cloud Music, (b) is all the category tags of NetEase Cloud Music, and (c) is the playlist information page of NetEase Cloud Music. The following uses NetEase Cloud Music materials as an example to explain the steps of the present invention in detail.
[0060] Experimental environment: The computer configuration is Intel(R) processor (3.2GHz) and 8GB random access memory (RAM), Windows10 64-bit operating system. The software environment is Spark distributed computing framework, Scala development environment and Python3.6 with data analysis and processing package installed.
[0061] Experimental steps:
[0062] The experimental steps are divided into two parts: Figure 4 and Figure 5 shown.
[0063] Figure 4 This is a flow chart for collecting online music data, specifically:
[0064] 101. Build a proxy IP pool. First, collect free proxy IPs from major websites, conduct usability tests on the obtained IPs, save the available IPs, read some IPs to build an IP pool during collection, randomly select an IP from the pool and put it into the request header each time, clear it once an IP is invalid, and repeat the above steps when the total number of IPs is less than a certain threshold;
[0065] 102. Dynamically loaded content collection. For data dynamically loaded using ajax in web pages, you need to first analyze the URL parameters, use PhantomJS+Selenium technology to simulate browser behaviors, such as scrolling, pulling down, and clicking, and then collect the data after it is loaded;
[0066] 103. Random time interval. To prevent the load on the website server and simulate user browsing visits, the collection request is set to a random time interval, and the corresponding access frequency is set according to different websites;
[0067] 104. Data preservation. The IP data in 101 is stored in the database and needs to be maintained regularly. The collected music data is saved as JSON format files. The collection process is written in Python, and the generated temporary files are saved as JSON format files;
[0068] Figure 5 The flowchart of the data analysis implemented by the present invention and processing into a music emotion database is specifically as follows:
[0069] 201. Data cleaning. The first part of the collected music data contains too much redundant information. The data is processed and divided into two parts: music text data and user behavior data. The music text data includes music lyrics, tags, author information, the name of the playlist where the music is located, etc. The user behavior data includes the number of plays, the number of favorites, comments, etc.;
[0070] 202. Music text data processing. Mainly for music playlists and user comment data, and the playlist name, text and comment text are processed separately. The cleaning methods include: (1) removing stop words and special characters; (2) lowercase English letters; (3) text segmentation and word frequency statistics; (4) synonym replacement. After segmentation and statistics, a synonym table for music data text needs to be established. For example, bgm and background music are synonyms, which are uniformly replaced with shorter words. The storage method is that the ID of each music corresponds to all the playlists and corresponding comments it is in, that is, a playlist name can appear in multiple music.
[0071] 203. Label screening and generation. The keyword library obtained by frequency statistics and sorting of the processing results of 202 is removed, and the words with low frequency of occurrence, i.e., the number of occurrences is less than or equal to 5, are then screened based on the music's own labels and high-frequency words to select relevant labels that can reflect the characteristics of the music. The final music labels will have two types: category and emotion. The core search label is the emotion label, i.e., the current song must have an emotion label;
[0072] 204. User behavior data processing. Among the currently collected user behavior data, the number of music plays, subscriptions, and favorites can be used as analysis data and calculated into initial scores to solve the cold start problem caused by the lack of user data in the early stages of the recommendation system;
[0073] 205. In 203, the music data with labels have been generated. The music labels can be processed into feature vectors using the term frequency-inverse document frequency method. The TF-IDF calculation is performed on the labels of each piece of music. The values of the remaining labels that do not appear are 0. Each piece of music can be represented as a one-dimensional feature vector. The similarity between two pieces of music is then calculated using the cosine similarity method. The calculation results are saved as a similarity matrix, and data with a similarity less than 0.6 is removed;
[0074] 206. Classify by tag, each tag corresponds to a category, sort the music under each category according to the initial score calculated in 204, and recalculate the music score and sort it when new user behavior data is generated;
[0075] 207. The classified and sorted music data, user-music related data and music similarity information are stored in the database. The final data can be saved in MongoDB and MySQL databases, and relevant access interfaces are opened.
[0076] The above is a preferred implementation mode of the present experiment. Although the present invention has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that it is still possible to modify the technical solutions described in the aforementioned embodiments, or to make equivalent replacements for some of the technical features therein; and these modifications or replacements should also be regarded as the scope of protection of the present invention.
Claims
1. A method for automatically collecting and processing a music emotion database, characterized in that: The specific steps are as follows: Step 1: Build a stable network music data collection system; Step 2: music tag generation and classification sorting; Step 3, music similarity calculation; Step 4, multiple data format reading and writing interfaces; Among them, step 2, music tag generation and classification sorting, is as follows: 2.1, based on the data processed in 1.5, analyze and filter tags from the music's own tags and the name of the playlist the music is in; 2.
2. The music’s own labels are retained, and all music playlists are further processed, including word segmentation, stop word removal, word frequency statistics and sorting, etc., low-frequency keywords are removed, and emotional labels are screened out based on the emotional vocabulary; 2.3, Music tag generation, emotional tags retain the top two tags with the highest frequency, and remove tags with emotional conflicts. For fear and relaxation, only the one with the highest frequency is selected. Other tags are music tags and non-overlapping high-frequency keywords. 2.4, perform weighted calculation on the user behavior data of the music, such as the number of plays, the number of favorites, and the number of subscriptions, to obtain a numerical representation that can be used to present the popularity of the music, i.e., the initial score, and classify and sort each tag based on the numerical value; Step 3, music similarity calculation, as follows: 3.1, the music tags are processed into feature vectors using the TF-IDF method, and the value of the non-appearing tags is 0, generating a music feature matrix; 3.2, calculate the cosine similarity of the feature matrix, design a corresponding data calculation model to solve the problem of excessive data calculation, and use a distributed data processing platform for calculation and processing; 3.3, similarity sorting, keep the music with similarity greater than or equal to 0.6, remove the music without similar music, and then sort according to popularity; Step 4, multiple data format reading and writing interfaces, as follows: 4.1, the general transmission format JSON is used for storage. The processed data is mainly divided into three parts: basic music information data, user-music related information data and music similarity matrix data. These data can all be saved in JSON format for easy transmission. At the same time, most databases and data applications can directly read and convert them. 4.2, MongoDB database storage interface, which has the function of directly processing JSON data and storing it in MongoDB, and also provides corresponding add, delete, modify and query functions; 4.2, MySQL database storage interface, has the function of directly processing JSON data and storing it in MySQL, while providing corresponding add, delete, modify and query functions.
2. The method for automatically collecting and processing a music emotion database as claimed in claim 1, characterized in that step 1, building a stable network music data collection system, is specifically as follows: 1.
1. Each time the collection system is started, it first obtains the public proxy IP in the network, tests and screens the obtained IP, and builds a proxy IP pool; 1.2, set the frequency of single IP access, clear invalid IPs in time, randomly select IPs and access at random times; 1.
3. For web pages that use ajax to dynamically load content, use PhantomJS+Selenium to simulate browser behavior and obtain page data after js rendering; 1.4, using the user's music playlist as the collection entry, obtain all music-related information in the current playlist; 1.
5. Data cleaning: remove duplicates, special symbols, replace synonyms, etc. from the collected data, and process it into music text data and user behavior data.
3. A method for automatically collecting and processing a music emotion database as described in claim 2, characterized in that the software environment of the method is a Spark distributed computing framework, a Scala development environment, and Python 3.6 with a data analysis and processing package installed.
4. A method for automatically collecting and processing a music emotion database as claimed in claim 3, characterized in that: The data file format of the collection and processing process is JSON format.
5. A method for automatically collecting and processing a music emotion database as claimed in claim 4, characterized in that: To ensure the accuracy of the labels, the music labels in 2.2 ultimately need to be manually reviewed.
Citation Information
Patent Citations
Chinese song emotion classification method based on multi-modal fusion
CN110674339A
Music emotion credible classification method based on deep learning
CN111462774A
Automatic music labeling method
CN113468366A
Method and apparatus for recommending music on basedautomatic analysis by user's purpose
KR1020070080299A
