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
-
New Slimbook EVO with Raw AMD Ryzen Power
If you're looking for serious power in a 14" ultrabook that is powered by Linux, Slimbook has just the thing for you.
-
The Gnome Foundation Struggling to Stay Afloat
The foundation behind the Gnome desktop environment is having to go through some serious belt-tightening due to continued financial problems.
-
Thousands of Linux Servers Infected with Stealth Malware Since 2021
Perfctl is capable of remaining undetected, which makes it dangerous and hard to mitigate.
-
Halcyon Creates Anti-Ransomware Protection for Linux
As more Linux systems are targeted by ransomware, Halcyon is stepping up its protection.
-
Valve and Arch Linux Announce Collaboration
Valve and Arch have come together for two projects that will have a serious impact on the Linux distribution.
-
Hacker Successfully Runs Linux on a CPU from the Early ‘70s
From the office of "Look what I can do," Dmitry Grinberg was able to get Linux running on a processor that was created in 1971.
-
OSI and LPI Form Strategic Alliance
With a goal of strengthening Linux and open source communities, this new alliance aims to nurture the growth of more highly skilled professionals.
-
Fedora 41 Beta Available with Some Interesting Additions
If you're a Fedora fan, you'll be excited to hear the beta version of the latest release is now available for testing and includes plenty of updates.
-
AlmaLinux Unveils New Hardware Certification Process
The AlmaLinux Hardware Certification Program run by the Certification Special Interest Group (SIG) aims to ensure seamless compatibility between AlmaLinux and a wide range of hardware configurations.
-
Wind River Introduces eLxr Pro Linux Solution
eLxr Pro offers an end-to-end Linux solution backed by expert commercial support.