How to create a macro to automatically extend silences of variable duration?

Hi everyone, I’m new to Audacity and I have a time consuming task that I do manually and I don´t know if it can be done automatically with a macro or something else.

I have audio files with about 50 audio chunks separated by silence chunks of 2 seconds and the chunks of audio have a duration between 0.9 to 2 seconds (see image1). And my goal is make that each chunk of audio begins at specific time. For example

  • 1st audio → begins at 0 seconds
  • 2nd audio → begins at 10 seconds
  • 3rd audio → begins at 20 seconds
  • ..
  • .
  • Nth audio → begins at (N-1)x10 seconds

Below (Image 2) I show the waveform after I do a manually search of silence intervals with “Analyze–>Label Sounds” with -50 db of threshold and minimum silence duration of 1 second.

Now I need to do some calculations to know how many seconds I need to add just before the beginning of 2nd audio (that currently begins at 3.270 seconds) in order that 2nd audio begins at 10 seconds position.

This is,
10 - (start of audio2 - start of audio1) = 10 - (3.27-0) =10-3.27 = 6.73 → seconds to add before start of audio2

The same for audio 3 would be:
10 - (start of audio3 - start of audio2) = 10 - (6.26 - 3.27) = 10 - 2.99 = 7.01 → seconds to add before start of audio3

Doing this N-1 times I get the number of seconds I need to add before each audio. Then I manually do “Generate–>Silence” for each part with the corresponding value of seconds calculated previously and the audio output will look like image3 with each audio chunk beginning at 0, 10, 20, 30, …, etc.

I did a macro to found the silence chunks but I don’t know how to insert the number of seconds needed before the beginning of each audio chunk in order to get the goal I explained above. Is this possible?

Thanks in advance.

There is an ExtendSilence plugin,
(but I don’t think it will do the synchronize-to-10-second-intervals specification).

Thanks for answer. I’ve been reading the questions for that plugin. They ask for additional things and someone answers with some code to add to the pluging or in Nyquist console they say. I’ll need to ask in other subforum or in that thread you shared for my specific case?

That thread is over a decade old. The creator of the plugin is @steve who may respond here.

The way I would do this task:

  1. Use Label Sounds to create range labels around each sound.
  2. Export Multiple to export each labelled sound as a separate WAV file.
  3. Close and restart Audacity
  4. Import all of the individual sounds into the new empty project. They will be imported as separate tracks, one above the other.
  5. Select All
  6. Using the Selection toolbar, extend the selected region up to 10 seconds.
  7. Apply this code using the Nyquist Prompt
()
*track*

This will “render” each track, converting the selected empty spaces into silence.

  1. Select All.
  2. Align End to End
  3. Mix and Render
1 Like

Excellent and detailed answer. I was able to do it following your step by step answer. After doing it manually I tried to do the steps in a macro but I didn´t find the way to export the multiple sounds nor import multiple files. Not sure if the rest of steps can be done using a macro but for steps 2 and 4 I couldn´t do it. Thanks so much for the help.