Equipping Alexa with self-programmed skills
More than a Word
Asking Alexa only for built-in functions like the weather report gets old quickly, and add-on skills from the skills store only go so far. With a few lines of code, Mike teaches this digital pet some new tricks.
Okay, I admit, I don't like getting up from the sofa to check out something on the Internet if my phone is out of reach. But who does? In the household of the future, a device like Amazon's Echo will be around to help you with things like this in the form of a tin can in the living room. The Amazon Echo Dot, which looks much like a hockey puck (Figure 1), is the successor to the tin-can-like Echo device and offers the same voice interface at a lower price point.
Amazon's dream, of course, might be that customers at home will just shout "Alexa, order toilet paper," to send the language assistant scurrying off to place the order with the Internet discounter, who then quickly dispatches a drone to deliver the much-needed household item to the anxiously waiting consumer.
Supposedly Safe
While the device constantly listens in the room, waiting to respond to the spoken word, it is in a kind of twilight state most of the time and does not forward incidental noise picked up by the microphone to the Amazon Cloud for analysis, according to the provider. Instead, the voice assistant waits for the user to speak what is known as the wake word, usually "Alexa," before activating the speech recognition-enabling connection to the Amazon Cloud. Instead of "Alexa," "Amazon," or "Echo," Star Trek fans can switch the wake word to "Computer" (Figure 2) and then talk to the assistant just as Captain Jean-Luc Picard spoke to the on-board computer on the bridge of the starship Enterprise.
Teaching Alexa New Tricks
Out the box, Alexa can answer simple questions. Skills [1], which are free thus far (but might well switch to the app payment model sometime in the future) are available from the Skills Store [2] (Figure 3). Skills are basically software packages programmed and published by third parties, much like apps in the App Store. From reading current share prices in a customized stock portfolio ("Motley Fool") through playing a game of Jeopardy, to controlling lamps in your smart home, you have a lot to choose from.
To teach Alexa a skill, you activate one in the Alexa smartphone app or simply speak into the microphone (e.g., "Alexa, enable The Fool"). A short time later, Alexa is familiar with the stock market via the Motley Fool skill and answers questions like "Ask The Fool how is the market doing today" or "Ask The Fool to add Microsoft to my watchlist."
If your fingers are itching at the thought of teaching Alexa to dance to your own tune, you can visit Amazon Developer Services [3] to set up an Alexa account, which is separate from Amazon's AWS business, designed for the development of Android apps (Figure 4). After approving the agonizingly long terms of service, click on the Alexa tab and then on Alexa Skills Kit [1] to view a list of home-grown skills programmed thus far (Figure 5), along with a button that reads Create New Skill.
Snapshot Output On-Call
As a practical example, I want Alexa to report on demand the title and date of the latest edition of the Snapshot programming column. To do so, Alexa reads a JSON file articles-en.json
from my site at Perlmeister.com behind the scenes. The file lists all the issues in reverse chronological order (Figure 6), picks up the first entry from the long list, extracts the month and year, and passes the two values back to the language processor, which in turn announces them to the user via the Echo Dot.
If I say, "Alexa, ask Latest Snapshot for issue," then Alexa forwards the question to the Latest Snapshot skill, which then retrieves and processes the data and returns an answer such as 04 2017, Home Run into the Cloud (if the April issue happens to be the latest published Linux Magazine).
The developer defines the name of the newly taught skill to which Alexa delegates requests below invocation name
in the web flow for new skills. Several words are allowed, but they must not contain keywords used elsewhere (e.g., "Alexa").
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
Latest Cinnamon Desktop Releases with a Bold New Look
Just in time for the holidays, the developer of the Cinnamon desktop has shipped a new release to help spice up your eggnog with new features and a new look.
-
Armbian 24.11 Released with Expanded Hardware Support
If you've been waiting for Armbian to support OrangePi 5 Max and Radxa ROCK 5B+, the wait is over.
-
SUSE Renames Several Products for Better Name Recognition
SUSE has been a very powerful player in the European market, but it knows it must branch out to gain serious traction. Will a name change do the trick?
-
ESET Discovers New Linux Malware
WolfsBane is an all-in-one malware that has hit the Linux operating system and includes a dropper, a launcher, and a backdoor.
-
New Linux Kernel Patch Allows Forcing a CPU Mitigation
Even when CPU mitigations can consume precious CPU cycles, it might not be a bad idea to allow users to enable them, even if your machine isn't vulnerable.
-
Red Hat Enterprise Linux 9.5 Released
Notify your friends, loved ones, and colleagues that the latest version of RHEL is available with plenty of enhancements.
-
Linux Sees Massive Performance Increase from a Single Line of Code
With one line of code, Intel was able to increase the performance of the Linux kernel by 4,000 percent.
-
Fedora KDE Approved as an Official Spin
If you prefer the Plasma desktop environment and the Fedora distribution, you're in luck because there's now an official spin that is listed on the same level as the Fedora Workstation edition.
-
New Steam Client Ups the Ante for Linux
The latest release from Steam has some pretty cool tricks up its sleeve.
-
Gnome OS Transitioning Toward a General-Purpose Distro
If you're looking for the perfectly vanilla take on the Gnome desktop, Gnome OS might be for you.