Audio processing method and device, equipment and storage medium
Through the capture and splicing of audio data streams played by the terminal, the pitch data is directly calculated, which solves the complex problem of obtaining pitch files in the existing technology and realizes efficient pitch file generation.
Patent Information
- Application Number
- CN202310169444.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-23
- Publication Date
- 2024-08-23
AI Technical Summary
The operation of obtaining the pitch file in the existing technology is too complicated, and the audio file needs to be downloaded and uploaded before the pitch analysis can be performed, resulting in cumbersome steps.
Capture at least two pieces of data through the data stream of the audio played by the terminal, splice it to form the built-in audio, and calculate the pitch data based on the fundamental frequency data of the built-in audio to achieve automatic acquisition of pitch files.
It simplifies the steps of obtaining pitch files, improves the efficiency of generating pitch files, reduces the complexity of operations, and can automatically generate pitch files without uploading original audio files.
Smart Images

Figure CN118538241A
Abstract
Description
Technical Field
[0001] The present application relates to the field of audio processing, and in particular to an audio processing method, apparatus, device and storage medium. Background Art
[0002] Pitch is one of the basic characteristics of sound, which refers to the various sounds of different pitches, that is, the height of the sound.
[0003] In the related art, the user needs to obtain the audio file first before being able to perform pitch analysis on the audio file and then obtain the pitch file of the audio file. For example, when a player customizes a pitch game, the player needs to download the audio file first, and then upload the audio file to the pitch game, so that the pitch game can analyze the pitch of the audio file and then generate the corresponding pitch game. For example, a karaoke game analyzes the audio file uploaded by the player to obtain the corresponding pitch file, generates a pitch line (pitch animation effect) based on the pitch file, and scores the player's singing based on the pitch line.
[0004] The operation of obtaining the pitch file using the method in the related art is too complicated. Summary of the invention
[0005] The embodiments of the present application provide an audio processing method, device, equipment and storage medium, which can improve the efficiency of generating pitch files. The technical solution is as follows.
[0006] According to one aspect of the present application, there is provided an audio processing method, the method being executed by a terminal, the method comprising:
[0007] splicing at least two pieces of data to obtain internally recorded audio; the at least two pieces of data are captured from a data stream required for the audio played by the terminal;
[0008] Based on the fundamental frequency data of the internally recorded audio, the pitch data of the internally recorded audio is calculated, and the pitch data includes the pitch of the internally recorded audio at at least one time point or time period.
[0009] According to another aspect of the present application, there is provided an audio processing device, the device comprising:
[0010] A splicing module, used for splicing at least two pieces of data to obtain internally recorded audio; the at least two pieces of data are captured from a data stream required for the audio played by the terminal;
[0011] A pitch module is used to calculate the pitch data of the internally recorded audio based on the fundamental frequency data of the internally recorded audio, and the pitch data includes the pitch of the internally recorded audio at at least one time point or time period.
[0012] According to another aspect of the present application, a computer device is provided, comprising: a processor and a memory, wherein the memory stores at least one instruction, at least one program, a code set or an instruction set, and the at least one instruction, the at least one program, the code set or the instruction set is loaded and executed by the processor to implement the audio processing method described above.
[0013] According to another aspect of the present application, a computer-readable storage medium is provided, wherein the storage medium stores at least one instruction, at least one program, a code set or an instruction set, and the at least one instruction, the at least one program, the code set or the instruction set is loaded and executed by a processor to implement the audio processing method described above.
[0014] According to another aspect of the embodiments of the present disclosure, a computer program product or a computer program is provided, the computer program product or the computer program including computer instructions, the computer instructions being stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the audio processing method provided in the above optional implementation.
[0015] The beneficial effects brought by the technical solution provided by the embodiment of the present application include at least:
[0016] By capturing at least two segments of data from the data stream of the audio played by the terminal, the audio data of the audio played by the terminal is directly obtained, and then the at least two segments of data are spliced together to obtain the complete internally recorded audio. Then, the pitch analysis of the internally recorded audio is performed to automatically obtain the pitch data of the internally recorded audio. This method does not require uploading the original audio file of the audio. The terminal can automatically obtain the audio file being played and generate the audio file, and perform pitch analysis on the audio file, thereby reducing the operation steps of obtaining the pitch file and improving the efficiency of obtaining the pitch file. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0018] Figure 1 is a block diagram of a computer device provided by an exemplary embodiment of the present application;
[0019] Figure 2 is a method flow chart of an audio processing method provided by another exemplary embodiment of the present application;
[0020] Figure 3 is a method flow chart of an audio processing method provided by another exemplary embodiment of the present application;
[0021] Figure 4 is a method flow chart of an audio processing method provided by another exemplary embodiment of the present application;
[0022] Figure 5 is a method flow chart of an audio processing method provided by another exemplary embodiment of the present application;
[0023] Figure 6 is a schematic diagram of an audio processing method provided by another exemplary embodiment of the present application;
[0024] Figure 7 is a method flow chart of an audio processing method provided by another exemplary embodiment of the present application;
[0025] Figure 8 is a method flow chart of an audio processing method provided by another exemplary embodiment of the present application;
[0026] Fig. 9 is a method flow chart of an audio processing method provided by another exemplary embodiment of the present application;
[0027] Fig.10 is a schematic diagram of an audio processing method provided by another exemplary embodiment of the present application;
[0028] Fig.11 is a schematic diagram of an audio processing method provided by another exemplary embodiment of the present application;
[0029] Fig.12 is a schematic diagram of an audio processing method provided by another exemplary embodiment of the present application;
[0030] Fig.13 is a schematic diagram of an audio processing method provided by another exemplary embodiment of the present application;
[0031] Fig.14 is a schematic diagram of an audio processing method provided by another exemplary embodiment of the present application;
[0032] Fig.15 is a method flow chart of an audio processing method provided by another exemplary embodiment of the present application;
[0033] Fig.16 is a block diagram of an audio processing device provided by another exemplary embodiment of the present application;
[0034] Fig.17 is a structural diagram of a server provided by another exemplary embodiment of the present application;
[0035] Fig.18 is a block diagram of a terminal provided by another exemplary embodiment of the present application. DETAILED DESCRIPTION
[0036] In order to make the objectives, technical solutions and advantages of the present application clearer, the implementation methods of the present application will be further described in detail below in conjunction with the accompanying drawings.
[0037] Figure 1 A schematic diagram of a computer device 101 provided by an exemplary embodiment of the present application is shown. The computer device 101 may be a terminal or a server.
[0038] The terminal may include at least one of a digital camera, a smart phone, a laptop computer, a desktop computer, a tablet computer, an intelligent speaker, an intelligent robot, and an intelligent wearable device. Optionally, the terminal may also be a device with an audio system, such as MP3 (Moving Picture Experts Group Audio Layer III), MP4 (Moving Picture Experts Group 4), a speaker, an intelligent speaker, a vehicle-mounted computer, a headset, a smart home device, etc.
[0039] Exemplarily, an operating system runs on the terminal, and the operating system may be an Android operating system.
[0040] The operating system provides an audio visualization interface, which has the ability to capture part of the data in the data stream played by the terminal. The audio visualization interface can perform an audio visualization task based on the captured part of the data.
[0041] Alternatively, a plug-in or software may be run on the terminal, and the plug-in or software has the ability to capture part of the data in the data stream played by the terminal. Optionally, the operating system may be a derivative operating system developed based on the Android operating system. Of course, the operating system may also be a Windows operating system, an iOS operating system, or other operating systems. Of course, it is not limited to this.
[0042] In an optional implementation, the audio processing method provided by the present application can be applied to an application with an audio processing function, which can be: a music player, a video player, a short video player, an audio editor, a video editor, an audio recording program, a video recording program, a social program, a life service program, a shopping program, a live broadcast program, a forum program, an information program, a life program, an office program, etc. Optionally, a client of the application is installed on the terminal.
[0043] Exemplarily, an audio processing program is stored on the terminal, and when the client needs to use the audio processing function provided by the embodiment of the present application, the client can run the audio processing program to complete the audio processing. Exemplarily, the audio processing process can be completed by the terminal, or by the terminal and the server together.
[0044] The terminal and the server are connected to each other via a wired or wireless network.
[0045] The terminal includes a first memory and a first processor. An audio processing program is stored in the first memory; the audio processing program is called and executed by the first processor to implement the audio processing method provided in the present application. The first memory may include but is not limited to the following: Random Access Memory (RAM), Read Only Memory (ROM), Programmable Read-Only Memory (PROM), Erasable Programmable Read-Only Memory (EPROM), and Electric Erasable Programmable Read-Only Memory (EEPROM).
[0046] The first processor may be composed of one or more integrated circuit chips. Optionally, the first processor may be a general-purpose processor, such as a central processing unit (CPU) or a network processor (NP). Optionally, the first processor may implement the audio processing method provided in the present application by running a program or code.
[0047] The server includes a second memory and a second processor. The second memory stores an audio processing program; the audio internal recording algorithm is called by the second processor to implement the audio processing method provided in the present application. Optionally, the second memory may include but is not limited to the following: RAM, ROM, PROM, EPROM, EEPROM. Optionally, the second processor may be a general-purpose processor, such as a CPU or NP.
[0048] Figure 2 A flowchart of an audio processing method provided by an exemplary embodiment of the present application is shown. The method can be executed by a terminal. The method includes the following steps.
[0049] Step 210, splicing at least two segments of data to obtain internally recorded audio; the at least two segments of data are captured from the data stream required for the audio played by the terminal.
[0050] Exemplarily, the embodiment of the present application can be executed by a first application on the terminal, and the first application has an audio internal recording and audio processing function. The first application can be an audio recording program, a video recording program, an audio processing program, a video processing program, a live broadcast application, a music game program, an audio analysis program, a social application, and at least one of a shopping application. Using the audio processing method provided in the embodiment of the present application, the audio data played by the application (including the first application and other applications except the first application) can be obtained by audio internal recording, so as to facilitate the subsequent processing of the audio data.
[0051] Exemplarily, the method of collecting and splicing data will be described in subsequent embodiments.
[0052] Step 220, based on the fundamental frequency data of the internally recorded audio, calculate the pitch data of the internally recorded audio, the pitch data including the pitch of the internally recorded audio at at least one time point or time period.
[0053] Exemplarily, the terminal can capture data from the data stream of the played audio, splice the captured data to generate the internally recorded audio, and perform fundamental frequency analysis on the internally recorded audio to obtain fundamental frequency data of the internally recorded audio, wherein the fundamental frequency data includes the fundamental frequency in at least one time period. According to the calculation formula of the fundamental frequency and the pitch, the pitch can be calculated to obtain the pitch data, and the pitch data includes the pitch in at least one time period or at least one time point.
[0054] Among them, the fundamental frequency is also called the baseband. In sound, the fundamental frequency refers to the frequency of the fundamental tone in a complex tone. Among the several tones that make up a complex tone, the fundamental tone has the lowest frequency and the greatest intensity. The height of the fundamental frequency determines the height of a tone.
[0055] For example, the pitch data can be used in a variety of application scenarios. For example, a pitch line can be generated based on the pitch data, and the pitch line can be displayed in a singing application to assist the user in singing. Alternatively, the pitch data can be used to generate a simple musical notation. Alternatively, the pitch data can be used to create a pitch animation effect.
[0056] In summary, the method provided in this embodiment directly obtains the audio data of the audio played by the terminal by capturing at least two segments of data from the data stream of the audio played by the terminal, and then splices the at least two segments of data together to obtain the complete internally recorded audio. Then, the internally recorded audio is subjected to pitch analysis to automatically obtain the pitch data of the internally recorded audio. This method does not require uploading the original audio file of the audio. The terminal can automatically obtain the audio being played to generate an audio file, and perform pitch analysis on the audio file, thereby reducing the operation steps for obtaining the pitch file and improving the efficiency of obtaining the pitch file.
[0057] Figure 2A flowchart of an audio processing method provided by an exemplary embodiment of the present application is shown. The method can be executed by a terminal. The method includes the following steps.
[0058] Step 210, splicing at least two segments of data to obtain internally recorded audio; the at least two segments of data are captured from the data stream required for the audio played by the terminal.
[0059] Exemplarily, the terminal splices at least two pieces of data to obtain internally recorded audio. The terminal has audio internal recording and audio processing functions. For example, the terminal can be at least one of a mobile phone, a computer, a tablet computer, a smart speaker, and a smart wearable device. Using the audio processing method provided in the embodiment of the present application, the audio data played by the terminal can be obtained through audio internal recording, which is convenient for performing subsequent processing of the audio data.
[0060] Exemplarily, the method of collecting and splicing data will be described in subsequent embodiments.
[0061] Step 220, based on the fundamental frequency data of the internally recorded audio, calculate the pitch data of the internally recorded audio, the pitch data including the pitch of the internally recorded audio at at least one time point or time period.
[0062] Exemplarily, the terminal can capture data from the data stream of the played audio, splice the captured data to generate the internally recorded audio, and perform fundamental frequency analysis on the internally recorded audio to obtain fundamental frequency data of the internally recorded audio, wherein the fundamental frequency data includes the fundamental frequency in at least one time period. According to the calculation formula of the fundamental frequency and the pitch, the pitch can be calculated to obtain the pitch data, and the pitch data includes the pitch in at least one time period or at least one time point.
[0063] For example, the pitch data can be used in a variety of application scenarios. For example, a pitch line can be generated based on the pitch data, and the pitch line can be displayed in a singing application to assist the user in singing. Alternatively, the pitch data can be used to generate a simple musical notation. Alternatively, the pitch data can be used to create a pitch animation effect.
[0064] In summary, the method provided in this embodiment directly obtains the audio data of the audio played by the terminal by capturing at least two segments of data from the data stream of the audio played by the terminal, and then splices the at least two segments of data together to obtain the complete internally recorded audio. Then, the internally recorded audio is subjected to pitch analysis to automatically obtain the pitch data of the internally recorded audio. This method does not require uploading the original audio file of the audio. The terminal can automatically obtain the audio being played to generate an audio file, and perform pitch analysis on the audio file, thereby reducing the operation steps for obtaining the pitch file and improving the efficiency of obtaining the pitch file.
[0065] Exemplarily, an exemplary embodiment of fundamental frequency analysis and pitch calculation is given.
[0066] Figure 3 A flowchart of an audio processing method provided by an exemplary embodiment of the present application is shown. The method can be executed by a terminal. Figure 2 In the illustrated embodiment, step 220 includes steps 221 to 224 , and step 220 may further include step 230 .
[0067] Step 210, splicing at least two segments of data to obtain internally recorded audio; the at least two segments of data are captured from the data stream required for the audio played by the terminal.
[0068] Exemplarily, when playing audio, the terminal can capture at least two segments of data in the data stream required by the terminal to play the audio; identify the data duplication portion of at least two segments of data; and splice at least two segments of data according to the location of the data duplication portion to obtain the internally recorded audio.
[0069] Exemplarily, the terminal can call an audio visualization interface to capture data in the data stream. The audio visualization interface is an API provided by the operating system, and the audio visualization interface is used to collect audio data currently played in the audio playback circuit of the terminal, and the audio data is a digital audio signal.
[0070] Exemplarily, the audio visualization interface may be bound to a specified application to collect the audio played by the specified application.
[0071] For example, the audio visualization interface can be a Visualizer interface. Set MediaPlayer (player) or AudioTrack (player) as the data source of the Visualizer. In the callback function of the player, use the setEnabled method of the Visualizer to enable the visualization function. Then, the data played by the MediaPlayer (player) or AudioTrack (player) can be collected through the Visualizer interface, and the time information corresponding to the data (playing time or start playing time) can be obtained.
[0072] Step 221, performing frame processing on the internally recorded audio to obtain at least two frames of framed audio.
[0073] For example, the internally recorded audio may be processed by dividing the frame into multiple frames according to the preset duration of each frame, so as to obtain multiple frames of divided audio. For example, if the internally recorded audio is processed by dividing the frame into multiple frames according to 10 ms per frame, if the duration of the internally recorded audio is 60 seconds, a total of 6000 frames of divided audio may be obtained.
[0074] Step 222: Perform fundamental frequency analysis on each frame of at least two frames of framed audio to obtain the fundamental frequency of each frame of framed audio.
[0075] Exemplarily, the fundamental frequency of each frame of the framed audio is calculated respectively.
[0076] Exemplarily, the fundamental frequency of each frame of the framed audio can be extracted by using a time domain analysis method. The time domain signal of the framed audio is used as input, and the minimum positive period of the time domain signal waveform is analyzed. The fundamental frequency is the inverse of the minimum positive period.
[0077] For example, methods such as auto-correlation function (ACF), average magnitude difference function (AMDF), and difference function are used to analyze the fundamental frequency of the framed audio.
[0078] Exemplarily, the formula for the autocorrelation function is:
[0079]
[0080] Where t is the period, W is the total number of sampling points in the framed audio, and x i is an audio signal of length t, x i+τ is an audio signal of length t+τ (i.e., from x i The audio signal at the position after the position is shifted by τ; or with τ as the period, x i The next cycle of the audio signal), when r i When (τ) takes the maximum value, τ is the minimum positive period of the frame audio, and the fundamental frequency of the frame audio is the reciprocal of the minimum positive period.
[0081] Exemplarily, the formula of the average amplitude difference function is:
[0082]
[0083] Where t is the period, W is the total number of sampling points in the framed audio, and x i is an audio signal of length t, x i+τ is an audio signal of length t (i.e., from x i The audio signal at the position after the position is shifted by τ; or with τ as the period, x i The next cycle of the audio signal), when D i When (τ) takes the minimum value, τ is the minimum positive period of the frame audio, and the fundamental frequency of the frame audio is the reciprocal of the minimum positive period.
[0084] Exemplarily, the formula of the difference function is:
[0085]
[0086] Where t is the period, W is the total number of sampling points in the framed audio, and xi is an audio signal of length t, x i+τ is an audio signal of length t (i.e., from x i The audio signal at the position after the position is shifted by τ; or with τ as the period, x i The next cycle of the audio signal), when d i When (τ) takes the minimum value, τ is the minimum positive period of the frame audio, and the fundamental frequency of the frame audio is the reciprocal of the minimum positive period.
[0087] Exemplarily, the frequency domain analysis method can also be used to extract the fundamental frequency of each frame of the framed audio. The framed audio is subjected to Fourier transform to obtain a spectrum, and the greatest common divisor of the peak point frequencies in the spectrum is analyzed, and the fundamental frequency is the greatest common divisor.
[0088] For example, for each candidate frequency f, a function is designed to express the possibility that f is the fundamental frequency, which is called the salience function; the frequency f that maximizes the salience function is the fundamental frequency. For example, the harmonic summation method is used:
[0089]
[0090] Among them, X(kf) is the amplitude of the spectrum of the framed audio at kf. Since there are peaks at integer multiples of the fundamental frequency f0 in the spectrum, the sum of the values of the spectrum at each multiple of f can be used to represent the significance H(f). The frequency f when the significance H(f) takes the maximum value is the fundamental frequency.
[0091] Exemplarily, the terminal may adopt any of the above methods to perform fundamental frequency analysis on each frame of at least two frames of framed audio to obtain the fundamental frequency of each frame of framed audio.
[0092] In an optional embodiment, taking the i-th frame of framed audio as an example, Fourier transform is performed on the i-th frame of framed audio in at least two frames of framed audio to obtain frequency domain data (spectrum), where i is a positive integer; the peak point frequency corresponding to the peak point in the frequency domain data is obtained; and the average value of the peak point frequency is determined as the fundamental frequency of the i-th frame of framed audio. Let i be i+1 and repeat the above steps to obtain the fundamental frequency of each frame of framed audio in the at least two frames of framed audio.
[0093] It should be noted that there may be at least one peak point in the frequency domain data. When there is only one peak point, the frequency corresponding to the peak point is determined as the fundamental frequency. When there are multiple peak points, the average value of multiple frequencies corresponding to multiple peak points is determined as the fundamental frequency.
[0094] Exemplarily, in order to more accurately extract the peak point of the frequency domain data, the frequency domain data can be fitted. Fourier transform is performed on the i-th frame of the at least two frames of the framed audio to obtain frequency domain data; the frequency domain data is fitted using an adaptive window spectrum peak fitting algorithm or a Gaussian fitting method to obtain fitted frequency domain data; the peak point frequency corresponding to the peak point in the fitted frequency domain data is obtained; and the average value of the peak point frequency is determined as the fundamental frequency of the i-th frame of the framed audio.
[0095] In another optional embodiment, the fundamental frequency of the human voice in the internally recorded audio can also be extracted. Taking the i-th frame of framed audio as an example, the i-th frame of framed audio in at least two frames of framed audio is subjected to Fourier transform to obtain frequency domain data (spectrum), where i is a positive integer; the frequency domain data within the frequency range of the fundamental frequency of the human voice in the frequency domain data is intercepted to obtain the human voice frequency domain data, wherein the fundamental frequency of the human voice can be a preset value, for example, the frequency range of the fundamental frequency of the human voice is 50Hz to 500Hz; the peak point frequency corresponding to the peak point in the human voice frequency domain data is obtained; and the average value of the peak point frequency is determined as the fundamental frequency of the i-th frame of framed audio.
[0096] In another optional embodiment, in order to improve the sensitivity of the fundamental frequency analysis algorithm, the frequency domain data can also be normalized. Taking the i-th frame of framed audio as an example, the i-th frame of framed audio in at least two frames of framed audio is Fourier transformed to obtain frequency domain data (spectrum), where i is a positive integer; the frequency domain data is normalized to obtain normalized frequency domain data; and the fundamental frequency in the normalized frequency domain data is obtained using the above frequency domain analysis method.
[0097] Exemplarily, the above methods can be combined arbitrarily to obtain new methods, which will not be described in detail here. The above method is used to calculate the fundamental frequency of each frame of the sub-frame audio, and the fundamental frequency of each frame of the sub-frame audio constitutes the fundamental frequency data of the internally recorded audio.
[0098] In another optional embodiment, when a frame of framed audio corresponds to multiple peak points, the fundamental frequency can also be filtered from the frequencies corresponding to the multiple peak points according to the filtering condition. Taking the i-th frame of framed audio as an example, the i-th frame of framed audio in at least two frames of framed audio is subjected to Fourier transform to obtain frequency domain data (spectrum), where i is a positive integer; at least one peak point of the frequency domain data is obtained, and the frequency corresponding to the at least one peak point is determined as a candidate fundamental frequency; and the fundamental frequency is filtered from the candidate fundamental frequencies according to the filtering condition.
[0099] The screening condition may be at least one of a frequency range and a frequency change trend.
[0100] Exemplarily, the frequency range may be a preset fundamental frequency range, for example, the frequency range is 50 Hz to 500 Hz.
[0101] Exemplarily, the frequency change trend is to select the fundamental frequency of the i-th frame of audio from the candidate fundamental frequencies according to the fundamental frequencies corresponding to the preceding and following frames of the i-th frame of audio. For example, each candidate fundamental frequency of the i-th frame of audio is subtracted from the fundamental frequency of the i-th frame of audio, and the candidate fundamental frequency with the smallest difference is determined as the fundamental frequency of the i-th frame of audio.
[0102] Step 223: Based on the fundamental frequency of each frame of the at least two frames of the framed audio, the pitch of each frame of the at least two frames of the framed audio is calculated.
[0103] Exemplarily, the pitch is calculated based on the fundamental frequency using the following formula:
[0104]
[0105] Among them, midi number is the pitch and f0 is the fundamental frequency.
[0106] Step 224, generating pitch data of the internally recorded audio based on the pitch of each frame of the at least two frames of the framed audio.
[0107] Exemplarily, a smoothing algorithm may be used to perform a weighted sliding average on the pitch of each frame of at least two frames of framed audio to obtain a smoothed pitch, and pitch data of the internally recorded audio may be generated based on the smoothed pitch of each frame of at least two frames of framed audio.
[0108] For example, the obtained pitch data may be as shown in Table 1.
[0109] Table 1
[0110]
[0111]
[0112] Step 230: Based on the pitch data, display the pitch animation effect of the internally recorded audio, where the pitch animation effect is used to indicate the change of pitch over time.
[0113] Pitch refers to the various sounds of different heights, that is, the height of the sound, one of the basic characteristics of the sound. The height of the sound is determined by the vibration frequency (fundamental frequency), and the pitch and fundamental frequency are positively correlated: the higher the fundamental frequency, the "higher" the sound, and vice versa.
[0114] Various animation effects can be created based on the audio pitch data. For example, a rhythm effect can be created based on the pitch data, which can show the pitch changes of the internally recorded audio. In video production, various animation effects can be generated based on the pitch data, so that the video picture changes show the effect of following the rhythm of the internally recorded audio.
[0115] Alternatively, a pitch line is created based on the pitch data, and the pitch line can be used to indicate pitch or for pitch correction. For example, in a singing application, a pitch line is displayed to indicate the pitch of the music and its changes to the user, so that the user can sing according to the pitch line, and the user's singing can be scored based on the pitch line.
[0116] Alternatively, a simplified musical notation can be produced based on the pitch data. The corresponding note name is determined based on the pitch at each time, the note duration is determined based on the duration of the same pitch, and then the simplified musical notation is generated based on the note name and the note duration.
[0117] For example, the pitch data includes "72 72 72 72 74 74 76 76 77 79 81 83", where the duration of each pitch data is 1s. The note name corresponding to the pitch data is "do do do do re re mi mi fa sol lasi" or "CCCCDDEEFGAB". The duration of "do" is 4s, the duration of "re" and "mi" is 2s, and the duration of "fa", "sol", "la" and "si" is 1s. In the case of 1 minute and 60 beats (i.e. 1 second 1 beat), the obtained simplified notation includes "whole note do half note re half note mi quarter note fa quarter note sol quarter note la quarter note si". In the case of 1 minute and 120 beats (i.e. 1 second 2 beats), the obtained simplified notation includes "whole note do whole note do whole note re whole note mi half note fa half note sol half note la half note si".
[0118] In summary, the pitch animation effect may include at least one of the following: a rhythmic effect generated based on pitch data, a pitch line generated based on pitch data, and a simplified musical notation generated based on pitch data.
[0119] Exemplarily, step 210, step 220, and step 230 may be executed by the same application program or by different application programs.
[0120] For example, the first application collects data and splices it to obtain internally recorded audio, and the first application sends the internally recorded audio to the second application; the second application receives the internally recorded audio, performs fundamental frequency analysis and pitch calculation on the internally recorded audio, and obtains the pitch data of the internally recorded audio; the second application sends the pitch data to the third application, and the third application generates and displays a pitch animation effect based on the pitch data.
[0121] Alternatively, an audio processing program may collect data and splice it to obtain internally recorded audio, and perform fundamental frequency analysis and pitch calculation on the internally recorded audio to obtain pitch data; the audio processing program may send the internally recorded audio and pitch data to a live broadcast application / game application / video production application, and the live broadcast application / game application / video production application may generate and display pitch animation effects based on the pitch data.
[0122] Alternatively, the live broadcast application / game application / video production application collects and splices data to obtain internally recorded audio, performs fundamental frequency analysis and pitch calculation on the internally recorded audio to obtain pitch data, and generates and displays pitch animation effects based on the pitch data.
[0123] In summary, the method provided in this embodiment provides a method for fundamental frequency analysis and pitch calculation. Different fundamental frequency analysis and pitch calculation methods can be used for different pitch acquisition requirements. For example, the pitch of the human voice in the internally recorded audio can be extracted, or the fundamental frequency can be extracted more accurately by using screening conditions, or the fundamental frequency can be extracted more quickly by using average value calculation. This method does not require uploading the original audio file of the audio. The terminal can automatically obtain the audio being played to generate an audio file, perform pitch analysis on the audio file, generate a pitch animation effect, reduce the operating steps for obtaining the pitch file, and improve the efficiency of obtaining the pitch file.
[0124] Exemplarily, an exemplary embodiment of applying the audio processing method in a screen recording application is given.
[0125] Figure 4 A flowchart of an audio processing method provided by an exemplary embodiment of the present application is shown. The method can be executed by a terminal. Figure 2 In the illustrated embodiment, step 200 is included before step 210 , and step 240 and step 250 are included after step 220 .
[0126] Step 200, in response to the screen recording start operation, execute the following steps simultaneously: record the screen to obtain image data, the image data includes at least one frame of the screen recorded in time sequence; call the audio visualization interface to capture at least two segments of data in the data stream required by the terminal to play audio.
[0127] Alternatively, in response to the screen recording start operation, the following steps are performed simultaneously: recording the screen to obtain image data, the image data including at least one frame of the screen recorded in chronological order; turning on the microphone to record ambient sound and generate microphone audio; calling the audio visualization interface to capture at least two segments of data in the data stream required by the terminal to play the audio.
[0128] Exemplarily, an application supporting a screen recording function is running on the terminal, and the method is executed by the application supporting the screen recording function.
[0129] Exemplarily, a screen recording start control is displayed on the application. In response to the screen recording start operation that triggers the Luping start control, screen recording setting information is obtained, and the screen recording setting information includes recording settings. The recording settings can be at least one of system recording, microphone recording, or system recording and microphone recording.
[0130] When the recording is set to system internal recording, the terminal records the screen image to obtain image data; and repeatedly calls the audio visualization interface according to the preset capture frequency to obtain at least two segments of internally recorded data.
[0131] When the recording is set to system internal recording and microphone recording, the terminal records the screen to obtain image data; and, turns on the microphone to record ambient sound to generate microphone audio; and, repeatedly calls the audio visualization interface at a preset capture frequency to obtain at least two segments of internally recorded data.
[0132] Exemplarily, recording of internal audio and recording of microphone audio are two recording methods, and the two recording methods are performed simultaneously. After the recording is completed, the two recording methods respectively obtain two audio files.
[0133] Step 210, splicing at least two segments of data to obtain internally recorded audio; the at least two segments of data are captured from the data stream required for the audio played by the terminal.
[0134] Step 220, based on the fundamental frequency data of the internally recorded audio, calculate the pitch data of the internally recorded audio, the pitch data including the pitch of the internally recorded audio at at least one time point or time period.
[0135] For example, after collecting a segment of data, the terminal can splice the data in real time, and perform fundamental frequency analysis and pitch calculation on the spliced audio to obtain the corresponding pitch in real time. The terminal can also splice all the data after the data collection is completed (screen recording is completed), and perform fundamental frequency analysis and pitch calculation on the internally recorded audio.
[0136] Step 240, display the screen recording editing interface, the screen recording editing interface includes a preview area and a pitch effect adding control, the preview area is used to preview the screen recording file; the screen recording file is generated based on the image data and the internally recorded audio.
[0137] Optionally, the screen recording file may also be generated based on image data, microphone audio, and internally recorded audio.
[0138] Exemplarily, after the screen recording is completed, the terminal generates a pitch animation effect based on the pitch data of the internally recorded audio, and displays an add control for the pitch animation effect on the screen recording preview interface (screen recording editing interface) to facilitate the user to choose whether to add the pitch animation effect to the screen recording.
[0139] Exemplarily, in response to triggering the screen recording end operation of the screen recording end control, a screen recording editing interface (or screen recording preview interface) is displayed, and the screen recording editing interface is used to preview the screen recording file, and / or the screen recording editing interface is used to edit the screen recording file.
[0140] In the screen recording editing interface, users can preview screen recording files, such as playing screen recording files, viewing each screen frame of the screen recording file, and playing the internally recorded audio and / or microphone audio in the screen recording file. In the screen recording editing interface, users can also edit screen recording files, such as editing the screen image, editing the internally recorded audio, and editing the microphone audio. In the screen recording editing interface, you can preview the edited screen recording file in real time.
[0141] Exemplarily, the screen recording editing interface includes a motion effect editing area, and the motion effect editing area can display a pitch motion effect adding control, and the pitch motion effect adding control is used to add a pitch animation effect to the screen image of the screen recording file.
[0142] Exemplarily, the screen recording editing interface may also include a progress bar, which may respond to a trigger operation by the user and display a screen image of the corresponding progress in the screen recording file in the preview area according to the position selected by the trigger operation.
[0143] Exemplarily, when the recording is set to system internal recording, the recording file includes internal recording audio and image data; when the recording is set to system internal recording and microphone recording, the recording file includes image data, microphone audio and internal recording audio.
[0144] Step 250, in response to the operation of triggering the pitch animation effect adding control, a pitch animation effect is added to the image data, wherein the playing progress of the pitch animation effect in the screen recording file is consistent with the playing progress of the internally recorded audio.
[0145] Exemplarily, the pitch animation effect includes at least one pitch image frame, and the duration of the pitch animation effect is the same as the duration of the internally recorded audio, and each pitch image frame in the pitch animation effect corresponds to the playback time. In other words, according to the playback time, each pitch image frame in the pitch animation effect corresponds to each screen frame in the image data.
[0146] Exemplarily, according to the playing time of each pitch image frame of the pitch animation effect, it is added to the corresponding screen image in the image data, so that the pitch animation effect can be seen from the screen image of the image data while the image data is being played.
[0147] Exemplarily, the triggering operation of the pitch animation effect adding control may also indicate an adding position, and the pitch animation effect is added to the adding position indicated by the triggering operation.
[0148] For example, the pitch animation effect may be a pitch line animation effect, and the pitch line animation effect may be added to the screen so that when the screen recording file is played, there is a line animation effect on the screen that changes with the pitch of the internally recorded audio.
[0149] Exemplarily, in response to the save operation, a final screen recording file is generated and saved according to the pitch animation effect, the internally recorded audio, and the image data; or, a final screen recording file is generated and saved according to the pitch animation effect, the internally recorded audio, the microphone audio, and the image data. When the final screen recording file is played, an animation effect that changes with the audio pitch will be displayed on the screen.
[0150] In summary, the method provided in this embodiment can use an audio visualization interface to record the audio in the system in an application with a screen recording function, and after the recording is completed, automatically obtain pitch data based on the internally recorded audio, and generate a pitch animation effect based on the pitch data. After the screen recording is completed, the user can add the animation effect to the screen recording according to the needs, so that the content of the screen recording changes with the audio pitch, enhance the user's perception of the audio, enrich the content of the screen recording, and improve the efficiency and effect of screen recording.
[0151] Exemplarily, an exemplary embodiment of applying the audio processing method in a music game program is given.
[0152] Figure 5 A flowchart of an audio processing method provided by an exemplary embodiment of the present application is shown. The method can be executed by a terminal. The method includes the following steps.
[0153] Step 210, splicing at least two segments of data to obtain internally recorded audio; the at least two segments of data are captured from the data stream required for the audio played by the terminal.
[0154] Exemplarily, the internally recorded audio is audio played by other applications.
[0155] Step 220, based on the fundamental frequency data of the internally recorded audio, calculate the pitch data of the internally recorded audio, the pitch data including the pitch of the internally recorded audio at at least one time point or time period.
[0156] Step 231, automatically generate a music game file based on the pitch data and the internally recorded audio.
[0157] Exemplarily, the pitch line is generated according to the pitch data, and the pitch line is a broken line or a line segment of different heights generated according to the pitch. For example, according to the pitch data "50 70 90 110 50 90 90 90" the following can be generated: Figure 6The height of the pitch line shown corresponds to the pitch. The higher the pitch, the higher the pitch. Users can know the pitch changes of the internally recorded audio by observing the height changes of the pitch line.
[0158] Music game files can be singing files, dancing game files, virtual instrument performance files, etc.
[0159] Exemplarily, after the music game file is run by the music game program, the music game interface is displayed, and the internally recorded audio is played; the music game interface displays a pitch animation effect; the user can enter the game operation in the music game interface to play the game. For example, the singing file can be run by the music game program, and the karaoke interface is displayed. The karaoke interface displays the pitch line generated according to the pitch data, and the internally recorded audio is played. The user can sing with reference to the pitch line in the karaoke interface and record the singing sound. For another example, after the dance game file is run by the music game program, the dance game interface is displayed, and the internally recorded audio is played; the dance game interface can display the pitch animation effect generated according to the pitch data, and the user can control the virtual dancer to dance with the pitch animation effect in the dance game interface. For another example, after the virtual instrument performance file can be run by the music game program, the instrument performance interface is displayed, and the instrument performance interface displays the simple score generated according to the pitch data, and the user can control the instrument to play with reference to the simple score.
[0160] For example, in a dance game program, different keys can be associated with pitch lines of different heights, allowing the user to press the corresponding key by observing the changes in the pitch lines or by listening to the recorded audio.
[0161] For another example, in a virtual musical instrument playing program, a simplified musical notation may be generated based on the pitch data, and then the user may play the musical instrument based on the simplified musical notation.
[0162] Step 232, run the music game file, play the internally recorded audio and pitch animation effects.
[0163] Among them, the playback progress of the pitch animation effect is consistent with the playback progress of the internally recorded audio.
[0164] Exemplarily, the pitch animation effect may be any of the above animation effects. For example, the pitch animation effect may be a pitch line or a rhythm effect. The pitch animation effect is used to guide game operations. Game operations need to correspond to the pitch of the internally recorded audio. Users can observe the pitch animation effect to intuitively know the pitch of the internally recorded audio, and then perform game operations corresponding to the pitch.
[0165] Step 233, receiving a game operation, calculating a matching degree between the game operation and the pitch data, and obtaining a game score, wherein the game operation includes: a first audio recorded through a microphone, and the matching degree includes a similarity between the pitch of the first audio and the pitch data.
[0166] Exemplarily, when the music game file is a singing file, a pitch line can be generated based on the pitch data and displayed in the singing interface. The pitch line can be used to guide the user's pronunciation and improve the user's singing pitch. In addition, the pitch of the user's voice can be analyzed in real time, and the pitch of the user's voice can be compared with the pitch line to obtain the user's game score.
[0167] That is, after running the music game file, the internally recorded audio and pitch line will be played automatically, and the microphone will be turned on for vocal recording. The user can sing the internally recorded audio with reference to the pitch line, the microphone will record the vocal audio, the terminal will analyze the pitch of the vocal audio, and compare the pitch of the vocal audio with the pitch data of the internally recorded audio. The higher the similarity, the higher the game score, and the lower the similarity, the lower the game score. After the internally recorded audio is played, the game settlement interface will be displayed, and the game score will be displayed on the game settlement interface.
[0168] In summary, the method provided in this embodiment allows the music game program to automatically generate a music game file corresponding to the audio data by collecting the audio data played by other applications, obtain the audio data played by other applications by calling the audio visualization interface, and then obtain the pitch data corresponding to the audio data, and then generate a pitch animation effect based on the pitch data to display the pitch animation effect after the music game file is run. This method can quickly generate a corresponding music game file using the audio played by other applications, thereby improving the efficiency of generating music game files.
[0169] Exemplarily, an exemplary embodiment of recognizing subtitles or lyrics based on internally recorded audio is given.
[0170] Figure 7 A flowchart of an audio processing method provided by an exemplary embodiment of the present application is shown. The method can be executed by a terminal. The method includes the following steps.
[0171] Step 210, splicing at least two segments of data to obtain internally recorded audio; the at least two segments of data are captured from the data stream required for the audio played by the terminal.
[0172] Exemplarily, the audio may be played by a second application, and the second application may be a music player or a video player.
[0173] Exemplarily, the method provided in this embodiment is executed by a first application, which may be an audio processing program. The first application uses the method provided in this embodiment to record the audio played by the second application to obtain internally recorded audio. Speech recognition is performed on the internally recorded audio, and a corresponding subtitle display file or lyrics display file is generated based on the recognition result of the speech recognition, so that when the second application lacks subtitles or lyrics, the missing subtitle file or lyrics file is supplemented for the second application.
[0174] Step 231, using Automatic Speech Recognition (ASR) technology to perform speech recognition on the internally recorded audio to obtain a recognition result.
[0175] Exemplarily, the ASR algorithm is called to perform speech recognition on the internally recorded audio to obtain a recognition result. For example, the internally recorded audio is input into the ASR algorithm, the ASR algorithm encodes and extracts features of the internally recorded audio to obtain speech features; the ASR algorithm decodes based on the speech features to obtain a predicted text (recognition result).
[0176] Step 232, generating a subtitle display file or a lyrics display file according to the recognition result.
[0177] Exemplarily, the first application automatically generates a subtitle display file or a lyrics display file according to the recognition result, and sends the subtitle display file or the lyrics display file to the second application. The second application can directly run the subtitle display file or the lyrics display file to display the corresponding subtitles or lyrics when playing the audio.
[0178] In summary, the method provided in this embodiment can automatically generate a corresponding subtitle file or lyrics file based on the recorded audio by means of audio internal recording. When there is no lyrics file of a certain song in the music player program, this method can be used to quickly generate the lyrics file of the song, and the lyrics of the song can be added by running the lyrics file in the music player program. Alternatively, when there is no subtitle file of a certain movie in the video player program, this method can be used to quickly generate the subtitle file, and the corresponding subtitles can be displayed when watching the movie by running the subtitle file in the video player program. This method improves the efficiency of generating subtitle files and lyrics files.
[0179] Exemplarily, an exemplary embodiment of recording audio through an audio visualization interface is provided.
[0180] Figure 8 A flowchart of an audio processing method provided by an exemplary embodiment of the present application is shown. The method can be executed by a terminal. Figure 2 In the illustrated embodiment, step 210 includes steps 211 to 213 .
[0181] Step 211: when playing audio, capture at least two segments of data in the data stream required by the terminal to play the audio.
[0182] Exemplarily, in response to receiving a recording instruction, at least two segments of data in a data stream corresponding to the audio being played by the terminal are captured.
[0183] For example, if the second application of the terminal is playing audio, the second application transmits the data stream of the audio to the audio playback circuit of the terminal. At this time, if the first application receives a recording instruction, the first application can collect data from the data stream. For example, the first application collects a piece of data at a time, and the first application can obtain multiple pieces of data by collecting multiple times.
[0184] The above example only takes the case where only the first application currently plays audio on the terminal. Of course, the terminal may also have multiple applications currently playing audio, and then multiple applications will transmit audio data streams to the audio playback circuit of the terminal. According to the recording settings, the first application can capture data from the data stream of the application specified by the recording settings, and the first application can also capture data from the total data stream, where the total data stream is obtained by superimposing the data streams of multiple applications currently playing.
[0185] Exemplarily, the amount of data captured by the terminal once can be customized. The amount of data captured by the terminal once has a maximum value, for example, the maximum value is 1 kB (kilobytes). The user can set the amount of data to any value less than the maximum value.
[0186] It should be noted that the amount of data captured by the terminal at one time is very small. The longest audio of this amount of data is only 20ms. When playing 20ms of audio data, the user cannot hear any melody and can only perceive noise. Therefore, in the related art, the audio data collected in this way cannot be used to play to the user, but can only be used for visualization processing, that is, for audio visualization. Audio visualization is to generate audio visual images frame by frame based on audio data, for example, to generate the spectral rhythm effect of music. The duration of a frame in an animation is usually 20ms. Therefore, the 20ms data captured by the terminal at one time is just used to generate a frame of audio visual images.
[0187] In the process of implementing the present application, the inventor discovered that through this data capture method, data can be directly captured from the data stream of the audio played by the terminal. The data only contains the audio played inside the terminal and is not mixed with noise outside the terminal. Therefore, the method provided in the embodiment of the present application is based on the data capture capability of the terminal to realize internal audio recording, so that the audio data obtained by internal recording is only the audio played inside the terminal.
[0188] Furthermore, through the audio recording method provided in the embodiment of the present application, the audio played by the terminal can be recorded without the terminal playing the audio externally. Since this recording method directly captures data from the data stream of the audio played by the terminal, the method can capture the data regardless of whether the audio of the data stream is played externally through the speaker. Therefore, even if the user adjusts the volume to 0, or the user listens to the audio played by the terminal with headphones, it will not affect the internal audio recording, and the terminal can record the internally recorded audio.
[0189] Exemplarily, the audio played by the terminal can be any audio, for example, the audio can be at least one of music, article recitation audio, video audio, call audio, application prompt sound, and system prompt sound. Moreover, the audio can be a mixed audio played by multiple applications. As long as it is the audio being played by the terminal, the terminal can capture a segment of the audio data from the audio data stream.
[0190] Exemplarily, since the amount of data captured by the terminal once is limited, for example, the amount of data captured by the terminal once is a first amount of data, and according to the preset sampling rate, the duration of the audio data collected by the first amount of data is a first duration. If the delay is ignored, the terminal starts capturing data at the first time, then at the second time the terminal will obtain a segment of data captured this time, and the duration from the first time to the second time is the first duration, then the segment of data captured by the terminal is the audio data of the audio played by the terminal from the first time to the second time.
[0191] Of course, the above example only captures once by the terminal, and the terminal can initiate multiple captures from the first time to the second time. For example, the terminal can initiate a capture at time 1, a capture at time 2, and a capture at time 3, and time 1 is earlier than time 2, earlier than time 3, and earlier than time 4. The capture initiated at time 1 obtains the first segment of data at time 4, the capture initiated at time 2 obtains the second segment of data at time 5, and the capture initiated at time 3 obtains the third segment of data at time 6. Among them, the duration from time 1 to time 4, time 2 to time 5, and time 3 to time 6 are all the first duration, and the data volume of the first segment of data, the second segment of data, and the third segment of data are all the first data volume. The first segment of data is the audio data of the audio played by the terminal from time 1 to time 3, the second segment of data is the audio data of the audio played by the terminal from time 2 to time 5, and the third segment of data is the audio data of the audio played by the terminal from time 3 to time 6. It can be seen that the audio recorded by the above three segments of data overlaps in time, and the three segments of data also have repeated data parts.
[0192] Exemplarily, the embodiment of the present application can be executed by a first application on the terminal, and the first application has an audio recording function. The first application can be at least one of an audio recording program, a video recording program, an audio processing program, a video processing program, a live broadcast application, a music game file, an audio analysis program, a social application, and a shopping application. Using the audio recording method provided in the embodiment of the present application, the audio data played by the application (including the first application and other applications except the first application) can be obtained by audio recording, so as to facilitate the subsequent processing of the audio data.
[0193] Exemplarily, when the user uses the audio recording function of the first application, the first application can use the method provided in the embodiment of the present application to record the audio. Optionally, in response to the operation of triggering the recording start control, at least two segments of data in the data stream required by the terminal for playing the audio are captured.
[0194] Exemplarily, in response to the operation of triggering the recording start control, a recording authorization interface is displayed, and in response to receiving the authorization operation on the recording authorization interface, at least two segments of data in the data stream required for the terminal to play the audio are captured. And / or, in response to the operation of triggering the recording start control, the first application sends a recording authorization request to at least one application currently playing the audio, and in response to receiving the authorization instructions of all applications in the at least one application, at least two segments of data in the data stream required for the terminal to play the audio are captured.
[0195] Step 212, identifying data duplication portions of at least two segments of data.
[0196] For example, since the terminal captures very little data at a time (the audio duration is very short), if you want to obtain all the data of the audio played by the terminal within a period of time, the terminal needs to capture data multiple times at a high frequency to ensure that the audio data within this period is not missing. However, due to high-frequency capture, the data obtained from two adjacent captures will have data duplication.
[0197] In an optional embodiment, there may be a delay between the end time of a capture by the terminal and the time when the captured data is obtained, and the delay may be inconsistent in each capture, which may cause the terminal to actually obtain the data captured earlier later. For example, the first capture may end at the first time, and the second capture may end at the second time, and the first time is earlier than the second time, that is, the first data captured for the first time is before the second data captured for the second time in terms of timing, but the terminal obtains the second data before the first data. At this time, if each segment of data is spliced according to the time when the terminal obtains each segment of data, splicing errors will obviously occur.
[0198] Based on the above considerations, the method provided in this embodiment determines the order of each segment of data by identifying the repeated parts of at least two segments of data. After deduplication of the repeated data, the data can be spliced in the determined order.
[0199] Exemplarily, the terminal may identify the repeated data portion of at least two segments of data by: sorting the at least two segments of data according to the acquisition time of the at least two segments of data (the time when the terminal obtains the data), using a small segment of data at the head of the later sampled data as a search sample, searching the earlier sampled data for the same portion as the search sample data, and if found, the later sampled data may be spliced with the earlier sampled data, and the splicing position may be the searched repeated data portion. Since the two segments of data have repeated data, the repeated data in the earlier sampled data may be deleted, and then the later sampled data may be spliced according to the splicing position. The repeated data in the later sampled data may also be deleted, and then the remaining portion may be spliced to the end of the earlier sampled data. Among them, the earlier sampled data is the data acquired earlier, and the later sampled data is the data acquired later.
[0200] Step 213, splicing at least two segments of data according to the location of the repeated portion of the data to obtain the internally recorded audio.
[0201] Exemplarily, when the terminal cannot accurately obtain the playback time / sampling time of each data segment, the terminal can determine the time sequence of each data segment and the repeated position of the two data segments (the location of the repeated data segment) based on the repeated data segments in at least two data segments, and the two data segments can be spliced together based on the repeated data segments. In this way, by traversing the repeated data segments in at least two data segments, the at least two data segments can be spliced into a complete data segment, which is the audio data (internal recorded audio) of the audio played by the terminal during the recording time.
[0202] For example, the terminal may splice each acquired data with the previous data in real time. Alternatively, the terminal may splice the acquired at least two segments of data together after recording is completed.
[0203] For example, when the terminal splices data in real time, the terminal can apply the spliced audio data in real time. For example, each time the terminal splices a segment of data, it reports the splicing result to the server. Alternatively, each time the terminal splices a segment of data, it transmits the splicing result to the live broadcast application in real time, thereby realizing the audio played by the synchronous live broadcast terminal.
[0204] Exemplarily, the step of splicing data can be performed by the terminal or by the server. For example, the terminal reports the acquired data to the server, and the server sequentially splices at least two segments of data to obtain the internally recorded audio. Alternatively, the terminal sequentially splices at least two segments of data to obtain the internally recorded audio, and then the terminal can report the internally recorded audio to the server.
[0205] In another optional embodiment, when the terminal obtains a segment of data, it can also obtain the playback time of the segment of data, and the terminal can sequentially splice at least two segments of data according to the start playback time of each segment of data to obtain the internally recorded audio. That is, the terminal splices at least two segments of data according to the time sequence to obtain the internally recorded audio.
[0206] In summary, the method provided in this embodiment directly obtains the audio data of the audio played by the terminal by capturing at least two segments of data from the data of the audio played by the terminal, identifies the order and splicing position of the at least two segments of data according to the repeated parts of the data in the at least two segments of data captured, and then splices the at least two segments of data together to obtain the complete internally recorded audio. The internally recorded audio recorded by this method does not require the terminal to play the audio externally. It only needs the terminal to play the audio to capture the data of the audio played from inside the terminal. The data contains pure audio played by the terminal without external noise. Compared with recording audio with a microphone, this method can record clearer audio played inside the terminal and avoid the influence of external sound on the internally recorded audio.
[0207] In the process of implementing the present application, the inventor also found that the user could not hear any information when the collected data was played, and the data spliced according to the collection time contained a lot of noise and could not be heard clearly by the user. The method provided in this embodiment can determine the sequence of each segment of data according to the repeated parts of the data between the data when the terminal cannot obtain the playback time of each segment of data. After deduplication of the repeated parts, each segment of data can be spliced according to the sequence to obtain the internal recorded audio, which solves the problem that the fragmented data is too scattered and cannot be spliced.
[0208] Illustratively, the embodiment of the present application also provides a method for splicing data.
[0209] Fig. 9 A flowchart of an audio processing method provided by an exemplary embodiment of the present application is shown. The method can be executed by a terminal. Figure 8 In the illustrated embodiment, step 211 includes step 2111 , step 212 includes steps 2121 to 2123 , and step 213 includes step 2131 .
[0210] Step 2111: when playing audio, call the audio visualization interface to capture at least two segments of data in the data stream required by the terminal to play audio.
[0211] Exemplarily, the terminal calls the audio visualization interface once to capture a piece of data. The at least two pieces of data are obtained by the terminal calling the audio visualization interface at least twice.
[0212] Exemplarily, the terminal calls the audio visualization interface to capture at least two segments of data in a data stream required by the terminal to play audio according to a preset capture frequency; wherein data duplication exists between two adjacently sampled segments of data.
[0213] Exemplarily, the terminal calls the audio visualization interface to obtain the audio data played by the terminal. The audio visualization interface is an interface provided by the operating system to collect audio data of a preset duration for performing audio visualization tasks. The data is the audio data of the preset duration collected by the audio visualization interface. The terminal repeats the previous calling step according to the preset capture frequency to obtain at least two segments of data. The time interval of the preset capture frequency is less than or equal to the preset duration. The preset duration can be achieved by setting the amount of data obtained in each call.
[0214] Exemplarily, the terminal or the first application program repeatedly calls the audio visualization interface according to a preset capture frequency and obtains the data returned by the audio visualization interface. That is, the terminal or the first application program can obtain the segments of data currently played by the terminal in real time.
[0215] Exemplarily, when a user uses the audio recording function of the first application, the first application can use the method provided in the embodiment of the present application to record audio. Optionally, in response to the operation of triggering the recording start control, the audio visualization interface is repeatedly called at a preset capture frequency to obtain at least two segments of data.
[0216] Exemplarily, in response to the operation of triggering the recording start control, the recording authorization interface is displayed, and in response to receiving the authorization operation on the recording authorization interface, the audio visualization interface is repeatedly called according to the preset capture frequency to obtain at least two pieces of data. And / or, in response to the operation of triggering the recording start control, the first application sends a recording authorization request to at least one application currently playing audio, and in response to receiving the authorization instructions of all applications in the at least one application, the audio visualization interface is repeatedly called according to the preset capture frequency to obtain at least two pieces of data.
[0217] Exemplarily, the audio visualization interface is an API (Application Programming Interface) provided by the operating system of the terminal. Through the audio visualization interface, the audio data currently played by the terminal can be collected from the operating system level, that is, the collected audio data can be the audio currently played by any application on the terminal, or, when multiple applications play audio at the same time, the collected audio data is the audio mixed by the audio played by multiple applications.
[0218] Exemplarily, the audio visualization interface may be a Visualizer interface, or the audio visualization interface may be a Visualizer.getWaveForm interface, wherein the preset duration of the acquisition needs to be greater than (Visualizer.getSamplingRate() / 1000) / Visualizer.getCaptureSizeRange()[1].
[0219] Exemplarily, the audio visualization interface is used to collect audio data currently being played in the audio playback circuit of the terminal, and the collected data is PCM (Pulse Code Modulation) data.
[0220] Exemplarily, the audio visualization interface is used to collect audio data from the audio playback circuit of the input terminal. Fig.10 As shown, if all applications running on the terminal need to play audio, the audio data will flow through the operating system, be transmitted to the audio playback circuit, and then be played out through the speakers in the audio playback circuit. When the first application calls the audio visualization interface 301, the operating system can return the currently played audio data to the first application through the audio visualization interface.
[0221] Exemplarily, the data collected by the audio visualization interface may be PCM audio data, or the audio data may be audio data in other audio formats.
[0222] Exemplarily, the data collected by the audio visualization interface is audio data adjusted by the operating system. Alternatively, the data collected by the audio visualization interface is audio data that has not been adjusted by the operating system. After other applications output audio data, the operating system can process the audio data according to user settings or default settings, and transmit the processed audio data to the audio playback circuit for playback. The data collected by the audio visualization interface can be the original audio data output by the application, or it can be audio data adjusted by the operating system.
[0223] For example, the operating system can adjust the audio data according to the volume set by the user, and the data collected by the audio visualization interface can be the audio data after the volume is adjusted, or the audio data before the volume is adjusted. When the audio visualization interface is used to collect data before the volume is adjusted, the terminal can record the audio data being played by the application in a silent state. At this time, the volume of the data collected by the audio visualization interface is the default volume output by the application.
[0224] Exemplarily, the audio visualization interface is originally used to perform audio visualization tasks. In the audio visualization task, the operating system opens the audio visualization interface so that the application can collect audio data of a preset duration through the audio visualization interface, and the application processes the audio data to realize audio visualization. For example, the application performs Fourier transform on the collected audio signal to obtain a spectrum diagram, and then obtains the spectrum animation effect of music.
[0225] Exemplarily, since the audio visualization interface is used to realize audio visualization, and audio visualization uses frame-by-frame data to produce frame-by-frame visualization images, the amount of data collected by the audio visualization interface is relatively small. For example, only 1kB or less of data can be collected, so the audio duration of a segment of data is only 20 milliseconds (ms) or less. Based on the audio visualization interface for audio visualization, an embodiment of the present application provides an audio recording method, which collects the audio currently played by the terminal in real time and in fragments by calling the audio visualization interface at high frequency, and then splices the complete audio based on the large number of collected data fragments.
[0226] Exemplarily, the audio visualization interface collects audio in real time. Ignoring the interface call delay, if the first application calls the audio visualization interface at the first moment, the data returned by the audio visualization interface is the data played by the terminal from the first moment to the second moment, wherein the duration from the first moment to the second moment is equal to the preset duration (e.g., 20ms) of the audio visualization interface collecting audio.
[0227] For example, in order to record the complete internal audio, the time interval of the preset capture frequency needs to be less than or equal to the preset duration. For example, when the preset duration is 20ms, the time interval of the preset capture frequency needs to be less than 20ms, and the preset capture frequency needs to be higher than 50Hz (Hertz).
[0228] For example, the preset capture frequency is 100Hz and the preset duration is 20ms. The terminal calls the audio visualization interface every 10ms, and the data obtained each time is 20ms. Assuming that the terminal starts calling the audio visualization interface from time 0, the first call to the terminal obtains 0-20ms data, the second call to the terminal obtains 10-30ms data, the third call to the terminal obtains 20-40ms data, and so on.
[0229] Exemplarily, in response to receiving an operation to trigger an audio internal recording end control, calling the audio visualization interface is stopped.
[0230] Exemplarily, when calling the audio visualization interface, the first application can also indicate the application that needs to be recorded. For example, the first application calls the audio visualization interface and carries the audio session identifier (audioSessionId) of the second application, then the operating system will return the data currently played by the second application to the first application, so that targeted audio internal recording can be achieved to avoid interference from other application audio (for example, there is a message prompt tone when recording music). Of course, when calling the audio visualization interface, the first application can indicate the recorded mixed audio (mixed data of all audio currently being played) without carrying the application identifier (that is, audioSessionId is 0). If the value of the audio session identifier is 0, the audio mixed with the audio currently played by all applications can be recorded.
[0231] In another optional embodiment, the audio visualization interface may also be an audio visualization interface for performing audio visualization provided by other applications (e.g., a third application). Alternatively, the audio visualization interface may be an interface for collecting audio data of a preset duration provided by other applications or an operating system.
[0232] In another optional embodiment, the functions of the above audio visualization interface can also be implemented by using a plug-in or a program, that is, calling a first plug-in or a first program to capture at least two segments of data in a data stream required by the terminal for playing audio.
[0233] In another optional embodiment, the user can schedule the recording time, for example, receiving a recording time scheduling operation, the recording time scheduling operation includes setting the recording time from the first time to the second time. At the first time, the first application starts to call the audio visualization interface to collect data according to the preset capture frequency until the second time ends. During the first time to the second time, the first application can obtain multiple segments of data by calling the audio visualization interface at a high frequency.
[0234] Exemplarily, the data obtained through the audio visualization interface may correspond to a start playback time, which may be the time when the first application calls the audio visualization interface, or the start playback time may be the actual playback start time of the data returned by the audio visualization interface. Alternatively, the start playback time may be the acquisition time of the first audio data of the data returned by the audio visualization interface. Based on the start playback time and the duration of the data (preset duration), the time corresponding to each audio data in the data can be determined. The start playback time may be the local time (for example, Beijing time) or the recording time of this recording (the time when recording starts is 0).
[0235] Alternatively, each audio data in the data has a corresponding playback time, and the playback time may be the actual playback time of each audio data in the data returned by the audio visualization interface, or the playback time may be the data acquisition time of each audio data in the data returned by the audio visualization interface.
[0236] Exemplarily, in response to the user turning on recording, if the user turns on both microphone recording and system internal recording, the terminal will turn on the microphone while executing step 2111, and record the microphone audio through the microphone. It should be noted that microphone recording and the audio recording method provided in the embodiment of the present application are two completely independent recording methods, and the two recording methods do not interfere with each other when executed simultaneously, and the two recording methods each generate a recording file (microphone audio and internal recording audio), and the microphone audio and the internal recording audio are two audio files. When synthesizing the final recorded audio, the ambient audio and the internal recording audio can be synthesized to obtain the recorded audio. Alternatively, two audio files, ambient audio and internal recording audio, can be obtained after the recording is completed.
[0237] In one embodiment, if the terminal turns on the external speaker mode, the microphone audio will also be mixed with the sound of the internally recorded audio. At this time, if you want to obtain pure terminal external audio, you can subtract the internally recorded audio from the microphone audio to obtain pure terminal external audio, for example, pure human voice audio, or pure ambient noise.
[0238] In another embodiment, if the terminal turns on the external speaker mode, and the microphone audio contains the sound of the internally recorded audio, the microphone audio can be used to fill the gap in the internally recorded audio. For example, if a call to the audio visualization interface fails and no data within a certain period of time is obtained, the audio data during this period of time in the microphone audio can be used to fill in the missing data portion of the internally recorded audio to complete the internally recorded audio. Alternatively, after denoising the microphone audio, the audio data during this period of time in the denoised microphone audio is filled in the missing data portion of the internally recorded audio. In this way, both the clarity and integrity of the internally recorded audio can be guaranteed.
[0239] Step 2121: for at least two segments of data, use the first header data of the later sampled data as a search sample.
[0240] Exemplarily, in order to search for repeated data in at least two segments of data, the first x bytes of the rear sampled data may be selected as search samples, that is, the first header data includes data from the 1st byte to the xth byte in the rear sampled data, where x is a positive integer. Optionally, x may be 16, and the first header data is the first 16 bytes of the rear sampled data.
[0241] The search sample is used to find the data repetition part in other data (previously sampled data) in at least two segments of data.
[0242] Wherein, at least two segments of data can be divided into first sampling data and second sampling data according to the order of acquisition time. It should be noted that first sampling data and second sampling data are relative concepts. For example, the first segment of data is the first sampling data of the second segment of data, the second segment of data is the second sampling data of the first segment of data, and the third segment of data is the first sampling data of the third segment of data.
[0243] For example, the length of the first header data will affect the search efficiency and accuracy. If the length is too long, the repeated data may not be searched. If the length is too short, the wrong repeated data may be searched. Therefore, it has been verified experimentally that when the data size of each segment is 1kB, the search effect is better when the first 16 bytes of the post-sampling data are taken as the search sample.
[0244] Step 2122, determining target data that is the same as the search sample data from the previously sampled data.
[0245] Exemplarily, the first header data of the later sampled data is used to search for the same data portion (target data) in the earlier sampled data.
[0246] Exemplarily, the first sampled data here may be a segment of data sampled before the second sampled data. Alternatively, the first sampled data may be: a segment of data obtained by splicing at least one segment of data sampled before the second sampled data.
[0247] Exemplarily, the first sampling data includes: first first sampling data adjacent to the second sampling data, and second first sampling data not adjacent to the second sampling data; when the target data does not exist in the first first sampling data, the target data is determined from the second first sampling data, wherein the second first sampling data is collected earlier than the first first sampling data.
[0248] For example, since at least two pieces of data are obtained by sampling, the sampled data may have errors or deviations. The criteria for determining whether the data are identical here may be: the data are 100% identical, or the data identical rate exceeds a preset value, such as 99%, 98%, etc.
[0249] Exemplarily, different sampling start times may result in completely different sampled data for the same data. For example, for a string of data "1 2 3 4 5 6 7 8 9 10", if sampling starts at the first time, a segment of data that may be obtained is "1 3 5 7 9", and if sampling starts at the second time, a segment of data that may be obtained is "2 4 6 810". It can be seen that the data obtained by the two segments are completely different, but in fact they should be different sampling parts of repeated data. Therefore, a method for determining whether the data is the same can also be: fitting the search sample to obtain a first fitting curve, fitting the first sampled data to obtain a second fitting curve, calculating the similarity between the first fitting curve and each segment of the candidate curve in the second fitting curve, and determining the data portion corresponding to the segment of the candidate curve with the highest similarity as the target data. Among them, the candidate curve can be intercepted from the second fitting curve according to a time window, and the length of the time window is equal to the length of the first fitting curve.
[0250] Step 2123, determine the second header data of the later sampled data as the data repetition part; the data length of the second header data is equal to the data length from the target data to its tail in the first sampled data.
[0251] Exemplarily, after the target data is searched, the length of the data overlap portion is determined based on the length from the location of the target data in the first sampled data to its tail, and then the data overlap portion is deleted from the later sampled data based on the length of the data overlap portion.
[0252] Exemplarily, when the target data is found in the second online sampled data, the data after the second header data is deleted from the later sampled data and is concatenated with the tail of the second previous sampled data.
[0253] Exemplarily, in order to further improve the recognition accuracy of the data duplication part, the third data part of the first sampled data can also be intercepted, the third data part is all the data from the target data to the end of the first sampled data, and the third data part includes the target data; the data overlap rate between the third data part and the second header data is calculated, and when the data overlap rate is greater than the first value, the second header data is determined as the data duplication part. The first value can be set by itself, for example, the first value can be 99%, 98%, 95%.
[0254] Step 2131, concatenate the data after deleting the second header data in the later sampled data with the tail of the earlier sampled data.
[0255] Exemplarily, the second header data in the later sampled data is deleted to remove the repeated data in the first sampled data and the later sampled data, and then the remaining data after the deletion is spliced to the end of the first sampled data.
[0256] Exemplarily, duplicate parts of data of at least two segments of data are deduplicated.
[0257] Exemplarily, if the time interval of the preset capture frequency is less than the preset duration, then two adjacent data in at least two data segments have a data duplication portion, or at least two data segments have a time overlap portion.
[0258] In an optional embodiment, the terminal can identify the repeated part according to whether the audio data is the same. The terminal obtains the spliced audio, which is obtained by splicing the first n segments of at least two segments of data, where n is a positive integer; deletes the overlapping part of the data in the n+1th segment of data that overlaps with the spliced audio, and obtains the deduplicated n+1th segment of data.
[0259] Exemplarily, the terminal can determine the first x bytes of the n+1th data segment of at least two data segments, where x is a positive integer; determine the target data that overlaps with the first x bytes in the spliced audio; determine the byte length L of the repeated data portion according to the number of bytes from the first byte of the target data to the last byte of the spliced audio, where L is a positive integer; delete the first L bytes of the n+1th data segment to obtain the n+1th data segment after deduplication. Exemplarily, x can take a value greater than 16.
[0260] For example, Fig.11 As shown, for a piece of data 302 collected, the first x bytes of data 302 are taken as search samples; the search sample is searched from the sequence of spliced audio to determine the length L of repeated data (the repeated part of the data) (the length from the first byte searched to the end of the spliced audio sequence is repeated data); the repeated data in data 302 (from the beginning to the position with a length of L) is removed to obtain valid data of data 302; the valid data is appended to the spliced audio to obtain new spliced audio; and the next piece of data is spliced in the same manner as described above.
[0261] For example, the spliced audio has 100 bytes and the data to be spliced has 20 bytes. When the 1st to 5th bytes of the data to be spliced are the same as the 91st to 95th bytes of the spliced audio, delete the 1st to 10th bytes of the data to be spliced to obtain the deduplicated data (the 11th to the 20th bytes), and then add the deduplicated data to the end of the spliced audio, and finally get 110 bytes.
[0262] Exemplarily, in order to improve the search efficiency, the search can be started from the end of the spliced audio, and the searched data range is equal to the data amount of a segment of data. For example, the spliced audio includes 100 bytes, a segment of data includes 10 bytes, and the search sample is 5 bytes, then first search whether the 95th to 100th bytes of the spliced audio are the same as the search sample, then search the 94th to 99th bytes, then search the 93rd to 98th bytes, then search the 92nd to 97th bytes, then search the 91st to 96th bytes, then search the 90th to 95th bytes, and the search ends here.
[0263] In another optional embodiment, the terminal can identify the repeated part according to the playback time. Each audio data in the data corresponds to a playback time. The terminal obtains the spliced audio, which is obtained by splicing the first n segments of at least two segments of data, where n is a positive integer; delete the part of the n+1 segment of data that coincides with the spliced audio time, and obtain the deduplicated n+1 segment of data. Splice the deduplicated n+1 segment of data to the end of the spliced audio to obtain a new spliced audio. Repeat the above steps to splice the next segment of data.
[0264] For example, if the spliced audio is spliced to 200ms, and the data to be spliced is from 160ms to 220ms, then delete the data from 160ms to 200ms to leave the part from 201ms to 220ms, and splice the remaining part to the end of the spliced audio, then the new spliced audio is spliced to 220ms.
[0265] Exemplarily, at least two deduplicated data segments are sequentially spliced to obtain internally recorded audio.
[0266] Exemplarily, deduplication may be removing the same portion of audio data. Alternatively, deduplication may be removing the same portion of playback time. Alternatively, deduplication may be removing the same portion of audio data and the same time.
[0267] Exemplarily, deduplication is to remove the part of the data with a later time that is repeated with the data with a previous time, that is, to retain the repeated part of the data with a previous time. Of course, deduplication can also be to remove the repeated part of the data with a previous time and the data with a later time, that is, to retain the repeated part of the data with a later time.
[0268] Exemplarily, the deduplicated n+1th segment of data is spliced to the end of the spliced audio to obtain new spliced audio; let n be equal to n+1 and repeat the step of "obtaining the spliced audio, deleting the overlapping part of the n+1th segment of data that overlaps with the spliced audio", and sequentially splice at least two segments of data to obtain the internally recorded audio.
[0269] For example, Fig.12As shown, data 1, data 2, data 3, and data 4 arranged in sequence are obtained through the audio visualization interface, among which data 1 and data 2 have overlapping part 1, data 2 and data 3 have overlapping part 2, and data 3 and data 4 have overlapping part 3; the overlapping part is deleted from the latter data, the overlapping part 1 is deleted from data 2, the overlapping part 2 is deleted from data 3, and the overlapping part 3 is deleted from data 4; then data 1 is spliced with the remaining data 2, 3, and 4 to obtain the internally recorded audio.
[0270] In an optional embodiment, when the target data cannot be found from the first sampled data, the later sampled data can be placed at the end of the data list, and other data can be spliced first. After the other data are spliced, the search sample of the later sampled data can be used to search for the same part of the data. That is, when the target data cannot be found from the first sampled data, the order of the later sampled data is adjusted to put it at the end, and the terminal will repeat the cycle in order to try to splice the later data.
[0271] Exemplarily, the terminal stores a data list, which is used to sequentially store at least two segments of data, and delete a segment of data from the data list after it is successfully spliced; when the target data that is the same as the search sample data cannot be determined from the first sampled data, the later sampled data is stored at the end of the data list; and a segment of data at the head of the data list is spliced according to the storage order of the data in the data list.
[0272] In another optional embodiment, when the data to be spliced (eg, the n+1th segment of data) does not overlap with the spliced audio, the data may also be spliced based on the playback time of the audio data in the data.
[0273] Optionally, the n+1th data segment corresponds to a first time, and the first time is the starting playback time of the terminal playing the n+1th data segment; each byte in the spliced audio corresponds to a playback time; if the n+1th data segment does not overlap with the spliced audio, and the spliced audio does not have audio data at the first time, the n+1th data segment is spliced to the first time of the spliced audio to obtain new spliced audio.
[0274] Exemplarily, the first sampling data and the second sampling data respectively correspond to time information; when the target data identical to the search sample data cannot be determined from the first sampling data, and there is no time overlap between the first sampling data and the second sampling data, the first sampling data and the second sampling data are spliced according to the time information; wherein, after splicing, there is a data missing portion between the first sampling data and the second sampling data.
[0275] For example, Fig.13As shown, there is no overlapping audio data between data 303 and the spliced audio (the audio data are the same), and data 303 is from 140ms to 160ms, and the spliced audio is from 0ms to 120ms, and there is no overlapping time between data 303 and the spliced audio (or the spliced audio has no audio data at the time corresponding to data 303), then data 303 is directly spliced to the corresponding time point after the spliced audio, that is, data 303 is spliced to the position of 140ms to obtain new spliced audio (0ms to 160ms), and the new spliced audio has no audio data (blank part) from 120ms to 140ms.
[0276] Optionally, when the n+1th data segment does not have any overlapping part with the spliced audio, and the spliced audio has audio data at the first time, delete the time overlapping part in the n+1th data segment to obtain the deduplicated n+1th data segment, and the time overlapping part includes the time overlapping part of the spliced audio and the n+1th data segment; splice the deduplicated n+1th data segment to the end of the spliced audio to obtain new spliced audio.
[0277] Exemplarily, the first sampled data and the second sampled data respectively correspond to time information; when the target data identical to the search sample data cannot be determined from the first sampled data, and there is a time overlap between the first sampled data and the second sampled data, the data after the time overlap is deleted from the second sampled data and is concatenated with the end of the first sampled data.
[0278] Exemplarily, when there is no matching part that overlaps with the first x bytes in the spliced audio, and there is audio data in the spliced audio at the first time, the byte length M of the part to be deleted is determined according to the number of bytes from the byte corresponding to the first time in the spliced audio to the last byte of the spliced audio, where M is a positive integer; delete the first M bytes of the n+1th segment of data to obtain the n+1th segment of data after deduplication; splice the n+1th segment of data after deduplication to the end of the spliced audio to obtain new spliced audio.
[0279] For example, Fig.14 As shown, there is no overlapping audio data (the audio data is the same) between data 304 and the spliced audio, and data 304 is from 100ms to 160ms, and the spliced audio is from 0ms to 120ms. There is a time overlapping part between data 304 and the spliced audio: 100ms to 120ms, then the time overlapping part in data 304 is deleted to obtain the deduplicated data 304: 120ms to 160ms, that is, the deduplicated data 304 is spliced to the end of the spliced audio to obtain new spliced audio (0ms to 160ms).
[0280] In an optional embodiment, when there are three or more data segments with the same time-repeating portion (same time but different audio data), the median of the audio data of multiple time-repeating portions can be taken and then spliced to the spliced audio to reduce the audio acquisition error rate.
[0281] In summary, the method provided in this embodiment realizes internal audio recording by multiplexing the audio visualization interface. The integrity of the collected audio is ensured by calling the audio visualization interface at a high frequency, and the duplicate data is first deduplicated and then spliced to obtain the complete internal audio. The clarity of the internal audio is improved, and the impact of environmental noise on the internal audio is reduced. Moreover, using this method, even if the volume of the audio played by the terminal is very low, the terminal can still record the internal audio clearly and accurately, which greatly improves the recording effect of the internal audio.
[0282] The method provided in this embodiment is not limited to microphones, and can also capture the audio played by the terminal when the terminal does not have audio capture hardware. Moreover, even if the terminal is connected to headphones and has no external audio, the method provided in this embodiment of the application can also capture the internally recorded audio, which greatly improves the applicable scenarios of audio internal recording and reduces the hardware requirements for audio internal recording.
[0283] The method provided in this embodiment uses the first few bytes of the data to be spliced as search samples to search for repeated parts in the spliced audio, thereby improving the search efficiency. After the repeated part is found, the first few bytes of the data to be spliced are deleted directly according to the number of bytes from the repeated part to the end of the spliced audio, thereby achieving fast deduplication, efficient splicing, and improving the efficiency of audio internal recording.
[0284] The method provided in this embodiment can also deduplicate and splice audio data in time according to the starting playback time or playback time of the data when the audio data comparison method cannot match the repeated part of the data, thereby improving the audio splicing efficiency and reducing the audio splicing error rate.
[0285] Exemplarily, an embodiment of the present application also provides a method for completing missing audio data.
[0286] Fig.15 A flowchart of an audio processing method provided by an exemplary embodiment of the present application is shown. The method can be executed by a terminal. Figure 8 In the illustrated embodiment, step 213 also includes steps 214 to 217 .
[0287] Step 211: when playing audio, call the audio visualization interface to capture at least two segments of data in the data stream required by the terminal to play audio.
[0288] Step 212, identifying data duplication portions of at least two segments of data.
[0289] Step 213, splicing at least two segments of data according to the location of the repeated portion of the data to obtain the internally recorded audio.
[0290] Exemplarily, the methods of step 211 to step 213 may refer to the method provided in any of the above embodiments.
[0291] Step 214, intercepting two reference audio segments that are adjacent to the data missing portion in the internally recorded audio.
[0292] Exemplarily, the internally recorded audio includes a data missing portion, and there is no audio data in the data missing portion. The data missing portion refers to a portion of the internally recorded audio where there is no audio data for a continuous period of time. Optionally, there may be multiple data missing portions in the internally recorded audio. This embodiment takes filling the data missing portion as an example for explanation, and the same method may be used to fill other data missing portions.
[0293] Exemplarily, the data missing part (data missing part) means that there is no audio data in a continuous period of time, or the amount of audio data in a continuous period of time does not meet the requirements (or the sampling rate of the audio data in this period of time does not meet the requirements). That is, all or part of the audio data is missing in the data missing part.
[0294] Exemplarily, in order to improve the integrity of the internally recorded audio, it is necessary to fill in the audio data of the missing data portion. This embodiment uses a neural network model to predict the audio data of the missing data portion, and the input data required for the prediction includes: a reference audio segment before the missing data portion, a reference audio segment after the missing data portion, and the amount of missing data or blank duration of the missing data portion. For example, if the missing data portion is 120ms to 160ms, then the reference audio before the missing data portion (100ms to 120ms) and the reference audio after the missing data portion (160ms to 170ms) can be taken. The neural network model is used to predict the audio data of the missing data portion based on the changing trend of the audio data before and after the missing data portion.
[0295] Exemplarily, the time lengths of the adjacent reference audios can be the same or different. For example, more audio before the part where data is missing can be captured as reference audio so that the neural network model can learn the historical change trends and change characteristics of the internally recorded audio, so as to better predict the audio data of the part where data is missing.
[0296] Step 215, obtaining the missing data amount of the data missing part.
[0297] Exemplarily, the amount of missing data is used to indicate to the neural network model the amount of data that needs to be predicted.
[0298] Alternatively, the terminal may also obtain the blank duration of the data missing portion. The blank duration is used to indicate to the neural network model the time length of the data missing portion that needs to be predicted.
[0299] Alternatively, the terminal can obtain the blank duration of the missing data part and the sampling rate of the audio data of the internally recorded audio. The blank duration, sampling rate, and the two previous and next reference audios are used as input data of the model to enable the model to predict the audio data of the missing data part.
[0300] Step 216, input the two reference audios and the amount of missing data into the audio prediction model to obtain predicted data, where the amount of predicted data is equal to the amount of missing data.
[0301] The audio prediction model is a neural network model obtained by pre-selection and training. The model structure of the neural network model can be arbitrary. For example, the audio prediction model can use a convolutional neural network, or a long short-term memory network (Long Short-Term Memory, LSTM).
[0302] Among them, the two reference audios and the amount of missing data are the input data of the model, and the predicted data are the output data of the model.
[0303] Alternatively, two reference audios and blank duration are the input data of the model, and the predicted data is the output data of the model.
[0304] Step 217, fill the missing data portion of the internally recorded audio with the predicted data to obtain the completed audio.
[0305] After using the audio prediction model to predict the audio data of the missing part (prediction data), the prediction data can be used to fill in the missing part, thereby making the internal recorded audio more complete and obtaining the completed audio.
[0306] To sum up, the method provided in this embodiment uses a neural network model to complete the missing parts of the audio data in the internally recorded audio, thereby reducing the impact of the failure of the audio visualization interface call on the internally recorded audio and improving the data integrity and continuity of the internally recorded audio.
[0307] The following is an embodiment of the device of the present application. For details not described in detail in the embodiment of the device, reference can be made to the corresponding records in the above method embodiment, and they will not be repeated herein.
[0308] Fig.16 A schematic diagram of the structure of an audio processing device provided by an exemplary embodiment of the present application is shown. The device can be implemented as all or part of a terminal through software, hardware, or a combination of both. The device includes:
[0309] A splicing module 401 is used to splice at least two pieces of data to obtain internally recorded audio; the at least two pieces of data are captured from a data stream required for the audio played by the terminal;
[0310] A pitch module 402, configured to calculate pitch data of the internally recorded audio based on the fundamental frequency data of the internally recorded audio, wherein the pitch data includes the pitch of the internally recorded audio at at least one time point or time period;
[0311] In an optional embodiment, the pitch module 402 is used to perform frame processing on the internally recorded audio to obtain at least two frames of framed audio;
[0312] The pitch module 402 is used to perform fundamental frequency analysis on each frame of the at least two frames of framed audio to obtain the fundamental frequency of each frame of the framed audio;
[0313] The pitch module 402 is used to calculate the pitch of each frame of audio in the at least two frames of audio based on the fundamental frequency of each frame of audio in the at least two frames of audio;
[0314] The pitch module 402 is used to generate the pitch data of the internally recorded audio based on the pitch of each frame of the at least two frames of framed audio.
[0315] In an optional embodiment, the pitch module 402 is used to perform Fourier transform on each frame of the at least two frames of framed audio to obtain frequency domain data;
[0316] The pitch module 402 is used to obtain the peak point frequency corresponding to the peak point in the frequency domain data;
[0317] The pitch module 402 is used to determine the average value of the peak point frequencies as the fundamental frequency.
[0318] In an optional embodiment, the device further includes:
[0319] A display module is used to display a pitch animation effect of the internally recorded audio based on the pitch data, wherein the pitch animation effect is used to indicate changes in pitch over time.
[0320] In an optional embodiment, an application supporting a screen recording function is running on the terminal, and the device further includes:
[0321] The screen recording module 404 is used to respond to the screen recording start operation and execute the following steps at the same time:
[0322] Recording a screen image to obtain image data, wherein the image data includes at least one frame of the screen image recorded in time sequence;
[0323] An audio visualization interface is called to capture the at least two segments of data in the data stream required by the terminal to play the audio.
[0324] In an optional embodiment, the device further includes:
[0325] The display module 403 is used to display a screen recording editing interface, wherein the screen recording editing interface includes a preview area and a pitch effect adding control, wherein the preview area is used to preview the screen recording file; the screen recording file is generated according to the image data and the internally recorded audio;
[0326] The display module 403 is used to add the pitch animation effect to the image data in response to the operation of triggering the pitch animation effect adding control;
[0327] Among them, the playing progress of the pitch animation effect in the screen recording file is consistent with the playing progress of the internally recorded audio.
[0328] In an optional embodiment, the device further includes:
[0329] A game module 405, for automatically generating a music game file based on the pitch data and the internally recorded audio;
[0330] The game module 405 is used to run the music game file and play the internally recorded audio and the pitch animation effect;
[0331] The game module 405 is used to receive game operations, calculate the matching degree between the game operations and the pitch data, and obtain a game score;
[0332] The game operation includes: a first audio recorded through a microphone, and the matching degree includes a similarity between a pitch of the first audio and the pitch data.
[0333] In an optional embodiment, the device further includes:
[0334] The recognition module 406 is used to perform speech recognition on the internally recorded audio by using automatic speech recognition technology ASR to obtain a recognition result;
[0335] The recognition module 406 is used to generate a subtitle display file or a lyrics display file according to the recognition result.
[0336] In an optional embodiment, the splicing module 401 is used to capture the at least two segments of data in the data stream required by the terminal to play the audio when playing the audio;
[0337] The splicing module 401 is used to identify the data duplication part of the at least two segments of data;
[0338] The splicing module 401 is used to splice the at least two segments of data according to the location of the repeated part of the data to obtain the internally recorded audio.
[0339] In an optional embodiment, the splicing module 401 is used to call an audio visualization interface to capture the at least two segments of data in the data stream required by the terminal to play the audio.
[0340] In an optional embodiment, the splicing module 401 is used to call the audio visualization interface to capture the at least two segments of data in the data stream required by the terminal to play the audio according to a preset capture frequency;
[0341] There is data duplication between two adjacent sampled data segments.
[0342] In an optional embodiment, the splicing module 401 is used to use the first header data of the later sampled data as a search sample for the at least two segments of data;
[0343] The splicing module 401 is used to determine the target data that is the same as the search sample data from the first sampled data;
[0344] The splicing module 401 is used to determine the second header data of the later sampled data as the data repetition part; the data length of the second header data is equal to the data length from the target data to its tail in the first sampled data.
[0345] In an optional embodiment, the first sampling data includes: first first sampling data adjacent to the second sampling data, and second first sampling data not adjacent to the second sampling data;
[0346] The splicing module 401 is configured to determine the target data from the second prior sampling data when the target data does not exist in the first prior sampling data.
[0347] In an optional embodiment, the splicing module 401 is used to splice the data after deleting the second header data in the later sampled data with the tail of the second previous sampled data.
[0348] Fig.17800 is a schematic diagram of the structure of a server provided by an embodiment of the present application. Specifically, the server 800 includes a central processing unit (CPU) 801, a system memory 804 including a random access memory (RAM) 802 and a read-only memory (ROM) 803, and a system bus 805 connecting the system memory 804 and the central processing unit 801. The server 800 also includes a basic input / output system (I / O system) 806 that helps transmit information between various devices in the computer, and a large-capacity storage device 807 for storing an operating system 813, application programs 814 and other program modules 815.
[0349] The basic input / output system 806 includes a display 808 for displaying information and an input device 809 such as a mouse and a keyboard for inputting information to a user account. The display 808 and the input device 809 are connected to the central processing unit 801 through an input / output controller 810 connected to the system bus 805. The basic input / output system 806 may also include an input / output controller 810 for receiving and processing inputs from a plurality of other devices such as a keyboard, a mouse, or an electronic stylus. Similarly, the input / output controller 810 also provides output to a display screen, a printer, or other types of output devices.
[0350] The mass storage device 807 is connected to the central processing unit 801 through a mass storage controller (not shown) connected to the system bus 805. The mass storage device 807 and its associated computer readable medium provide non-volatile storage for the server 800. That is, the mass storage device 807 may include a computer readable medium (not shown) such as a hard disk or a read-only optical disk (English: Compact Disc Read-Only Memory, referred to as: CD-ROM) drive.
[0351] Without loss of generality, computer-readable media may include computer storage media and communication media. Computer storage media include volatile and non-volatile, removable and non-removable media implemented by any method or technology for storing information such as computer-readable instructions, data structures, program modules or other data. Computer storage media include RAM, ROM, Erasable Programmable Read-Only Memory (EPROM), Electrically Erasable Programmable Read-Only Memory (EEPROM), flash memory or other solid-state memory technology, CD-ROM, Digital Versatile Disc (DVD) or other optical storage, cassettes, tapes, disk storage or other magnetic storage devices. Of course, those skilled in the art will know that computer storage media are not limited to the above. The above-mentioned system memory 804 and mass storage device 807 can be collectively referred to as memory.
[0352] According to various embodiments of the present application, the server 800 can also be connected to a remote computer on the network through a network such as the Internet. That is, the server 800 can be connected to the network 812 through the network interface unit 811 connected to the system bus 805, or the network interface unit 811 can be used to connect to other types of networks or remote computer systems (not shown).
[0353] The present application also provides a terminal, which includes a processor and a memory, wherein the memory stores at least one instruction, and the at least one instruction is loaded and executed by the processor to implement the audio processing method provided by each of the above method embodiments. It should be noted that the terminal can be as follows Fig.18 The terminal provided.
[0354] Fig.18 The structure block diagram of a terminal 900 provided by an exemplary embodiment of the present application is shown. The terminal 900 may be: a smart phone, a tablet computer, an MP3 player (Moving Picture Experts Group Audio Layer III), an MP4 player (Moving Picture Experts Group Audio Layer IV), a laptop computer or a desktop computer. The terminal 900 may also be called a user account device, a portable terminal, a laptop terminal, a desktop terminal or other names.
[0355] Typically, the terminal 900 includes a processor 901 and a memory 902 .
[0356] The processor 901 may include one or more processing cores, such as a 4-core processor, an 8-core processor, etc. The processor 901 may be implemented in at least one hardware form of DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), and PLA (Programmable Logic Array). The processor 901 may also include a main processor and a coprocessor. The main processor is a processor for processing data in the awake state, also known as a CPU (Central Processing Unit); the coprocessor is a low-power processor for processing data in the standby state. In some embodiments, the processor 901 may be integrated with a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content to be displayed on the display screen. In some embodiments, the processor 901 may also include an AI (Artificial Intelligence) processor, which is used to process computing operations related to machine learning.
[0357] The memory 902 may include one or more computer-readable storage media, which may be non-transitory. The memory 902 may also include a high-speed random access memory, and a non-volatile memory, such as one or more disk storage devices, flash memory storage devices. In some embodiments, the non-transitory computer-readable storage medium in the memory 902 is used to store at least one instruction, which is used to be executed by the processor 901 to implement the audio processing method or audio processing method provided in the method embodiment of the present application.
[0358] In some embodiments, the terminal 900 may further optionally include: a peripheral device interface 903 and at least one peripheral device. The processor 901, the memory 902 and the peripheral device interface 903 may be connected via a bus or a signal line. Each peripheral device may be connected to the peripheral device interface 903 via a bus, a signal line or a circuit board. Specifically, the peripheral device includes: at least one of a radio frequency circuit 904, a display screen 905, a camera assembly 906, an audio circuit 907, a positioning assembly 908 and a power supply 909.
[0359] The peripheral device interface 903 may be used to connect at least one peripheral device related to I / O (Input / Output) to the processor 901 and the memory 902. In some embodiments, the processor 901, the memory 902, and the peripheral device interface 903 are integrated on the same chip or circuit board; in some other embodiments, any one or two of the processor 901, the memory 902, and the peripheral device interface 903 may be implemented on a separate chip or circuit board, which is not limited in this embodiment.
[0360] The radio frequency circuit 904 is used to receive and transmit RF (Radio Frequency) signals, also known as electromagnetic signals. The radio frequency circuit 904 communicates with the communication network and other communication devices through electromagnetic signals. The radio frequency circuit 904 converts electrical signals into electromagnetic signals for transmission, or converts received electromagnetic signals into electrical signals. Exemplarily, the radio frequency circuit 904 includes: an antenna system, an RF transceiver, one or more amplifiers, a tuner, an oscillator, a digital signal processor, a codec chipset, a user account identity module card, and the like. The radio frequency circuit 904 can communicate with other terminals through at least one wireless communication protocol. The wireless communication protocol includes, but is not limited to: the World Wide Web, a metropolitan area network, an intranet, various generations of mobile communication networks (2G, 3G, 4G and 5G), a wireless local area network and / or a WiFi (Wireless Fidelity) network. In some embodiments, the radio frequency circuit 904 may also include circuits related to NFC (Near Field Communication), which is not limited in this application.
[0361] The display screen 905 is used to display the UI (User Interface). The UI may include graphics, text, icons, videos and any combination thereof. When the display screen 905 is a touch display screen, the display screen 905 also has the ability to collect touch signals on the surface or above the surface of the display screen 905. The touch signal can be input to the processor 901 as a control signal for processing. At this time, the display screen 905 can also be used to provide virtual buttons and / or virtual keyboards, also known as soft buttons and / or soft keyboards. In some embodiments, the display screen 905 can be one, and the front panel of the terminal 900 is set; in other embodiments, the display screen 905 can be at least two, which are respectively set on different surfaces of the terminal 900 or are folded; in some other embodiments, the display screen 905 can be a flexible display screen, which is set on the curved surface or folded surface of the terminal 900. Even, the display screen 905 can also be set as a non-rectangular irregular shape, that is, a special-shaped screen. The display screen 905 can be made of materials such as LCD (Liquid Crystal Display), OLED (Organic Light-Emitting Diode) and the like.
[0362] The camera assembly 906 is used to capture images or videos. Exemplarily, the camera assembly 906 includes a front camera and a rear camera. Typically, the front camera is arranged on the front panel of the terminal, and the rear camera is arranged on the back of the terminal. In some embodiments, there are at least two rear cameras, which are any one of a main camera, a depth of field camera, a wide-angle camera, and a telephoto camera, so as to realize the fusion of the main camera and the depth of field camera to realize the background blur function, the fusion of the main camera and the wide-angle camera to realize panoramic shooting and VR (Virtual Reality) shooting function or other fusion shooting functions. In some embodiments, the camera assembly 906 may also include a flash. The flash can be a monochrome temperature flash or a dual-color temperature flash. A dual-color temperature flash refers to a combination of a warm light flash and a cold light flash, which can be used for light compensation at different color temperatures.
[0363] The audio circuit 907 may include a microphone and a speaker. The microphone is used to collect sound waves from the user account and the environment, and convert the sound waves into electrical signals and input them into the processor 901 for processing, or input them into the radio frequency circuit 904 to achieve voice communication. For the purpose of stereo acquisition or noise reduction, there may be multiple microphones, which are respectively arranged at different parts of the terminal 900. The microphone may also be an array microphone or an omnidirectional acquisition microphone. The speaker is used to convert the electrical signal from the processor 901 or the radio frequency circuit 904 into sound waves. The speaker may be a traditional film speaker or a piezoelectric ceramic speaker. When the speaker is a piezoelectric ceramic speaker, it can not only convert the electrical signal into sound waves audible to humans, but also convert the electrical signal into sound waves inaudible to humans for purposes such as ranging. In some embodiments, the audio circuit 907 may also include a headphone jack.
[0364] The positioning component 908 is used to locate the current geographical location of the terminal 900 to implement navigation or LBS (Location Based Service). The positioning component 908 can be a positioning component based on the US GPS (Global Positioning System), China's Beidou system or Russia's Galileo system.
[0365] The power supply 909 is used to power various components in the terminal 900. The power supply 909 can be an alternating current, a direct current, a disposable battery, or a rechargeable battery. When the power supply 909 includes a rechargeable battery, the rechargeable battery can be a wired rechargeable battery or a wireless rechargeable battery. A wired rechargeable battery is a battery charged through a wired line, and a wireless rechargeable battery is a battery charged through a wireless coil. The rechargeable battery can also be used to support fast charging technology.
[0366] In some embodiments, the terminal 900 further includes one or more sensors 910 , including but not limited to: an acceleration sensor 911 , a gyroscope sensor 912 , a pressure sensor 913 , a fingerprint sensor 914 , an optical sensor 915 , and a proximity sensor 916 .
[0367] The acceleration sensor 911 can detect the magnitude of acceleration on the three coordinate axes of the coordinate system established by the terminal 900. For example, the acceleration sensor 911 can be used to detect the components of gravity acceleration on the three coordinate axes. The processor 901 can control the display screen 905 to display the user account interface in a horizontal view or a vertical view according to the gravity acceleration signal collected by the acceleration sensor 911. The acceleration sensor 911 can also be used to collect motion data of games or user accounts.
[0368] The gyro sensor 912 can detect the body direction and rotation angle of the terminal 900, and the gyro sensor 912 can cooperate with the acceleration sensor 911 to collect the 3D action of the user account on the terminal 900. The processor 901 can implement the following functions based on the data collected by the gyro sensor 912: motion sensing (such as changing the UI according to the tilt operation of the user account), image stabilization during shooting, game control, and inertial navigation.
[0369] The pressure sensor 913 can be set on the side frame of the terminal 900 and / or the lower layer of the display screen 905. When the pressure sensor 913 is set on the side frame of the terminal 900, it can detect the holding signal of the user account on the terminal 900, and the processor 901 performs left and right hand recognition or shortcut operation according to the holding signal collected by the pressure sensor 913. When the pressure sensor 913 is set on the lower layer of the display screen 905, the processor 901 controls the operability controls on the UI interface according to the pressure operation of the user account on the display screen 905. The operability controls include at least one of a button control, a scroll bar control, an icon control, and a menu control.
[0370] The fingerprint sensor 914 is used to collect the fingerprint of the user account, and the processor 901 identifies the identity of the user account based on the fingerprint collected by the fingerprint sensor 914, or the fingerprint sensor 914 identifies the identity of the user account based on the collected fingerprint. When the identity of the user account is identified as a trusted identity, the processor 901 authorizes the user account to perform relevant sensitive operations, which include unlocking the screen, viewing encrypted information, downloading software, paying, and changing settings. The fingerprint sensor 914 can be set on the front, back or side of the terminal 900. When a physical button or a manufacturer logo is set on the terminal 900, the fingerprint sensor 914 can be integrated with the physical button or the manufacturer logo.
[0371] The optical sensor 915 is used to collect the ambient light intensity. In one embodiment, the processor 901 can control the display brightness of the display screen 905 according to the ambient light intensity collected by the optical sensor 915. Specifically, when the ambient light intensity is high, the display brightness of the display screen 905 is increased; when the ambient light intensity is low, the display brightness of the display screen 905 is reduced. In another embodiment, the processor 901 can also dynamically adjust the shooting parameters of the camera component 906 according to the ambient light intensity collected by the optical sensor 915.
[0372] The proximity sensor 916, also called a distance sensor, is usually arranged on the front panel of the terminal 900. The proximity sensor 916 is used to collect the distance between the user account and the front of the terminal 900. In one embodiment, when the proximity sensor 916 detects that the distance between the user account and the front of the terminal 900 is gradually decreasing, the processor 901 controls the display screen 905 to switch from the screen-on state to the screen-off state; when the proximity sensor 916 detects that the distance between the user account and the front of the terminal 900 is gradually increasing, the processor 901 controls the display screen 905 to switch from the screen-off state to the screen-on state.
[0373] Those skilled in the art will understand that Fig.18 The structure shown in the figure does not constitute a limitation on the terminal 900, and the terminal 900 may include more or less components than those shown in the figure, or combine some components, or adopt a different component arrangement.
[0374] The memory also includes one or more programs, which are stored in the memory and include programs for performing the audio processing method provided in the embodiment of the present application.
[0375] The present application also provides a computer device, which includes: a processor and a memory, wherein the storage medium stores at least one instruction, at least one program, a code set or an instruction set, and the at least one instruction, at least one program, a code set or an instruction set is loaded and executed by the processor to implement the audio processing method provided by the above-mentioned method embodiments.
[0376] The present application also provides a computer-readable storage medium, which stores at least one instruction, at least one program, code set or instruction set. The at least one instruction, at least one program, code set or instruction set is loaded and executed by a processor to implement the audio processing method provided by the above-mentioned method embodiments.
[0377] The present application also provides a computer program product or a computer program, which includes a computer instruction stored in a computer-readable storage medium. A processor of a computer device reads the computer instruction from the computer-readable storage medium, and the processor executes the computer instruction, so that the computer device executes the audio processing method provided in the above optional implementation.
[0378] It should be understood that the "plurality" mentioned in this article refers to two or more. "And / or" describes the association relationship of the associated objects, indicating that there can be three relationships. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the associated objects are in an "or" relationship.
[0379] A person skilled in the art will understand that all or part of the steps to implement the above embodiments may be accomplished by hardware or by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, and the above-mentioned storage medium may be a read-only memory, a disk or an optical disk, etc.
[0380] The above are only optional embodiments of the present application and are not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application should be included in the protection scope of the present application.
[0381] It should be noted that during the process of recording audio data, the present application can display a prompt interface, pop-up window or output voice prompt information. The prompt interface, pop-up window or voice prompt information is used to prompt the user that audio data is currently being recorded, so that the present application only starts to execute the relevant steps of recording audio data after obtaining the user's confirmation operation on the prompt interface or pop-up window, otherwise (that is, when the user's confirmation operation on the prompt interface or pop-up window is not obtained), the relevant steps of recording audio data are terminated, that is, the internally recorded audio is not obtained. In other words, the internally recorded audio collected by this application is collected with the user's consent and authorization, and the collection, use and processing of relevant data need to comply with the relevant laws, regulations and standards of relevant countries and regions.
Claims
1. An audio processing method, characterized in that: The method is executed by a terminal, and includes: splicing at least two pieces of data to obtain internally recorded audio; the at least two pieces of data are captured from a data stream required for the audio played by the terminal; Based on the fundamental frequency data of the internally recorded audio, the pitch data of the internally recorded audio is calculated, and the pitch data includes the pitch of the internally recorded audio at at least one time point or time period.
2. The method according to claim 1, characterized in that The step of calculating the pitch data of the internally recorded audio based on the fundamental frequency data of the internally recorded audio comprises: Performing frame processing on the internally recorded audio to obtain at least two frames of framed audio; Performing fundamental frequency analysis on each frame of the at least two frames of framed audio to obtain the fundamental frequency of each frame of the framed audio; Calculate the pitch of each frame of audio in the at least two frames of audio based on the fundamental frequency of each frame of audio in the at least two frames of audio; Based on the pitch of each frame of the at least two frames of the framed audio, the pitch data of the internally recorded audio is generated.
3. The method according to claim 2, characterized in that The performing fundamental frequency analysis on each frame of the at least two frames of the framed audio to obtain the fundamental frequency of each frame of the framed audio includes: Performing Fourier transform on each frame of the at least two frames of framed audio to obtain frequency domain data; Obtaining the peak point frequency corresponding to the peak point in the frequency domain data; The average value of the peak point frequencies is determined as the fundamental frequency.
4. The method according to any one of claims 1 to 3, characterized in that: The method further comprises: Based on the pitch data, a pitch animation effect of the internally recorded audio is displayed, wherein the pitch animation effect is used to indicate changes in pitch over time.
5. The method according to any one of claims 1 to 3, characterized in that: An application supporting a screen recording function is running on the terminal, and the method further includes: In response to the screen recording start operation, the following steps are performed simultaneously: Recording a screen image to obtain image data, wherein the image data includes at least one frame of the screen image arranged in time sequence; An audio visualization interface is called to capture the at least two segments of data in the data stream required by the terminal to play the audio.
6. The method according to claim 5, characterized in that The method further comprises: Displaying a screen recording editing interface, the screen recording editing interface including a preview area and a pitch effect adding control, the preview area is used to preview the screen recording file; the screen recording file is generated according to the image data and the internally recorded audio; In response to receiving a trigger operation of a pitch animation effect adding control, adding the pitch animation effect to the image data; Among them, the playing progress of the pitch animation effect in the screen recording file is consistent with the playing progress of the internally recorded audio.
7. The method according to any one of claims 1 to 3, characterized in that: The method further comprises: Automatically generate a music game file based on the pitch data and the internally recorded audio; Running the music game file, playing the internally recorded audio and the pitch animation effect; receiving a game operation, calculating a matching degree between the game operation and the pitch data, and obtaining a game score; The game operation includes: a first audio recorded through a microphone, and the matching degree includes a similarity between a pitch of the first audio and the pitch data.
8. The method according to any one of claims 1 to 3, characterized in that: The method further comprises: Using automatic speech recognition technology to perform speech recognition on the internally recorded audio to obtain a recognition result; A subtitle display file or a lyrics display file is generated according to the recognition result.
9. The method according to any one of claims 1 to 3, characterized in that: The step of splicing at least two pieces of data to obtain internally recorded audio includes: When playing the audio, capturing the at least two segments of data in the data stream required by the terminal to play the audio; Identifying a data duplication portion of the at least two segments of data; According to the location of the repeated portion of the data, the at least two segments of data are spliced to obtain the internally recorded audio.
10. The method according to claim 9, characterized in that The capturing of at least two segments of data in the data stream required by the terminal to play the audio includes: An audio visualization interface is called to capture the at least two segments of data in the data stream required by the terminal to play the audio.
11. The method according to claim 10, characterized in that The calling of the audio visualization interface to capture the at least two segments of data in the data stream required by the terminal to play the audio includes: Calling an audio visualization interface to capture the at least two segments of data in the data stream required by the terminal to play the audio according to a preset capture frequency; There is data duplication between two adjacent sampled data segments.
12. The method according to claim 9, characterized in that The step of identifying the data repetition part of the at least two segments of data comprises: For the at least two segments of data, using the first header data of the later sampled data as a search sample; Determine target data identical to the search sample data from the first sampled data; The second header data of the later sampled data is determined as the data repetition part; the data length of the second header data is equal to the data length from the target data to the tail of the earlier sampled data.
13. The method according to claim 12, characterized in that The first sampling data includes: first first sampling data adjacent to the second sampling data, and second first sampling data not adjacent to the second sampling data; The determining, from the first sampled data, target data identical to the search sample data comprises: When the target data does not exist in the first previous sampling data, the target data is determined from the second previous sampling data.
14. The method according to claim 13, characterized in that The step of splicing the at least two segments of data according to the location of the repeated portion of the data to obtain the internally recorded audio includes: The data after deleting the second header data in the later sampled data is concatenated with the tail of the second earlier sampled data.
15. An audio processing device, characterized in that: The device comprises: A splicing module, used for splicing at least two pieces of data to obtain internally recorded audio; the at least two pieces of data are captured from a data stream required for the audio played by the terminal; A pitch module is used to calculate the pitch data of the internally recorded audio based on the fundamental frequency data of the internally recorded audio, and the pitch data includes the pitch of the internally recorded audio at at least one time point or time period.
16. A computer device, characterized in that: The computer device includes: a processor and a memory, wherein the memory stores at least one instruction, at least one program, a code set or an instruction set, and the at least one instruction, the at least one program, the code set or the instruction set is loaded and executed by the processor to implement the audio processing method as described in any one of claims 1 to 14.
17. A computer-readable storage medium, characterized in that: The storage medium stores at least one instruction, at least one program, a code set or an instruction set, and the at least one instruction, the at least one program, the code set or the instruction set is loaded and executed by the processor to implement the audio processing method as described in any one of claims 1 to 14.
