matrix-io / matrixio-alexa-sdk-guide

Guide on how to setup the Alexa SDK in a Raspberry Pi with a MATRIX Creator/Voice.
4 stars 1 forks source link

Alexa SDK Guide with MATRIX Creator/Voice

Guide on how to setup the Alexa SDK in a Raspberry Pi with a MATRIX Creator/Voice.

Required Hardware

Before get started, let's review what you'll need.

First, this guide can take around an hour to install all packages and build the Alexa SDK. We have made an image with all packages installed and part of the SDK already built that takes that time to just few minutes. We recommned following the full guide in this readme, it will make you see how everything is installed and build but. If you are really in a hurry, the version of this guide using a pre-built image is here.

Let's get started

Once you have the Raspberry Pi with the SD Card inserted, the MATRIX board connected to it, power up the Raspberry Pi and open a terminal either in the Raspbian Desktop or just by ssh into it ( if you are you are using the Raspbian Lite version, in this case see guide on how to ssh here ).

1. Installing MATRIX software

In order to allow the Google Assistant software to have access to MATRIX Voice microphones you need to first install:

# 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 in case of Kernel Updates
sudo reboot 

Connect after reboot and continue with:

# Update again is needed in case Kernel Updates
sudo apt-get update
# Installation MATRIX Pacakages
sudo apt install matrixio-creator-init
# Install kernel modules package
sudo apt install matrixio-kernel-modules

# Reboot
sudo reboot

Wait a bit and try to reconnect again.

2. Register a Product in Amazon Developer

You'll need to register a device and create a security profile at Amazon developer website. If you already have a registered product that you can use for testing, feel free to skip ahead. If not, follow step-by-step instructions here.

IMPORTANT:

For Allowed origins use: http://localhost:3000 and https://localhost:3000. For Allowed Return URLs use http://localhost:3000/authresponse and https://localhost:3000/authresponse.

3. Install Alexa SDK

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

wget https://raw.githubusercontent.com/matrix-io/avs-device-sdk/yc/sensory-support/tools/RaspberryPi/setup.sh
wget https://raw.githubusercontent.com/matrix-io/avs-device-sdk/yc/sensory-support/tools/RaspberryPi/config.txt

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

Run the setup script with your configuration as an argument:

bash ./setup.sh ./config.txt

This installation can take some time, about an hour, so go find something useful to do while waiting :)

After the setup script has finished running, you'll need to generate an authorization token. Run this command, and open your browser and navigate to http://localhost:3000. Log in with your Amazon credentials and follow the instructions provided:

bash ./startauth.sh

4. Run Alexa!

Let's run the Sample App:

bash ./startsample.sh

The output should be similar to example-output.txt.