ISE Blog

Turn your Android Device into an Amazon Echo

If you're not familiar with Amazon Echo or its competitor Google Home by now, take a look around you. You're living in the future. We can now control things in our homes, get information and sports scores, or even order a pizza (well, more on that later) all by just asking Alexa.

This is interesting from a development perspective too, as Amazon has opened Alexa for developers, and Google will be opening Home for developers soon. This means not only can you develop your own skills to handle new Alexa requests not supported out of the box, but the community is able to communicate with Alexa directly from an Android app. The AlexaAndroid library is an open source library designed to let you do just that, and is much easier than working with the AVS API directly.

I installed the sample app to give it a try. As explained in the README on the library's github page there are three main functions it allows you to perform:

  • Send Live Audio
  • Send Prerecorded Audio
  • Send Text Request

Live Audio

When I tried the live audio it did exactly what I expected. It let me press a button in the sample app to begin a request, and speak my request at my device. It then sent the request to Alexa, got a response and played the response. For instance I tapped the mic and said, "add eggs to my shopping list," which it was happy to do, responding, "I've added eggs to your shopping list." When I said, "I'd like to order a pizza," it thought I wanted to order it from Amazon, and tried to add the top result for "pizza" which was a "Pizazz." Of course, adding the Domino's skill from the companion app would have let me order pizza, but where's the fun in that?

Add Eggs to Your Shopping List

Remember the eggs? Yes

Amazon Alexa Companion App

Order a pizza? You wanted this, right?

Installing the Amazon Alexa companion app (seen above) on your device also lets you check the results of your queries, which is really useful for testing custom skills. Regardless, this function seems to work exactly as expected. When I did it in a noisy environment I had to tap the microphone again to end my request, but Alexa was able to process the request just as well as an Echo. That makes sense as the processing is all being done server side, though I suppose it could vary based on the quality of the microphone on the Android device you're using.

Beyond allowing a user to talk with Alexa within your own app, the voice recording feature doesn't seem to add much to your app. The response you get simply has audio which you can play, so getting your app to do something with that result requires a lot of extra work and access to the skill you're trying to use to provide an alternate method of tracking its state.

Prerecorded Audio

Sending prerecorded audio to Alexa allows your users to press a button or interact with your app in other ways to send Alexa a command. Just record the commands you're interested in using ahead of time and send them using the prerecorded audio function. Again, the result you get isn't very helpful to an app developer yet - all you can really do is play it.

The sample app sends "Tell me a joke" for prerecorded audio and lets you press the button to get Alexa to tell a joke. It makes it easy to see if you're developing an app that utilizes a custom skill you've developed how you could make use of Alexa as a component of your app.

Text Requests

This accomplishes the same end as prerecorded audio without including audio files with your app, and allowing more dynamic and flexible requests. It actually uses Android text to speech to speak the audio at Alexa, so again it's really using the same interface adding a convenience layer. The requests also take longer and are less likely to succeed.

I entered, "What should we have for dinner?" and after about 5 seconds got the response "Pizza is always a good answer, but don't forget your vegetables."

What next?

Amazon's public API for Alexa is a step in the right direction for developers, and the AlexaAndroid library is one easy though limited way to use it in an Android app. For custom skills which need interactive apps along with Alexa voice interfaces, it may make more sense for the app to communicate with the backend directly rather than through the Alexa interface. It is hard to argue with the novelty factor of hearing the Alexa voice coming out of your phone though.

If you do try it out let us know how it goes! And keep in mind this open source library is licensed under the GPL 2.0, so use accordingly.


If you're interested in this or other mobile and innovation work, feel free to contact us to see how we could work together, or to join our team!

Clay Schumacher, Senior Software Engineer

Clay Schumacher, Senior Software Engineer

Clay Schumacher is a Senior Software Engineer and Practice Lead of Mobile Development at ISE. Clay lives in Normal, IL where he works from his home office and Slingshot Cowork. For the last four years he has worked to develop mobile solutions that delight our clients and end users. Clay enjoys agile/lean software development, and treats each project team as a startup bent on delivering the best app for each unique problem. He enjoys traveling and playing games with his wife and two daughters.