Notice: This code and the corresponding google API have changed several times since this was first published. It is currently not stable, so do not rely on this being reliable or even working. I will try and remedy the stability of it, but currently this is low on my list of priorities.
Get on the bus
Google calendar makes sweet love to your alarm clock
(Inspired from Raspberry Pi as a Google Calender Alarm Clock)
This year, my kids started riding the school bus, which is super convenient and means I don't have to spend extra time getting them to school. That is, if they make the bus. Sometimes they lose track of time, and I wanted a pretty reliable way of reminding them when it's time to go outside to wait for the big yellow limousine to escort them to school.
Since I am lazy, I decided to have this automated, which uses (ideally) a Raspberry Pi and Google Calendar to check for events that start with 'say' or have corresponding mp3 titles.
- An event titled
say Don't forget to brush your teethwill announce the phrase 'Don't forget to brush your teeth'.
- An event with the title
Get on the busfires an appropriately annoying song snippet from the mp3s folder by The Doodlebops called
It's dynamic in the sense that it will try and play any mp3 with the event title, and falls back to a default mp3 (my default.mp3 is an old school Nokia ringtone-- of course, you can make yours anything you wish).
If you're on Linux, you can install
sudo apt-get install mpg123
If you're on OS X, you can install
brew install mpg123
Or you can download the source and run:
./configure make make install
Pre-requisite for Linux text to speech:
sudo apt-get install espeak
Install the requirements:
pip install -r requirements.txt
Create a new project on the Google Developers Console
Enable the Calendars API
Create the file
Create new Client ID for standalone application and download the JSON as
CLIENT_SECRET_FILE = 'client_secrets.json'in
Create a new key for browser application and set the
API KEYvalue as
API_KEY = xxxin
Create a new Google calendar and set the ID as
CALENDAR_ID = xxxin
config.py(Click drop-down arrow by calendar name; choose 'Calendar Settings'; find ID by 'Calendar Address' section)
FREQUENCY_CHECK(in seconds) and
Run the program:
All new events will try to play the name of the event as an mp3 file in the
mp3s folder with spaces converted to underscores, i.e.:
Get on the bus ==
If the event has no corresponding mp3 file,
default.mp3 will play. To have the sound play repeatedly until the event's time expires, enter
repeat as the event's description.
API_KEY = '123456789qwertyuiop987654321asdfghjkl54321' CALENDAR_ID = 'email@example.com' CLIENT_SECRET_FILE = 'client_secrets.json' FREQUENCY_CHECK = 5 # in seconds MP3_FOLDER = 'mp3s'