Cool Audio Reminder script using MAC OS's text-to-speech
Cool Audio Reminder Script With MAC OS Text-to-speech Feature
Why#
We know that sitting for too long is harmful for our health ↗. My solution to this problem is to set up a friendly reminder using Mac OS X’s speech to text feature, and a bit of programming. So here we go:
Steps#
1). Create a reminder file under your home directory, for example,
$ vi ~/break_reminderbashStand up and walk around Your_Name.
Don't be lazy Your_Name, I know you can do it.
Stand up now, Your_Name, and do some exercises.
Sitting for too long is not healthy for you Your_Name.
Take a walk, get some water Your_Name.
You need a short break Your_Name.
Don't stick your butt to the chair for too long Your_Name.plaintextObviously change Your_Name to something that you want the voice to call you. This is one that I created, feel free to change the content.
2). Create the reminder shell script
$ vi ~/reminder.shbash#!/usr/bin/env bash
(( total_lines = $(wc -l < ~/break_reminder) )) && (( line = $RANDOM % $total_lines + 1 )) && sed -n ${line}p ~/break_reminder|saybash3). Run some dry tests by running
bash ~/reminder.shbash4). Add the reminder to crontab
crontab -ebash0 9-16 * * 1-5 bash ~/reminder.shbashThis will run the reminder script from 9am to 4pm hourly on the clock Monday through Friday. If you are new to crontab, refer to http://en.wikipedia.org/wiki/Cron ↗ for more details.
Notes#
- I tried putting the meat inside ~/reminder.sh directly into crontab, didn’t work, that’s why this extra script is needed.
- Feel free to change the env from bash to zsh in ~/reminder.sh, I have tested it to work with both bash and zsh.
- Personally I prefer Serena’s voice, you need to download it via these steps: Search for “Dictation & Speech” in the spotlight -> Tick “Text to Speech” -> Tick “Customize”, then “Serena” from System Voice dropdown, you will be prompted to download the voice file if it has not been downloaded before.
- The reminder (break_reminder) and script (reminder.sh) can be found in my github repository: https://github.com/midnightcodr/break_reminder ↗.