DIY Smart Speaker Featured

How to Build Smart Speaker with Alexa and Google Assistant (DIY)

These days, smart assistants are taking the tech world by storm. Amazon’s Alexa and Google’s Assistant are now being embedded within every device, be it car devices, showers, or practically almost everything that was unveiled at CES 2018. But despite all that, the most selling devices sporting these assistants are the company’s own products, that is, the Amazon Echo and the Google Home.

While both the smart speakers are great by themselves, wouldn’t it be great to have the power of them both on one device? Well, now you can. We, at Beebom, have created our own guide of how to create your own smart speaker having the capabilities of both Google Assistant and Amazon Alexa. So without any further ado, let’s get right into it.

Note: The following project has been created with the help of a GitHub project.

Things You Need:

  • Raspberry Pi 3 (link)
  • microSD Card 32GB (link)
  • USB Wall Charger (link)
  • 3-port USB Hub (link)
  • USB-A to microUSB Cable (link)
  • USB Microphone (link)
  • Portable Speaker with AUX input (link)
  • Keyboard and Mouse (link)
  • Display with HDMI port (link)
  • HDMI Cable (link)

Smart Speaker

Steps to Build Smart Speaker:

1. To start off, you’ll first need to set up your Raspberry Pi. To do so, simply download the NOOBS package, extract it to your microSD card and plug it into your Raspberry Pi. Hook up the USB Keyboard, Mouse, Mic and the Speaker to the Pi and turn it on. You will now get a first time setup. Simply select Debian and install to start the installation of Debian on your Raspberry Pi.

NOOBS Package Download

2. Now, you need to create your Amazon Developer Account and create a security profile. You can follow the GitHub project instructions as well. Once done, note down your Amazon account’s credentials.

Amazon Developer Account

Next up, create a Google Developer Account and enable the Google Assistant API. Once you’re through with that, download the credentials.json file of your Google Product to /home/pi and rename it to assistant.json.

Google Assistant API Enabler

3. Now, run the following commands one by one to clone the GitHub project and make the installer files executable:

git clone https://github.com/shivasiddharth/Assistants-Pi  
sudo chmod +x /home/pi/Assistants-Pi/prep-system.sh    
sudo chmod +x /home/pi/Assistants-Pi/audio-test.sh   
sudo chmod +x /home/pi/Assistants-Pi/installer.sh
sudo /home/pi/Assistants-Pi/prep-system.sh

First, OS will be updated and upgraded. Thereafter, you will be prompted to select the audio setup. Select “3” from the options. Now, restart the Raspberry Pi.

Audio Setup 3

4. Upon reboot, first, check your audio setup by

sudo /home/pi/Assistants-Pi/audio-test.sh

The script is interactive, just press “y” if you hear the audio, or “n” if you don’t. In case you don’t hear the audio, you need to check the wires.

Audio Test

5. Now that your system is ready, run the following command to start the installer:

sudo /home/pi/Assistants-Pi/installer.sh  

The script will now execute. It is a pretty straightforward script, simply follow the on-screen instructions.

Installation

6. Once both the assistants have been installed, you’ll be shown a screen as below. Run the commands one by one to authenticate Alexa. Once you’re through with that, make the changes in the README file located at /home/pi/Assistants-Pi to start the assistants on boot.

Authentication

And that’s it. Your 2-in-1 smart speaker is ready. Also, while you can use the entire setup barebones, we decided to wrap things up inside a nice little cardboard box and apply a black chart paper while Beebom-ify-ing things up. You can also check out our video of the same below, to see our speaker in action:

SEE ALSO: Google Home vs Amazon Echo: Google Assistant Takes on Alexa

The DIY Smart Speaker: Best of Both Worlds

Well, I know that you can buy your own Amazon Echo Dot and the Google Home Mini, but you might also be aware that those products aren’t available everywhere. What’s more is that with the above guide, you can create a speaker that gives you the power of both the voice assistants combined into a single device. Oh, and aren’t DIY projects always fun? I know I enjoyed a lot making my own smart speaker, and the end result was more than satisfactory. But what about you? Do share with us your experience of building your own smart speaker in the comments down below.

139 Comments

  1. Please pray for me I am starting to do this project I hope that I will not encounter any mistakes.

  2. hi! may I ask if we can change the name? instead of alexa/google we want to use fairi. can we do this? how?

  3. ENTERED THE COMMAND : /home/pi/env/bin/python -u /home/pi/GassistPi/src/main.py –device_model_id ‘ ENTERED MODEL ID ‘
    AND GOT THIS…..
    Traceback (most recent call last):
    File “/home/pi/GassistPi/src/main.py”, line 33, in
    import psutil
    File “/home/pi/GassistPi/src/psutil/__init__.py”, line 96, in
    from . import _pslinux as _psplatform
    File “/home/pi/GassistPi/src/psutil/_pslinux.py”, line 26, in
    from . import _psutil_linux as cext
    ImportError: cannot import name ‘_psutil_linux’ from ‘psutil’ (/home/pi/GassistPi/src/psutil/__init__.py)

    PLZ KINDLY HELP ME OUT WITH THIS..!!

  4. sudo /home/pi/Assistants-Pi/installer.sh getting error saying command not found
    Please help I had figured out the rest of the scripts by adding /scripts after /Assistants-Pi/scripts
    Please help

    1. hello

      thank you i was stuck on the same part and then you told me about the /scripts part and that worked for me

      maybe you are typing in the wrong command

      thanks,
      Akash

    1. no
      aurdino is a microCONTROLLER
      it does not have the computation power to do that
      yon need a microPROCESSOR to do these things

  5. Hi after entering first line of instruction I’m being asked for a user name and password.please help

  6. ‘AVM file not running’ error is showing up when I run tests for Alexa and ‘No command found’ for Google Assistant. What should I do?

  7. Do a proper video of installation because many things are going on the right way with us. And I m not able to understand the last 9 step on the readme file.

  8. thnks beebom for such tech ur teaching us
    in public for free
    i am so greatfull to be ur youtube subscriber

  9. hey getting this error not hearing the voice i am using the mic given in the link please help stuck from days

    =============Recording Mic Audio Sample=============
    Recording WAVE ‘/home/pi/mic-test.wav’ : Signed 16 bit Little Endian, Rate 16000 Hz, Mono
    Warning: rate is not accurate (requested = 16000Hz, got = 44100Hz)
    please, try the plug plugin

    Finished recording the samples.

    Playing back the recorded audio sample……

    Playing WAVE ‘/home/pi/mic-test.wav’ : Signed 16 bit Little Endian, Rate 44100 Hz, Mono
    Did you hear the recorded audio sample?
    [y/n] >>

  10. After installing both Assistants to run the alexa in three different terminals… I’m getting a error called JAVA_HOME environment variable is not set.. plz help me with this error!! Beebom help me

      1. I have commented for help about a month ago… no one responded from beebom! hence I assumed that beebom is not useful at all and a waste of time following that.

        1. This Error Is Quite Easy To Solve On Windows So If You Use Windows Then Just Search For Environment Variables In The Start Menu And Open The First Search Result. Locate The Path Where You Java Is Installed And Go To “Bin” Subfolder And Then Copy The Path And Paste It There And Name It As “JAVA_HOME”. And Restart The PC. And As For Linux Users, Just Search Google For How To Add Environment Variables In Linux.

  11. Is the Alexa in AssistantsPi a recent version from the SDK? Does it have the drop-in and announce feature?
    Also, Does anyone know how to get it ti work with the google AIY v1.0 voice hat?

  12. I am able to run Google Assistant, but can not play songs from google music, it just says ‘looking for songs by artist xxxx’ and then ‘No match found’ and then restarts.
    I dont have paid subscription for google music, is that the reason?. I have my playlists saved in google music.
    Please help.

  13. Hello, It Is Asking For Username & Password For Cloning The GitHub Project What Should I Enter ?

  14. I have reached the point of cloning at github. I have created an account, detail left out, but on the first command I am getting the error— remote: Repository not found. I am not familiar with github and it’s commands. What am I missing.

    1. I am able to run Google Assistant, but can not play songs from google music, it just says ‘looking for songs by artist xxxx’ and then ‘No match found’ and then restarts.
      I dont have paid subscription for google music, is that the reason?. I have my playlists saved in google music.
      Please help.

  15. I have connected raspberry pi 3 with my laptop ,but there is no option to install debian on raspberry pi

      1. I’m not shure what you are doing. But If you hooked up your raspberry with your laptop through usb or something in the hope to install an OS. Nothing is going to happen. You need to install an OS like debian (for Raspberry pi — Raspbian) on an SD card or connect a monitor, keybord, mouse etc to your raspberry and install it through Noobs.
        More info:
        https://www.raspberrypi.org/documentation/installation/

        1. first of all thanks for answering Wilbert, but i followed the above instructions which you are you telling for connecting raspberry pi to computer by installing noobs/raspberian os in sd card and plug into my raspberry pi .
          Now there my problem arises after extracting os in my sd card and plug into my pi ,but after that when i connect my pi to monitor there is nothing happening on screen (means no setup showing)……
          so can you help me on that where i am doing wrong.

    1. You have to connect it on an external display with the file on your sd card plugged in to the raspberry pi

  16. Thanks for the great work on this smart speaker! I got GoogleAssistent running 100%. I only have a problem with Alexa. When I start the raspberry Pi I here “Hello” and when I use the wakeword “Ok Alexa” it gives the short tone. After that it stays quite. No answers or reactions to the wake word. When I reboot the raspberry I hear again “Hello” and I can can a reaction one time. It is just as If it cannot login/connect to amazon.
    I guess that the “ProductID” asked for during the installation is the same “Product ID” as I entered at product information page at amazon and not some complex code as in Client ID

    1. Found what I was doing wrong. I used raspbian lite (no desktop) and installed everything trough ssh. That want work for the authenticating process. Tried it with desktop version and that works ok for Alexa. But ….. now Gassist refuses. I cant start it manually “source env/bin/activate” gives me the error “no such file or directory”. When I check there is no directory “env” in /home/pi.” /home/pi/env/bin/python -u /home/pi/GasssistPi/src/main.py –project_id ‘xxxx’ –device_model_id ‘xxxxxx’” same problem. What Am I missing?

  17. Maybe a silly question but where do I download the credentials.json file. I’ve been searching and searching on my google developer site but I can’t find it….

  18. I entered the command as mentioned in the readme file for raspberry pi 3b and it says no file or directory named “gassistpi –whatever”.
    What to do?

  19. In audio test , inm unable to listen the sound and it is asking to check the sound.conf and asoundrc files but nothing helped me.. Plzz help me
    i have a project on this on tuesday

  20. i tried this process on raspian. i tried installing noobs but i m facing problems . And this process failed in raspian . can anyone help

  21. I’m getting this err when I try running “/home/pi/env/bin/python -u /home/pi/GasssistPi/src/main.py –project_id ‘xxxx’ –device_model_id ‘xxxxxx’

    File “/home/pi/GassistPi/src/main.py”, line 25, in
    import psutil
    “import error no module named ‘psutil’

    please help.
    Alexa is working fine and it start up correctly during bootup.

  22. Dear Sir, I “build” a Google Assistant on a Raspberry Pi 3 B. I want to use the broadcast command in view to send a message to 3 devices, one Google Home mini and 2 RPi devices. In Google Home on Android the genuine Google Home can be assigned to a room. The RPi it is seen as virtual device and cannot be assigned to a room. How I can do that? Have you an idea about that? Thank you for any advice. Cezar

  23. Alexa Works on boot up of Raspberry pi3 but Google Assistant does not work . I made changes according to readme file located at directory. If i manually run the command “source env/bin/activate” “google-assistant-demo” then it works. Whats exactly i am missing can you tell please?

  24. Can we use Bluetooth speaker with the mic or separately we should buy USB mic and speaker?

  25. The setup of Raspberry Pi 3 has been completed. Then I have also installed the Google Assistant API. After that what is the next step to continue to make assistant?
    #ASK BEEBOM?

    1. a 16GB card should work fine.
      a 4GB card will definitely not work.
      an 8GB card might or might not work, considering it has a decent amount of storage space available but was not tested by us at the time of building the smart assistant.

    2. I AM Using *GB MicroSD Card And It Ca Be Possible It Works Fine ! Also You Should Have Minimum Of 8GB MicroSD Card

    1. You’ll have to manually switch modes between the AUX input and the Bluetooth input, the toggle for which is present on the rear side of the speaker we’ve used.

  26. If I want to install Google Assistant or Alexa only , Can I press 1 or 2 in installation section?
    #AskBeebom

  27. How can I start it in boot also how to connect to wifi automatically
    And Beebom Thanks for Everything

    1. Once you’ve installed Debian using the NOOBS package, connect to WiFi on the first boot by heading over to settings or the quick launch tray.
      As for making the assistant startup on boot, simply follow the steps mentioned in the README file.

  28. I am in grade 9. Can you please explain to me how to do the assistant with the laptop Dell intel core i5?
    If the beebom is the best, then beebom will explain me briefly

    1. Your question is a little unclear, but from what I can make out, it seems as if you’re trying to ask how to set up the assistant using just your laptop. If that is the case, while you can use the laptop for installing Debian on the Raspberry Pi 3 using the NOOBS package as mentioned in the tutorial above, you’ll still need a USB Keyboard, Mouse, and HDMI compatible screen to continue the setup on the Raspberry Pi.
      Hope that helps. Do feel free to comment back in order to allow us to assist you better.

  29. Thanks for all the help you have been providing. I have successfully created a Alexa powered smart speaker and it is working exceedingly well and got connected to the Alexa app too. But when I ask it to play some music, it says that Amazon music is not supported on this device and says the same for Saavn too. I can just play through TuneIn. How to resolve this issue?

    1. In the Alexa app, there should be a way to log in via Spotify. Alternatively, you can purchase a membership for Amazon Music and play songs locally as well.

      1. There isn’t one in mine and doesn’t give me the option to activate prime music either.It says it is not supported on this device

  30. How can i connect the assistant to a Bluetooth speaker or any speaker by an aux cable

    Plz reply

    1. Connection to Bluetooth speakers is not possible at the moment. You can, however, connect any speaker via the aux cable into the 3.5mm jack on the Raspberry Pi.

      1. when i run the audio test and i m unable to hear the sound and it is asking to check soundconf and .asoundrc files . plzz hlp me

  31. bro , i want to connect a home theater to that instead of a portable speaker , so definitely i will have to power that to a switch board ,now the issue is:

    if there is a power cut in my house will the program in the raspberry pi run again automatically once the power comes or should i do any thing to start it again.

    1. Just make sure you are able to carry out the installation and setup process without any power cuts. Once you’re through with that, Alexa and Google Assistant will be set-up in order to start automatically at the time of booting. So even in the case of a power failure, whenever the power comes back on and the Raspberry Pi boots up, Alexa and Google Assistant will start simultaneously without fail.

  32. I just setup my speaker for Alexa and not for Google assistant. How to make Alexa bootup automatically on start?

    1. In the README file, you’ll find a couple of commands that need to be added to the Raspbian’s system in order to make Alexa’s script executable on boot.

  33. Can I directly use my laptop instead of keyboard, mouse and monitor?? If no then can I use my T.V. with HDMI port instead of monitor??

    1. You cannot use your laptop. However, you can easily use your TV via HDMI as a monitor alternative.

    1. A USB Hub is used simply to supply power to both the speaker and the Raspberry Pi at the same time. If you want, you can choose to use separate wall chargers for both.

  34. Can i use a bluetooth speaker having an in-built microphone instead of using wireless mic as you have done?

    1. Bluetooth speakers are currently not supported by both Alexa and Google Assistant, and neither would you get an option for it within the script. You’ll have to rely on a wired 3.5mm speaker for it.

      1. then can I output audio through the 3.5mm port to headphones and for audio input use a speaker having mike (connect it to the USB port)?

    1. Bixby, Cortana, and Siri are all closed AIs, so as of now there is no way to add either of them.
      Google and Amazon provide open-source APIs for Assistant and Alexa respectively, hence this project includes both of them.

    1. For Pi 2, you’ll have to buy a WiFi Adapter to connect it to the internet. Other than that, it’ll work just fine.

  35. Hey, what changes do I have to make according to the readme file? It says enter project id and model ID but I am confused which of the following: client id, client secret and product ID do I have to enter there. Also, can I use the mic inbuilt in my speaker?Please reply

    1. the ” client id, client secret and product ID” are related to your Amazon account.
      on the other hand, “project id and model ID” are you google account details.
      Basically, your project id = What you named your product as while creating it in the google page
      the model id = your raspberry Pi’s model, ie, Pi3

      1. But I just setup my speaker for Alexa and not for Google assistant. How to make Alexa bootup automatically on start?

  36. Hey, what changes do I have to make according to the readme file? It says enter project id and model ID but I am confused which of the following: client id, client secret and product ID do I have to enter there. Also, can I use the mic inbuilt in my speaker?

    1. Once you’ve installed Debian on your pi using the NOOBS Package, you can connect it to the WiFI during the first run.

    1. You can use it for home automation the same way you would use the standard Amazon Echo or the Google Home, by simply pairing them up with the smart device.

    1. For Alexa, download the Alexa app on Android/iOS and login with your Amazon Developer Account.
      For Google, download the Google Home app on Android/iOS and login with your Google Account.
      While the speaker should automatically show up within the Alexa app, you’ll be required to search for the speaker using the nearby feature in the Google Home app.

    1. A bluetooth mouse might work if the manufacturer of your mouse supports Linux distros, since Raspbian is based on Debian which is a Linux distro.
      As for the speaker, you’ll be required to make use of a wired 3.5mm speaker only. As you can see in the screenshot of Step 3, the script currently does not support bluetooth speakers or mics.

  37. What about building a smart android tv box using raspberry pi 3 that would be an amazing project and I request all of you awesome guys to put a tutorial on it.

    1. You can run the commands using JuiceSSH on your Android phone. However, you’d still be needing a PC for setting up the microSD card for the Raspberry Pi in the first place.

    1. Yes, you can. In the audio setup, press “5” instead of 3 as described in the above method.

    1. You’ll need the keyboard, mouse and monitor for the initial setup. Later on, you can simply run the scripts using SSH or VNC.

      1. Alternatively, you can also install Raspbian on your Raspberry Pi in CUI (console) mode, and then connect it using SSH. However, you’ll still be requiring a PC for setting up the microSD card in the first place.

  38. What if i want to use a speaker with inbuilt mic and bluetooth? I’m specifically talking about jbl flip 3. Please help which option to choose to get the mic working with the raspberry.

    1. the mic won’t work in that case. the reason for that is that the 3.5mm jack on the Raspberry Pi is for output only and not input. Furthermore, Bluetooth can’t be used as a mode of communication for this. You’ll have to rely on a speaker that connects with the 3.5mm jack and a USB Mic.

Leave a Reply