Voice Search has reached nearly 48% of the total volume of search done on the web.

With Google being the default search engine(68% of all search).

There is an instant rise in demand for smart speakers and voice assistants.

Smart speaker market is expected to grow from USD 1.94 billion in 2017 to USD 11.57 billion by 2023, at a CAGR of 34.7%.

Alexa and google voice assistants once thought to be propriety technology is now open to deployed the choice of your hardware.

Alexa Can be Ported to multiple Platforms, In this blog post we are going to build a Alexa Voice Assistant using Raspberry Pi 4. Let’s Continue.

Bill of Materials (BOM)

  • Raspberry Pi 4 (Recommended) or Pi 3 Model B+.
  • Micro SD card – Minimum 8 GB.
  •  Microphone – Raspberry Pi doesn’t have a built-in microphone. To interact with Alexa, you must plug in an external microphone.
  • USB Micro phone
  • MATRIX Voice (FAR Field Audio MiC)
  • MATRIX Creator (FAR Field Audio MiC)
  • Respeaker  (FAR Field Audio MiC)
  • External speaker or headset – Your audio source needs to connect to the Pi with 3.5 mm audio cable.
  • USB keyboard and mouse – Choose any compatible keyboard and mouse.
  • Raspberry Pi fan – Choose any compatible fan. Without a fan, the Raspberry Pi might overheat.
  • HDMI monitor – Choose any compatible monitor. Alternatively, you can remote SSH into your Pi.
  • Internet connection – Ethernet connection or a 2.4 Ghz Wi-Fi.

Before we start, once all the steps are done, we are going to have a fully functioning Alexa completely built on Raspberry Pi.

This Alexa will be at par with the current eco-dot available the market.

Advantage.

  1. A High-quality Audio input circuitry instead of simple Mic. Here we have used

 Far Field array Mic as an audio input. FAR field boards have great advantage in processing the alexa commands when alexa is already playing music.

  • There are many options available in the market, we have recommended
    • MATRIX Voice 
    • Respeaker

Step 1 Register a Product in Amazon Developer

You’ll need to register a device and create a security profile in the Amazon developer website. If you have already registered a product and even created Security Profile, we still recommend you create a new one for this demo. Follow step-by-step instructions here.

Step 2 Create an Amazon Developer account

To access Amazon Voice Service, you need an Amazon Developer account. You create one by visiting the Amazon Developer Services and Technologies website and clicking on “Sign In” and then on “Create your account”. You can also sign in via your regular Amazon account, if available.

Enter the login information you want (name, e-mail address, and password) and click “Create your Amazon Developer account”.

Step 3 Register Raspberry Pi for Alexa Voice Service

Once you have provided the necessary information and agreed to the terms of use and guidelines, you will have access to the Developer Dashboard, which allows you to view and manage your various Amazon projects. Under the heading “Amazon Alexa” you will find “Alexa Voice Service”, which starts the activation of your Raspberry for the language assistant:

 Step 4 Select Product Type

Under “Product name” and “Product ID,” you can enter “AlexaPi” or “RaspberryPiAlexa”, for example.

As “Product type” select the option “Device with Alexa built-in“. Click no for the question about the use of a companion app.

For “Product category”, choose “Wireless speakers”. In the product description, you don’t have to use big words, an entry like “Raspberry Pi Alexa Speaker” is sufficient.

Since you want to command your Raspberry Pi like the classic Alexa speaker; exclusively by voice command, check “Hands-free” (voice command from close range) and “Far-field” (voice command from a distance) as planned types of interaction.

The concluding questions about commercial use or use of the Raspberry for Alexa for Business and Alexa Mobile Accessory protocol should be answered with a “no”, as should the question of whether your project is specifically tailored for children.

Step 5 Create a LWA security profile

The next step is to create an LWA (Login With Amazon) security profile for the Raspberry Pi so that it can verify itself with Amazon. Since you do not yet have one, click on “CREATE NEW PROFILE” and then enter a suitable name and a short description of the profile:

 Step 6 LWS Authentication

After clicking on “NEXT”, another menu appears in which you specify the URLs for the LWS authentication. Enter the following addresses here (and save them with “ADD”):

Then check the box to give your consent to the Amazon and Alexa Voice service agreements and end the profiling process by clicking the “FINISH” button:

You have the option to add multiple URLs. You can also remove them at any time using the cross symbol.

If the setup was successful, Amazon will send you a pop-up notification.

 Step 7 Write down product and client information

The profile you have created for your AlexaPi is now available for selection at any time under “Products”. Before you start installing Alexa, however, you should already call up and note down the product and client information required for configuring the language assistant. To do this, click on the profile of the Raspberry in the product overview and note what’s written under “Client ID” and “Client secret”.

The decisive product information is the “Product ID”, which is the same as the assigned product name (in this tutorial “AlexaPi”).

Under the product details, you will not only find the verification information, but you can also activate features such as the reminder function or Bluetooth.

 Step 8 Software Image

The manual installation below may take over an hour to finish so we have provided a downloadable image pre-configured image here with everything pre-installed. You can use etcher.io to flash the image onto your SD Card.

Skip to Step 10 if you use our image.

Step 9

The following steps marked with (Manual) are only required if you downloaded the default Raspbian Stretch image.

NOOBS-image

# Add repo and key
curl https://apt.matrix.one/doc/apt-key.gpg | sudo apt-key add -
echo "deb https://apt.matrix.one/raspbian $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/matrixlabs.list
# Update packages and install
sudo apt-get update
sudo apt-get upgrade
# Reboot
sudo reboot

In order for the Alexa Voice Service to utilize the microphones of the MATRIX Creator or MATRIX Voice, you need to install the following:

sudo reboot

After reboot connect again and run:

# Update again
sudo apt-get update
# Install MATRIX Pacakages
sudo apt install matrixio-creator-init
# Install kernel modules package
sudo apt install matrixio-kernel-modules
# Reboot
sudo reboot

Wait till the reboot is complete and reconnect again.

Step 10 Downloading Alexa SDK Scripts (Manual)

Download the install script. We recommend running these commands from the home directory (~/) or Desktop, however, you can run the script anywhere.

<code>wget https:</code>//<code>raw.githubusercontent.com</code>/matrix-io/<code>avs-device-sdk</code>/master/<code>tools</code>/MatrixLabs/<code>setup.sh &amp;&amp; wget https:</code>//<code>raw.githubusercontent.com</code>/matrix-io/<code>avs-device-sdk</code>/master/<code>tools</code>/MatrixLabs/<code>config.txt</code>

Step  11 Registering Your Pi as an Alexa Device

With all the initial installations downloaded, all that’s left is to configure your Raspberry Pi so that it’s identified by Amazon as the Alexa device you registered in step 1.

Open the file in a editor and use the Client IDProduct ID from the registration steps to fill the file config.txt. Check here if you need help editing the file.

Step 12 Installing Alexa SDK

This setup script will pass your device config to Amazon and install the final dependencies needed. If you followed the manual installation, you may need to retry this command a few times (until there are no errors).

bash ./setup.sh ./config.txt

This installation can take about 30 min, so go and find something to do while waiting :). After finished reboot the Pi:

sudo reboot

Step 13 Run Alexa!

Let’s run the Sample App:

bash ./startsample.sh

The first time the app will display a message like this:

######################################################
#       > > > > > NOT YET AUTHORIZED < < < < <       #
######################################################
############################################################################################
#     To authorize, browse to: 'https://amazon.com/us/code' and enter the code: {XXXX}     #
############################################################################################

Open a browser (could be on another device), go to https://amazon.com/us/code and use the code provided {XXXX} inside the curly brackets. Login in Amazon, then select “Allow” and wait for it to get the token (it may take as long as 30 seconds). This authentication is just required this first time running the app. After authentication is done you should see this message:

########################################
#       Alexa is currently idle!       #
######################################## 

Now, you can say Alexa!

0 0 vote
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments