How to remove silences which are shorter than X seconds

I want to remove silences which are smaller than 2 sec, but currently there is no setting in “Truncate Silence” for Maximum limit of silence. Did “Truncate Silence” once had a Max limit for duration of silence to be detected?
https://forum.audacityteam.org/t/how-to-remove-very-short-bouts-of-silence-successfully/21183/9
Is that version available now? I’m using Audacity-Win 2.2.2
Thanks

What’s the job? Doing that to normal speech will turn announcing into one long word with big gaps in it here and there. So you must have a special application.

And the special application may be the reason it doesn’t already exist.

Koz

I’m using “Extend Silences” plug-in to separate segments of a talk and insert longer pauses (proportional to the previous sound duration) so I can use that audio for listen-and-repeat practice. The problem is that whatever threshold you set, there are always some parts of the audio which are dividing to very short segments and actually making it harder to comprehend. If I could remove just those very short silences (not all of them) the result would be much more acceptable.

Use the “Truncate Silence” effect (see: Truncate Silence - Audacity Manual)
Select “Truncate Detected Silence” as the “Action”, and truncate to “0.0”

I’ve tried it before, as I said I’m looking for a way to remove JUST those silences which are smaller than 2 seconds. But the duration value for “Truncate Silence” is the minimum duration and every silence longer than that (not shorter) would be deleted.

As it says in the manual: Truncate Silence - Audacity Manual

Detect Silence

There are two controls that determine which audio will be treated as “silence”:

  1. Level (dB): To be treated as silence, the audio must be below this level. If not enough silences are being reduced, increase the level to a higher (less negative) number. Note that due to rounding, audio may be truncated that appears in the Amplify effect to be exactly at the level you enter here.
  2. Duration (seconds): The minimum duration that will be treated as silence. > To be treated as silence, the audio must remain below the “Level (dB)” entered for at least this amount of time. If not enough silences are being reduced, reduce this duration level. The shortest duration value you can enter is 0.001 seconds.

Steve, as it says clearly any silence which lasts at least for the amount of time we set, will be detected and truncated. Can you modify the “Truncate Silence” code so a maximum duration for silence detection can also be set?
I’ve tested it before posting this topic, and made this sample just for you. Here I want to truncate only those silences which are smaller than 2sec (those two 1sec silences). Set the duration 2sec and truncate to 0sec and see what happens.
Before:

After:


Doh! My mistake, you said that right at the start.
No, Audacity does not provide a way to do that, and as far as I’m aware the Truncate Silence effect has never provided that option.

One possible workaround is that you can “shield” some parts of the recording from being truncated by generating some sound into another track to overlap the parts that you don’t want truncated. For example, to truncate only the 4th gap in the stereo track below, I have generated tones into a mono track that overlap the other gaps:
tracks000.png
Then, selecting both tracks and applying Truncate Silence, the first three gaps and the final three gaps are “shielded” by the tones in the mono track:
tracks001.png

Could you take a look at it’s code? The current duration is actually the minimum duration for detecting a silence, so maybe the “maximum duration” option can be added in the same way without much effort.

It’s a bit more complex than that. There must be a minimum duration that is not truncated, otherwise you will lose small bits of audio at every zero crossing point. Also, because “silence” is defined as “audio below a given threshold”, we generally don’t want to truncate very small sections that are below the threshold as doing so will clip the ends of words in voice recordings, or natural pauses in music recordings. In virtually all practical use cases there needs to be a minimum duration that is not truncated.

As a practical effect, the “extra control” that you are requesting would need to be “ignore spaces bigger than…” while still retaining a smaller “ignore spaces smaller than…”.

As this is a built-in effect it is not simple to make a custom version of the effect. The code would need to be modified, and then rebuild Audacity from the source code.

It would probably be relatively simple to create a Nyquist Plug-in that removes ONE silence from the selected audio, but removing multiple silences from a long track will be problematic due to the memory management limitations of Nyquist plug-ins.

Here’s a way you can do it.

The attached plug-in will mark silences that are:

  • Below the threshold level
  • Longer than “Minimum duration of silence”
  • Shorter than “Maximum duration of silence”

This effect will be very slow on long audio selections.
The effect returns a maximum of 1000 labels.
For stereo tracks, the effect analyzes a mono mix of the selected audio.

When the sections have been marked, you can use “Edit Menu > Labeled Audio > Delete” to remove the labelled silences (https://manual.audacityteam.org/man/edit_menu_labeled_audio.html#delete)
shortsilencemarker.ny (1.73 KB)

Wow! I kind of gave up on this after my last post here and tried to solve it in a different way. But that plugin you kindly uploaded is really working! I should try it’s different settings but surely this can help a lot.

This is a very useful tip and should be considered when playing with the settings in your “Label Short Silences” plug-in.

And just for the record, my other workaround was like this:

  1. Extend Silence with an appropriate threshold (for example -40db)
  2. Find long chunks of sound with “Sound Finder ML” plug-in (for example longer than 5sec)
  3. Truncate Silences after those chunks to prevent creating extra silence in the next step (more than 5sec in this case)
  4. Go over the labeled chunks of the sounds from the end toward the beginning with “Sync-Locks On” and use Extend Silence on them with a higher threshold (for example -30db)

Thanks a lot