How to Build an Alexa Speaker with Raspberry Pi

To effectively “Build” our own Alexa speaker, we'll install Amazon Voice Service (AVS) on a Raspberry Pi 4 in this tutorial. We'll call this project AlexaPi. The Amazon Alexa Voice Service (AVS) SDK makes this project feasible. We'll discuss a Raspberry Pi Alexa with a visual interface in a future article if you're set on an Echo Show on Raspberry Pi (Alexa with a screen). The AlexaPi with screen project cannot be started until the stages in the article have been completed.

Why build an Alexa when you could just buy one?

If you don't already have a Raspberry Pi, an Amazon Echo device is less expensive. As of this writing, a brand new Echo Dot sells for $24.99 on Amazon, which is $10 less than the cheapest Raspberry Pi 4, even before you factor in the cost of extra components.

The educational process, not the result, is what makes AlexaPi so enjoyable. You'll get an understanding of how Alexa works behind the scenes and possibly spark an interest in creating your unique device with Alexa included in it. To encourage device makers to incorporate Alexa into their products, Amazon has made this Pi project possible.

lilygo Official Store

What is the difference between AlexaPi and Echo devices?

AlexaPi includes many of the basic features of an Echo device, but it is not intended to be a replacement for purchasing an Echo device. These are some key similarities and differences between Echo and AlexaPi.

  • IHeartRadio, TuneIn, and Audible are some of the music services that are activated by default (for US users at the time of the writing of this article). Additional Music Service Providers (MSPs) must be requested with “your Amazon point of contact,” according to Amazon. Once again, the purpose of this project was to encourage hardware makers to include Alexa in their products for sale.
  • The same process can be used to operate smart home devices like the TP-Link Kasa, Teckin Avatar, and more with your AlexaPi.
  • On AlexaPi, Alexa skills are accessible. For instance, ask Alexa to start the cat food. This is a skill I wrote that plays the sound of opening a can of cat food.
  • Calling and messaging: At the time of writing this article in the US, calling using AlexaPi is not supported.

What You’ll Need

Timing: Give yourself a minimum of one hour to do this project. Depending on your Pi model and internet speed, the primary install step takes 30 minutes to over an hour.

The majority of this tutorial is focused on terminal commands. We strongly recommend reading through 25+ Linux Commands Raspberry Pi Users Need to Know first if they are unfamiliar with terminal commands on your Raspberry Pi.

AlexaPi Setup and Install

  1. Connect your Raspberry Pi to your USB speaker and microphone.
  2. Boot your Raspberry Pi. See our articles on How to Setup a Raspberry Pi: A Beginner’s Guide or How to do a headless Raspberry Pi install. if you don't already have a microSD card.
  3. Launch the Chromium browser on your Pi desktop.
  4. Create or login to your Amazon developer account at https://developer.amazon.com/.
  5. Click on Developer Console in the top-right corner.
  6. Mouse over Alexa and click Alexa Voice Service.
how to build an alexa speaker with raspberry pi 1
(Image credit: LEDEdit PRO)
  1. Click Manage Your Products
Alexa Voice Service
(Image credit: LEDEdit PRO)
  1. Click Add New Products
  2. Complete the Product Information form.
    • Give your product a name and an ID.
    • Select Device with Alexa built-in for a product type.
    • Select No for the companion app.
    • Select Other for Product Category and enter your value in the text field.
    • Enter your Brief product description.
    • Select Hands-free for “How will end users interact with your product?”
    • Uploading an image is optional.
    • Select No for commercial distribution, Alexa for Business, AWS IoT Core, and children’s products.
    • Click Next.
Alexa Voice Service
(Image credit: LEDEdit PRO)

Next, you’ll be prompted to set up your AVS Security profile.

  1. Click Create New Profile.
  2. Enter your profile name and description.
  3. Click Next.
How do I use Alexa as a speaker on Raspberry Pi?
(Image credit: LEDEdit PRO)
  1. Click Other Devices and Platforms in the Platform Information area.
  2. Enter a Client ID name of your choosing.
  3. Click Generate ID.
Can you run Alexa on Raspberry Pi?
(Image credit: LEDEdit PRO)
  1. Click Download, and a config.json file will download to your Pi.
  2. Check the box for terms and conditions and click Next.
Can you use Alexa as an output speaker?
(Image credit: LEDEdit PRO)
  1. Click OK. You’ll be taken back to the product page. You should see the product you just created.
Can a Raspberry Pi power a speaker?
(Image credit: LEDEdit PRO)
How do you make an Alexa speaker?
(Image credit: LEDEdit PRO)
  1. Select AV Jack by right-clicking the speaker icon in the top-right corner of your Raspberry Pi desktop.
AV Jack
(Image credit: LEDEdit PRO)
  1. Set the volume to 100%, and left-click on the same speaker icon.
  2. Open your file manager and navigate to your Downloads folder.
Can Raspberry Pi play audio?
(Image credit: LEDEdit PRO)
  1. Move your config.json file from Downloads to pi.
Can Raspberry Pi connect to Bluetooth speaker?
(Image credit: LEDEdit PRO)
  1. Open a Terminal on your Raspberry Pi desktop.
  2. Run updates: udo apt-get update && sudo apt-get upgrade
  3. Next, enter the following as one command:
wget https://raw.githubusercontent.com/alexa/avs-device-sdk/master/tools/Install/setup.sh \

wget https://raw.githubusercontent.com/alexa/avs-device-sdk/master/tools/Install/genConfig.sh \

wget https://raw.githubusercontent.com/alexa/avs-device-sdk/master/tools/Install/pi.sh
How to Turn Your Raspberry Pi Into an Amazon Echo
(Image credit: LEDEdit PRO)
  1. Next, run the install script.
sudo bash setup.sh config.json [-s 1234]
Raspberry Pi - Alexa Tutorial
(Image credit: LEDEdit PRO)
  1. Type Agree and press Enter if you agree with AVS's terms and conditions. Depending on your Raspberry Pi model and internet speed, this step might take anywhere from 30 minutes to over an hour.
Raspberry Pi Quick Start Guide | Alexa Voice Service
(Image credit: LEDEdit PRO)
  1. You'll be prompted to review the license agreement throughout the installation process. To view the agreement, press Enter. To page through the agreement, press the spacebar.
Raspberry Pi Alexa: Build your own Amazon Echo
(Image credit: LEDEdit PRO)
  1. When prompted, type yes if you accept the license agreement.
Alexa Using Raspberry Pi and Bluetooth Speaker
(Image credit: LEDEdit PRO)

Your build is complete when you see **** Completed Configuration/Build ***.

How to Add Alexa to a Raspberry Pi (Or Any Linux Device)
(Image credit: LEDEdit PRO)

Troubleshooting

  • During installation, your Raspberry Pi could sometimes freeze or overheat. If this occurs, unplug your Raspberry Pi and let it cool for at least five minutes. Restart your terminal command when your Pi has cooled, and plug it back in. sudo bash setup.sh config.json [-s 1234].
  • If you get a fatal error, use curl/curl.h: No such file or directory, which means you must install curl. Enter the following in your terminal:
sudo apt-get install libcurl4-openssl-dev

sudo apt-get install libcurl4-gnutls-dev

Launching AVS on Raspberry Pi

Congratulations if you reached **** Completed Configuration/Build *** in the previous step! In the next step, we will start the Alexa app and verify Alexa with our account. Authentication only needs to be done once per AVS app.

keyestudio Official Store

  1. In the terminal, enter
sudo bash startsample.sh
How do I use speakers with my Raspberry Pi?
(Image credit: LEDEdit PRO)
  1. In your terminal, you'll see a lot of lines scrolling quickly. Scroll up till you see: Visit “https://amazon.com/us/code” to authorize and input the code: [Your unique 6-digit code here]
raspberry pi echo command
(Image credit: LEDEdit PRO)
  1. In your Chromium browser, navigate to https://amazon.com/us/code.
  2. Enter the provided code and click “Continue“.
raspberry pi smart speaker
(Image credit: LEDEdit PRO)
  1. Click Allow.
raspberry pi alexa alternative
(Image credit: LEDEdit PRO)
  1. If you see “Success! Your registration is now complete”, you can start testing your AlexaPi.
start testing your AlexaPi
(Image credit: LEDEdit PRO)
  1. Say, “Alexa, good morning.” This should be a “hands-free” experience that does not require you to press any more keys for it to function. Great work if your AlexaPi responds!
  2. By asking, “Alexa,…” you may now continue to test your AlexaPi. This is a list of “Fun Things to Ask Alexa“.
  3. In your Chromium browser, navigate to https://alexa.amazon.com.
Fun Things to Ask Alexa
(Image credit: LEDEdit PRO)
  1. location. After you set your device location, you can listen to your current local weather by saying, “Alexa, tell me the weather“.
Alexa, tell me the weather
(Image credit: LEDEdit PRO)
  1. To add Smart Home devices, click on Smart Home on the left menu and enable account linking per the instructions from your device manufacturer.
  2. When you are done with AlexaPi, return to the Terminal and press Ctrl-C.

Fun Things to Ask Your Raspberry Pi-Powered Alexa

What will you ask Alexa now that she is working on your Raspberry Pi? Here are some options.

  • Play music.
  • Can you rap?
  • Can you sing?
  • Talk like a pirate.
  • Open the cat food.
  • Make me a sandwich.
  • What’s the first rule of the fight club?

You might add a few LEDs to your project using this Amazon LED tutorial to mimic the lighted ring on the top of the Echo device.

We will add Smart Screen in a future article if you finish the tutorial and are disappointed that there is no Echo Show functionality.

Leave a Reply

Your email address will not be published. Required fields are marked *

20 Easy Raspberry Pi Projects Toys, Tools, Gadgets

20 projects using the Raspberry Pi, a tiny and affordable computer, for beginners looking to make cool things, Projects are explained with full-color visuals and simple step-by-step instructions.