How to silence the first and last 0.5 seconds of multiple clips programatically

I am recording over 1,000 audio clips for an audio project. Unfortunately, most of these clips have a loud noise at the very start and very end. This noise is most likely me pressing the toggle button for recording.

I want to silence the first and last 0.5 seconds of each clip. I have already used PyAudacity to automate some things for this project, but I have come to a problem I’m having trouble solving on my own.

Each clip is unevenly sized. So I can’t do fixed intervals.

Would it be possible to program something like:

  1. Select the start of a clip (boundary)
  2. From there, select 0.5 seconds to the right
  3. Silence audio selection (Ctrl +L)
  4. Move the selection line to the end of the clip
  5. Silence 0.5 seconds to the left.
  6. Rinse and repeat?

I attempted to attach a screenshot because visual aid helps sometimes. If there’s any other factors you need to know if you are trying to help me, let me know.

NOTE: I don’t wish to add new silence to the clip. I want to silence the first and last 0.5 seconds of each clip.

NOTE: I have also tried the click removal tool to no avail. It either badly damages the quality of the audio or does not remove the starting click sounds well enough.

Hello! In the Audacity program, the cursor can be programmed to jump for at least 1 second, so cursor jumping for 0.5 seconds will not work. If you are satisfied with the silence of the sound at intervals of 1 second, then you can write such a macro as you need. But in your case I would apply Noise Gate. Set the appropriate threshold and it will automatically silence quiet areas. This is the easiest working solution

1 Like

Thank you for your response. Unfortunately, some of the recordings have vital parts that are about as loud as the extraneous noises. So I must go with the more complicated option.

I love problems like this.

If your clips are contiguous (as shown in your screen shot) the attached macro implements the steps in your first post.

Download the macro file and put it in the Audacity Macros folder. Location will vary by operating system; see Macros - Audacity Manual

From Tools > Macro Manager click “Import Macro” and import the “SilenceStartAndEnd” macro.

In Audacity > Preferences > Keyboard Shortcuts, apply a simple shortcut to the macro.

Start by placing the cursor at the start of the track.
Run the macro. The first clip should have the first and last 0.5 seconds silenced. The cursor should be at the start of the next clip.
Run the macro again and again until all clips have be processed.

SilenceStartAndEnd.txt (237 Bytes)

1 Like

Thank you so much Bill. This works as intended. There are only two obstacles left for me now:

Append one second of audio to the start and finish of each clip.
Export each audio clip with its label as its name.

That’s what I’ll be tackling tonight. Thank you again for helping me get this far.

I wrote yesterday that if you are satisfied with silence for 1 second, then you can easily use a macro. For example, the following:


Or, based on the standard Fade Ends macro, create your own for silence

And don’t wrack your brain how to rename files. Export them with Audacity, with the names they have now, then use mp3tag to batch rename based on the their tags in seconds

The attached macro will add one second the start and end of each clip.

To use it, first create a new track, generate 1 second of silence into that track, select the 1 second of silence, copy, then select the first track and move the cursor to the start of the track.

Then invoke the macro repeatedly.

AddOneSecond.txt (344 Bytes)