This takes a microphone input, takes its absolute value (that’s the general procedure for any amplitude-follower), puts out its peak value every millisecond and checks if it’s above a certain level (in this case 0.2) or below a certain different level (in this case 0.03). Using -two- thresholds like that, in contrast to only one, makes the whole thing "flicker" a bit less. I.e. you need a somewhat higher amplitude to trigger it to ON, after which it stays ON until it actually gets -significantly- quieter.
Often, you’ll also want to expand this a bit, for example you might consider adding a minimum time for the toggle to stay on after it has been activated, before it can be deactivated again. (Again, to reduce possible "flickering" of the toggle when you’re dealing with certain sounds that rise and fall quickly in amplitude.)