Audacity has a few tools for this kind of thing.
-
The Envelope Tool (though personally I find this tool far too fiddly for more than occasional use)
-
The Adjustable Fade effect: https://manual.audacityteam.org/man/adjustable_fade.html
I find that the presets in this effect are sufficient in most cases. -
The Auto Duck effect: https://manual.audacityteam.org/man/auto_duck.html
Very handy when doing a lot of “ducking”.