Code Monkey home page Code Monkey logo

get-on-the-bus's Introduction

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.

For example:

  1. An event titled say Don't forget to brush your teeth will announce the phrase 'Don't forget to brush your teeth'.
  2. An event with the title Get on the bus fires an appropriately annoying song snippet from the mp3s folder by The Doodlebops called get_on_the_bus.mp3.

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).

Pre-requisite: mpg123

  • If you're on Linux, you can install mpg123 via apt-get:

    sudo apt-get install mpg123
  • If you're on OS X, you can install mpg123 via Homebrew:

    brew install mpg123
  • Or you can download the source and run:

    ./configure
    make
    make install

Pre-requisite for Linux text to speech: espeak

sudo apt-get install espeak
  1. Install the requirements:

     pip install -r requirements.txt
    
  2. Create a new project on the Google Developers Console

  3. Enable the Calendars API

  4. Create the file config.py

  5. Create new Client ID for web application and download the JSON as client_secrets.json and set CLIENT_SECRET_FILE = 'client_secrets.json' in config.py

  6. Create a new key for browser application and set the API KEY value as API_KEY = xxx in config.py

  7. Create a new Google calendar and set the ID as CALENDAR_ID = xxx in config.py (Click drop-down arrow by calendar name; choose 'Calendar Settings'; find ID by 'Calendar Address' section)

  8. Add FREQUENCY_CHECK (in seconds) and MP3_FOLDER location in config.py.

  9. Run the program: python alarm.py

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 == mp3s/get_on_the_bus.mp3

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.

Example config.py file:

API_KEY = '123456789qwertyuiop987654321asdfghjkl54321'
CALENDAR_ID = '[email protected]'
CLIENT_SECRET_FILE = 'client_secrets.json'
FREQUENCY_CHECK = 5 # in seconds
MP3_FOLDER = 'mp3s'

get-on-the-bus's People

Contributors

ehamiter avatar epochblue avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.