Shopping Cart

No products in the cart.


Shopping Cart

No products in the cart.

Kevin Elgan
April 14, 2020

Day 14: Musical Alarms

On day 14 of our 30-day skill challenge, we continue learning about date and time to build a Chatterbox alarm clock!

Let's continue our journey with time to learn how we can teach Chatterbox to wake you up to your favorite song.

What's the difference between a timer and alarm?

While a timer is for a specific duration of time, alarms will alert you when the system date/time matches your "wake up" time.

Just in the previous timer skill, the mechanism for both timers and alarms are the same: date/time objects. But in practice there are a couple subtle differences.

Building an Alarm

Since, alarms and timers are essentially the same building blocks, we are going to look at our timer code as a starting point and build out our alarm skill from there.

You can duplicate your Timer skill by right-clicking on the On Phrases block and clicking duplicate.

Let's start with how we'll be asking for an alarm. You might say "Set an alarm for 7am" or "Wake me up at 7am." Instead of the duration variable, we'll need a "time" variable. After these changes, your skill should look like this:

Now the general actions inside the Listen block that are needed are the same, but the variables, event name and speech needs to be altered. We'll now be extracting date from "time" instead of "duration."

It's also good practice to name the event, so we can call this alarm. The When slot will remain the same with Extracted_date.

Last of all, we need to program the action that we want. We'll be using a Speak block to speak a custom wake up message, then we'll be using the Play Audio block to play your favorite song from Youtube.

Inside the Schedule Event block should look similar to this:

The Speak block will speak a custom wake up message while the Play Audio

For this skill, we'll be waking up to Viva la Vida by Coldplay https://www.youtube.com/watch?v=dvgZkm1xWPE

Last step will be to acknowledge the user that the alarm has been set.

Let's put it all together

Your skill should look something similar to the following:

How do you turn off the alarm?

Chatterbox has a couple very basic skills to make it easier for you. There are built-in welcome skills, volume skills, and a Stop skill. To turn off the alarm, push the big yellow button and say "Stop" and Chatterbox will stop the current action.

Get a 10% discount code when you sign up for our newsletter!

The educational smart speaker to teach kids about coding, artificial intelligence and privacy.
powered by Mycroft
linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram