Is it possible to convert a mp4 file to mp3 or flac, clearing background noises in the process?
Or is it possible to run audacity totally trough shell, No GUI?
If the background noise has some repetitive structure to it, you can remove it with the noiseprof and noisered effects of sox, see e.g. this script. Relevant bits repeated for convenience:
# Create background noise profile from mp3
/usr/bin/sox noise.mp3 -n noiseprof noise.prof
# Remove noise from mp3 using profile
/usr/bin/sox input.mp3 output.mp3 noisered noise.prof 0.21
Audacity currently has experimental scripting support.