
SoX: How to Add Fade-In & Fade-Out to Audio
Updated
Add a smooth five-second fade-in and fade-out to an audio file using SoX

Before we start, make sure you have SoX installed on your computer and an audio file ready to edit, like a WAV file.
First, open your terminal and navigate to the folder where your audio file is saved using the cd command.
Next, run this command to apply a five-second fade to the beginning and end of your track:
sox input.wav output.wav fade h 5 0 5
Just swap input.wav with your actual file name and output.wav with whatever you want to name the finished file.
In this command, the h gives you a smooth, natural-sounding curve, and the 0 tells SoX to automatically find the end of your audio so you don't have to look up its exact length.
Once you hit enter, SoX will process the file (this happens almost instantly for short clips), while longer recordings might take a few seconds.
To confirm everything sounds right, test your new file directly in the terminal by running play output.wav, or open it in your regular media player to hear the transitions.
If your audio clip is shorter than ten seconds, lower those 5 values so the fade-in and fade-out don't overlap in the middle.
