Personalized music recommendation method and device, computer equipment and medium
By analyzing user listening records, calculating similarity, filtering candidate songs, and using the Mel spectrum and music emotion recognition model to extract emotional features, the problem of insufficient accuracy of existing music recommendation methods is solved, and more efficient personalized music recommendation is achieved.
Patent Information
- Application Number
- CN202411717145.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-26
- Publication Date
- 2025-03-18
AI Technical Summary
The existing music recommendation methods are insufficient in terms of accuracy and cannot effectively meet users' personalized needs.
By obtaining listening records for target users and known users, computing similarity to determine the associated users, comparing listening records for associated users to filter candidate songs, extracting emotional features using the Mel spectrum and music emotion recognition model, and computing emotional demand vectors to recommend the most matched songs.
It improves the accuracy of personalized music recommendations, can better meet the emotional needs of target users, and enhances the rationality and accuracy of recommendation results.
Smart Images

Figure CN119646256A_ABST
Abstract
Description
Technical Field
[0001] The present invention is applicable to the technical field of information recommendation, and in particular relates to a personalized music recommendation method, device, computer equipment and medium. Background Art
[0002] Personalized music recommendation refers to recommending music tracks to users based on factors such as user usage records, usage habits, and personal attributes.
[0003] Most existing music recommendation methods are based on the analysis of user listening records. The most common idea is to select unlistened tracks from the track lists of users with similar listening records and recommend them to target users by comparing their listening records. However, since people with similar listening records may not have exactly the same emotional needs, and the emotional needs of target users are time-sensitive, the method of directly recommending unlistened tracks to target users has great limitations, resulting in low accuracy of personalized recommendations and failure to meet the needs of target users.
[0004] Therefore, in the field of information recommendation technology, how to improve the accuracy of personalized music recommendations has become an urgent problem to be solved. Summary of the invention
[0005] In view of this, embodiments of the present invention provide a personalized music recommendation method, apparatus, computer device and medium to solve the problem of low accuracy of personalized music recommended by existing methods.
[0006] In a first aspect, an embodiment of the present invention provides a personalized music recommendation method, the personalized music recommendation method comprising: Obtain a first listening record of a target user within a first preset time period, and second listening records of N known users within the first preset time period, respectively calculate first similarities between the first listening record and the N second listening records, and determine the known users corresponding to the largest M first similarities as associated users, where N and M are integers, and 0<M≤N; Compare the songs in the first listening record with the songs in the second listening record of the associated user, and determine H songs that the target user has not listened to as candidate songs, where H is an integer and H>0; Obtain a third listening record of the target user within a second preset time period, calculate the Mel spectrum of the song in the third listening record and the Mel spectrum of H candidate songs, input all the Mel spectrums into a trained music emotion recognition model for feature extraction, and output a first emotion feature vector corresponding to the song in the third listening record and a second emotion feature vector corresponding to the candidate song; Calculate the mean of all first emotional feature vectors, determine the mean as the emotional demand vector, calculate the second similarities between the emotional demand vector and H second emotional feature vectors respectively, and determine the candidate songs corresponding to the largest K second similarities as recommended songs, where K is an integer, 0<K≤H.
[0007] In a second aspect, an embodiment of the present invention provides a personalized music recommendation device, the personalized music recommendation device comprising: A user screening module is used to obtain a first listening record of a target user within a first preset time period and a second listening record of N known users within the first preset time period, respectively calculate a first similarity between the first listening record and the N second listening records, and determine the known users corresponding to the largest M first similarities as associated users, where N and M are integers, and 0<M≤N; a song screening module, used to compare the songs in the first listening record with the songs in the second listening record of the associated user, and determine H songs that the target user has not listened to as candidate songs, where H is an integer and H>0; a feature extraction module, for obtaining a third listening record of the target user within a second preset time period, calculating the Mel spectrum of the songs in the third listening record and the Mel spectrum of H candidate songs, inputting all the Mel spectrums into a trained music emotion recognition model for feature extraction, and outputting a first emotion feature vector corresponding to the songs in the third listening record and a second emotion feature vector corresponding to the candidate songs; The song recommendation module is used to calculate the mean of all first emotional feature vectors, determine the mean as the emotional demand vector, calculate the second similarities between the emotional demand vector and H second emotional feature vectors respectively, and determine the candidate songs corresponding to the largest K second similarities as recommended songs, where K is an integer, 0<K≤H.
[0008] In a third aspect, an embodiment of the present invention provides a computer device, comprising a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the processor implements the personalized music recommendation method as described in the first aspect when executing the computer program.
[0009] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the personalized music recommendation method as described in the first aspect is implemented.
[0010] Compared with the prior art, the embodiments of the present invention have the following beneficial effects: obtaining a first listening record of a target user within a first preset time period, and a second listening record of N known users within the first preset time period, respectively calculating a first similarity between the first listening record and the N second listening records, determining that the known users corresponding to the largest M first similarities are associated users, comparing songs in the first listening record with songs in the second listening record of the associated user, determining that H songs that the target user has not listened to are candidate songs, obtaining a third listening record of the target user within the second preset time period, calculating the Mel spectrum of the song in the third listening record and the Mel spectrum of the H candidate songs, and combining all the Mel spectrums. The frequency spectra are respectively input into the trained music emotion recognition model for feature extraction, and the first emotion feature vector corresponding to the song in the third listening record and the second emotion feature vector corresponding to the candidate song are output, the mean of all the first emotion feature vectors is calculated, and the mean is determined as the emotion demand vector, and the second similarities between the emotion demand vector and the H second emotion feature vectors are calculated respectively, and the candidate songs corresponding to the largest K second similarities are determined as recommended songs. According to the similarity of the listening preferences of the target user and the known users, and the similarity of the emotional needs of the candidate songs and the target user, K recommended songs are determined and recommended to the target user, thereby improving the accuracy of the personalized recommendation results for the target user. BRIEF DESCRIPTION OF THE DRAWINGS
[0011] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0012] Figure 1 This is a schematic diagram of an application environment of a personalized music recommendation method provided by Embodiment 1 of the present invention; Figure 2 is a flowchart of a personalized music recommendation method provided in Embodiment 1 of the present invention; Figure 3 is a structural diagram of a personalized music recommendation device provided in Embodiment 2 of the present invention; Figure 4 It is a structural diagram of a computer device provided in Embodiment 3 of the present invention. DETAILED DESCRIPTION
[0013] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present invention. However, it should be clear to those skilled in the art that the present invention may be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present invention.
[0014] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, integers, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or combinations thereof.
[0015] It should also be understood that the term "and / or" used in the present description and the appended claims refers to and includes any and all possible combinations of one or more of the associated listed items.
[0016] As used in the present specification and the appended claims, the term "if" may be interpreted as "when" or "upon" or "in response to determining" or "in response to detecting", depending on the context. Similarly, the phrase "if it is determined" or "if [described condition or event] is detected" may be interpreted as meaning "upon determination" or "in response to determining" or "upon detection of [described condition or event]" or "in response to detecting [described condition or event]", depending on the context.
[0017] In addition, in the description of the present specification and the appended claims, the terms "first", "second", "third", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance.
[0018] References to "one embodiment" or "some embodiments" etc. described in the present specification mean that one or more embodiments of the present invention include specific features, structures or characteristics described in conjunction with the embodiment. Therefore, the statements "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways.
[0019] The embodiments of the present invention can acquire and process relevant data based on artificial intelligence technology. Artificial Intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results.
[0020] AI basic technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing technology, operation / interaction systems, mechatronics, etc. AI software technologies mainly include computer vision technology, robotics technology, biometrics technology, speech processing technology, natural language processing technology, and machine learning / deep learning.
[0021] It should be understood that the order of execution of the steps in the following embodiments does not imply a precedence of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.
[0022] In order to illustrate the technical solution of the present invention, specific embodiments are provided below for illustration.
[0023] A personalized music recommendation method provided by the first embodiment of the present invention can be applied in the following aspects: Figure 1 In the application environment, the client communicates with the server. The client includes but is not limited to PDAs, desktop computers, laptops, ultra-mobile personal computers (UMPCs), netbooks, cloud computing devices, personal digital assistants (PDAs), and other computer devices. The server can be implemented with an independent server or a server cluster consisting of multiple servers.
[0024] See also Figure 2 , is a flow chart of a personalized music recommendation method provided by the first embodiment of the present invention. The personalized music recommendation method can be applied to Figure 1 The personalized music recommendation method may include the following steps: Step S201, obtain the first listening record of the target user within the first preset time period, and the second listening records of N known users within the first preset time period, calculate the first similarities between the first listening record and the N second listening records respectively, and determine the known users corresponding to the largest M first similarities as associated users.
[0025] Among them, personalized music recommendation refers to analyzing the listening preferences of the target user according to the listening records and listening habits of the target user, so as to make personalized recommendations of music tracks to the user. Therefore, this embodiment obtains the first listening record of the target user within the first preset time to record and analyze the listening record and listening habits of the target user, and the second listening records of N known users within the first preset time period to record and analyze the listening records and listening habits of the known users, where N is an integer greater than 0.
[0026] The first preset time period includes a first start time and a first end time, the first end time is the current time, and the first start time can be set according to actual conditions. By performing a quantitative analysis on the songs listened to by the target user and the known user in the first preset time period, the target user and the known user's preference for each song can be obtained, thereby obtaining a first listening record representing the target user's listening preference and a second listening record representing the known user's listening preference.
[0027] The higher the first similarity between the second listening record and the first listening record, the closer the listening habits of the corresponding known user are to the target user. Therefore, this embodiment selects known users whose listening habits are similar to those of the target user as associated users of the target user and makes personalized recommendations to the target user.
[0028] Specifically, the first similarities between the first listening record and the N second listening records are calculated respectively, and the known users corresponding to the largest M first similarities are determined as associated users, wherein the specific value of M can be set according to actual conditions, and M is an integer, 0<M≤N.
[0029] Optionally, obtaining a first listening record of a target user within a first preset time period includes: Obtain all first songs listened to by the target user within a first preset time period, the total number of first listening times, and the first listening number of each first song; Calculate a first ratio of the first listening times of each first song to the first total listening times, and determine the first ratio as a first listening frequency corresponding to the first song; According to the preset order and the first listening frequencies of all the first songs, a first listening record of the target user is composed.
[0030] Among them, in order to characterize the listening preferences of the target user, this embodiment obtains all the first songs listened to by the target user within the first preset time period, the total number of first listening times and the first listening times of each first song. The first total number of listening times is used to indicate the total number of times the target user listens to songs within the first preset time period. The first listening times is used to indicate the number of times the target user listens to the corresponding first song within the first preset time period. Then, the first ratio of the first listening times to the first total number of listening times can be used as the first listening frequency of the corresponding first song, which is used to indicate the target user's preference for the corresponding first song.
[0031] The first listening frequencies of all the first songs are sorted according to the preset order of all the songs to form the first listening record of the target user to characterize the listening preference of the target user.
[0032] This embodiment calculates the first listening frequency of each first song through all the first songs listened to by the target user within the first preset time period, the total number of first listening times and the first listening number of each first song, and sorts the first listening frequencies of all the first songs according to a preset order to form the first listening record of the target user, thereby improving the accuracy of the characterization of the target user's listening preference. Optionally, obtaining the second listening records of N known users within the first preset time period includes: For any known user, obtaining all second songs listened to by the known user within a first preset time period, the total number of second listening times, and the second listening number of each second song; Calculating a second ratio of the second listening times to the second total listening times of each second song, and determining the second ratio as a second listening frequency corresponding to the second song; According to the preset sequence and the second listening frequencies of all the second songs, a second listening record of the known user is formed; Traverse all known users and obtain the second listening records of all known users.
[0033] Among them, in order to characterize the listening preferences of known users, this embodiment obtains, for any known user, all second songs listened to by the known user within the first preset time period, the total number of second listening times and the second listening times of each second song. The second total number of listening times is used to indicate the total number of times the known user listens to songs within the first preset time period, and the second listening times is used to indicate the number of times the known user listens to the corresponding second song within the first preset time period. The second ratio of the second listening times to the second total number of listening times can be used as the second listening frequency of the corresponding second song, which is used to indicate the degree of preference of the known user for the corresponding second song.
[0034] The second listening frequencies of all the second songs of the known user are sorted according to the preset order of all the songs to form the second listening record of the known user to characterize the listening preference of the known user.
[0035] By traversing all known users, the second listening records of all known users can be obtained.
[0036] This embodiment calculates the second listening frequency of each second song through all second songs listened to by a known user within a first preset time period, the total number of second listening times and the second listening number of each second song, and sorts the second listening frequencies of all second songs according to a preset order to form a second listening record of the known user, thereby improving the accuracy of characterizing the listening preferences of the known user.
[0037] The above steps of obtaining the first listening record of the target user within the first preset time period and the second listening records of N known users within the first preset time period, respectively calculating the first similarities between the first listening record and the N second listening records, and determining the known users corresponding to the largest M first similarities as associated users, characterize the listening preferences of the target user and the N known users through the first listening record and the N second listening records, and based on the first similarities between the first listening record and the N second listening records, select the known users corresponding to the largest M first similarities as associated users who are closer to the listening preferences of the target user, as the basis for personalized recommendation for the target user, thereby improving the rationality and accuracy of the results of personalized recommendation.
[0038] Step S202, compare the songs in the first listening record with the songs in the second listening record of the associated user, and determine H songs that the target user has not listened to as candidate songs.
[0039] Among them, since the listening habits of the associated user and the target user are closer, when making personalized music recommendations for the target user, the songs in the first listening record and the songs in the second listening record of the associated user are compared to obtain H songs that the target user has not listened to. The H songs that the target user has not listened to can then be used as candidate songs to be recommended to the target user, where H is an integer and H>0.
[0040] The above step of comparing the songs in the first listening record with the songs in the second listening record of the associated user to determine H songs that the target user has not listened to as candidate songs, by comparing the songs listened to by the target user and the songs listened to by associated users whose listening habits are similar to those of the target user, can make the H songs that the target user has not listened to serve as candidate songs to be recommended, thereby improving the rationality and accuracy of the results of personalized recommendations for the target user.
[0041] Step S203, obtain the third listening record of the target user within the second preset time period, calculate the Mel spectrum of the song in the third listening record and the Mel spectrum of H candidate songs, input all the Mel spectrum into the trained music emotion recognition model for feature extraction, and output the first emotion feature vector corresponding to the song in the third listening record and the second emotion feature vector corresponding to the candidate song.
[0042] Each song contains different emotions, and the songs that the target user listens to in a certain period of time can represent the target user's emotional needs in that period of time. Correspondingly, the user's emotional needs are time-sensitive, that is, the target user has different moods in different time periods, and the emotions he wants to get from music are also different.
[0043] Therefore, this embodiment obtains the third listening record of the target user within the second preset time period. Compared with the start time of the first preset time period, the start time of the second preset time period is closer to the current time of the target user, so as to obtain a third listening record that is closer to the current emotional needs of the target user.
[0044] For the H candidate songs to be recommended to the target user, the closer the emotions contained in the candidate songs are to the emotions contained in the songs in the target user's third listening record, the higher the possibility that the corresponding candidate songs will be recommended to the target user.
[0045] In the task of extracting song emotions, in order to improve the accuracy of song emotion extraction, the song audio needs to be converted into a corresponding spectrogram, and the data on the spectrogram is used as the corresponding speech information. The frequency of a common spectrogram is linearly distributed, but the human ear's perception of frequency is logarithmic, that is, it is sensitive to changes in the low frequency band and insensitive to changes in the high frequency band. The nonlinearly distributed Mel spectrum can effectively match the human ear's perception of frequency.
[0046] Therefore, this embodiment calculates the Mel spectrum of the song in the third listening record and the Mel spectrum of H candidate songs, and uses the trained music emotion recognition model to extract features from all the Mel spectrums respectively, and outputs the first emotion feature vector corresponding to the song in the third listening record and the second emotion feature vector corresponding to the candidate song. Among them, the first emotion feature vector can be used to represent the emotion contained in the song in the corresponding third listening record, and the second emotion feature vector can be used to represent the emotion contained in the corresponding candidate song, so as to serve as the basis for personalized music recommendation for target users.
[0047] Optionally, obtaining a third listening record of the target user within the second preset time period includes: Determine a second preset time period, the second preset time period includes a second start time and a second end time, the second end time is the current time, and the second start time is less than the first start time in the first preset time period; All third songs listened to by the target user within the second preset time period are obtained to form a third listening record of the target user.
[0048] Among them, the second preset time period includes a second start time and a second end time, and the second end time is the current time. In order to make the start time of the second preset time period closer to the current time of the target user, so as to obtain a third listening record that is closer to the current emotional needs of the target user, the second start time in this embodiment is less than the first start time in the first preset time period.
[0049] Then, all third songs listened to by the target user in the second preset time period are obtained to form the third listening record of the target user, which is used to characterize the song listening information of the target user in the second preset time period.
[0050] This embodiment composes a third listening record of the target user based on all third songs listened to by the target user within the second preset time period, and by setting the second start time in the second preset time period to be less than the first start time in the first preset time period, the third listening record is closer to the current emotional needs of the target user, thereby improving the accuracy of the characterization of the current emotional needs of the target user.
[0051] Optionally, calculating the Mel spectrum of the song in the third listening record and the Mel spectrum of the H candidate songs includes: For any song or any candidate song in the third listening record, obtain a corresponding first spectrogram, filter the first spectrogram according to a Mel filter to obtain a second spectrogram, perform logarithm and discrete cosine transform processing on the second spectrogram to obtain a third spectrogram, perform dimensionality reduction processing on the third spectrogram to obtain a corresponding Mel spectrum; The songs in the third listening record and the H candidate songs are traversed to obtain the Mel spectra of the songs in the third listening record and the Mel spectra of the H candidate songs.
[0052] Among them, in the process of converting the song from audio form to Mel spectrum form, the first spectrogram of the corresponding song is first obtained, and then the first spectrogram is filtered according to the Mel filter to obtain the second spectrogram, and then the second spectrogram is logarithmically and discrete cosine transformed to obtain the third spectrogram, and finally the third spectrogram is subjected to dimensionality reduction processing to obtain the corresponding Mel spectrum, so as to effectively match the human ear's perception of frequency, which serves as the basis for extracting emotional features of the song to improve the accuracy of the extracted emotional features.
[0053] This embodiment converts the song from audio form to Mel spectrum form to obtain the Mel spectrum of the song in the third listening record and H candidate songs, so as to effectively match the human ear's perception of frequency, which serves as the basis for extracting emotional features of the song in the third listening record and H candidate songs, thereby improving the accuracy of the extracted emotional features.
[0054] Optionally, the trained music emotion recognition model includes a trained audio feature extraction model and a trained bidirectional long short-term memory network model; All Mel spectra are input into the trained music emotion recognition model for feature extraction, and the output of the first emotion feature vector corresponding to the song in the third listening record and the second emotion feature vector corresponding to the candidate song includes: Input all the Mel spectra into the trained audio feature extraction model for feature extraction, and output a first audio feature vector corresponding to the song in the third listening record and a second audio feature vector corresponding to the candidate song; All first audio feature vectors and all second audio feature vectors are respectively input into the trained bidirectional long short-term memory network model for feature extraction, and the first emotion feature vector corresponding to the song in the third listening record and the second emotion feature vector corresponding to the candidate song are output.
[0055] Among them, the trained music emotion recognition model includes a trained audio feature extraction model and a trained bidirectional long short-term memory network model. The trained audio feature extraction model includes several convolution layers for extracting features from the input Mel spectrum, and a maximum pooling layer after each convolution layer for reducing the dimension of the extracted features. The trained audio feature extraction model outputs a first audio feature vector corresponding to the song in the third listening record and a second audio feature vector corresponding to the candidate song; the trained bidirectional long short-term memory network model is used to extract features from all first audio feature vectors and all second audio feature vectors, and output a first emotion feature vector corresponding to the song in the third listening record and a second emotion feature vector corresponding to the candidate song to represent the corresponding emotion information.
[0056] This embodiment performs feature extraction on the Mel-spectrograms of the songs in the third listening record and H candidate songs according to the trained audio feature extraction model, outputs a first audio feature vector corresponding to the songs in the third listening record and a second audio feature vector corresponding to the candidate songs, and uses the trained bidirectional long short-term memory network model to perform feature extraction on all the first audio feature vectors and all the second audio feature vectors, outputs a first emotion feature vector corresponding to the songs in the third listening record and a second emotion feature vector corresponding to the candidate songs, so as to characterize the corresponding emotion information, thereby improving the accuracy of characterization of the emotion information.
[0057] The above steps of obtaining the third listening record of the target user within the second preset time period, calculating the Mel spectrum of the songs in the third listening record and the Mel spectrum of H candidate songs, inputting all the Mel spectrums into the trained music emotion recognition model for feature extraction, and outputting the first emotion feature vector corresponding to the songs in the third listening record and the second emotion feature vector corresponding to the candidate songs, first obtain the third listening record that is closer to the current emotional needs of the target user, calculate the Mel spectrum of the songs in the third listening record and the Mel spectrum of H candidate songs, perform feature extraction on all the Mel spectrums according to the trained music emotion recognition model, output the first emotion feature vector corresponding to the songs in the third listening record and the second emotion feature vector corresponding to the candidate songs, so as to effectively match the human ear's perception of frequency and improve the accuracy of extracting the first emotion feature vector and the second emotion feature vector.
[0058] Step S204, calculate the mean of all first emotional feature vectors, determine the mean as the emotional demand vector, calculate the second similarities between the emotional demand vector and H second emotional feature vectors respectively, and determine the candidate songs corresponding to the largest K second similarities as recommended songs.
[0059] Among them, the first emotional feature vector can represent the emotion contained in the song in the corresponding third listening record, then calculate the mean of all first emotional feature vectors, and determine the mean as the emotional demand vector, which can be used to represent the emotional demand information of the target user in the second time period.
[0060] The second similarities between the emotional demand vector and the H second emotional feature vectors are calculated respectively. The larger the second similarity, the closer the emotion contained in the corresponding candidate song is to the emotional demand of the target user. Therefore, the candidate songs corresponding to the largest K second similarities are determined as recommended songs, and personalized recommendations are made to the target user, where K is an integer, 0<K≤H.
[0061] The above step of calculating the mean of all first emotional feature vectors, determining the mean as the emotional demand vector, respectively calculating the second similarities between the emotional demand vector and H second emotional feature vectors, and determining the candidate songs corresponding to the largest K second similarities as recommended songs, determines the mean of all first emotional feature vectors as the emotional demand vector to characterize the emotional demand information of the target user in the second time period, further determines the candidate songs corresponding to the largest K second similarities as recommended songs based on the second similarities between the emotional demand vector and the H second emotional feature vectors, and makes personalized recommendations to the target users, thereby improving the accuracy of the personalized recommendation results.
[0062] The embodiment of the present invention obtains a first listening record of a target user within a first preset time period, and a second listening record of N known users within the first preset time period, respectively calculates a first similarity between the first listening record and the N second listening records, determines that the known users corresponding to the largest M first similarities are associated users, compares songs in the first listening record with songs in the second listening record of the associated users, determines that H songs that the target user has not listened to are candidate songs, obtains a third listening record of the target user within the second preset time period, calculates the Mel spectrum of the song in the third listening record and the Mel spectrum of the H candidate songs, and inputs all the Mel spectrums into the training set. Feature extraction is performed in the trained music emotion recognition model, and the first emotion feature vector corresponding to the song in the third listening record and the second emotion feature vector corresponding to the candidate song are output. The mean of all first emotion feature vectors is calculated, and the mean is determined as the emotion demand vector. The second similarities between the emotion demand vector and H second emotion feature vectors are calculated respectively, and the candidate songs corresponding to the largest K second similarities are determined as recommended songs. According to the similarity between the listening preferences of the target user and known users, and the similarity between the candidate songs and the emotional needs of the target user, K recommended songs are determined and recommended to the target user, thereby improving the accuracy of the personalized recommendation results for the target user.
[0063] Corresponding to the personalized music recommendation method in the above embodiment, Figure 3 A structural block diagram of a personalized music recommendation device provided in Embodiment 2 of the present invention is given. For the sake of convenience, only the parts related to the embodiment of the present invention are shown.
[0064] See also Figure 3 , the personalized music recommendation device comprises: The user screening module 31 is used to obtain the first listening record of the target user within the first preset time period and the second listening records of N known users within the first preset time period, respectively calculate the first similarities between the first listening record and the N second listening records, and determine the known users corresponding to the largest M first similarities as associated users, where N and M are integers, N>0, 0<M≤N; A song screening module 32 is used to compare the songs in the first listening record with the songs in the second listening record of the associated user, and determine H songs that the target user has not listened to as candidate songs, where H is an integer and H>0; The feature extraction module 33 is used to obtain the third listening record of the target user within the second preset time period, calculate the Mel spectrum of the song in the third listening record and the Mel spectrum of H candidate songs, input all the Mel spectrums into the trained music emotion recognition model for feature extraction, and output the first emotion feature vector corresponding to the song in the third listening record and the second emotion feature vector corresponding to the candidate song; The song recommendation module 34 is used to calculate the mean of all first emotional feature vectors, determine the mean as the emotional demand vector, calculate the second similarities between the emotional demand vector and H second emotional feature vectors respectively, and determine the candidate songs corresponding to the largest K second similarities as recommended songs, where K is an integer, 0<K≤H.
[0065] Optionally, the user screening module 31 includes: A first song acquisition submodule, used to acquire all first songs listened to by the target user within a first preset time period, the total number of first listening times, and the first listening number of each first song; A first listening frequency calculation submodule, used for calculating a first ratio of a first listening number of each first song to a first total listening number of each first song, and determining the first ratio as a first listening frequency corresponding to the first song; The first listening record determination submodule is used to compose the first listening record of the target user according to a preset order and the first listening frequencies of all the first songs.
[0066] Optionally, the user screening module 31 includes: A second song acquisition submodule is used to acquire, for any known user, all second songs listened to by the known user within a first preset time period, a total number of second listening times, and a second listening number of each second song; A second listening frequency calculation submodule, used for calculating a second ratio of a second listening number of each second song to a second total listening number of each second song, and determining the second ratio as a second listening frequency corresponding to the second song; A second listening record determination submodule, for forming a second listening record of a known user according to a preset order and a second listening frequency of all second songs; The known user traversal submodule is used to traverse all known users and obtain the second listening records of all known users.
[0067] Optionally, the feature extraction module 33 includes: A time period determination submodule, used to determine a second preset time period, the second preset time period includes a second start time and a second end time, the second end time is the current time, and the second start time is less than the first start time in the first preset time period; The third listening record determination submodule is used to obtain all third songs listened to by the target user within the second preset time period to form the third listening record of the target user.
[0068] Optionally, the feature extraction module 33 includes: A first Mel spectrum calculation submodule is used to obtain a corresponding first spectrogram for any song or any candidate song in the third listening record, filter the first spectrogram according to the Mel filter to obtain a second spectrogram, perform logarithm and discrete cosine transformation on the second spectrogram to obtain a third spectrogram, and perform dimensionality reduction processing on the third spectrogram to obtain a corresponding Mel spectrum; The second Mel spectrum calculation submodule is used to traverse the songs in the third listening record and the H candidate songs to obtain the Mel spectrum of the songs in the third listening record and the Mel spectrum of the H candidate songs.
[0069] Optionally, the trained music emotion recognition model includes a trained audio feature extraction model and a trained bidirectional long short-term memory network model, and the feature extraction module 33 includes: A first feature extraction submodule is used to input all Mel spectra into the trained audio feature extraction model for feature extraction, and output a first audio feature vector corresponding to the song in the third listening record and a second audio feature vector corresponding to the candidate song; The second feature extraction submodule is used to input all the first audio feature vectors and all the second audio feature vectors into the trained bidirectional long short-term memory network model for feature extraction, and output the first emotion feature vector corresponding to the song in the third listening record and the second emotion feature vector corresponding to the candidate song.
[0070] It should be noted that the information interaction, execution process and other contents between the above modules are based on the same concept as the embodiment of the method of the present invention. Their specific functions and technical effects can be found in the method embodiment part and will not be repeated here.
[0071] Figure 4 This is a schematic diagram of the structure of a computer device provided in Embodiment 3 of the present invention. Figure 4 As shown, the computer device of this embodiment includes: at least one processor ( Figure 4 Only one is shown in the figure), a memory, and a computer program stored in the memory and executable on at least one processor, wherein when the processor executes the computer program, the steps of any of the above-mentioned embodiments of the personalized music recommendation method are implemented.
[0072] The computer device may include, but is not limited to, a processor and a memory. Those skilled in the art will appreciate that Figure 4 This is merely an example of a computer device and does not constitute a limitation on the computer device. The computer device may include more or fewer components than those shown in the figure, or a combination of certain components, or different components. For example, it may also include a network interface, a display screen, and an input device.
[0073] The processor may be a CPU, or other general-purpose processors, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.
[0074] The memory includes a readable storage medium, an internal memory, etc., wherein the internal memory may be the memory of a computer device, and the internal memory provides an environment for the operation of the operating system and computer-readable instructions in the readable storage medium. The readable storage medium may be a hard disk of a computer device, and in other embodiments, it may also be an external storage device of the computer device, for example, a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. equipped on the computer device. Further, the memory may also include both an internal storage unit of the computer device and an external storage device. The memory is used to store an operating system, an application program, a boot loader (BootLoader), data, and other programs, such as the program code of a computer program, etc. The memory may also be used to temporarily store data that has been output or is to be output.
[0075] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device is divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated into a processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of the present invention. The specific working process of the units and modules in the above-mentioned device can refer to the corresponding process in the above-mentioned method embodiment, which will not be repeated here. If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on such understanding, the present invention implements all or part of the processes in the above-mentioned embodiment method, which can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a computer-readable storage medium. When the computer program is executed by the processor, the steps of the above-mentioned method embodiment can be implemented. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may at least include: any entity or device capable of carrying computer program code, recording medium, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium. For example, a USB flash drive, a mobile hard disk, a magnetic disk or an optical disk. In some jurisdictions, according to legislation and patent practice, computer-readable media cannot be electric carrier signals and telecommunication signals.
[0076] The present invention implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by a computer program product. When the computer program product runs on a computer device, the computer device can implement the steps in the above-mentioned method embodiment when executing.
[0077] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0078] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0079] In the embodiments provided by the present invention, it should be understood that the disclosed devices / computer equipment and methods can be implemented in other ways. For example, the device / computer equipment embodiments described above are only schematic, for example, the division of modules or units is only a logical function division, and there may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0080] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0081] The above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention, and should be included in the protection scope of the present invention.
Claims
1. A personalized music recommendation method, characterized in that: The personalized music recommendation method comprises: Obtain a first listening record of a target user within a first preset time period, and second listening records of N known users within the first preset time period, respectively calculate first similarities between the first listening record and the N second listening records, and determine the known users corresponding to the largest M first similarities as associated users, where N and M are integers, and 0<M≤N; Compare the songs in the first listening record with the songs in the second listening record of the associated user, and determine H songs that the target user has not listened to as candidate songs, where H is an integer and H>0; Obtain a third listening record of the target user within a second preset time period, calculate the Mel spectrum of the song in the third listening record and the Mel spectrum of H candidate songs, input all the Mel spectrums into a trained music emotion recognition model for feature extraction, and output a first emotion feature vector corresponding to the song in the third listening record and a second emotion feature vector corresponding to the candidate song; Calculate the mean of all first emotional feature vectors, determine the mean as the emotional demand vector, calculate the second similarities between the emotional demand vector and H second emotional feature vectors respectively, and determine the candidate songs corresponding to the largest K second similarities as recommended songs, where K is an integer, 0<K≤H.
2. The personalized music recommendation method according to claim 1, characterized in that: The obtaining of a first listening record of a target user within a first preset time period includes: Obtaining all first songs listened to by the target user within the first preset time period, the total number of first listening times, and the first listening number of each first song; Calculating a first ratio of a first listening count of each first song to the first total listening count, and determining the first ratio as a first listening frequency corresponding to the first song; According to the preset order and the first listening frequencies of all the first songs, the first listening record of the target user is composed.
3. The personalized music recommendation method according to claim 1, characterized in that: The obtaining of the second listening records of N known users within the first preset time period includes: For any known user, obtaining all second songs listened to by the known user within the first preset time period, the total number of second listening times, and the second listening number of each second song; Calculating a second ratio of the second listening times of each second song to the second total listening times, and determining the second ratio as a second listening frequency corresponding to the second song; According to the preset order and the second listening frequencies of all the second songs, a second listening record of the known user is formed; Traverse all known users and obtain the second listening records of all known users.
4. The personalized music recommendation method according to claim 1, characterized in that: The obtaining of the third listening record of the target user within the second preset time period includes: Determine the second preset time period, the second preset time period includes a second start time and a second end time, the second end time is the current time, and the second start time is less than the first start time in the first preset time period; All third songs listened to by the target user within the second preset time period are obtained to form a third listening record of the target user.
5. The personalized music recommendation method according to claim 1, characterized in that: The calculating of the Mel spectrum of the song in the third listening record and the Mel spectrum of H candidate songs comprises: For any song or any candidate song in the third listening record, obtain a corresponding first spectrogram, filter the first spectrogram according to a Mel filter to obtain a second spectrogram, perform logarithm and discrete cosine transform processing on the second spectrogram to obtain a third spectrogram, perform dimensionality reduction processing on the third spectrogram to obtain a corresponding Mel spectrum; The songs in the third listening record and the H candidate songs are traversed to obtain the Mel spectra of the songs in the third listening record and the Mel spectra of the H candidate songs.
6. The personalized music recommendation method according to claim 1, characterized in that: The trained music emotion recognition model includes a trained audio feature extraction model and a trained bidirectional long short-term memory network model; The step of inputting all Mel spectra into the trained music emotion recognition model for feature extraction, and outputting the first emotion feature vector corresponding to the song in the third listening record and the second emotion feature vector corresponding to the candidate song comprises: Inputting all the Mel spectra into the trained audio feature extraction model for feature extraction, and outputting a first audio feature vector corresponding to the song in the third listening record and a second audio feature vector corresponding to the candidate song; All first audio feature vectors and all second audio feature vectors are respectively input into a trained bidirectional long short-term memory network model for feature extraction, and a first emotion feature vector corresponding to the song in the third listening record and a second emotion feature vector corresponding to the candidate song are output.
7. A personalized music recommendation device, characterized in that: The personalized music recommendation device comprises: A user screening module is used to obtain a first listening record of a target user within a first preset time period and a second listening record of N known users within the first preset time period, respectively calculate a first similarity between the first listening record and the N second listening records, and determine the known users corresponding to the largest M first similarities as associated users, where N and M are integers, and 0<M≤N; a song screening module, used to compare the songs in the first listening record with the songs in the second listening record of the associated user, and determine H songs that the target user has not listened to as candidate songs, where H is an integer and H>0; a feature extraction module, for obtaining a third listening record of the target user within a second preset time period, calculating the Mel spectrum of the songs in the third listening record and the Mel spectrum of H candidate songs, inputting all the Mel spectrums into a trained music emotion recognition model for feature extraction, and outputting a first emotion feature vector corresponding to the songs in the third listening record and a second emotion feature vector corresponding to the candidate songs; The song recommendation module is used to calculate the mean of all first emotional feature vectors, determine the mean as the emotional demand vector, calculate the second similarities between the emotional demand vector and H second emotional feature vectors respectively, and determine the candidate songs corresponding to the largest K second similarities as recommended songs, where K is an integer, 0<K≤H.
8. The personalized music recommendation device according to claim 7, characterized in that: The user screening module comprises: A first song acquisition submodule, used to acquire all first songs listened to by the target user within the first preset time period, the total number of first listening times, and the first listening number of each first song; A first listening frequency calculation submodule, used for calculating a first ratio of a first listening number of each first song to the first total listening number, and determining the first ratio as a first listening frequency corresponding to the first song; The first listening record determination submodule is used to compose the first listening record of the target user according to a preset order and the first listening frequencies of all the first songs.
9. A computer device, characterized in that: The computer device includes a processor, a memory, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the personalized music recommendation method according to any one of claims 1 to 6 is implemented.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the personalized music recommendation method according to any one of claims 1 to 6 is implemented.