Activate code on sound

Hi All,

I am trying to get my computer to run a script when a sound above a volume threshold is made. Unfortunately, I don’t know what commands I need to make that happen. Could anyone tell me what I need to do?



In vanilla AppleScript you can do that only with an AppleScript stay-open applet using the on idle handler

something like this, the code checks the output volume every 2 seconds

property threshold : 25

on idle
	set {output volume:currentOutputVolume} to (get volume settings)
	if currentOutputVolume > threshold then
		-- do something
	end if
	return 2
end idle


Are you looking for something to happen from a sound input. i.e mic. or as Stefan has answered.


Thanks for the suggestion, Stefan, but I am really looking for something from mic input. I might be able to modify your suggestion to get to something that would work for me, but what I really want is that if an ambient sound from somewhere in the room is above a certain threshold, the computer will respond by launching another script.