A method, device, equipment and storage medium for cutting and restoring voice files
By setting the maximum silence time and minimum silence value to crop the invalid silence parts in the voice file, the word segmentation problem caused by the traditional voice cropping method is solved and the accuracy of voice analysis is improved.
Patent Information
- Application Number
- CN202011046908.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-09-29
- Publication Date
- 2024-08-27
- Estimated Expiration
- 2040-09-29
AI Technical Summary
Traditional speech clipping methods cannot guarantee the integrity of the word meaning of the clipped speech segments, resulting in word segmentation and affecting speech analysis results, such as keyword extraction and speech transcription.
By setting the maximum silence time and minimum silence value, obtain the invalid speech clips whose audio energy value is less than or equal to the minimum silence value in the original speech file, determine whether their duration is greater than the maximum silence time, and trim the invalid speech clips whose duration is greater than the maximum silence time. , eliminate invalid voice fragments, and sequentially splice valid voice fragments to restore the voice file.
This ensures the integrity of the speech fragments, avoids word segmentation, and improves the accuracy of speech analysis results.
Smart Images

Figure CN112185424B
Abstract
Description
Technical Field
[0001] The invention belongs to the field of voice processing, and in particular relates to a voice file cutting and restoring method, device, equipment and storage medium. Background Art
[0002] In speech analysis, in order to prevent the speech from being used for other purposes, the speech files need to be cropped. During speech analysis, the analysis system requires that the speech segments are complete. If the traditional speech cropping method is used, the integrity of the meaning of the speech segments after cropping cannot be guaranteed, and word breakage occurs, resulting in the inability to perform normal speech analysis on the sound segments, such as keyword extraction, speech transcription, etc. Summary of the invention
[0003] In view of the above problems, the present invention proposes a method for cutting and restoring a voice file, setting a maximum silence time and a minimum silence value;
[0004] Get the original audio file;
[0005] Obtain invalid speech segments in the original speech file whose audio energy value is less than or equal to the minimum silence value;
[0006] Determine whether the duration of the invalid voice segment is greater than the maximum silence time;
[0007] Trim the start and end points of invalid speech segments whose duration is greater than the maximum silence time;
[0008] Eliminate and trim invalid speech segments to obtain multiple valid speech segments;
[0009] Sequentially splice multiple valid voice segments to obtain a restored voice file.
[0010] Preferably, the setting of the minimum silence value specifically includes:
[0011] Collect the average energy value of the initial silent segment of the original voice file;
[0012] Set the minimum silence value equal to the average energy value.
[0013] Preferably, the setting of the minimum silence value specifically includes:
[0014] Collect the average energy value of the initial silent segment of the original voice file;
[0015] The average energy value is multiplied by a preset coefficient to obtain an empirical energy value;
[0016] Set the minimum silence value equal to the experience energy value.
[0017] Preferably, the step of obtaining an invalid speech segment in the original speech file whose audio energy value is lower than the minimum silence value comprises:
[0018] Sampling points are set at equal time intervals on the original voice file, and audio energy values are collected at the sampling points;
[0019] At least P consecutive audio energy values are greater than the minimum silence value, and at least Q consecutive audio energy values are less than or equal to the minimum silence value, there is no sampling point between the P sampling points and the Q sampling points, and the area between the P sampling points and the Q sampling points is the starting point of an invalid speech segment;
[0020] At least M consecutive audio energy values are less than or equal to the minimum silence value, and at least N consecutive audio energy values are greater than the minimum silence value, there is no sampling point between the M sampling points and the N sampling points, and the area between the M sampling points and the N sampling points is the end point of the invalid voice segment.
[0021] Preferably, P=Q=M=N.
[0022] Preferably, the step of obtaining an invalid speech segment in the original speech file whose audio energy value is lower than the minimum silence value comprises:
[0023] The original voice file is divided into multiple segmentation units with equal time intervals, each segmentation unit is set with multiple sampling points, and audio energy values are collected at the sampling points;
[0024] The average audio energy value in at least A consecutive segmentation units is greater than the minimum silence value, and the average audio energy value in at least B consecutive segmentation units is less than or equal to the minimum silence value. There is no segmentation unit between the A segmentation unit and the B segmentation unit, and the segment between the A segmentation unit and the B segmentation unit is the starting point of an invalid speech segment.
[0025] The average audio energy value in at least C consecutive segmentation units is less than or equal to the minimum silence value, and the average audio energy value in at least D consecutive segmentation units is greater than the minimum silence value, there is no segmentation unit between the C segmentation units and the D segmentation units, and the segmentation unit between the C segmentation units and the D segmentation units is the end point of the invalid voice segment.
[0026] Preferably, A=B=C=D.
[0027] Preferably, obtaining summary information of the original voice file;
[0028] Calculate and restore the summary information of the voice file;
[0029] Compare the summary information of the original voice file and the summary information of the restored voice file to see if they are the same.
[0030] Preferably, obtaining the length of the original voice file;
[0031] Calculate the length of the restored voice file, calculate the length of the invalid voice segment, and sum the length of the restored voice file and the length of the invalid voice segment;
[0032] Compare the length of the original voice file with the length of the restored voice file after summation and the length of the invalid voice segment to see if they are equal.
[0033] Preferably, the position information of the valid voice segments is obtained, and the valid voice segments are spliced based on the position information of the valid voice segments.
[0034] Preferably, the segment name of the valid voice segment is calculated, and the segment name is generated by performing an XOR operation on the current timestamp plus a multi-bit random number.
[0035] Preferably, the file name of the original voice file is obtained, and the file name is assigned to the restored voice file.
[0036] The present invention also provides a voice file cutting and restoring device, comprising:
[0037] The setting module is used to set the maximum silent time and minimum silent value;
[0038] A voice acquisition module is used to acquire the original voice file;
[0039] A segment acquisition module, which acquires invalid speech segments in the original speech file whose audio energy value is lower than the minimum silence value;
[0040] A judgment module is used to judge whether the length of the invalid voice segment is greater than the maximum silence time;
[0041] A trimming module, used for trimming the start and end points of the invalid speech segment to obtain a valid speech segment when the invalid speech segment is longer than the maximum silence time;
[0042] The restoration module is used to sequentially splice multiple valid voice segments to obtain a restored voice file.
[0043] The present invention also proposes a voice file cutting and restoring device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the method as described in any one of claims 1 to 10 when executing the computer program.
[0044] The present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 10 are implemented.
[0045] The voice file cutting and restoring method, device, equipment and storage medium of the present invention can identify the silent part in the voice file, and can cut from the silent part when cutting the voice, so as to ensure the integrity of the voice segment, avoid the phenomenon of word segmentation, and improve the accuracy of the voice analysis result.
[0046] Other features and advantages of the present invention will be described in the following description, and partly become apparent from the description, or understood by practicing the present invention. The purpose and other advantages of the present invention can be realized and obtained by the structures pointed out in the description, claims and drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0048] Figure 1 A flowchart of a method for cutting and restoring a voice file according to an embodiment of the present invention;
[0049] Figure 2 A flowchart of obtaining the starting point and end point of an invalid voice segment according to an embodiment of the present invention;
[0050] Figure 3 The figure is a schematic diagram of voice file cutting and restoration according to an embodiment of the present invention. DETAILED DESCRIPTION
[0051] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0052] The purpose of Voice Activity Detection (VAD) is to identify and eliminate long periods of silence from the sound signal stream, so as to save voice channel resources without reducing service quality. This embodiment is based on the pydub open source voice processing tool of the Python programming language and uses the VAD voice activation detection technology to trim voice files.
[0053] Reference Figure 1 The voice file cutting and restoring method in this embodiment includes the following steps.
[0054] First, the original voice file is obtained, which may contain one or more silent segments.
[0055] Configure the vad clipping parameter information, specifically set the maximum silence time (unit: milliseconds), that is, the maximum allowed silence duration, and set the minimum silence value dBSPL (sound pressure: SPL, Sound Pressure Levels). If the audio energy value is less than or equal to the minimum silence value, it is considered to be silence. If the audio energy value is greater than the minimum silence value, it is not considered to be silence.
[0056] Get the segments in the original voice file whose audio energy value is lower than the minimum silence value. The segments represent silence segments and need to be trimmed and deleted. The segments are identified as invalid voice segments. The original voice file often contains multiple invalid voice segments. By traversing the entire original voice file, multiple invalid voice segments are obtained.
[0057] Determine whether the duration of the invalid voice segment is greater than the maximum silence time. If the duration of the invalid voice segment is greater than the maximum silence time, the invalid voice segment will affect the subsequent voice analysis work, and the invalid voice segment needs to be cut out, so the starting point and end point of the invalid voice segment are cut and removed to obtain a valid voice segment; after all the invalid voice segments are cut out, multiple valid voice segments are obtained, and then multiple valid voice segments are sequentially spliced to obtain a restored voice file, and the restored voice file is sent to a predetermined storage location. If the duration of the invalid voice segment is less than or equal to the maximum silence time, the invalid voice segment will not affect the subsequent voice analysis work because it is too small, so the invalid voice segment can be retained.
[0058] The ideal silence energy value is 0, so the above minimum silence value is 0 under ideal conditions. However, there is often background sound of a certain intensity in the scene of audio collection. This pure background sound should be considered as silence, but its energy value is obviously not 0. Therefore, the background sound of the audio actually collected usually has a certain basic energy value.
[0059] Generally, the original voice files collected have a short silence at the beginning, which is usually several hundred milliseconds long. This short silence is the basis for estimating the minimum silence value. When estimating the minimum silence value, select a certain number of frames, such as the first 100 frames of voice data (these are "silence"), calculate their average energy value, and then add an empirical value or multiply by a coefficient greater than 1 to obtain the empirical energy value. Set the minimum silence value to be equal to the empirical energy value. This minimum silence value is the benchmark for judging whether a frame of voice is silent. A value greater than this value is valid voice, and a value less than or equal to this value is silence. Adding an empirical value or multiplying by a coefficient greater than 1 is not necessary. You can directly set the minimum silence value to be equal to the average energy value.
[0060] Alternatively, you can set the minimum silence value based on experience. The decibel range can be referenced as follows:
[0061] 0-20 decibels is very quiet and almost imperceptible;
[0062] 20-40 decibels, quiet, like a whisper;
[0063] 40-60 decibels is normal, for normal indoor conversation;
[0064] Listen to the current original voice file and select an appropriate minimum silence value based on experience, such as 22 decibels. This eliminates the need to collect and calculate the average energy value of a short silence at the beginning of the original voice file, thereby improving the efficiency of trimming and restoring.
[0065] The maximum silence time can be estimated based on experience and the length of the silence segment in the current original voice file to ensure that longer invalid voice segments are trimmed out.
[0066] To obtain invalid speech segments in the original speech file whose audio energy value is lower than the minimum silence value, you need to obtain the starting point and end point of the invalid speech segment. The starting point of the invalid speech segment is also the end point of the valid speech segment, and the end point of the invalid speech segment is also the starting point of the valid speech segment. Figure 2 , the acquisition of the starting point and the end point of the invalid voice segment specifically includes the following steps.
[0067] A speech segment is a one-dimensional continuous function with time as the independent variable. The speech data processed by the computer is a sequence of sampling values of the speech signal sorted by time. The size of these sampling values also represents the energy of the speech signal at the sampling point.
[0068] The audio energy value of a sampling point is usually the square of the sampling value. The audio energy value of a speech containing multiple sampling points can be defined as the sum of the squares of each sampling value. The average energy value of a speech containing multiple sampling points can be defined as the sum of the squares divided by the number of sampling points.
[0069] In this way, the audio energy value of a speech is related to both the size of the sampling value and the number of sampling points contained in it. In order to examine the change of the audio energy value, it is necessary to first divide the speech signal into fixed time lengths, such as 20 milliseconds. Each segmentation unit is called a frame, and each frame contains the same number of sampling points. Then, the average energy value of each frame of speech is calculated.
[0070] Traverse the entire audio segment to determine whether there are consecutive A frames with an average energy value greater than the minimum silence value. If not, move back 3 frames to continue the determination. If so, move to the next frame to determine whether there are consecutive B frames with an average energy value less than or equal to the minimum silence value. If not, if not, move back 3 frames to continue the determination. Determine whether there are consecutive C frames with an average energy value less than or equal to the minimum silence value. If not, if not, move back 3 frames to continue the determination. If so, move to the next frame to determine whether there are consecutive D frames with an average energy value greater than the minimum silence value. If not, if not, move back 3 frames to continue the determination.
[0071] If the average energy values of consecutive A frames are large and greater than the minimum silence value, and the average energy values of consecutive B frames are small and less than or equal to the minimum silence value, and there are no other frames between frames A and B, it can be considered that the space between frames A and B is the starting point of an invalid speech segment; similarly, if the average energy values of consecutive C frames are small and less than or equal to the minimum silence value, and the average energy values of consecutive D frames are large and greater than the minimum silence value, and there are no other frames between frames C and D, it can be considered that the space between frames C and D is the end point of an invalid speech segment.
[0072] The values of A, B, C and D may be equal or different from each other, depending on the adaptability of the current voice file.
[0073] By obtaining the starting and ending positions of the invalid voice segments in the voice file according to the above steps, the invalid voice segments in the voice file can be trimmed to obtain multiple complete valid voice segments.
[0074] There is another method for obtaining the starting point and the end point of the invalid voice segment, and the steps are as follows.
[0075] Sampling points are set at equal time intervals on the original voice file, and audio energy values are collected at the sampling points.
[0076] At least P consecutive audio energy values are greater than the minimum silence value, and at least Q consecutive audio energy values are less than or equal to the minimum silence value. There is no sampling point between the P sampling points and the Q sampling points. Any point between the P sampling points and the Q sampling points is the starting point of an invalid speech segment.
[0077] At least M consecutive audio energy values are less than or equal to the minimum silence value, and at least N consecutive audio energy values are greater than the minimum silence value. There is no sampling point between the M sampling points and the N sampling points. Any point between the M sampling points and the N sampling points is the end point of the invalid voice segment.
[0078] The values of P, Q, M and N may be equal or different from each other, depending on the adaptability of the current voice file.
[0079] The values of A, B, C, D, P, Q, M and N above determine the sensitivity of endpoint detection. The smaller the values of A, B, C, D, P, Q, M and N, the higher the sensitivity of start and end point detection, and vice versa. The sensitivity of start and end point detection should be set to different values in different voice application scenarios. For example, in the application of voice-controlled remote control, since voice commands are generally simple control commands, the possibility of long pauses such as commas or periods in the middle is very small, so it is reasonable to increase the sensitivity of endpoint detection. P, Q, M and N are set to smaller values, and the corresponding audio duration is generally about 200-400 milliseconds. In large-scale voice dictation applications, since there will be long pauses such as commas or periods in the middle, it is advisable to reduce the sensitivity of endpoint detection. At this time, the values of P, Q, M and N are set to larger values, and the corresponding audio duration is generally 1500-3000 milliseconds. Therefore, the values of A, B, C, D, P, Q, M and N should be made adjustable in practice, and their values should be selected according to the scenario of the voice application.
[0080] In order to realize the sequential splicing of multiple valid voice segments, it is necessary to record the time sequence of multiple valid voice segments, so an index file is created. The index file includes the position information of each valid voice segment. The position information is the sequential position of the valid voice segment in the entire original voice file. When restoring, multiple valid voice segments are sequentially spliced based on the position information.
[0081] In addition, the index file also includes the segment name of each valid voice segment. The segment name is generated by XOR operation of the current timestamp plus a 6-digit random number. The number of random numbers can be set according to actual conditions to ensure the uniqueness and randomness of the valid voice segment.
[0082] Furthermore, it is necessary to verify the restored voice file to see whether the length of the restored voice file is correct and whether there is any missing content in the restored voice file.
[0083] First, obtain the length of the original voice file, then calculate the length of the restored voice file and the length of the invalid voice segment, sum the length of the restored voice file and the length of the invalid voice segment, and compare whether the length of the original voice file is equal to the summed length of the restored voice file and the length of the invalid voice segment. If they are equal, there is no lost voice segment. If they are not equal, it means that the voice segment is lost and needs to be checked.
[0084] Regarding verifying whether the restored voice file has any missing content, first obtain the summary information of the original voice file, then calculate the summary information of the restored voice file, and compare whether the summary information of the original voice file and the summary information of the restored voice file are the same. If they are the same, it means that the restored voice file has no missing content. If they are different, it means that the restored voice file has lost content.
[0085] Therefore, the index file also includes the length of the original voice file and the summary information of the original voice file, which is convenient for verifying the restored voice file.
[0086] In addition, the index file also includes the file name of the original voice file. When the restored voice file is generated, the file name is assigned to the restored voice file.
[0087] The embodiment of the present invention further provides a voice file cutting and restoring device, comprising:
[0088] The setting module is used to set the maximum silent time and minimum silent value;
[0089] A voice acquisition module is used to acquire the original voice file;
[0090] A segment acquisition module, which acquires invalid speech segments in the original speech file whose audio energy value is lower than the minimum silence value;
[0091] A judgment module is used to judge whether the length of the invalid voice segment is greater than the maximum silence time;
[0092] A trimming module, used for trimming the start and end points of the invalid speech segment to obtain a valid speech segment when the invalid speech segment is longer than the maximum silence time;
[0093] The restoration module is used to sequentially splice multiple valid voice segments to obtain a restored voice file.
[0094] An embodiment is given below to illustrate the method for cutting and restoring a voice file.
[0095] The path of the original voice file and the output path of the restored voice file are input into the voice file cutting and restoring device.
[0096] The voice acquisition module acquires the original voice file based on the path of the original voice file, and acquires the file name, summary information and length of the original voice file.
[0097] Create an index file, which includes the file name, summary information and length of the original voice file. Store the index file, which is saved in a JSON data structure.
[0098] The index file structure is as follows:
[0099]
[0100]
[0101] Set the maximum silence time to 1000 milliseconds.
[0102] Collect a short silence at the beginning of the original voice file, select the first 100 frames of voice data, calculate its average energy value as 22 decibels, and then multiply 22 decibels by 1.2 to get an empirical energy value of 26.4, so set the minimum silence value to 26.4.
[0103] Sampling points are set at equal time intervals on the original voice file, with a time interval of 20 milliseconds, and audio energy values are collected at the sampling points. If at least 5 consecutive audio energy values are greater than the minimum silence value of 26.4, and at least 5 consecutive audio energy values are less than or equal to the minimum silence value of 26.4, and there is no sampling point between the 5 sampling points where the audio energy values are greater than the minimum silence value of 26.4 and the 5 sampling points where the audio energy values are less than or equal to the minimum silence value of 26.4, then the middle position of these 10 sampling points is the starting point of the invalid voice segment;
[0104] At least 5 consecutive audio energy values are less than or equal to the minimum silence value 26.4, and at least 5 consecutive audio energy values are greater than the minimum silence value 26.4. There are no sampling points between the 5 sampling points where the audio energy values are less than or equal to the minimum silence value 26.4 and the 5 sampling points where the audio energy values are greater than the minimum silence value 26.4. The middle position of these 10 sampling points is the end point of the invalid speech segment.
[0105] Reference Figure 3, traverse the entire original voice file, obtain four invalid voice segments ab, cd, ef, and gh, calculate the duration of the four silent segments ab, cd, ef, and gh respectively, and then compare the duration of the four silent segments ab, cd, ef, and gh with the maximum silence time of 1000 milliseconds respectively, and obtain that the duration of the ab silent segment is less than 1000 milliseconds, the duration of the cd silent segment is greater than 1000 milliseconds, the duration of the ef silent segment is greater than 1000 milliseconds, and the duration of the gh silent segment is less than 1000 milliseconds. In this case, the ab and gh silent segments should be retained, and the cd and ef silent segments should be cut out. Therefore, the pydub module is referenced to cut at the four positions c, d, e, and f, and the invalid voice segments cd and ef are separated from the original voice file. The invalid voice segments cd and ef are removed to obtain three valid voice segments jc, de, and fk. The segment names and position information of the three valid voice segments are calculated respectively, and the segment names and position information of the three valid voice segments are stored in the index file.
[0106] At the same time, multiple voice files are cropped and restored. In order to prevent confusion between different voice files, or to restore multiple valid voice segments after obtaining them instead of immediately restoring them but after a period of time, it is necessary to temporarily store the cropped valid voice segments. Therefore, three valid voice segments and index files are stored.
[0107] During restoration, firstly, three valid voice segments and the storage path of the index file are inputted into the voice file cutting and restoring device, the three valid voice segments and the index file are called out, and the three valid voice segments are sequentially spliced based on the position information of the three valid voice segments to obtain the restored voice file.
[0108] Calculate the summary information of the restored voice file, compare the summary information of the restored voice file with the summary information in the index file, and determine whether the restored voice file has any missing content.
[0109] Calculate the length of the restored voice file and the length of the invalid voice segment, sum the length of the restored voice file and the length of the invalid voice segment, compare the length in the index file with the summed length of the restored voice file and the length of the invalid voice segment to see if they are equal, and determine whether there is any missing voice segment.
[0110] If the restored voice segment passes the comparison, the restored voice file is saved in the output path of the restored voice file.
[0111] An embodiment of the present invention provides a voice file cutting and restoring device, comprising: a processor, a memory, and a computer program stored in the memory and executable on the processor, such as a voice file cutting and restoring program. When the processor executes the computer program, the steps in the above-mentioned voice file cutting and restoring method embodiment are implemented, or when the processor executes the computer program, the functions of each module / unit in the above-mentioned device embodiments are implemented.
[0112] Exemplarily, the computer program may be divided into one or more modules / units, which are stored in the memory and executed by the processor to implement the present invention. The one or more modules / units may be a series of computer program instruction segments capable of implementing specific functions, which are used to describe the execution process of the computer program in the cutting and restoring device.
[0113] The voice file cutting and restoring device may be a computing device such as a desktop computer, a notebook, a PDA, and a cloud server. The voice file cutting and restoring device may include, but is not limited to, a processor and a memory. For example, the voice file cutting and restoring device may also include an input and output device, a network access device, a bus, etc.
[0114] The processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor, etc. The processor is the control center of the voice file cutting and restoring device, and uses various interfaces and lines to connect various parts of the entire voice file cutting and restoring device.
[0115] The memory can be used to store the computer program and / or module, and the processor realizes various functions of the voice file cutting and restoring device by running or executing the computer program and / or module stored in the memory, and calling the data stored in the memory. The memory can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area can store data created according to the use of the mobile phone (such as audio data, a phone book, etc.), etc. In addition, the memory can include a high-speed random access memory, and can also include a non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.
[0116] If the module / unit integrated in the voice file cutting and restoring device is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present invention implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electrical carrier signal, telecommunication signal and software distribution medium, etc. It should be noted that the content contained in the computer-readable medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media does not include electrical carrier signals and telecommunication signals.
[0117] Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent substitutions for some of the technical features therein; and these modifications or substitutions do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for cutting and restoring a voice file, characterized in that: Set the maximum silent time and set the minimum silent value; Get the original audio file; Obtain invalid speech segments in the original speech file whose audio energy value is less than or equal to the minimum silence value; Determine whether the duration of the invalid voice segment is greater than the maximum silence time; Trim the start and end points of invalid speech segments whose duration is greater than the maximum silence time; Eliminate and trim invalid speech segments to obtain multiple valid speech segments; Sequentially splice multiple valid voice segments to obtain restored voice files, and verify the content of the restored voice files; The process of sequentially splicing multiple valid voice segments to obtain a restored voice file includes: Create an index file and record the location information of each valid voice segment in the index file; According to the position information of each valid voice segment, multiple valid voice segments are sequentially spliced to obtain a restored file; The position information of each valid voice segment is the sequential position of each valid voice segment in the entire voice file; the index file includes the segment name of each valid voice segment, which is generated by XOR operation of adding a few random digits to the timestamp in front of the segment name; Verify the contents of the restored voice file, including Get the summary information of the original audio file; Calculate and restore the summary information of the voice file; Compare the summary information of the original voice file and the summary information of the restored voice file to see if they are the same.
2. The reduction method according to claim 1, characterized in that: The setting of the minimum silence value specifically includes: Collect the average energy value of the initial silent segment of the original voice file; Set the minimum silence value equal to the average energy value.
3. The reduction method according to claim 1, characterized in that: The setting of the minimum silence value specifically includes: Collect the average energy value of the initial silent segment of the original voice file; The average energy value is multiplied by a preset coefficient to obtain an empirical energy value; Set the minimum silence value equal to the experience energy value.
4. The reduction method according to any one of claims 1 to 3, characterized in that: The step of obtaining an invalid speech segment in the original speech file where the audio energy value is lower than the minimum silence value comprises: Sampling points are set at equal time intervals on the original voice file, and audio energy values are collected at the sampling points; At least P consecutive audio energy values are greater than the minimum silence value, and at least Q consecutive audio energy values are less than or equal to the minimum silence value, there is no sampling point between the P sampling points and the Q sampling points, and the area between the P sampling points and the Q sampling points is the starting point of an invalid speech segment; At least M consecutive audio energy values are less than or equal to the minimum silence value, and at least N consecutive audio energy values are greater than the minimum silence value, there is no sampling point between the M sampling points and the N sampling points, and the area between the M sampling points and the N sampling points is the end point of the invalid voice segment.
5. The reduction method according to claim 4, characterized in that: P=Q=M=N.
6. The reduction method according to any one of claims 1 to 3, characterized in that: The step of obtaining an invalid speech segment in the original speech file where the audio energy value is lower than the minimum silence value comprises: The original voice file is divided into multiple segmentation units with equal time intervals, each segmentation unit is set with multiple sampling points, and audio energy values are collected at the sampling points; The average audio energy value in at least A consecutive segmentation units is greater than the minimum silence value, and the average audio energy value in at least B consecutive segmentation units is less than or equal to the minimum silence value. There is no segmentation unit between the A segmentation unit and the B segmentation unit, and the segment between the A segmentation unit and the B segmentation unit is the starting point of an invalid speech segment. The average audio energy value in at least C consecutive segmentation units is less than or equal to the minimum silence value, and the average audio energy value in at least D consecutive segmentation units is greater than the minimum silence value, there is no segmentation unit between the C segmentation units and the D segmentation units, and the segmentation unit between the C segmentation units and the D segmentation units is the end point of the invalid voice segment.
7. The reduction method according to claim 6, characterized in that: A=B=C=D.
8. The reduction method according to any one of claims 1 to 3, 5 and 7, characterized in that: Get the length of the original voice file; Calculate the length of the restored voice file, calculate the length of the invalid voice segment, and sum the length of the restored voice file and the length of the invalid voice segment; Determine whether the length of the original voice file is equal to the summed result.
9. The reduction method according to any one of claims 1 to 3, 5 and 7, characterized in that: The location information of the valid voice segments is obtained, and the valid voice segments are spliced based on the location information of the valid voice segments.
10. The reduction method according to any one of claims 1 to 3, 5 and 7, characterized in that: Calculate the segment name of the valid voice segment. The segment name is generated by XOR operation of the current timestamp plus a multi-bit random number.
11. The reduction method according to any one of claims 1 to 3, 5 and 7, characterized in that: Get the file name of the original voice file and assign the file name to the restored voice file.
12. A voice file cutting and restoring device, characterized in that: include: The setting module is used to set the maximum silent time and minimum silent value; A voice acquisition module is used to acquire the original voice file; A segment acquisition module, which acquires invalid speech segments in the original speech file whose audio energy value is lower than the minimum silence value; A judgment module is used to judge whether the length of the invalid voice segment is greater than the maximum silence time; A trimming module, used for trimming the start and end points of the invalid speech segment to obtain a valid speech segment when the invalid speech segment is longer than the maximum silence time; The restoration module is used to sequentially splice multiple valid voice segments to obtain a restored voice file and verify the content of the restored voice file; The process of sequentially splicing multiple valid voice segments to obtain a restored voice file includes: Create an index file and record the location information of each valid voice segment in the index file; According to the position information of each valid voice segment, multiple valid voice segments are sequentially spliced to obtain a restored file; The position information of each valid voice segment is the sequential position of each valid voice segment in the entire voice file; the index file includes the segment name of each valid voice segment, which is generated by XOR operation of adding a few random digits to the timestamp in front of the segment name; Verify the contents of the restored voice file, including Get the summary information of the original audio file; Calculate and restore the summary information of the voice file; Compare the summary information of the original voice file and the summary information of the restored voice file to see if they are the same.
13. A voice file cutting and restoring device, characterized in that: The method comprises a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the method according to any one of claims 1 to 11 when executing the computer program.
14. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 11 are implemented.
