I am interested in using my old MacBook as an audio baby monitor. My imagined workflow is to set a noise threshold for the internal microphone in the MacBook when baby is stirring or whining and to use Messages to text me or my wife when the threshold is reached.
When I'm looking in System Preferences, I can see the Input level
for the microphone is picking up noise, but how can I get a quantifiable number in Terminal?
I've seen online about osascript -e "get volume settings"
to access a numeric value for how sensitive the microphone should be set, but I can't find a way to access how loud of an input is coming in at any given time.
Any ideas out there?
Best Answer
Using command line tools you can do the following:
Install portaudio, ffmpeg and all dependencies with brew
Install pip by downloading get-pip.py (direct link) and executing
Install soundmeter
Run soundmeter. To get help use the -h switch:
Simply running
soundmeter
will output an RMS value. After defining a threshold you can trigger a shell script action (which may itself trigger an AppleScript script) with the -e switch.Entering
soundmeter --segment 0.1 --log
watching online TV (climate change and coffee farming in Colombia - the end of Arabica beans) will show something like:Just to confirm: that's the microphone input level and not the sound level of the TV stream because the above installation runs in a VM guest and the TV stream on the hosting Mac - tested but not logged with some clapping which will increase the RMS to values above 200!
To send a message after a triggering event do the following - change
<user_name>
to your OS X short username and<telephone_number>
to an appropriate telephone number below:Create a dir and change to it:
Create an AppleScript:
with the content:
Create a shell script:
with the content:
and change the permissions:
Now start soundmeter with a command like this:
This should send a message to your (iPhone) telephone number. Please note that you can't send an iMessage to yourself. Sending it to an alias may work. Other similar (Apple)scripts are available here: How to send an imessage text with applescript, only in provided service?