Video soundtrack processing method, electronic device and computer-readable storage medium
By identifying and merging important sound segments and background tracks in the original video sound, the problem of visual and auditory separation caused by video soundtrack in the existing technology is solved, and the look and feel of the short video is improved.
Patent Information
- Application Number
- CN202310159949.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-16
- Publication Date
- 2024-09-10
- Estimated Expiration
- 2043-02-16
AI Technical Summary
When the existing technology generates a short video with a soundtrack, the electronic device needs to delete the original video sound before splicing, resulting in a visual and auditory separation in the video, affecting the viewing effect.
By identifying important sound fragments in the video original sound and merging them with the background audio track, a fusion soundtrack is generated to ensure that the important original sound in the video is retained and the vision and hearing are unified.
It achieves the visual and auditory unification of video soundtracks, improves the look and feel of short videos, and avoids the problem of visual and auditory separation.
Smart Images

Figure CN117119266B
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence technology, and in particular to a video soundtrack processing method, an electronic device, and a computer-readable storage medium. Background Art
[0002] With the development of the Internet and the popularity of mobile terminal devices, a new media communication method based on short video content has emerged. Among them, short videos are generally less than five minutes long and have a variety of content forms. When short videos first appeared in people's lives, professional video editing staff were generally required to use professional video editing tools to complete the production process of short videos. In order to enable non-professional short video makers to make short videos and record their lives through short videos, an application with a one-click filming function came into being. This application can automatically generate short videos with music based on photos and videos taken by users.
[0003] However, in the process of generating a short video with music through the one-click video function, the electronic device generally needs to automatically splice the photos and videos taken by the user first. After that, the background music in the splicing template or the background music matched from the music library is used to replace the original sound in the video, resulting in a visual and auditory disconnection in the generated short video, thus affecting the viewing effect of the short video. Summary of the invention
[0004] In view of this, the present application provides a video soundtrack processing method, an electronic device, and a computer-readable storage medium, which can solve the problem of video visual and auditory separation.
[0005] In a first aspect, the present application provides a method for processing video soundtracks, which is applied to an electronic device running an application that supports video and audio editing. Among them, the electronic device can obtain the original soundtrack of the video to be soundtracked, and obtain the target sound segment in the original soundtrack. The target sound segment obtained by the electronic device can be an important sound that needs to be retained in the original soundtrack. Afterwards, the electronic device obtains the background soundtrack and merges the target sound segment with the background soundtrack to generate a fused soundtrack. Finally, the electronic device replaces the original soundtrack with the fused soundtrack to complete the video soundtrack.
[0006] In summary, the electronic device can identify the sound clip from the original soundtrack of the video to be matched, merge the sound clip with the background soundtrack, and match the video to be matched based on the fused soundtrack. While using the background soundtrack to enhance the atmosphere of the video, it can ensure that the important original sound in the video is preserved, ensure the unity of vision and hearing, and improve the matching effect.
[0007] In a possible implementation of the first aspect, obtaining a target sound segment in an original sound track includes: inputting the original sound track into a sound event detection model to identify important original sounds in the original sound track, and obtaining one or more sound segments including the important original sounds. The electronic device then selects the target sound segment from the one or more sound segments according to a screening condition.
[0008] That is to say, after the electronic device uses the sound event detection model to identify the important original sound in the original soundtrack, it can further filter the identification results based on the pre-set filtering conditions, so as to ensure that the target sound segment containing the important original sound can be accurately determined based on the original soundtrack. Then, it is ensured that the electronic device can compose music for the music video according to the target sound segment, and ensure that the video can highlight the important original sound while using the background music to set off the atmosphere, so as to ensure the unity of vision and hearing.
[0009] In a possible implementation manner of the first aspect, the screening condition includes one or more of the following: confidence, a score of a type tag, a distance between sound clips, and a threshold value for the number of sound clips that can be retained.
[0010] In some examples, confidence is used to indicate the noise situation of a sound clip. A type label is used to indicate the sound type corresponding to the sound included in the sound clip. For example, if a sound clip includes the sound of a cat, the type label of the sound clip output by the sound event detection model is a cat's meow. The distance between sound clips is used to indicate the time interval between the end time point of one sound clip and the start time point of another sound clip. The threshold value of the number of sound clips that can be retained can be determined based on the length of the video to be matched with music, or can be preset in the electronic device to avoid retaining too many target sound clips that affect the final soundtrack effect.
[0011] In a possible implementation of the first aspect, when filtering a target sound clip from one or more sound clips according to a filtering condition, the electronic device may obtain a confidence level of each sound clip in the one or more sound clips, and then determine that a first sound clip in the one or more sound clips whose confidence level is greater than or equal to a first preset confidence threshold is the target sound clip.
[0012] In this design, if the confidence of a sound clip is low, it means that the sound clip is more likely to contain noise, and vice versa, if the confidence of a sound clip is high, it means that the sound clip is less likely to contain noise. Therefore, the electronic device can filter out sound clips that may contain noise based on the confidence.
[0013] In a possible implementation of the first aspect, when filtering a target sound segment from one or more sound segments according to a filtering condition, the electronic device may first obtain the type labels of the one or more sound segments output by the sound event detection model, and then determine the score of each sound segment in the one or more sound segments according to the type labels of the one or more sound segments. Afterwards, the electronic device may determine that the second sound segment in the one or more sound segments is the target sound segment. The score of the second sound segment is greater than a first preset score threshold; and / or the second sound segment is a first number of sound segments ranked first in the score, and the first number is less than or equal to the threshold of the number of sound segments that can be retained.
[0014] In this design method, the electronic device scores the sound clips according to the type labels of the sound clips, and then determines the sound clips whose scores meet certain conditions as the target sound clips. The sound clips with higher scores can be screened out to ensure the correlation between the sound clips and the video to be matched with music. The sound clips with lower scores can also be screened out through the scores to ensure that the soundtrack emphasizes the key sounds with higher scores.
[0015] In a possible implementation manner of the first aspect, the number of target sound clips is less than or equal to a threshold number of retainable sound clips, and the threshold number of retainable sound clips corresponds to the duration of the video to be matched with music.
[0016] That is to say, under the premise that the number of target sound clips is less than or equal to the threshold number of sound clips that can be retained, the electronic device selects the target sound clips from the sound clips identified in the original sound track according to the screening conditions, to ensure that the selected target sound clips can effectively retain the important sounds in the original sound track.
[0017] In a possible implementation of the first aspect, when the electronic device selects a target sound segment from one or more sound segments according to a screening condition, the one or more sound segments can be divided into a retained sound group and a candidate sound group according to the screening condition. The retained sound group includes a second number of retained segments, the candidate segments included in the candidate sound group are sound segments other than the retained segments in the one or more sound segments, the second number is less than or equal to the threshold number of retained sound segments, and the first comprehensive score of the retained segment is greater than the second comprehensive score of the candidate segment. Afterwards, the electronic device obtains the start and end positions of the retained segments and the candidate segments output by the sound event detection model, and according to the start and end positions and the candidate sound group, screens and / or replaces the retained segments in the retained sound group, the last retained segment in the retained sound group is the target sound segment, and the distance between the target sound segments is greater than or equal to the preset distance threshold.
[0018] Based on this, the electronic device can first preliminarily screen the sound clips according to the screening conditions to obtain a retained sound group and a candidate sound group. Afterwards, the electronic device further calculates the distance between the sound clips based on the start and end positions of the retained clips and the candidate clips, thereby screening and replacing the sound clips in the retained sound group to ensure that the distance between the target sound clips in the retained sound group is greater than or equal to the preset distance.
[0019] In a possible implementation of the first aspect, when the electronic device screens and / or replaces the reserved segments in the reserved sound group according to the start and end positions and the candidate sound group, it can first determine whether the distance between the first reserved segment and the second reserved segment is less than a preset distance threshold according to the first start and end positions of the first reserved segment in the reserved sound group and the second start and end positions of the second reserved segment in the reserved sound group. In the case where the distance between the first reserved segment and the second reserved segment is less than the preset distance threshold, it means that the first reserved segment and the second reserved segment are both reserved, and when the first reserved segment and the second reserved segment are played, the interval between them is short, and the original sound will be mixed, so the electronic device can delete the first reserved segment and / or the second reserved segment. In the case where the distance between the first reserved segment and the second reserved segment is greater than or equal to the preset distance threshold, it means that the first reserved segment and the second reserved segment are both reserved, and when the first reserved segment and the second reserved segment are played, there is a long background sound in between, and the audio will not be mixed, so the electronic device can determine that the first reserved segment and the second reserved segment are the target sound segments.
[0020] That is to say, electronic devices ensure sufficient auditory buffer time through the distance between sound clips, that is, the time point when one sound clip ends and another sound clip starts, to avoid the simultaneous playback of multiple important sounds, which fails to highlight the key sounds.
[0021] In a possible implementation of the first aspect, if the distance between the first retained segment and the second retained segment is less than a preset distance threshold, the electronic device may select a third number of candidate segments with a higher comprehensive score in the candidate sound group as the first candidate segment to be supplemented. The third number is less than or equal to the number of retained segments deleted from the retained sound group, and the comprehensive score of the candidate segment to be supplemented is greater than or equal to the second score threshold, thereby ensuring the quality of the candidate segment selected by the electronic device. Afterwards, the electronic device may determine whether the distance between the first candidate segment to be supplemented and the retained segment in the retained sound group is less than the preset distance threshold, and if the distance between the first candidate segment to be supplemented and the retained segment in the retained sound group is less than the preset distance threshold, reselect the second candidate segment to be supplemented in the candidate sound group; if the distance between the first candidate segment to be supplemented and the retained segment in the retained sound group is greater than or equal to the preset distance threshold, add the first candidate segment to be supplemented to the retained sound group.
[0022] In the above design method, after preliminarily determining the first candidate segment to be added, the electronic device can further determine the distance between the first candidate segment to be added and each retained segment in the retained sound group to determine whether the first candidate segment to be added as a retained segment will affect the final soundtrack effect.
[0023] In a possible implementation of the first aspect, the electronic device may first obtain the playback position of the target sound segment in the original sound track, and then determine the corresponding splicing position in the background sound track based on the playback position. The playback position is used to indicate the time period in which the target sound segment is played in the original sound track, and the splicing position is used to indicate the time period in the background sound track for playing the target sound segment. The electronic device then splices the target sound segment to the corresponding splicing position in the background sound track, thereby achieving fusion of the target sound segment and the background sound track to generate a fused soundtrack.
[0024] In a possible implementation of the first aspect, the volume corresponding to the splicing position in the background sound track can be reduced to a first preset volume, thereby ensuring that after the target sound segment is spliced to the splicing position, the background music will not affect the playback of important sounds in the target sound segment, thereby ensuring the clarity of the important sounds.
[0025] In a possible implementation manner of the first aspect, the volume of the target sound segment can be increased to a second preset volume within a preset start time period of the splicing position, and the volume of the target sound segment can be reduced to a third preset volume within a preset end time period of the splicing position.
[0026] In some examples, the preset start time period is, for example, a period of time starting from a preset splicing position, so as to achieve a progressive playback effect of the target sound segment in the spliced fusion soundtrack. The preset end time period is, for example, a period of time before the end of the preset splicing position, so as to achieve a gradual out playback effect of the target sound segment in the spliced fusion soundtrack.
[0027] In this way, after the target sound clip is integrated into the background soundtrack, the connection between the important original soundtrack and the background music is natural, thereby improving the soundtrack effect of the video.
[0028] In a possible implementation of the first aspect, an electronic device may receive a sound event detection model sent by a server, wherein the sound event detection model includes a front-end feature extractor, a convolutional neural network, a bidirectional gated recurrent neural network, a fully connected neural network, and a result post-processing module. The sound event detection model is obtained by training using a sample audio track. In order to ensure that the sound event detection model can accurately identify a sound segment including a certain sound in an audio segment, a sample audio track including a sample sound segment and annotation information corresponding to the sample sound segment may be used to train the sound event detection model, wherein the annotation information is used to indicate a type label of the sample audio track. After the server trains the sound event detection model using the sample audio track, the sound event detection model may be sent to the electronic device, or the electronic device may request the server to obtain the sound event detection model, thereby ensuring that the electronic device can detect multiple sound segments from the original audio track using the sound event detection model.
[0029] In a possible implementation of the first aspect, a user may operate an electronic device to obtain a video to be matched with music. In response to the user operation, the electronic device may determine the video material selected by the user, where the video material includes one or more videos and / or one or more pictures. Afterwards, the electronic device splices the one or more videos and / or one or more pictures according to the order in which the video materials are selected by the user to generate the video to be matched with music, thereby ensuring the diversity of the content of the video to be matched with music.
[0030] In a possible implementation of the first aspect, the original soundtrack of the video to be matched with music includes the soundtracks of one or more previous videos, and / or the soundtracks matched to one or more pictures according to preset rules, so that it can be ensured that the video to be matched with music includes the original soundtrack that matches the content, so that when the music is subsequently matched based on the original soundtrack, it can be ensured that the important sounds of the video to be matched with music can be highlighted after the music is matched.
[0031] In a possible implementation of the first aspect, the background sound track and the original sound track have the same time length, ensuring the adaptability of the fused soundtrack obtained by using the background soundtrack and the sound clip as the soundtrack for the video to be matched.
[0032] In a second aspect, the present application provides an electronic device, which includes a display screen, a memory and one or more processors; the display screen, the memory and the processor are coupled; the display screen is used to display an image generated by the processor, and the memory is used to store computer program code, and the computer program code includes computer instructions.
[0033] Among them, when the processor executes the computer instructions, the electronic device performs the following operations: obtain the original sound track of the video to be matched with music; obtain the target sound clip in the original sound track, the target sound clip is the important sound that needs to be retained in the original sound track; obtain the background sound track; merge the target sound clip with the background sound track to generate a fused soundtrack; replace the original soundtrack with the fused soundtrack to complete the video soundtrack.
[0034] In another possible design of the second aspect, when the processor executes computer instructions, the electronic device further performs the following operations: inputting the original sound track into the sound event detection model to obtain one or more sound clips; and filtering the target sound clip from the one or more sound clips according to the filtering conditions.
[0035] In another possible design manner of the second aspect, the screening conditions include one or more of the following: confidence, a score of the type label, a distance between sound clips, and a threshold value for the number of sound clips that can be retained.
[0036] In another possible design manner of the second aspect, when the processor executes computer instructions, the electronic device also performs the following operations: obtaining the confidence of each sound segment in one or more sound segments; determining that a first sound segment in the one or more sound segments is a target sound segment, and the confidence of the first sound segment is greater than or equal to a first preset confidence threshold.
[0037] In another possible design manner of the second aspect, when the processor executes computer instructions, the electronic device further performs the following operations: obtaining type labels of one or more sound clips output by the sound event detection model; determining a score of each of the one or more sound clips based on the type labels of the one or more sound clips; determining that a second sound clip among the one or more sound clips is a target sound clip, and the score of the second sound clip is greater than a first preset score threshold; and / or the second sound clip is a first number of sound clips ranked first in the score, and the first number is less than or equal to a threshold value of the number of sound clips that can be retained.
[0038] In another possible design of the second aspect, the number of target sound clips is less than or equal to a threshold number of retainable sound clips, and the threshold number of retainable sound clips corresponds to the length of the video to be matched with music.
[0039] In another possible design manner of the second aspect, when the processor executes computer instructions, the electronic device further performs the following operations: according to the screening conditions, one or more sound clips are divided into retained sound groups and candidate sound groups, respectively; wherein the retained sound group includes a second number of retained clips, the candidate clips included in the candidate sound group are sound clips other than the retained clips in one or more sound clips, the second number is less than or equal to the threshold number of reservable sound clips, and the first comprehensive score of the retained clips is greater than the second comprehensive score of the candidate clips; the start and end positions of the retained clips and the candidate clips output by the sound event detection model are obtained; according to the start and end positions and the candidate sound groups, the retained clips in the retained sound group are screened and / or replaced, the last retained retained clip in the retained sound group is the target sound clip, and the distance between the target sound clips is greater than or equal to the preset distance threshold.
[0040] In another possible design manner of the second aspect, when the processor executes the computer instructions, the electronic device also performs the following operations: determining whether the distance between the first retained segment and the second retained segment is less than a preset distance threshold based on the first start and end positions of the first retained segment in the retained sound group and the second start and end positions of the second retained segment in the retained sound group; deleting the first retained segment and / or the second retained segment if the distance between the first retained segment and the second retained segment is less than the preset distance threshold; determining the first retained segment and the second retained segment as target sound segments if the distance between the first retained segment and the second retained segment is greater than or equal to the preset distance threshold.
[0041] In another possible design manner of the second aspect, when the processor executes computer instructions, the electronic device further performs the following operations: select a third number of candidate segments with higher comprehensive scores in the candidate sound group as the first candidate segments to be added, the third number is less than or equal to the number of retained segments deleted from the retained sound group, and the comprehensive scores of the candidate segments to be added are greater than or equal to the second score threshold; determine whether the distance between the first candidate segment to be added and the retained segments in the retained sound group is less than a preset distance threshold; if the distance between the first candidate segment to be added and the retained segments in the retained sound group is less than the preset distance threshold, reselect a second candidate segment to be added in the candidate sound group; if the distance between the first candidate segment to be added and the retained segments in the retained sound group is greater than or equal to the preset distance threshold, add the first candidate segment to be added to the retained sound group.
[0042] In another possible design manner of the second aspect, when the processor executes computer instructions, the electronic device also performs the following operations: obtaining the playback position of the target sound clip in the original sound track; the playback position is used to indicate the time period in which the target sound clip is played in the original sound track; determining the corresponding splicing position in the background sound track based on the playback position; the splicing position is used to indicate the time period in the background sound track for playing the target sound clip; and splicing the target sound clip to the corresponding splicing position in the background sound track.
[0043] In another possible design manner of the second aspect, when the processor executes the computer instruction, the electronic device further performs the following operations: reducing the volume corresponding to the splicing position in the background audio track to a first preset volume.
[0044] In another possible design manner of the second aspect, when the processor executes the computer instructions, the electronic device also performs the following operations: increasing the volume of the target sound clip to a second preset volume within a preset start time period of the splicing position, and reducing the volume of the target sound clip to a third preset volume within a preset end time period of the splicing position.
[0045] In another possible design manner of the second aspect, when the processor executes computer instructions, the electronic device also performs the following operations: receiving a sound event detection model sent by the server, the sound event detection model includes a front-end feature extractor, a convolutional neural network, a bidirectional gated recurrent neural network, a fully connected neural network and a result post-processing module, the sound event detection model is trained using a sample audio track, the sample audio track includes sample sound clips and annotation information corresponding to the sample sound clips, and the annotation information is used to indicate a type label of the sample audio track.
[0046] In another possible design of the second aspect, when the processor executes computer instructions, the electronic device also performs the following operations: in response to user operations, determine the video material selected by the user, the video material including one or more videos and / or one or more pictures; according to the order in which the user selects the video material, splice one or more videos and / or one or more pictures to generate a video to be accompanied by music.
[0047] In another possible design of the second aspect, the original soundtrack of the video to be matched with music includes the soundtrack of one or more previous videos, and / or the soundtrack matched to one or more pictures according to preset rules.
[0048] In another possible design of the second aspect, the background audio track and the original audio track have the same time length.
[0049] In a third aspect, the present application provides a computer-readable storage medium, comprising computer instructions, which, when executed on an electronic device, enables the electronic device to execute the method described in the first aspect and any possible design thereof.
[0050] In a fourth aspect, the present application provides a computer program product. When the computer program product is run on an electronic device, the electronic device executes the method described in the first aspect and any possible design thereof.
[0051] In a fifth aspect, a device is provided, which is included in an electronic device, and the device has the function of implementing the behavior of the electronic device in any of the above aspects and possible implementation methods. The function can be implemented by hardware, or by hardware executing corresponding software. The hardware or software includes at least one module or unit corresponding to the above function. For example, an allocation module or unit, a scanning module or unit, a recycling module or unit, a moving module or unit, and a storage module or unit, etc.
[0052] In a sixth aspect, the present application provides a chip system, which includes a processor and may also include a memory, for implementing any one of the methods provided in the first aspect. The chip system may be composed of a chip, or may include a chip and other discrete devices.
[0053] It can be understood that the electronic device described in the second aspect and any possible design thereof provided above, the computer-readable storage medium described in the third aspect, and the computer program product described in the fourth aspect are all used to execute the corresponding methods provided above. Therefore, the beneficial effects that can be achieved can be referred to the beneficial effects in the corresponding methods provided above, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0054] Figure 1 A schematic diagram of a first display interface provided in an embodiment of the present application;
[0055] Figure 2 A schematic diagram of a communication system provided in an embodiment of the present application;
[0056] Figure 3 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application;
[0057] Figure 4 A schematic diagram of the hardware structure of a chip provided in an embodiment of the present application;
[0058] Figure 5 A structural diagram of a sound event detection model provided in an embodiment of the present application;
[0059] Figure 6A schematic diagram of a second display interface provided in an embodiment of the present application;
[0060] Figure 7 A schematic diagram of a sound clip detection process provided in an embodiment of the present application;
[0061] Figure 8 A schematic diagram of a process of screening and replacing a reserved sound in a reserved sound group provided in an embodiment of the present application;
[0062] Fig. 9 A schematic diagram of a fusion soundtrack generation process provided in an embodiment of the present application;
[0063] Fig.10 A schematic diagram of a process of video soundtrack processing provided in an embodiment of the present application;
[0064] Fig.11 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0065] In the following, the terms "first" and "second" are used for descriptive purposes only and are not to be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features. In the description of this embodiment, unless otherwise specified, "plurality" means two or more.
[0066] Since the embodiments of the present application involve the application of neural networks, for ease of understanding, the relevant terms and concepts of neural networks that may be involved in the embodiments of the present application are first introduced below.
[0067] (1) Neural Network
[0068] A neural network can be composed of neural units. A neural unit can be a s The output of the operation unit can be:
[0069]
[0070] Where, s = 1, 2, ... n, n is a natural number greater than 1, W s For x s, b is the bias of the neural unit. f is the activation function of the neural unit, which is used to introduce nonlinear characteristics into the neural network to convert the input signal in the neural unit into the output signal. The output signal of the activation function can be used as the input of the next convolutional layer, and the activation function can be a sigmoid function. A neural network is a network formed by connecting multiple single neural units mentioned above, that is, the output of one neural unit can be the input of another neural unit. The input of each neural unit can be connected to the local receptive field of the previous layer to extract the features of the local receptive field. The local receptive field can be an area composed of several neural units.
[0071] (2) Deep Neural Networks
[0072] A deep neural network (DNN), also known as a multi-layer neural network, can be understood as a neural network with multiple hidden layers. According to the position of different layers, the neural network inside the DNN can be divided into three categories: input layer, hidden layer, and output layer. Generally speaking, the first layer is the input layer, the last layer is the output layer, and the layers in between are all hidden layers. The layers are fully connected, that is, any neuron in the i-th layer must be connected to any neuron in the i+1-th layer.
[0073] Although DNN looks complicated, the work of each layer is not complicated. In simple terms, it can be expressed as the following linear relationship: in, is the input vector, is the output vector, The offset vector, W is the weight matrix (also called coefficient), and α() is the activation function. Each layer is just an input vector After such a simple operation, the output vector Since DNN has many layers, the coefficient W and the offset vector The number of these parameters is also relatively large. The definitions of these parameters in DNN are as follows: Take the coefficient W as an example: Assume that in a three-layer DNN, the linear coefficient from the 4th neuron in the second layer to the 2nd neuron in the third layer is defined as The superscript 3 represents the layer number of the coefficient W, while the subscripts correspond to the third layer index 2 of the output and the second layer index 4 of the input.
[0074] In summary, the coefficients from the kth neuron in the L-1th layer to the jth neuron in the Lth layer are defined as
[0075] It should be noted that the input layer does not have a W parameter. In a deep neural network, more hidden layers allow the network to better describe complex situations in the real world. Theoretically, the more parameters a model has, the higher its complexity and the greater its "capacity", which means it can complete more complex learning tasks. Training a deep neural network is the process of learning the weight matrix, and its ultimate goal is to obtain the weight matrix of all layers of the trained deep neural network (the weight matrix formed by many layers of vector W).
[0076] (3) Loss Function
[0077] In the process of training a deep neural network, because we hope that the output of the deep neural network is as close as possible to the value we really want to predict, we can compare the predicted value of the current network with the target value we really want, and then update the weight vector of each layer of the neural network according to the difference between the two (of course, there is usually an initialization process before the first update, that is, pre-configuring parameters for each layer in the deep neural network). For example, if the predicted value of the network is high, adjust the weight vector to make it predict a lower value, and keep adjusting until the deep neural network can predict the target value we really want or a value very close to the target value we really want. Therefore, it is necessary to pre-define "how to compare the difference between the predicted value and the target value", which is the loss function or objective function, which are important equations used to measure the difference between the predicted value and the target value. Among them, taking the loss function as an example, the higher the output value (loss) of the loss function, the greater the difference, so the training of the deep neural network becomes a process of minimizing this loss as much as possible.
[0078] (4) Back propagation algorithm
[0079] The neural network can use the error back propagation (BP) algorithm to correct the size of the parameters in the initial neural network model during the training process, so that the reconstruction error loss of the neural network model becomes smaller and smaller. Specifically, the forward transmission of the input signal to the output will generate error loss, and the parameters in the initial neural network model are updated by back propagating the error loss information, so that the error loss converges. The back propagation algorithm is a back propagation movement dominated by error loss, which aims to obtain the optimal parameters of the neural network model, such as the weight matrix.
[0080] In some scenarios, in response to user operations, the electronic device can take pictures or videos through a camera, or obtain pictures or videos sent by other electronic devices, or download pictures or videos from the Internet. Afterwards, the electronic device can process the pictures and / or videos with music to generate a video including background music.
[0081] Some examples include Figure 1 As shown, the electronic device displays a first display interface, which is used to display pictures and videos acquired by the electronic device. The first display interface is, for example, a gallery application interface. When the electronic device displays the first display interface, it can detect the user's operation of selecting multiple pictures and / or videos. After the electronic device determines that a picture or video is selected, it can display a selection mark on the icon corresponding to the selected picture or video to prompt the user of the selection result of the picture or video. For example, Figure 1 In the first display interface shown, each icon has a mark, which is used to indicate the selection status of the corresponding picture or video. Figure 1 If there is a hollow circle on the icon, it means that the picture or video corresponding to the icon is not selected. If there is a check mark inside the circle on the icon, it means that the picture or video corresponding to the icon is selected. Figure 1 In the first display interface shown, after the electronic device detects that the user clicks the one-click video control 11, it can stitch multiple pictures selected by the user into one video, or stitch pictures and videos selected by the user into one video, or generate one or more videos selected by the user into one video. Afterwards, the electronic device can add background music to the generated video.
[0082] Among them, in the above-mentioned process of adding background music to the video, the electronic device can obtain background music from a locally stored audio file. For example, the local music library of the electronic device stores preset background music, or background music saved by the user. Alternatively, the electronic device can also obtain background music from a cloud server or the Internet. For example, the electronic device determines the background music from a cloud server or the Internet connected to the electronic device through a music matching algorithm. Afterwards, the electronic device can automatically add the determined background music to the video, or add background music to the video in response to the user's operation of selecting background music.
[0083] Although the above method can generate a video with background music, in the process of adding background music, the electronic device needs to delete the original sound in the video before splicing, and then add the determined background music to the video generated after splicing, resulting in visual and auditory separation in the final video, thereby affecting the viewing effect of the short video.
[0084] Therefore, the present application provides a method for generating video soundtracks, where an electronic device can identify important sounds in the original sound of a video, and fuse the identified important sounds with the determined background music, and use the fused music as the soundtrack of the generated video. Since the fused music includes important sounds in the original sound of the video, as well as background music, it can be ensured that the video soundtrack contains both background music for setting the atmosphere and important original sounds that match the video content, so that the visual and auditory senses of the video are integrated, ensuring the viewing effect of the video.
[0085] Figure 2 Schematic diagram of a communication system for the video soundtrack generation method provided in the embodiment of the present application. Figure 2 As shown, the communication system at least includes an electronic device 100. In some examples, the communication system may also include a server 200.
[0086] Optionally, the electronic device 100 may be, for example, a mobile phone, a computer, a tablet computer, a laptop computer, an ultra-mobile personal computer (UMPC), a netbook, a personal digital assistant (PDA), a wearable device, an artificial intelligence (AI) device, or other terminal device. The operating system installed in the electronic device 100 includes but is not limited to: Or other operating systems. This application does not limit the specific type of the electronic device 100 or the installed operating system.
[0087] Optionally, the server 200 may be a device or server with computing functions such as a cloud server or a network server. The server may be a single server, a server cluster consisting of multiple servers, or a cloud computing service center.
[0088] In some embodiments, the electronic device 100 is configured with a sound event detection model, which is used to identify the original sound of the video and determine the start and end positions and type tags of the original sound of the video. The start and end positions are used to indicate the start time and end time of the original sound of the video in the playback time of the entire video. The type tag is used to indicate the type of the original sound of the video, such as human voice, animal sound, applause, etc.
[0089] For example, after the electronic device 100 obtains the spliced video in response to the user operation, it can input the video original sound of the spliced video as an input parameter to the sound event detection model. Afterwards, the electronic device 100 can obtain the start and end positions and type labels corresponding to the important video original sound output by the sound event detection model. Afterwards, the electronic device 100 can determine the important video original sound that needs to be retained based on the video label, and merge the video original sound with the determined background music based on the start and end positions of the video original sound to generate the final video soundtrack.
[0090] In some examples, the electronic device 100 may be pre-installed with a sound event detection model, or the electronic device 100 may obtain the sound event detection model sent by the server 200.
[0091] Alternatively, when the electronic device 100 determines that music is needed for the video, it sends the original sound of the video to the server 200, and the server 200 determines the start and end positions and type labels corresponding to the important original sound of the video through the sound event detection model.
[0092] Figure 3 1 shows a schematic diagram of the structure of the electronic device 100. The electronic device 100 may include a processor 310, an external memory interface 320, an internal memory 321, a universal serial bus (USB) interface 330, a charging management module 340, a power management module 341, a battery 342, an antenna 1, an antenna 2, a mobile communication module 350, a wireless communication module 360, an audio module 370, a speaker 370A, a microphone 370C, an earphone interface 370D, a sensor module 380, a button 390, a motor 391, an indicator 392, a camera 393, a display screen 394, and a subscriber identification module (SIM) card interface 395.
[0093] It is to be understood that the structure illustrated in the embodiment of the present invention does not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may include more or fewer components than shown in the figure, or combine some components, or separate some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.
[0094] The processor 310 may include one or more processing units, for example, the processor 310 may include an application processor (AP), a modem processor, a graphics processor (GPU), an image signal processor (ISP), a controller, a memory, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Different processing units may be independent devices or integrated into one or more processors.
[0095] The controller may be the nerve center and command center of the electronic device 100. The controller may generate an operation control signal according to the instruction operation code and the timing signal to complete the control of fetching and executing instructions.
[0096] The processor 310 may also be provided with a memory for storing instructions and data. In some embodiments, the memory in the processor 310 is a cache memory. The memory may store instructions or data that the processor 310 has just used or cyclically used. If the processor 310 needs to use the instruction or data again, it may be directly called from the memory. This avoids repeated access, reduces the waiting time of the processor 310, and thus improves the efficiency of the system.
[0097] In some embodiments, the processor 310 may include one or more interfaces. The interface may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface, etc.
[0098] The I2C interface is a bidirectional synchronous serial bus, including a serial data line (SDA) and a serial clock line (SCL). In some embodiments, the processor 310 may include multiple groups of I2C buses. The processor 310 may be coupled to the touch sensor 380K, the charger, the flash, the camera 393, etc. through different I2C bus interfaces. For example: the processor 310 may be coupled to the touch sensor 380K through the I2C interface, so that the processor 310 communicates with the touch sensor 380K through the I2C bus interface to realize the touch function of the electronic device 100.
[0099] It is understandable that the interface connection relationship between the modules illustrated in the embodiment of the present invention is only a schematic illustration and does not constitute a structural limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may also adopt different interface connection methods in the above embodiments, or a combination of multiple interface connection methods.
[0100] The charging management module 340 is used to receive charging input from a charger. The charger may be a wireless charger or a wired charger. In some wired charging embodiments, the charging management module 340 may receive charging input from a wired charger through the USB interface 330. In some wireless charging embodiments, the charging management module 340 may receive wireless charging input through a wireless charging coil of the electronic device 100. While the charging management module 340 is charging the battery 342, it may also power the electronic device through the power management module 341.
[0101] The power management module 341 is used to connect the battery 342, the charging management module 340 and the processor 310. The power management module 341 receives input from the battery 342 and / or the charging management module 340, and supplies power to the processor 310, the internal memory 321, the external memory, the display screen 394, the camera 393, and the wireless communication module 360. In some other embodiments, the power management module 341 may also be disposed in the processor 310. In other embodiments, the power management module 341 and the charging management module 340 may also be disposed in the same device.
[0102] The wireless communication function of the electronic device 100 can be implemented through the antenna 1, the antenna 2, the mobile communication module 350, the wireless communication module 360, the modem processor and the baseband processor.
[0103] Antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in electronic device 100 can be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve the utilization of antennas. For example, antenna 1 can be reused as a diversity antenna for a wireless local area network. In some other embodiments, the antenna can be used in combination with a tuning switch.
[0104] The mobile communication module 350 can provide solutions for wireless communications including 2G / 3G / 4G / 5G, etc., applied to the electronic device 100. The mobile communication module 350 may include at least one filter, a switch, a power amplifier, a low noise amplifier (LNA), etc. The mobile communication module 350 can receive electromagnetic waves from the antenna 1, and filter, amplify, etc. the received electromagnetic waves, and transmit them to the modulation and demodulation processor for demodulation.
[0105] The wireless communication module 360 can provide wireless communication solutions for application in the electronic device 100, including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication technology (NFC), infrared technology (IR), etc.
[0106] In some embodiments, antenna 1 of electronic device 100 is coupled to mobile communication module 350, and antenna 2 is coupled to wireless communication module 360, so that electronic device 100 can communicate with the network and other devices through wireless communication technology.
[0107] The electronic device 100 implements the display function through a GPU, a display screen 394, and an application processor. The GPU is a microprocessor for image processing, which connects the display screen 394 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 310 may include one or more GPUs, which execute program instructions to generate or change display information.
[0108] The display screen 394 is used to display images, videos, etc. The display screen 394 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode or an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), Miniled, MicroLed, Micro-oLed, a quantum dot light-emitting diode (QLED), etc. In some embodiments, the electronic device 100 may include 1 or N display screens 394, where N is a positive integer greater than 1.
[0109] The electronic device 100 can realize the shooting function through ISP, camera 393, video codec, GPU, display screen 394 and application processor. ISP is used to process the data fed back by camera 393. For example, when taking a photo, the shutter is opened, and the light is transmitted to the camera photosensitive element through the lens. The light signal is converted into an electrical signal, and the camera photosensitive element transmits the electrical signal to the ISP for processing and converts it into an image visible to the naked eye. ISP can also perform algorithm optimization on the noise, brightness and skin color of the image. ISP can also optimize the exposure, color temperature and other parameters of the shooting scene. In some embodiments, ISP can be set in camera 393.
[0110] The camera 393 is used to capture still images or videos. The object generates an optical image through the lens and projects it onto the photosensitive element. The photosensitive element can be a charge coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor. The photosensitive element converts the light signal into an electrical signal, and then passes the electrical signal to the ISP to be converted into a digital image signal. The ISP outputs the digital image signal to the DSP for processing. The DSP converts the digital image signal into an image signal in a standard RGB, YUV or other format. In some embodiments, the electronic device 100 may include 1 or N cameras 393, where N is a positive integer greater than 1.
[0111] Digital signal processors are used to process digital signals. In addition to processing digital image signals, they can also process other digital signals.
[0112] Video codecs are used to compress or decompress digital videos. The electronic device 100 may support one or more video codecs. Thus, the electronic device 100 may play or record videos in a variety of coding formats, such as Moving Picture Experts Group (MPEG) 1, MPEG2, MPEG3, MPEG4, etc.
[0113] NPU is a neural network (NN) computing processor. By drawing on the structure of biological neural networks, such as the transmission mode between neurons in the human brain, it can quickly process input information and can also continuously self-learn. Through NPU, applications such as intelligent cognition of electronic device 100 can be realized, such as image recognition, face recognition, voice recognition, text understanding, etc.
[0114] The external memory interface 320 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100. The external memory card communicates with the processor 310 through the external memory interface 320 to implement a data storage function, such as storing music, video and other files in the external memory card.
[0115] The internal memory 321 may be used to store computer executable program codes, which include instructions. The processor 310 executes various functional applications and data processing of the electronic device 100 by running the instructions stored in the internal memory 321. The internal memory 321 may include a program storage area and a data storage area.
[0116] The electronic device 100 can implement audio functions such as music playing and recording through the audio module 370, the speaker 370A, the microphone 370C, the headphone interface 370D, and the application processor.
[0117] The audio module 370 is used to convert digital audio information into analog audio signal output, and is also used to convert analog audio input into digital audio signal. The audio module 370 can also be used to encode and decode audio signals. In some embodiments, the audio module 370 can be arranged in the processor 310, or some functional modules of the audio module 370 can be arranged in the processor 310.
[0118] The speaker 370A, also called a "speaker", is used to convert an audio electrical signal into a sound signal. The electronic device 100 can listen to music or listen to a hands-free call through the speaker 370A.
[0119] Microphone 370C, also called "microphone" or "microphone", is used to convert sound signals into electrical signals. When making a call or sending a voice message, the user can make a sound by approaching the microphone 370C with his mouth to input the sound signal into the microphone 370C. The electronic device 100 can be provided with at least one microphone 370C. In other embodiments, the electronic device 100 can be provided with two microphones 370C, which can not only collect sound signals but also realize noise reduction function.
[0120] The earphone interface 370D is used to connect a wired earphone and can be a USB interface 330 or a 3.5 mm open mobile terminal platform (OMTP) standard interface or a cellular telecommunications industry association of the USA (CTIA) standard interface.
[0121] The sensor module 380 may include a gyro sensor 380B, a distance sensor 380F, a touch sensor 380K, an ambient light sensor 380L, and the like.
[0122] The gyro sensor 380B can be used to determine the motion posture of the electronic device 100. In some embodiments, the angular velocity of the electronic device 100 around three axes (i.e., x, y, and z axes) can be determined by the gyro sensor 380B. The gyro sensor 380B can be used for anti-shake shooting. Exemplarily, when the shutter is pressed, the gyro sensor 380B detects the angle of the electronic device 100 shaking, calculates the distance that the lens module needs to compensate based on the angle, and allows the lens to offset the shaking of the electronic device 100 through reverse movement to achieve anti-shake. The gyro sensor 380B can also be used for navigation and somatosensory game scenes.
[0123] The distance sensor 380F is used to measure the distance. The electronic device 100 can measure the distance by infrared or laser. In some embodiments, when shooting a scene, the electronic device 100 can use the distance sensor 380F to measure the distance to achieve fast focusing.
[0124] The ambient light sensor 380L is used to sense the brightness of the ambient light. The electronic device 100 can adaptively adjust the brightness of the display screen 394 according to the perceived brightness of the ambient light. The ambient light sensor 380L can also be used to automatically adjust the white balance when taking pictures. The ambient light sensor 380L can also cooperate with the proximity light sensor 380G to detect whether the electronic device 100 is in a pocket to prevent accidental touches.
[0125] The touch sensor 380K is also called a "touch panel". The touch sensor 380K can be set on the display screen 394, and the touch sensor 380K and the display screen 394 form a touch screen, also called a "touch screen". The touch sensor 380K is used to detect touch operations acting on or near it. The touch sensor can pass the detected touch operation to the application processor to determine the type of touch event. Visual output related to the touch operation can be provided through the display screen 394. In other embodiments, the touch sensor 380K can also be set on the surface of the electronic device 100, which is different from the position of the display screen 394.
[0126] The key 390 includes a power key, a volume key, etc. The key 390 may be a mechanical key or a touch key. The electronic device 100 may receive key input and generate key signal input related to user settings and function control of the electronic device 100.
[0127] Motor 391 can generate vibration prompts. Motor 391 can be used for incoming call vibration prompts, and can also be used for touch vibration feedback. Indicator 392 can be an indicator light, which can be used to indicate charging status, power changes, messages, missed calls, notifications, etc.
[0128] The SIM card interface 395 is used to connect a SIM card. The SIM card can be connected to or disconnected from the electronic device 100 by inserting or removing the SIM card interface 395. The electronic device 100 can support 1 or N SIM card interfaces, where N is a positive integer greater than 1.
[0129] Figure 4 The hardware structure of a chip provided in an embodiment of the present application includes a neural-network processing unit (NPU) 400. The chip can be arranged in Figure 2 The server 200 shown is used to complete the training process of the sound event detection model.
[0130] The neural network processor NPU400 is mounted on the host central processing unit (CPU) as a coprocessor, and the host CPU assigns tasks. The core part of NPU400 is the operation circuit 403, and the controller 404 controls the operation circuit 403 to extract data from the memory (weight memory or input memory) and perform operations.
[0131] In some implementations, the operation circuit 403 includes multiple processing units (process engines, PEs) inside. In some implementations, the operation circuit 403 is a two-dimensional systolic array. The operation circuit 403 can also be a one-dimensional systolic array or other electronic circuits capable of performing mathematical operations such as multiplication and addition. In some implementations, the operation circuit 403 is a general-purpose matrix processor.
[0132] For example, assume there is an input matrix A, a weight matrix B, and an output matrix C. The operation circuit 403 takes the corresponding data of the matrix B from the weight memory 402 and caches it on each PE in the operation circuit 403. The operation circuit 403 takes the matrix A data from the input memory 401 and performs a matrix operation with the matrix B, and the partial result or the final result of the matrix is stored in the accumulator 408 (accumulator).
[0133] The vector calculation unit 407 can further process the output of the operation circuit 403, such as vector multiplication, vector addition, exponential operation, logarithmic operation, size comparison, etc. For example, the vector calculation unit 407 can be used for network calculations of non-convolutional / non-FC layers in a neural network, such as pooling, batch normalization, local response normalization, etc.
[0134] In some implementations, the vector calculation unit 407 can store the vector of processed outputs to the unified memory 406. For example, the vector calculation unit 407 can apply a nonlinear function to the output of the operation circuit 403, such as a vector of accumulated values, to generate an activation value.
[0135] In some implementations, the vector calculation unit 407 generates normalized values, merged values, or both.
[0136] In some implementations, the vector of processed outputs can be used as activation input to the computational circuit 403, e.g., for use in subsequent layers in a neural network.
[0137] The unified memory 406 is used to store input data and output data. The weight data is directly stored in the input data in the external memory to the input memory 401 and / or the unified memory 406 through the storage unit access controller 405 (direct memory access controller, DMAC), the weight data in the external memory is stored in the weight memory 402, and the data in the unified memory 406 is stored in the external memory.
[0138] The bus interface unit 410 (BIU) is used to implement the interaction between the main CPU, DMAC and instruction fetch memory 409 through the bus.
[0139] The instruction fetch buffer 409 connected to the controller 404 is used to store instructions used by the controller 404. The controller 404 is used to call the instructions cached in the instruction fetch buffer 409 to control the working process of the computing accelerator.
[0140] Generally, the unified memory 406, the input memory 401, the weight memory 402 and the instruction fetch memory 409 are all on-chip memories, and the external memory is a memory outside the NPU, which can be a double data rate synchronous dynamic random access memory (DDR SDRAM), a high bandwidth memory (HBM) or other readable and writable memory.
[0141] In some embodiments, the electronic device detects the user's operation of selecting pictures and / or videos, and can splice the pictures and / or videos selected by the user to generate a spliced video to be matched with music. Afterwards, the electronic device can add background music to the generated video to be matched with music. In order to avoid the original video sound of the video to be matched with music being completely covered by the background music during the process of adding background music, the electronic device can determine the important sounds that need to be retained in the original video sound, merge the important sounds with the background music, and use the merged sounds as the video soundtrack of the video to be matched with music.
[0142] Optionally, the electronic device can determine the important sounds included in the original sound of the video through a sound event detection model. Among them, the sound event detection model can be a deep learning model, and the sound event detection model includes a convolutional neural network and a bidirectional gated recurrent network. The sound event detection model can be trained using a labeled target sound segment containing the audio to be detected, so as to ensure that the sound event detection model can detect the start and end positions of important sounds in a long video original sound, and distinguish the type label and confidence of the important sound. Among them, the relevant contents of the detection method, start and end positions, type labels and confidence of important sounds are detailed in the corresponding positions below, and will not be repeated here.
[0143] The training process of the sound event detection model is introduced as follows.
[0144] In some embodiments, the server may construct a sound event detection model for performing sound detection. Figure 5 As shown, the sound event detection model constructed by the server includes a front-end feature extractor, a convolutional neural network, a bidirectional gated recurrent neural network, a fully connected neural network and a result post-processing module. After acquiring the input audio, the sound event detection model can perform recognition processing on the input audio to obtain an output result, which includes, for example, a target sound segment included in the recognized input audio, the start and end positions of the target sound segment, and a type label of the target sound segment.
[0145] Optionally, the server may obtain a training data set, and train the sound event detection model through the training data in the training data set, so that the sound event detection model has the sound detection capability of outputting the above output results. During the training process, based on the principle of the loss function and the back propagation algorithm, the parameters of the sound event detection model are corrected to reduce the error loss of the output result. Afterwards, when the server determines that the error loss of the output result meets the use requirements, it can be determined that the training of the sound event detection model is completed. Optionally, the training data set is, for example, a sample audio set containing a plurality of sample audios, wherein each sample audio may include one or more target sound segments, and the sample audio set also includes annotation information for indicating the start and end positions and type labels of the target sound segments. For example, the target sound segment included in a sample audio is a cat's cry, and the annotation information of the sample audio includes the start and end positions of the cat's cry in the sample audio (such as the start and end time appearing in the sample audio) and the type label of the cat's cry. Afterwards, after obtaining the sample audio set, the server can use the sample audio in the sample audio set and the corresponding annotation information as training data to train the sound event detection model.
[0146] In some examples, the server adjusts parameters such as batch size and learning rate to batch the sample audio in the sample audio set as input audio, and inputs it to Figure 5 The sound event detection model shown in FIG. Afterwards, the server determines the error loss between the output result and the annotation information corresponding to the input audio to correct the parameters of the sound event detection model. After multiple iterations of training, the training process of the initial sound event detection model can be completed. Among them, the batch size is used to indicate the number of sample audios input by the server to the sound event detection model each time. The learning rate is used to determine the step size of each iteration of the sound event detection model using the input audio. The server can make the loss function converge to the minimum value by adjusting the learning rate.
[0147] Exemplarily, after the front-end feature extractor obtains the input audio (such as the sample audio in the sample audio set), the input audio can be converted into a 64-dimensional log-Mel power spectrum, and then the sound features of the target sound segment included in the input audio can be extracted by Fourier transform at a sampling frequency of 20 milliseconds (ms). The sampling process can be implemented using a Hann window of size 40ms.
[0148] After that, after the front-end feature extractor completes the feature extraction process, it sends the extracted sound features to the convolutional neural network (CNN). The CNN receives the sound features and learns based on the sound features. After that, the CNN outputs a first learning result, which includes information for indicating the type label of the sound segment.
[0149] For example, the convolutional neural network in the sound event detection model can be implemented by a five-layer convolutional neural network with a convolution kernel size of 3x3. The first layer of the convolutional network uses a 64-dimensional channel, and the other layers of the convolutional network use 128-dimensional channels. The activation layer in the convolutional neural network is implemented using LeakyReLU, and the spectrum graph is locally pooled in the time and frequency domain after each layer of the convolutional network. Optionally, the local pooling operation can be performed by a 2×2 average pooling layer with a step size of 2, and a 2x downsampling (i.e., sampling a sample sequence interval once) to reduce the amount of calculation.
[0150] Optionally, the convolutional neural network can be a sparse convolutional neural network, which can activate and / or weight sparse features of data, that is, it can eliminate zero-value calculations by not transmitting zero-value data or using a data selection module to skip zero-value data, thereby improving the calculation speed of the convolutional neural network and effectively alleviating the demand for hardware resources.
[0151] Then, if Figure 5As shown, the bidirectional gate recurrent neural network (bidirectional gate recurrent unit, BGRU) receives the first learning result output by the CNN, learns and memorizes the longer context-dependent information in the first learning result, that is, learns the characteristics of continuous sounds in the original sound track of the input audio. The BGRU consists of two gate recurrent units (gate recurrent unit, GRU). One GRU is forward and accepts forward input; the other is a reverse GRU that learns reverse input. Optionally, corresponding to the 128-dimensional channel adopted by the convolutional neural network, the bidirectional gate recurrent network can be composed of a gate unit containing 128 hidden units. Optionally, the GRU includes, for example, a reset gate and an update gate. The reset gate is used to control how much past information to forget in the process of sound feature learning, that is, it helps to capture short-term dependencies in the time series of the original sound track. The update gate is used to control the amount of data that can be retained until the current moment in the process of learning the sound features. It can also be understood as determining how much information from the previous time step and the current time step will be passed on to the future, which helps capture long-term dependencies in the time series of the original sound track. Therefore, the sound features in the first learning result are further learned through BGRU, and the time correlation between the sound segments in the original sound track is learned, and the second learning result is obtained, which includes the continuous sound features of the original sound track.
[0152] Optionally, the second learning result includes type label information and continuous sound features corresponding to the original sound track. Therefore, the second learning result can continue to be classified using a fully connected neural network (FCNN) based on the type label information and continuous sound features corresponding to the original sound track.
[0153] Optionally, the fully connected neural network includes an input layer and two layers of feedforward neural networks, corresponding to the gated unit of BGRU containing 128 hidden units. The first layer of feedforward neural network of the fully connected neural network may contain 128 hidden neurons, and the feedforward neural network layer is composed of leakyReLU. The neurons of the second layer of feedforward neural network are determined by the number of types of target sound clips, and the activation function is Sigmoid. Each node in the fully connected neural network except the input layer is connected to all nodes in the previous layer, so it has good nonlinear mapping ability, and the nonlinear features of the bidirectional GRU output are weighted. If these nonlinear features are combined, a third learning result for characterizing the classification result of the fully connected neural network can be finally obtained. The classification result is used to classify sound clips with different types of labels.
[0154] Afterwards, the result post-processing module can obtain the third learning result output by the fully connected neural network, and perform double threshold filtering on the third learning result. Optionally, the threshold parameter is not easily affected by the change of duration in the process of double threshold filtering. Therefore, the result post-processing module performs result post-processing by double threshold filtering, which can effectively prevent the problem of jitter noise of type labels in the third learning result. Afterwards, the result post-processing model can output relevant information of the recognized sound segment, such as the start and end positions of the sound segment, type labels and other information.
[0155] Optionally, the result post-processing module can also compare the relevant information of the output sound segment with the annotation information of the input audio to determine the error loss between the output result and the annotation information of the input audio, so as to perform parameter correction on the sound event detection model based on the error loss. For example, the result post-processing module can compare the start and end positions of the identified sound segment with the start and end positions of the target sound segment included in the input audio, so as to determine the error value of the start and end positions between the identified sound segment and the target sound segment included in the input audio. For another example, the result post-processing module can quantify the difference between the type label of the identified sound segment and the type label of the target sound segment included in the input audio through the following binary cross entropy loss (BCE) function formula (1).
[0156]
[0157] In the above formula (1), y is a binary label 0 or 1, p(y i ) is the probability that the output sound segment belongs to the y type label, i represents the i-th type label, i = 1, 2, 3...N, N is a positive integer.
[0158] Based on the above formula (1), if the type label of the target sound segment is 1, if the type label of the recognized sound segment approaches 1, then the value of the BCE function should approach 0. On the contrary, if the type label of the recognized sound segment approaches 0 at this time, then the value of the loss function approaches infinity.
[0159] Optionally, after determining the error value (such as the value of the loss function) between the output sound segment and the target sound segment, the server determines whether the error value is within the preset acceptable error value range. If it is not within the preset acceptable error value range, the server can use the back propagation algorithm to optimize and adjust the parameters of the sound event detection model, and continue to train the sound event detection model. If the error value is within the preset acceptable error value range, the server can stop training the sound event detection model and obtain the trained sound event detection model. Afterwards, the server can send the trained sound event detection model to the electronic device. Accordingly, the electronic device can use the trained sound event detection model to identify the sound segment of the original soundtrack of the video to be accompanied by music, and can find the sound segment including the target sound from the original soundtrack, as well as the start and end positions and type labels of the sound segment.
[0160] Optionally, confidence is also called reliability, or confidence level, confidence coefficient. When sampling to estimate the overall parameter, the confidence can be used to describe the probability that the estimated value and the overall parameter are within a certain allowable error range. Before training the sound event detection model, the server can determine the average value of the target sound segment and the sample variance of the target sound segment in the sample audio set, thereby calculating a numerical value representing the degree of deviation, and then based on the data and a table indicating the correspondence between the degree of deviation numerical value and the confidence, determine the confidence of the target sound segment, and add the confidence to the annotation information. Then the subsequently trained sound event detection model can also output the confidence of the identified sound segment. Optionally, the confidence of the sound segment output by the trained sound event detection model can be used to indicate the noise situation of the sound segment. The above introduces the process of the server training the sound event detection model. After completing the training of the sound event detection model, the server can send the trained sound detection module to the electronic device.
[0161] It should be understood that the electronic device can deploy the sound event detection model sent by the server before the user uses it. Alternatively, the electronic device requests the server to obtain the sound event detection model when it needs to compose music for a video.
[0162] The following is an introduction to the video soundtrack process of electronic devices.
[0163] In some embodiments, a first application is installed in the electronic device, and the first application can be used to synthesize the video file. Optionally, the first application is, for example, a gallery application, an image life application, or the like.
[0164] In some examples, the electronic device can obtain video material and background music in response to user operation during the process of running the first application. For example, the first application runs and calls a software development kit (SDK) interface to obtain video material and background music.
[0165] In some embodiments, after acquiring the video material, the electronic device may cut and splice the video material to obtain a video to be matched with music composed of multiple video materials. The video material may include one or more videos, or one or more videos and one or more pictures.
[0166] In some examples, the video material acquired by the electronic device includes multiple videos, and the electronic device can directly splice the multiple videos to obtain a spliced video.
[0167] For example, Figure 6 In the second display interface shown, when the electronic device is displaying the image life application, after detecting that the user has selected video A, video B, and video C, it detects that the user has clicked the video processing control 61, and can determine that the user has instructed to generate a video to be matched with music based on video A, video B, and video C. Then, the electronic device can splice video A, video B, and video C to generate a video to be matched with music. For example, according to the order in which the user selects video A, video B, and video C, the electronic device splices the end time of video A with the start time of video B, and splices the end time of video B with the start time of video C, to obtain a spliced video D, which is the video to be matched with music.
[0168] It should be understood that the electronic device may also determine the order of the video materials selected by the user in the spliced video in other ways, and the embodiments of the present application are not limited to this.
[0169] In other examples, the video material obtained by the electronic device includes one or more videos, and the electronic device can identify each video according to a preset video segment identification rule to obtain the highlight segments of each video. Afterwards, the electronic device splices the identified highlight segments according to a preset splicing method to obtain a spliced video. The spliced video includes the original video sound corresponding to each highlight segment.
[0170] For example, the video material obtained by the electronic device includes video A and video B. The electronic device identifies video A and video B respectively according to the preset video segment identification rules, and determines that video A includes highlight segment 1 and highlight segment 2, and highlight segment 1 is located before highlight segment 2 in video A; video B includes highlight segment 3. Afterwards, the electronic device determines that the user first selects video A and then selects video B, then the electronic device first splices highlight segment 1 and highlight segment 2 in order, and then splices highlight segment 3 to the video after the splicing of highlight segment 1 and highlight segment 2, thereby obtaining the video to be matched with music. Among them, highlight segment 1, highlight segment 2 and highlight segment 3 all include the corresponding original sound of the video.
[0171] In other examples, the video material obtained by the electronic device includes one or more videos and one or more pictures, and the electronic device can convert the picture format to a video format. Afterwards, the electronic device splices the video in the video material and the video obtained after converting the picture format to obtain the video to be matched with music.
[0172] The video obtained by converting the image format is without sound. Alternatively, the electronic device can also add the original sound of the video to the video obtained by converting the image format according to the user's needs or a preset conversion template. The method of converting the image format and the method of adding the original sound of the video can be referred to the prior art, and the embodiments of the present application do not limit this.
[0173] For example, the electronic device obtains video A, video B, and picture C. The electronic device may first perform format conversion processing on picture C to convert picture C into video C. Afterwards, the electronic device may splice video A, video B, and video C corresponding to picture C according to the order in which the user selects video A, video B, and picture C. Among them, video A and video B include the corresponding video original sound, and video C includes the video original sound added by the electronic device.
[0174] In some other examples, the video material obtained by the electronic device includes one or more videos and one or more pictures. The electronic device can identify each video according to the preset video segment identification rules to obtain the highlights of each video. In addition, the electronic device can convert the picture format to a video format. Afterwards, the electronic device splices the obtained highlights and the converted picture to obtain the video to be matched with music.
[0175] For example, the electronic device obtains video A, video B, and picture C. The electronic device identifies video A and video B respectively according to the preset video segment identification rules, and determines that video A includes highlight segment 1 and highlight segment 2, and highlight segment 1 is located before highlight segment 2 in video A; video B includes highlight segment 3. In addition, the electronic device performs format conversion processing on picture C and converts picture C into video C. Afterwards, the electronic device can splice highlight segment 1, highlight segment 2, highlight segment 3, and video C according to the order in which the user selects video A, video B, and picture C. Among them, highlight segment 1, highlight segment 2, and highlight segment 3 all include corresponding video original sounds, and video C includes the video original sound added by the electronic device.
[0176] In some embodiments, the electronic device can perform video splicing by adding a transition connection between each video to be spliced (or highlight clip) during the process of cutting and splicing the video with music. Optionally, the transition connection method includes, for example, any one of direct splicing, fade-in and fade-out, rotation, etc. The specific method of splicing videos can refer to the prior art, and will not be described in detail here.
[0177] In other embodiments, the video material acquired by the electronic device can also be directly used as the video to be matched with music. Optionally, the video to be matched with music can be a video acquired by the electronic device from other devices or networks. For example, electronic device 1 responds to user operations and produces a spliced video to be matched with music. Afterwards, electronic device 1 sends the video to be matched with music to electronic device 2. After electronic device 2 acquires the video to be matched with music, it responds to user operations and matches the video with music. For another example, the electronic device responds to user operations and downloads a video. Afterwards, the electronic device matches the video with music.
[0178] In some embodiments, after the electronic device obtains the video to be matched with music, it can separate the original sound track of the original sound of the video from the video to be matched with music. The sound track is also called a channel, which is used to record the sound and music effects in the video. A video can include multiple sound tracks, and each sound track can independently record different timbres.
[0179] Thus, the original soundtrack of the video to be matched with music can be one track or multiple tracks. For example, if the electronic device detects that the video selected by the user is a music video released by a singer, the original soundtrack separated from the video to be matched with music includes a track of the singer's singing voice and a track of the music sound.
[0180] In some embodiments, after obtaining the original soundtrack of the video to be matched with music, the electronic device can input the original soundtrack into a pre-trained sound event detection model to obtain an output result. The output result includes one or more sound clips, the start and end positions of the one or more sound clips corresponding to the video to be matched with music, and the type labels and confidence of the one or more sound clips. It should be understood that the output sound clip is an important sound that needs to be retained in the audio to be matched with music, and the sound clip can be subsequently merged with the background music to obtain the video soundtrack.
[0181] As described above, during the training process of the sound event detection model, the server trains the sound recognition capability of the sound event detection model through the labeled target sound clips. Therefore, after the electronic device detects the original sound track through the sound event detection model, it can detect the sound clips that match the target sound clips in the original sound track to output the detection result. For example, the electronic device detects the original sound track through the sound event detection model, and can detect that the original sound track includes a sound clip with the labeled information of a cat's meow, a sound clip with the labeled information of cheering, etc.
[0182] The start and end positions are used to indicate the position of the sound clip in the video to be matched with music. For example, the start time and end time of the sound clip in the video to be matched with music; or the start time and duration of the sound clip in the video to be matched with music. For example, the start and end positions are 2s-4s, which is used to indicate that the sound clip is located at the 2nd to 4th second position in the video to be matched with music.
[0183] The type label is used to indicate the type of sound corresponding to the sound included in the sound clip. For example, the sound clip includes the sound of a cat, and the type label of the sound clip output by the sound event detection model is a cat's meow. For another example, the input audio includes audio clip A, audio clip B, and audio clip C. Sound clip A includes the sound of a person speaking, sound clip B includes the sound of a person singing, and sound clip C includes the sound of a crowd cheering. Then, the sound event detection model can output sound clip A, sound clip B, sound clip C, and the type labels corresponding to the three sound clips are human voices.
[0184] It should be understood that developers can preset the target sound segments and corresponding annotation information included in the sample audio for training the sound event detection model according to needs, and the annotation information includes the type label of the target sound segment. Then, in the subsequent process of the electronic device detecting the sound segment through the trained sound event detection model, the output sound segment and type label have different output results corresponding to different training data. For example, as in the above example scenario, the input audio includes audio segment A, audio segment B and audio segment C, sound segment A includes the sound of a person speaking, sound segment B includes the sound of a person singing, and sound segment C includes the sound of a crowd cheering. Based on the acquired input audio, the sound event detection model outputs an output result including the identified sound segment C, and the type label of sound segment C is cheering.
[0185] The confidence level is used to indicate the noise level of the sound clip. In the subsequent process of fusing the sound clip and the background music, the electronic device can filter out the sound clip with a low confidence level to avoid retaining the sound clip including the noise and affecting the soundtrack effect of the video.
[0186] In some embodiments, the electronic device inputs the original sound track separated from the video to be matched with music into a pre-trained sound event detection model to obtain one or more sound clips. Afterwards, the electronic device can also filter the one or more sound clips and retain some of the sound clips to make the final soundtrack more prominent.
[0187] For example, after the electronic device obtains N sound clips through the sound event detection model, it can select M sound clips from the N sound clips based on the type labels and confidence levels of the N sound clips. Wherein N is a positive integer, and M is a positive integer less than or equal to N. For example, the electronic device can determine the number of sound clips that can be retained based on the length of the video to be matched with music. If the length of the video to be matched with music is one minute, less than or equal to 2 sound clips can be retained. Alternatively, a threshold value for the number of sound clips that can be retained is preset in the electronic device, for example, the threshold value is 2.
[0188] For example, Figure 7 As shown in the schematic diagram of the sound clip detection process, after the electronic device inputs the original soundtrack of the video to be matched with music into the sound event detection model, four sound clips included in the original soundtrack can be obtained, such as sound clip A, sound clip B, sound clip C, and sound clip D. Among them, for example, the type label of sound clip A is human speech with a confidence of 0.9, the type label of sound clip B is laughter with a confidence of 0.8, the type label of sound clip C is cat meow with a confidence of 0.3, and the type label of sound clip D is applause with a confidence of 0.9.
[0189] In some examples, based on the above Figure 7 In the example scenario shown, the electronic device can filter out low-confidence sound clips to prevent the sound event detection model from making false detections, so that the detected sound clips include noise sound clips. For example, the electronic device sets the confidence threshold to 0.8 and filters out sound clips with confidence lower than 0.8. Figure 7 In step ① shown in FIG. 1 , the sound segment C whose confidence does not meet the confidence threshold requirement is filtered out, and the sound segments A, B, and D whose confidence meets the confidence threshold requirement are retained. Figure 7 In the example scenario shown, the electronic device can also retain the sound clips corresponding to the type tags with higher values according to the type tags, so as to ensure the importance and prominence of the retained sound clips. For example, the electronic device can score the type tags of the sound clips output by the sound event detection model based on pre-set rules, and retain some sound clips with higher scores.
[0190] For example, in Figure 7 In step ② shown, the electronic device can score the sound clip A, sound clip B, and sound clip D according to the type label. For example, in the pre-set rules, the full score is 10, the score weight of the type label is human speech is 0.5, the score weight of the type label is laughter is 0.8, and the score weight of the type label is applause is 0.7. The electronic device can score 5 for sound clip A, 8 for sound clip B, and 7 for sound clip D. Afterwards, the electronic device can retain the sound clip B and sound clip D with higher scores. When retaining the sound clip with higher score, the electronic device can use the score threshold to determine whether the score of the sound clip is higher.
[0191] Assume that the full score is 10 points, the score weight of the type label is human speech is 0.5, the score weight of the type label is laughter is 0.8, and the score weight of the type label is applause is 0.9. Then, the electronic device obtains a score of 5 for sound clip A, a score of 8 for sound clip B, and a score of 9 for sound clip D. In addition, the electronic device determines that less than or equal to 2 sound clips can be retained based on the length of the video to be matched with music. Then, the electronic device can sort the scores of sound clip A, sound clip B, and sound clip D, and retain the sound clip B and sound clip D with the highest scores.
[0192] It should be understood that the electronic device may first filter out the sound clips that do not meet the requirements according to the confidence threshold, and then determine the retained sound clips according to the type label score. Alternatively, the electronic device may first determine the retained sound clips according to the type label score, and then filter out the sound clips that do not meet the requirements according to the confidence threshold. The present embodiment of the application does not limit the order of selecting the screening conditions during the sound clip screening process of the electronic device.
[0193] Optionally, in the process of determining to retain sound clips according to the type tags, there may be a problem that the sound clips to be retained exceed the number of sound clips required for the video to be matched with music after the final score sorting due to the same type tags having the same score. Figure 7 In the scenario shown, the sound clips output by the sound event detection model also include sound clip E, the confidence of sound clip E meets the confidence threshold requirement, and the type label of sound clip E is the same as the type label of sound clip B, and the type label scores are the same. In this case, the electronic device sorts the scores of the sound labels and can determine to retain sound clip D. In addition, due to the requirement on the number of sound clips that can be retained, the electronic device can only select at most one sound clip from sound clip E and sound clip B to retain.
[0194] For example, the electronic device may pre-set rules including that if multiple sound clips with the same type tag receive the same score, the electronic device may determine the sound clip to be retained according to the pre-set time rule. For example, if the pre-set rule states that the priority of the sound clip with an earlier playback time is greater than the priority of the sound clip with a later playback time, the electronic device may determine that the sound clip E with a playback time earlier than the sound clip B is the retained sound clip. If the pre-set rule states that the priority of the sound clip with an earlier playback time is less than the priority of the sound clip with a later playback time, the electronic device may determine that the sound clip B with a playback time later than the sound clip E is the retained sound clip.
[0195] In some embodiments, the important sound to be retained in the original sound of the video to be matched with the theme information of the video to be matched with the music. For example, the theme information of the video to be matched with the music is a birthday celebration, so in the above example Figure 7 In the scene shown, the importance of laughter, applause, and human voices is higher than that of a cat's meow. That is, the electronic device can determine the scoring weight of the type label of each sound clip according to the theme information, so that the sound clips finally retained are the sound clips that the user wants to retain and are consistent with the theme information.
[0196] It should be understood that the electronic device may not be able to obtain the theme information of the video to be matched with music. Then, in this case, the scoring weights of various types of tags can also be pre-configured in the electronic device.
[0197] In some examples, the electronic device may also increase the scoring weight of the type tags that match the theme information according to the theme information of the video to be matched with music, and / or reduce the scoring weight of the type tags that do not match the theme information. For example, the electronic device inputs the original soundtrack of the video to be matched with music whose theme information is birthday celebration into the sound event detection model, and the type tags of the sound clips obtained include human voice, laughter, dog barking, and singing. Among them, since the type tags that match the theme information of birthday celebration are human voice, laughter, and singing, the electronic device may increase the scoring weight of the type tags as human voice, laughter, and singing. For example, the electronic device may add a weight increase amount to the original scoring weight, wherein the original scoring weight is the default scoring weight value when there is no theme information, and the weight increase amount is pre-set. When there is no theme information of the video to be matched with music, the electronic device may directly assign a scoring weight to each important sound according to the scoring weight rules preset in advance. In some examples, the electronic device may determine the scoring weight of the type tag of the sound clip according to the theme information to be matched with music based on the following formula (2).
[0198] Remain i =conf i *Weight(label i |theme) (2)
[0199] Among them, in formula (2), Remain i represents the score weight of the i-th sound clip, theme represents the theme information, confi is the confidence of the sound clip, Weight(label i |theme) represents the weight function of the type label of the i-th sound clip in a certain theme information, and i is a natural number.
[0200] Among them, the confidence conf i The value range is generally (0-1). If the electronic device has filtered out low-confidence sound segments before determining the scoring weight based on formula (2), then conf in the above formula (2) i The actual range of may be (K-1). In practical applications, the confidence threshold K is generally set to 0.8. By setting the confidence in formula (2), it is possible to set a higher scoring weight for audio with high confidence as much as possible, thereby preventing the electronic device from retaining the wrong type of audio.
[0201] In the above formula (2), Weight(label i|theme) can be determined based on pre-set rules. For example, in a video content with the theme of birthday celebration, it is generally believed that the importance of the sound of singing the birthday song is greater than the sound of applause, and the importance of the sound of clinking glasses is greater than the sound of applause. If in the pre-set rules, the scoring weight of the sound of singing the birthday song is 0.9, the weight of the sound of clinking glasses is 0.8, and the weight of the sound of applause is 0.6, then the electronic device can determine the weight to be 0.9 when the theme information (theme) is birthday celebration and the type label of the i-th sound clip is singing the birthday song.
[0202] Afterwards, the electronic device may determine the score of the type label of the sound clip based on the above formula (2), thereby determining the sound clip that needs to be retained.
[0203] In some embodiments, the electronic device can obtain the theme information of the video to be matched with music input by the user through the SDK interface. Alternatively, the electronic device can also identify the display content of the video to be matched with music through an image recognition algorithm to determine the theme information of the video to be matched with music. Among them, the relevant content of the image recognition algorithm can refer to the existing technology, and the embodiments of the present application do not limit this.
[0204] For example, after the electronic device completes the splicing of video materials and generates the video to be matched with music, a pop-up window prompts the user to add the theme information of the video to be matched with music. For example, if the user enters birthday party, the electronic device can determine that the theme information of the video to be matched with music is birthday celebration.
[0205] For another example, the electronic device may use an image recognition algorithm to identify that the displayed content of the video to be matched with music includes information such as birthday cakes and birthday hats, and may determine that the theme information of the video to be matched with music is a birthday celebration.
[0206] In one embodiment, the electronic device can filter the sound clips detected by the sound event detection model based on the duration of the sound clips, so as to ensure the effect of the soundtrack. For example, the electronic device can filter the sound clips with a duration of 2s-5s from the sound clips to avoid the failure to achieve the effect of highlighting the key sounds after the soundtrack is used for the soundtrack video based on the sound clips with a duration of too short or too long.
[0207] In some embodiments, the electronic device can screen the sound clips with closer distances among the sound clips output by the sound event detection model according to the start and end positions of the sound clips, so that the sound clips retained at the end are separated by a sufficient time length. This avoids the sound interference of the sound clips in the subsequent music matching process, resulting in the problem that the key sound is not prominent after the music matching. In addition, the difficulty of sound fusion between the sound clips and the background music is reduced.
[0208] For example, the electronic device can determine whether there are any two sound clips where the distance between the start position of one retained clip and the end position of the other retained clip is less than a preset distance threshold. Optionally, the electronic device can select and retain the sound clips with higher confidence and / or higher type label scores among the sound clips with closer distances based on the confidence and / or type label scores according to the methods described in the above embodiments.
[0209] For example, Figure 7 As shown, in step ①, after the electronic device filters out the sound segment C whose confidence is lower than the confidence threshold, the sound segment A, sound segment B, and sound segment D are retained. Afterwards, in step ②, the electronic device can determine whether the distances between the sound segment A and the sound segment B, the sound segment A and the sound segment D, and the sound segment B and the sound segment D are too close. If the electronic device determines that the distance between the end position of the sound segment A and the start position of the sound segment B is less than the preset distance threshold, the electronic device can then select to delete one of the sound segments according to the confidence and / or type label scores of the sound segment A and the sound segment B. Alternatively, both sound segments whose distance is less than the preset distance threshold are deleted.
[0210] Exemplarily, the electronic device may determine the distance between two sound segments according to the following formula (3).
[0211]
[0212] Among them, Distance i,j represents the distance between the i-th sound segment and the j-th sound segment, Indicates the time point (i.e., starting position) at which the i-th sound clip starts playing. Indicates the time point (i.e., the end position) at which the i-th sound clip ends playing. Indicates the time point when the jth sound clip starts playing. Indicates the time point at which the jth sound clip ends playing, where the time point is in seconds, and i and j are natural numbers.
[0213] In some embodiments, the electronic device screens the N sound clips output by the sound event detection model through the confidence and / or type label scores to obtain M sound clips, and these M sound clips constitute the reserved sound group R. In addition, the sound clips filtered by the electronic device constitute the candidate sound group I. Afterwards, the electronic device can determine whether the distance between the sound clips in the reserved sound group R is less than the distance threshold. If there are sound clips whose distance is less than the distance threshold, the electronic device can determine the sound clips that need to be deleted from the reserved sound group R, and select a corresponding number of sound clips from the candidate sound group I to add to the reserved sound group R, so that the start and end positions of each reserved clip in the reserved sound group R are not too close, ensuring that the prominent sound clips in the soundtrack will not cause the sound confusion effect in the auditory sense due to the too close playback distance, and also avoiding the problem of visual and auditory separation in video playback due to the small number of highlighted sounds.
[0214] It should be understood that if the electronic device fails to determine the sound clips that can be added to the retained sound group R from the retained sound group R based on screening conditions such as confidence and / or type label scores, then the number of sound clips that the electronic device ultimately determines need to be retained is less than M.
[0215] Alternatively, after the electronic device has filtered out some sound clips in the retained sound group R according to the distance threshold, it is no longer necessary to select sound clips from the candidate sound group I to be added to the retained sound group R, thereby effectively ensuring the quality of the sound clips in the retained sound group R.
[0216] For example, Figure 8 A schematic diagram of a process of screening and replacing the reserved sounds in the reserved sound group R provided by an embodiment of the present application. Figure 8 As shown, first, the electronic device determines the retained sound group R and the candidate sound group I according to the screening conditions such as the confidence and / or type label scores (such as step S801). Optionally, after the electronic device outputs N sound clips through the sound event detection model, the N sound clips are divided into the retained sound group R and the candidate sound group I according to the screening conditions such as the confidence and / or type label scores. For example, the electronic device performs a comprehensive score on the sound clips according to the screening conditions, and divides the M sound clips whose comprehensive scores are greater than or equal to the score threshold and are ranked first into the retained sound group R, and divides the remaining sound clips into the candidate sound group I. Among them, the comprehensive score is determined by, for example, the comprehensive confidence threshold and the score threshold of the type label.
[0217] Afterwards, the electronic device determines, based on the above formula (3), that the distance between the retained segment x and the retained segment y in the retained sound group R is less than a preset distance threshold (such as step S802). Optionally, the retained segment x and the retained segment y are any two sound segments in the retained sound group R. After determining that the distance between the retained segment x and the retained segment y in the retained sound group R is less than the preset distance threshold, the electronic device may delete the retained segment x and / or the retained segment y in the retained sound group R according to a preset rule (such as step S803). For example, the electronic device may delete one of the two retained segments with a low confidence and / or a low type label score according to screening conditions such as confidence and / or type label scores.
[0218] Afterwards, the electronic device selects candidate segments to be added to the retained sound group R from the candidate sound group I (as in step S804). For example, the electronic device selects a corresponding number of candidate segments whose comprehensive scores are greater than or equal to the score threshold and ranked first based on the comprehensive scores of the candidate segments in the candidate sound group.
[0219] Afterwards, the electronic device calculates the distance between the candidate segment to be added and any retained segment in the retained sound group R based on the above formula (3), and determines whether the distance between the candidate segment to be added and the determined retained segment is less than a preset distance threshold (such as step S805).
[0220] For example, the electronic device determines that the distance between the candidate segment to be added and the reserved segment in the reserved sound group R is less than the preset distance threshold (such as step S805). Then, in response to the distance between the candidate segment to be added and the reserved segment in the reserved sound group R being less than the preset distance threshold, the electronic device returns to step S804 and continues to select the candidate sound segment to be added from the candidate sound group I.
[0221] For another example, the electronic device determines that the distance between the candidate segment to be added and the reserved segment in the reserved sound group R is greater than or equal to the preset distance threshold (such as step S805). Then, in response to the distance between the candidate segment to be added and the reserved segment in the reserved sound group R being greater than or equal to the preset distance threshold, the electronic device adds the candidate segment to be added to the reserved sound group R (such as step S806).
[0222] In this way, the electronic device loops through the above steps S802 to S806. Afterwards, as described in step S802, in response to the distance between the reserved segment x and the reserved segment y in the reserved sound group R being greater than or equal to the preset distance threshold, the electronic device may output the reserved sound group R (as described in step S807). At this point, the electronic device may finally determine the reserved sound group R.
[0223] In some embodiments, the screening conditions include one or more of the following: confidence, score of type label, distance between sound clips, threshold value of the number of sound clips that can be retained. The electronic device can screen the N sound clips output by the sound event detection model according to the screening conditions to determine the M sound clips that are finally retained. Among them, the process of the electronic device screening the sound clips according to the screening conditions can refer to the implementation methods described in the above embodiments. It should be understood that the embodiments of the present application do not limit the screening conditions used in the sound clip screening process and the order in which the screening conditions are used.
[0224] In some examples, the electronic device may filter the N sound clips output by the sound event detection model according to the filtering conditions, determine the comprehensive scores of the N sound clips, sort the N sound clips according to the comprehensive scores, and then determine the sound clips that are finally retained.
[0225] Exemplarily, the electronic device detects the original soundtrack through the sound event detection model to obtain sound clips A, sound clips B, sound clips C, and sound clips D. After the electronic device performs comprehensive scoring on the detected sound clips based on the screening conditions, all the sound clips are sorted based on the comprehensive scores, and the order of the comprehensive scores from high to low is as follows: sound clip A, sound clip B, sound clip C, and sound clip D. If the comprehensive scores of sound clips A, sound clip B, and sound clip C are all greater than the preset score threshold, but since at most two sound clips can be selected as the reserved clips in the reserved sound group corresponding to the length of the video to be matched with music, the electronic device can select sound clips A and sound clip B as the reserved clips in the reserved sound group.
[0226] Alternatively, after determining the ranking of the output sound clips based on the comprehensive scores, the electronic device directly selects the corresponding number of sound clips ranked first as the reserved clips according to the length of the video to be matched with music, and adds them to the reserved clip group. For example, the electronic device adds sound clip A and sound clip B as the reserved clips to the reserved clip group. That is, the electronic device does not need to preset a preset score threshold.
[0227] Optionally, the electronic device may determine the comprehensive score of the sound segment according to the confidence level of the sound segment and / or the score of the type tag. The specific implementation of determining the comprehensive score of the sound segment may be combined with the methods described in the above embodiments, which will not be described in detail.
[0228] Afterwards, the electronic device can be Figure 8The method shown is to screen and replace the reserved segments in the reserved sound group. For example, if the electronic device determines that the distance between the starting position of the reserved segment A and the ending position of the reserved segment B is less than the preset distance threshold, the reserved segment B in the reserved sound group can be deleted according to the preset rules, such as the comprehensive score of the reserved segment B is lower than the comprehensive score of the reserved segment A. Afterwards, the electronic device adds the sound segment C with the highest comprehensive score in the candidate segment group as the segment to be added to the reserved sound group, and determines whether the distance between the reserved segment A and the sound segment C is less than the preset distance threshold. If the distance between the reserved segment A and the reserved segment C is still less than the preset distance threshold, the electronic device deletes the sound segment C from the reserved sound group. Afterwards, as described above, since the comprehensive score of the sound segment D is less than the preset score threshold and cannot be added to the reserved sound group, the electronic device can compose music for the video to be composed based on the reserved sound group including the reserved segment A.
[0229] In this way, the electronic device filters the sound clips output by the sound event detection model through preset filtering conditions to obtain sound clips that meet the requirements, thereby ensuring the quality of the subsequently generated soundtrack.
[0230] In one embodiment, after obtaining the sound clip corresponding to the original soundtrack of the video to be matched with music, the electronic device may merge the sound clip with the background music to obtain a fused soundtrack.
[0231] For example, Fig. 9 The figure shows a schematic diagram of a fusion soundtrack generation process provided by an embodiment of the present application. The electronic device detects the original soundtrack using a sound event detection model, and after screening the sound clips output by the sound event detection model, obtains a sound clip A that meets the requirements (such as step ①). Afterwards, the electronic device can fuse the sound clip A with the background soundtrack to generate a fusion soundtrack (such as steps ② and ③).
[0232] Optionally, the background soundtrack is the same length as the original soundtrack, ensuring the adaptability of the fused soundtrack obtained by using the background soundtrack and the sound clips as the soundtrack for the video to be matched. Optionally, the duration of the background soundtrack acquired by the electronic device may be different from the duration of the video to be matched. Then, the electronic device can adjust the duration of the background soundtrack to the same length as the video to be matched (i.e., the same as the original soundtrack) by cutting, looping, etc.
[0233] Optionally, the electronic device can directly obtain the background soundtrack selected by the user as the background soundtrack corresponding to the video to be matched with music, or determine the background soundtrack according to the background music selected by the user. In addition, the electronic device can also automatically determine the corresponding background soundtrack for the video to be matched with music, for example, based on the theme information of the video to be matched with music, select a background soundtrack that matches the theme information from the background soundtrack library.
[0234] Optionally, the embodiments of the present application do not impose specific restrictions on the order of obtaining sound clips and background sound tracks. For example, after the electronic device determines the sound clip, it may display a prompt message to prompt the user to select a background sound track. Alternatively, after the electronic device determines the sound clip, it automatically matches the background sound track according to the theme information of the video to be matched with music. For another example, after the electronic device determines that the user selects the video material to be spliced, it displays a prompt message to prompt the user to select a background sound track. Afterwards, the electronic device splices the video material, filters the sound clips, etc. Alternatively, after the electronic device determines that the user selects the video material to be spliced, it displays a prompt message to prompt the user to enter the theme information, and automatically matches the background sound track according to the theme information. Afterwards, the electronic device splices the video material, filters the sound clips, etc.
[0235] As follows Fig. 9 Taking the scenario of merging the sound clip A with the background sound track as an example, various implementation methods of obtaining fused soundtracks by electronic devices are introduced in detail.
[0236] In some embodiments, the electronic device may determine the splicing position of the sound segment A in the background sound track according to the start time and duration of the sound segment A, and then the electronic device splices the sound segment A to the splicing position in the background sound track.
[0237] For example, the electronic device determines that the start time of sound A is the 2nd second after the music video starts, and the duration is 2 seconds. Then, the electronic device can replace the background sound track from the 2nd to the 4th second in the background sound track with sound segment A.
[0238] In this way, it is ensured that the sound segment A can be highlighted in the fused soundtrack, and then after the soundtrack video is soundtracked based on the fused soundtrack, the unity of vision and hearing is ensured, and the viewing experience of the video is improved.
[0239] Optionally, in the process of splicing the sound segment A to the background sound track, the electronic device may reduce the volume of the splicing position in the background sound track, and then splice the sound segment A to the splicing position in the background sound track.
[0240] For example, Fig. 9 As shown, during the sound fusion process, the electronic device reduces the volume of the background sound track between time point 1 and time point 2 in the background sound track to 20%, and then splices the sound segment A to the splicing position between time point 1 and time point 2.
[0241] In this way, when the sound clip is played in the fusion soundtrack, the volume of the background sound track is reduced, thereby avoiding the auditory confusion caused by the splicing of the background sound track and the sound clip A.
[0242] Optionally, when lowering the volume of the background soundtrack at the splicing position, the electronic device may use a fade-in and fade-out method to lower the background soundtrack at the splicing position, and then splice the sound segment A to the splicing position in the background soundtrack to prevent sudden changes in the sound from reducing the quality of the soundtrack.
[0243] For example, Fig. 9 As shown, during the sound fusion process, the electronic device controls the volume of the background sound track to decrease linearly within a short period of time starting from time point 1 in the splicing position, and controls the volume of the background sound track to increase linearly within a short period of time before the end of time point 2 in the splicing position, until the preset volume target value is reached. Afterwards, the electronic device splices the sound segment A to the corresponding splicing position in the background sound track.
[0244] In addition, the electronic device can also use fade-in and fade-out sound volume processing for the beginning and end of sound clip A, and then splice sound clip A into the sound track of the background sound track according to the corresponding start and end times, so as to obtain a naturally connected fusion soundtrack.
[0245] In some embodiments, after the electronic device obtains the fused soundtrack, it can use the fused soundtrack to replace the original soundtrack in the video to be matched, thereby completing the video matching process.
[0246] In this way, the electronic device can use the sound event detection model to identify the sound clip from the original soundtrack of the video to be matched with music, fuse the sound clip with the background soundtrack, and match the video to be matched with music based on the fused soundtrack. While using the background soundtrack to enhance the atmosphere of the video, it can ensure that the important original sound in the video is preserved, ensure the unity of vision and hearing, and improve the soundtrack effect.
[0247] For example, Fig.10 The following is a flow chart of a video music processing method provided by the embodiment of the present application. Fig.10 As shown, the method includes the following steps.
[0248] S1001: The electronic device obtains the original sound track of the video to be matched with music.
[0249] After the electronic device obtains the video to be matched with music, it can separate the original sound track of the original sound of the video from the video to be matched with music. Optionally, the electronic device can separate one original sound track from the video to be matched with music, or can separate multiple sound tracks. For example, the electronic device can display the sound track A, sound track B, and sound track C separated from the video to be matched with music to the user. Afterwards, in response to the user's selection operation of sound track A, the electronic device can use sound track A as the original sound track.
[0250] In some embodiments, before obtaining the original soundtrack of the video to be matched with music, the electronic device can determine the video material selected by the user in response to the user operation, and the video material includes one or more videos and / or one or more pictures. Afterwards, the electronic device splices the one or more videos and / or one or more pictures according to the order in which the video materials are selected by the user to generate the video to be matched with music.
[0251] In some examples, when the electronic device is displaying an image life application, after detecting that the user has selected video A, video B, and video C in sequence, it detects that the user has clicked on a control for instructing the electronic device to generate a video to be matched with music. Then, the electronic device can sequentially splice video A, video B, and video C to generate a video to be matched with music. For example, according to the order in which the user selects video A, video B, and video C, the electronic device sequentially splices the end time of video A with the start time of video B, and splices the end time of video B with the start time of video C, to obtain a spliced video D, which is the video to be matched with music.
[0252] In other examples, the video material acquired by the electronic device includes one or more videos and one or more pictures, and the electronic device can convert the picture format and convert the picture into a video format. Afterwards, the electronic device splices the video in the video material and the video obtained after converting the picture format to obtain the video to be matched with music. For example, the video material acquired by the electronic device includes video A, video B and picture C. The electronic device can first perform format conversion processing on picture C and convert picture C into video C. Afterwards, the electronic device can splice video A, video B, and video C corresponding to picture C according to the order in which the user selects video A, video B and picture C.
[0253] The original soundtrack of the video to be matched with music includes the soundtrack of one or more previous videos, and / or the soundtrack matched to one or more pictures according to preset rules. For example, video A and video B include the corresponding original soundtracks, and video C includes the original soundtrack added by the electronic device.
[0254] S1002: The electronic device obtains a target sound segment in the original sound track.
[0255] Optionally, the target sound segment is an important sound that needs to be retained in the original sound track. For example, the important sounds that need to be retained include the sound of people cheering and the sound of people talking. Then, if a sound segment included in the original sound track includes the sound of people cheering, the electronic device interface obtains the sound segment as the target sound segment.
[0256] In some embodiments, before obtaining the original soundtrack of the video to be matched with music, the electronic device can receive a sound event detection model sent by the server, the sound event detection model includes a front-end feature extractor, a convolutional neural network, a bidirectional gated recurrent neural network, a fully connected neural network and a result post-processing module, and the sound event detection model is obtained by training with a sample soundtrack, and the sample soundtrack includes a sample sound segment and annotation information corresponding to the sample sound segment, and the annotation information is used to indicate the type label of the sample soundtrack. Among them, the server can construct a sound event detection model for sound detection, and obtain a training data set to train the sound event detection model.
[0257] In some examples, the electronic device may input the original sound track into the sound event detection model, obtain one or more sound clips identified from the original sound track by the sound event detection model, and then filter the target sound clip from the one or more sound clips according to the filtering conditions.
[0258] For example, the sound event detection model can identify sound clips including human voices from various audios. After the electronic device inputs the original sound track into the sound event detection model, it can identify one or more sound clips including human voices. Afterwards, the electronic device selects the target sound clip from one or more sound clips based on one or more of the screening conditions such as confidence, score of type label, distance between sound clips, threshold of the number of sound clips that can be retained, etc.
[0259] S1003: The electronic device obtains a background audio track.
[0260] In some examples, the electronic device can obtain a background soundtrack corresponding to the background music in response to the user's selection operation of the background music. Optionally, the electronic device can identify the displayed content of the video to be matched with music through an image recognition algorithm and select a background soundtrack that matches the displayed content of the video to be matched with music.
[0261] For example, when processing the soundtrack of a video to be soundtracked, the user can select background music A from the local music library of the electronic device or from the network. In response to the user's selection operation of background music A, the electronic device can first obtain background music A from the local music library or from the network, and then separate the background sound track from background music A.
[0262] S1004: The electronic device fuses the target sound clip with the background sound track to generate a fused soundtrack.
[0263] In some embodiments, the electronic device may obtain the playback position of the target sound clip in the original sound track, that is, the time period of the target sound clip in the original sound track. Then, the electronic device determines the corresponding splicing position in the background sound track based on the playback position, that is, the time period in the background sound track for playing the target sound clip. Finally, the electronic device splices the target sound clip to the corresponding splicing position in the background sound track.
[0264] For example, the electronic device obtains that the playback position of the target sound clip in the original audio track is 2s-4s. Then, based on the playback position, it can determine that the corresponding splicing position in the background audio track is 2s-4s. The electronic device can then splice the target sound clip to the 2s-4s position in the background audio track, thereby generating a fusion soundtrack.
[0265] Optionally, the electronic device may also reduce the volume corresponding to the splicing position in the background sound track to a first preset volume.
[0266] For example, Fig. 9 As shown, during the sound fusion process, the electronic device reduces the volume of the background sound track between time point 1 and time point 2 in the background sound track to 20%, and then splices the sound segment A to the splicing position between time point 1 and time point 2. In this way, when the sound segment is played in the fused soundtrack, the volume of the background sound track is reduced, thereby avoiding the auditory confusion caused by the splicing of the background sound track and the sound segment A.
[0267] Optionally, the electronic device can also increase the volume of the target sound clip to a second preset volume within a preset start time period of the splicing position, and reduce the volume of the target sound clip to a third preset volume within a preset end time period of the splicing position, so as to achieve the fusion of the target sound clip with the background sound track in a gradual manner to generate a fusion soundtrack, thereby obtaining a fusion soundtrack with a natural connection.
[0268] For example, Fig. 9 As shown, in the process of fusing the target sound segment A with the background sound track, the electronic device can control the volume of the target sound segment to be linearly increased to a second preset volume within a short time range starting from time point 1 in the splicing position, and control the volume of the target sound segment to be linearly decreased to a third preset volume within a short time range before the end of time point 2 in the splicing position. Afterwards, the electronic device splices the target sound segment A to the corresponding splicing position in the background sound track.
[0269] It can be understood that the electronic device can also lower the volume of the background sound track to a fourth preset volume within the preset start time period of the splicing position, and increase the volume of the background sound track to a fifth preset volume within the preset end time period of the splicing position, so as to achieve the fusion of the target sound clip with the background sound track in a gradual manner to generate a fusion soundtrack, thereby obtaining a fusion soundtrack with a natural connection.
[0270] For example, Fig. 9 As shown, during the sound fusion process, the electronic device controls the volume of the background sound track to decrease linearly within a short period of time starting from time point 1 in the splicing position, and controls the volume of the background sound track to increase linearly within a short period of time before the end of time point 2 in the splicing position, until the preset volume target value is reached. Afterwards, the electronic device splices the sound segment A to the corresponding splicing position in the background sound track.
[0271] In some examples, the background soundtrack has the same duration as the original soundtrack. This ensures that the fused soundtrack obtained using the background soundtrack and the sound clip is suitable for the soundtrack of the video to be matched. Optionally, the duration of the background soundtrack acquired by the electronic device may be different from the duration of the video to be matched. Then, the electronic device can adjust the duration of the background soundtrack to the same as the duration of the video to be matched (i.e., the same as the original soundtrack) by cutting, looping, etc.
[0272] S1005: The electronic device will replace the original soundtrack with the fusion soundtrack to complete the video soundtrack.
[0273] After the target sound clip is merged with the background soundtrack to generate a fused soundtrack, the electronic device can replace the original soundtrack of the soundtracked video with the fused soundtrack, thus completing the process of soundtracking the video.
[0274] In this way, electronic equipment can use the background soundtrack to enhance the atmosphere of the video while ensuring that important original sounds in the video are preserved, ensuring the unity of vision and hearing and improving the soundtrack effect.
[0275] As a possible scenario, when the electronic device selects the target sound segment from one or more sound segments according to the screening condition, the screening can be performed according to the confidence level. For example, the electronic device can first obtain the confidence level of each sound segment in the one or more sound segments, and then determine that the first sound segment in the one or more sound segments is the target sound segment, and the confidence level of the first sound segment is greater than or equal to the first preset confidence level threshold.
[0276] For example, as mentioned above, in Figure 7In step ① shown, the electronic device sets the confidence threshold to 0.8, and can filter out the sound segment C with a confidence lower than 0.8. If the confidence of the sound segment is low, it means that there is a high possibility of noise in the sound segment, and vice versa, if the confidence of the sound segment is high, it means that there is a low possibility of noise in the sound segment. Therefore, the electronic device can filter out the low-confidence sound segment, thereby preventing the sound event detection model from making false detections, so that the detected sound segment includes the noise sound segment.
[0277] As a possible scenario, when the electronic device selects the target sound clip from one or more sound clips according to the screening condition, the screening can be performed according to the confidence. Optionally, the electronic device can select the target sound clip from one or more sound clips according to the score of the type label of the sound clip, so as to retain the sound clip corresponding to the type label with higher value, thereby ensuring the importance and prominence of the retained sound clip.
[0278] In some examples, the electronic device may obtain the type labels of one or more sound clips output by the sound event detection model, and then determine the score of each sound clip in the one or more sound clips according to the type labels of the one or more sound clips. Afterwards, the electronic device determines that the second sound clip in the one or more sound clips is the target sound clip, and the score of the second sound clip is greater than a first preset score threshold; and / or the second sound clip is a first number of sound clips ranked first in the score, and the first number is less than or equal to the threshold of the number of sound clips that can be retained.
[0279] For example, the electronic device scores sound clip A with 9 points, sound clip B with 8 points, and sound clip C with 4 points based on the type label of the sound clip. When the first preset score threshold is 7, the electronic device can determine that sound clip A and sound clip B are target sound clips. When the threshold of the number of sound clips that can be retained is 1, the electronic device can determine the sound clip A with the highest score as the target sound clip. If the first preset score threshold is 7, and the threshold of the number of sound clips that can be retained is 1, then the electronic device can only determine that the sound clip A with the previous score ranking is determined as the target sound clip from the sound clip A and the sound clip B with a score greater than 7.
[0280] Based on the above solution, the number of target sound clips is less than or equal to a threshold number of retainable sound clips, and the threshold number of retainable sound clips corresponds to the duration of the video to be matched with music.
[0281] For example, the electronic device may determine the threshold value of the number of sound clips to be retained according to the length of the video to be matched with music. For example, if the length of the video to be matched with music is one minute, less than or equal to 2 sound clips may be retained, and the threshold value of the number of sound clips to be retained is 2.
[0282] As a possible scenario, when the electronic device selects a target sound segment from one or more sound segments according to the screening conditions, the one or more sound segments can be divided into a retained sound group and a candidate sound group according to the screening conditions. The retained sound group includes a second number of retained segments, the candidate segments included in the candidate sound group are sound segments other than the retained segments in the one or more sound segments, the second number is less than or equal to the threshold number of retained sound segments, and the first comprehensive score of the retained segment is greater than the second comprehensive score of the candidate segment. Afterwards, the electronic device obtains the start and end positions of the retained segments and the candidate segments output by the sound event detection model, and screens and / or replaces the retained segments in the retained sound group according to the start and end positions and the candidate sound groups, the last retained segment in the retained sound group is the target sound segment, and the distance between the target sound segments is greater than or equal to the preset distance threshold.
[0283] Exemplarily, the electronic device screens the N sound clips output by the sound event detection model through the confidence and / or type label scores to obtain M sound clips, and the M sound clips constitute the reserved sound group R. In addition, the electronic device forms the sound clips other than the M sound clips in the N sound clips into the candidate sound group I. Afterwards, the electronic device can delete or replace one of the two reserved clips in the reserved sound group R whose distance is less than the preset distance threshold with the sound clip in the candidate sound group, so as to ensure that the distance between the last reserved clips in the reserved sound group is greater than or equal to the preset distance threshold.
[0284] Optionally, the electronic device may determine whether the distance between the first retained segment and the second retained segment is less than a preset distance threshold according to the first start and end positions of the first retained segment in the retained sound group and the second start and end positions of the second retained segment in the retained sound group. The distance between the first retained segment and the second retained segment may be determined based on formula (3) described above.
[0285] In some examples, when the distance between the first reserved segment and the second reserved segment is less than a preset distance threshold, the electronic device deletes the first reserved segment and / or the second reserved segment. When the distance between the first reserved segment and the second reserved segment is greater than or equal to the preset distance threshold, the first reserved segment and the second reserved segment are determined to be target sound segments. Among them, when deleting one between the first reserved segment and the second reserved segment, the electronic device may delete the reserved segment with a lower score in the first reserved segment and the second reserved segment. For example, if the distance between the first reserved segment and the second reserved segment is less than the preset distance threshold, and the score of the first reserved segment is 8, and the score of the second reserved segment is 6, the electronic device may determine to delete the second reserved segment.
[0286] In this way, by retaining the start and end positions of the fragments and the candidate fragments, the retained fragments in the retained sound group can be screened, thereby ensuring that the final soundtrack can highlight some key sounds of the temperament, thereby improving the soundtrack effect.
[0287] Optionally, when the distance between the first retained segment and the second retained segment is less than a preset distance threshold, the electronic device may select a third number of candidate segments with higher comprehensive scores from the candidate sound group as the first candidate segments to be supplemented, the third number is less than or equal to the number of retained segments deleted from the retained sound group, and the comprehensive scores of the candidate segments to be supplemented are greater than or equal to the second score threshold. Afterwards, the electronic device determines whether the distance between the first candidate segment to be supplemented and the retained segments in the retained sound group is less than a preset distance threshold, and when the distance between the first candidate segment to be supplemented and the retained segments in the retained sound group is less than the preset distance threshold, reselects the second candidate segment to be supplemented from the candidate sound group, and when the distance between the first candidate segment to be supplemented and the retained segments in the retained sound group is greater than or equal to the preset distance threshold, adds the first candidate segment to be supplemented to the retained sound group.
[0288] For example, the electronic device detects the original soundtrack through a sound event detection model to obtain sound clips A, sound clips B, sound clips C, and sound clips D. After the electronic device scores the detected sound clips, it sorts all the sound clips based on the scores, and the scores are arranged from high to low as follows: sound clip A, sound clip B, sound clip C, and sound clip D. If the scores of sound clips A, sound clip B, and sound clip C are all greater than the preset score threshold, but since at most two sound clips can be selected as the reserved clips in the reserved sound group corresponding to the length of the video to be matched with music, the electronic device can use sound clips A and sound clip B as the reserved clips in the reserved sound group. Alternatively, after determining the score ranking of the output sound clips, the electronic device directly selects the corresponding number of sound clips ranked first as the reserved clips according to the number of reserved sound clips determined by the length of the video to be matched with music, and adds them to the reserved clip group. For example, the electronic device adds sound clips A and sound clip B as reserved clips to the reserved clip group.
[0289] In this way, the electronic device screens and replaces the retained fragments in the retained sound group by judging the distance between the retained fragments in the retained sound group, so that the start and end positions of each retained fragment in the retained sound group R are not too close, ensuring that the prominent sound fragments in the soundtrack will not cause auditory confusion due to the playback distance being too close, and avoiding the problem of visual and auditory separation in video playback due to the small number of highlighted sounds.
[0290] Thus, by using the method of the embodiment of the present application, the electronic device can identify a sound clip from the original soundtrack of the video to be matched with music, fuse the sound clip with the background soundtrack, and match the video to be matched with music based on the fused soundtrack. While using the background soundtrack to enhance the atmosphere of the video, it can ensure that the important original sound in the video is preserved, ensure the unity of vision and hearing, and improve the soundtrack effect.
[0291] Combination of the above Figure 6-Figure 10 The video soundtrack processing method provided by the embodiment of the present application is described in detail. Fig.11 The electronic device provided by the embodiments of the present application is described in detail.
[0292] In one possible design, Fig.11 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. Fig.11 As shown, the electronic device 1100 may include: a processing unit 1101 and a transceiver unit 1102. The electronic device 1100 may be used to implement the functions of the electronic device involved in the above method embodiment.
[0293] Optionally, the processing unit 1101 is used to support the electronic device 1100 to execute Figure 8 S801-S807 in; and / or, also used to support the electronic device 1100 to execute Fig.10 S1001-S1005 in.
[0294] Optionally, the transceiver unit 1102 is used to support the electronic device 1100 to execute Figure 8 S801-S807 in; and / or, also used to support the electronic device 1100 to execute Fig.10 S1001-S1005 in.
[0295] Among them, the transceiver unit 1102 may include a receiving unit and a sending unit, and may be implemented by a transceiver or a transceiver-related circuit component, and may be a transceiver or a transceiver module. The operations and / or functions of each unit in the electronic device 1100 are respectively to implement the corresponding process of the data management method in the above method embodiment, and all relevant contents of each step involved in the above method embodiment can be referred to the functional description of the corresponding functional unit, and for the sake of brevity, they will not be repeated here.
[0296] Optionally, Fig.11 The electronic device 1100 shown may also include a storage unit ( Fig.11 (not shown), the storage unit stores a program or instruction. When the processing unit 1101 and the transceiver unit 1102 execute the program or instruction, Fig.11 The electronic device 1100 shown can execute the voice control method described in the above method embodiment.
[0297] Fig.11 The technical effects of the electronic device 1100 shown can refer to the technical effects of the voice control method described in the above method embodiment, and will not be repeated here.
[0298] In addition to being in the form of electronic device 1100, the technical solution provided in the present application may also be a functional unit or chip in the electronic device, or a device used in conjunction with the electronic device.
[0299] An embodiment of the present application also provides a computer-readable storage medium, which includes computer instructions. When the computer instructions are executed on the above-mentioned electronic device, the electronic device executes each function or step in the above-mentioned method embodiment.
[0300] The embodiment of the present application also provides a computer program product, including a computer program. When the computer program runs on an electronic device, the electronic device executes each function or step in the above method embodiment.
[0301] Through the description of the above implementation methods, technical personnel in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.
[0302] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another device, 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.
[0303] The units described as separate components may or may not be physically separated, and the components shown as units may be one physical unit or multiple physical units, that is, they may be located in one place or distributed in multiple different places. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0304] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0305] 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 readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium, including several instructions to enable a device (which can be a single-chip microcomputer, chip, etc.) or a processor (processor) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read only memory (ROM), random access memory (RAM), disk or optical disk and other media that can store program code.
[0306] The above contents are only specific implementation methods of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions within the technical scope disclosed in the present application shall be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.
Claims
1. A video music processing method, characterized in that: Applied to electronic equipment, the method comprises: Get the original soundtrack of the video to be matched with music; Acquire a target sound segment in the original sound track, where the target sound segment is an important sound that needs to be retained in the original sound track; Get the background audio track; Merging the target sound clip with the background sound track to generate a fused soundtrack; The fusion soundtrack replaces the original soundtrack to complete the video soundtrack; The step of obtaining the target sound segment in the original sound track includes: Inputting the original sound track into a sound event detection model to obtain one or more sound clips; According to the screening conditions, the target sound segment is screened from the one or more sound segments, the confidence of the target sound segment is greater than or equal to a first preset confidence threshold, and the score of the type label of the target sound segment is greater than a first preset score threshold; the confidence is used to indicate the noise situation of the sound segment; the type label is used to indicate the sound type corresponding to the sound included in the sound segment, and the score of the type label is used to indicate the importance of the type label.
2. The method according to claim 1, characterized in that The screening condition may further include one or more of the following: the distance between the sound clips, and a threshold value of the number of sound clips that can be retained.
3. The method according to claim 2, characterized in that Before filtering the target sound segment from the one or more sound segments according to the filtering condition, the method further includes: Obtaining type labels of the one or more sound segments output by the sound event detection model; Determining a score of each of the one or more sound clips according to the type tags of the one or more sound clips; The target sound clips are a first number of sound clips ranked first in terms of scores, and the first number is less than or equal to a threshold number of retainable sound clips.
4. The method according to claim 2, characterized in that: The number of the target sound segments is less than or equal to a threshold number of sound segments that can be retained, and the threshold number of sound segments that can be retained corresponds to the duration of the video to be matched with music.
5. The method according to claim 2, characterized in that: The step of filtering the target sound segment from the one or more sound segments according to the filtering condition includes: According to the screening condition, the one or more sound segments are divided into a reserved sound group and a candidate sound group respectively; wherein the reserved sound group includes a second number of reserved segments, the candidate segments included in the candidate sound group are sound segments other than the reserved segments in the one or more sound segments, the second number is less than or equal to a threshold value of the number of reservable sound segments, and the first comprehensive score of the reserved segment is greater than the second comprehensive score of the candidate segment; Obtaining the start and end positions of the retained segment and the candidate segment output by the sound event detection model; According to the start and end positions and the candidate sound group, the retained segments in the retained sound group are screened and / or replaced, the last retained segment in the retained sound group is the target sound segment, and the distance between the target sound segments is greater than or equal to a preset distance threshold.
6. The method according to claim 5, characterized in that The step of screening and / or replacing the reserved segments in the reserved sound group according to the start and end positions and the candidate sound group includes: determining, according to a first start and end position of a first reserved segment in the reserved sound group and a second start and end position of a second reserved segment in the reserved sound group, whether a distance between the first reserved segment and the second reserved segment is less than a preset distance threshold; When the distance between the first reserved segment and the second reserved segment is less than the preset distance threshold, deleting the first reserved segment and / or the second reserved segment; When the distance between the first reserved segment and the second reserved segment is greater than or equal to the preset distance threshold, the first reserved segment and the second reserved segment are determined to be the target sound segments.
7. The method according to claim 6, characterized in that In a case where the distance between the first retained segment and the second retained segment is less than the preset distance threshold, the method further includes: A third number of candidate segments with higher comprehensive scores are selected from the candidate sound group as first candidate segments to be supplemented, wherein the third number is less than or equal to the number of retained segments deleted from the retained sound group, and the comprehensive scores of the candidate segments to be supplemented are greater than or equal to a second score threshold; Determining whether the distance between the first candidate segment to be supplemented and the reserved segment in the reserved sound group is less than the preset distance threshold; When the distance between the first candidate segment to be supplemented and the reserved segment in the reserved sound group is less than the preset distance threshold, reselecting a second candidate segment to be supplemented in the candidate sound group; When the distance between the first candidate segment to be supplemented and the reserved segment in the reserved sound group is greater than or equal to the preset distance threshold, the first candidate segment to be supplemented is added to the reserved sound group.
8. The method according to claim 1 or 2, characterized in that: The step of fusing the target sound clip and the background sound track to generate a fused soundtrack includes: Obtaining a playback position of the target sound segment in the original sound track; the playback position is used to indicate a time period during which the target sound segment is played in the original sound track; Determine a corresponding splicing position in the background sound track based on the playing position; the splicing position is used to indicate a time period in the background sound track for playing the target sound segment; The target sound segment is spliced to the corresponding splicing position in the background sound track.
9. The method according to claim 8, characterized in that The method further comprises: The volume corresponding to the splicing position in the background audio track is reduced to a first preset volume.
10. The method according to claim 8, characterized in that The method further comprises: The volume of the target sound segment is increased to a second preset volume within a preset start time period of the splicing position, and the volume of the target sound segment is decreased to a third preset volume within a preset end time period of the splicing position.
11. The method according to claim 1 or 2, characterized in that: Before obtaining the original soundtrack of the video to be matched with music, the method further includes: In response to a user operation, determining a video material selected by the user, wherein the video material includes one or more videos and / or one or more pictures; According to the order in which the user selects the video materials, the one or more videos and / or one or more pictures are spliced together to generate a video to be matched with music.
12. The method according to claim 11, characterized in that The original soundtrack of the video to be matched with music includes the soundtrack of the one or more videos before splicing, and / or the soundtrack matched to the one or more pictures according to preset rules.
13. The method according to claim 1 or 2, characterized in that: The background audio track has the same duration as the original audio track.
14. An electronic device, characterized in that: The electronic device includes a display screen, a memory and one or more processors; the display screen, the memory and the processor are coupled; the display screen is used to display an image generated by the processor, and the memory is used to store computer program code, and the computer program code includes computer instructions; when the processor executes the computer instructions, the electronic device executes the method described in any one of claims 1-13.
15. A computer-readable storage medium, characterized in that: The method comprises computer instructions, which, when executed on an electronic device, cause the electronic device to execute the method as claimed in any one of claims 1 to 13.
Citation Information
Patent Citations
Audio processing method and device, electronic equipment and storage medium
CN112637632A
Audio identification method and device and computer readable storage medium
CN113761269A
Video data processing method and device, electronic equipment and computer storage medium
CN113992970A
Video editing method and device, computing equipment and storage medium
CN114339451A
Event identification method and device, electronic equipment and storage medium
CN115665504A
