Simple wearable projects with your Android phone
Tech on Tap
Create some interesting wearable projects with an Android device, an armband case, headphones, and MIT's free App Inventor package.
A wearable solution with voice recognition and speech-to-text capabilities can be used by anyone who needs information while their hands are busy or when they can't take their eyes away from their current task. Some examples include recipes for chefs, instruction manuals for mechanics, or directions for a cyclist.
In this article, I create an Android application that recognizes a spoken keyword that is searched in a text file; text-to-speech software echoes the result of the search. To create the Android app, I use MIT's App Inventor package, a free web-based Android app development tool you can use to create applications in a graphical environment.
For this project, you need a smartphone armband case and a set of headphones with a built-in microphone (Figure 1), as well as a Google user account [1] and a desktop or laptop computer to use App Inventor.
App Inventor
App Inventor [2] is a web-based app creation tool for Android devices with a graphical programming environment. App Inventor has two main screen modes: In Designer mode, you lay out the Android app in the Viewer screen, and in Blocks mode, you build the logic. On the right side of the top menubar, the Designer and Blocks buttons allow you to toggle between these two modes.
In Designer mode, you create an app layout by dragging a component from the Palette window onto the Viewer window. For the visuals on this application, you will use the following components from the User Interface section of the Palette: Button, which initiates speech recognition, Label, which first shows the Hit the Talk Button message and then shows the result of the speech recognition, and ListView, which shows the lines of the data file.
Also, you need some non-visual components. In the Media section of the Palette, drag the SpeechRecognizer and TextToSpeech components into the Viewer window and add the File component from the Storage group (Figure 2).
The Components window lets you rename or delete components. When you select a component, the Properties window shows the component's editable features. In this example, I renamed the button BT_Speak and changed the BackgroundColor, FontSize, Width, and Text fields from their defaults (Figure 3).
Logic
Once the layout design is complete, you can add logic by clicking on the Blocks button in the top menubar. Logic is built by selecting an object in the Blocks window and then clicking on the specific block you want to use (Figure 4).
App Inventor is pretty amazing when it comes to fast prototyping. This entire app only requires one variable and four when
blocks (Figure 5). The first step is to load the text file by calling the when Screen1.Initialize block. The when File1.GotText block loads the text file data into the global variable (THELIST
) and populates the ListView
component.
The when BT_Speak.Click block is activated on a button push and starts the speech recognition block. The final block, when SpeechRecognizer1.AfterGettingText, shows the result of the speech recognition in a label and it checks whether it is in the global variable. If the result is found, a text-to-speech message is generated with the full line of text.
Data File
The data file I used, places.txt
, is a list of some local landmarks, but you could use a number of other data choices, such as friends' addresses, recipe ingredients, or favorite restaurants. For readability, I recommend you put the keywords at the beginning of each line; for example:
"Hope Bay has a sandy beach with..." "The Glen is a horseshoe-shaped valley..." "Isaac Lake is a bird sanctuary with..." "Oliphant is great for kite surfing..." ...
For this example, the file was saved in the Android's Download
directory; this location needs to match the fileName
entered in the File1.ReadFrom
block definition (i.e., /Download/places.txt
) in the first when
block.
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
-
Canonical Releases Ubuntu 24.04
After a brief pause because of the XZ vulnerability, Ubuntu 24.04 is now available for install.
-
Linux Servers Targeted by Akira Ransomware
A group of bad actors who have already extorted $42 million have their sights set on the Linux platform.
-
TUXEDO Computers Unveils Linux Laptop Featuring AMD Ryzen CPU
This latest release is the first laptop to include the new CPU from Ryzen and Linux preinstalled.
-
XZ Gets the All-Clear
The back door xz vulnerability has been officially reverted for Fedora 40 and versions 38 and 39 were never affected.
-
Canonical Collaborates with Qualcomm on New Venture
This new joint effort is geared toward bringing Ubuntu and Ubuntu Core to Qualcomm-powered devices.
-
Kodi 21.0 Open-Source Entertainment Hub Released
After a year of development, the award-winning Kodi cross-platform, media center software is now available with many new additions and improvements.
-
Linux Usage Increases in Two Key Areas
If market share is your thing, you'll be happy to know that Linux is on the rise in two areas that, if they keep climbing, could have serious meaning for Linux's future.
-
Vulnerability Discovered in xz Libraries
An urgent alert for Fedora 40 has been posted and users should pay attention.
-
Canonical Bumps LTS Support to 12 years
If you're worried that your Ubuntu LTS release won't be supported long enough to last, Canonical has a surprise for you in the form of 12 years of security coverage.
-
Fedora 40 Beta Released Soon
With the official release of Fedora 40 coming in April, it's almost time to download the beta and see what's new.