How to automate the replacement of pauses with noise with "silence" of my own?

Below is a primitive yet working Python script I’ve finally come up with after some more trial and error, with huge back-and-forth support from Deepseek AI.

Download the script

Basically, it creates a macro named Room Tone.txt to be run from Audacity to (semi-)automate the track import, selection, copying, and pasting operations. But first, you’ll need to:

The script needs some tweaking hear and there, particularly some manual work with label fixing, file names and paths, your job priorities, etc., but it works okay.

How Script Works

  1. Import Files:

    • The room tone file (pause.wav) is imported into Audacity.
  2. Select and Copy Room Tone:

    • The room tone track (track 1) is selected.
    • The SelTrackStartToEnd command selects the entire duration of the room tone track.
    • The Copy command copies the selected room tone to the clipboard.
    • The room tone track is then deleted since it’s no longer needed.
  3. Replace Pauses:

    • For each pause defined in labels.txt, the macro:
      • Extends and shortens the start and end of each label to avoid possible overlaps. You can also experiment with crossfading, as pointed here.
      • Selects the pause in the main track.
      • Deletes the pause.
      • Pastes the room tone in its place.
  4. Save the Project:

    • The Export2 command saves the project as audio_edited.wav in the same directory as the original audio.wav file.

Hope it helps!