قالب وردپرس درنا توس
Home / Tips and Tricks / How to Add Alexa to Your Smart Mirror

How to Add Alexa to Your Smart Mirror



An intelligent mirror with a reflected Amazon echo. Josh Hendrickson

If you've built a smart mirror, you already have convenient access to calendars, weather, and news. But you can do more! With the Magic Mirror software, you can add modules for additional features like Alexa for voice control.

Other developers create these modules. Options vary from useful information such as Alexa or presence detection (via a camera or passive infrared sensor) to entertaining information such as snowflakes and Spotify playback information.

We recommend mmm-awesome-alexa because it seems to be well-maintained by an active developer, even though there are other Alexa modules for the Magic Mirror software.

If you prefer to install Google Assistant, Google offers a complete tutorial for installing Assistant on a Raspberry Pi, which includes steps, pictures, and download links. While there are some Magic Mirror modules for Google Assistant, our investigation found that the modules are problematic and frequently crash or obscure the mirror information. If you want the easiest possible setup, we recommend that you add the Google AIY kit and use its special tutorial.

To install most of the modules, perform some basic steps:

  1. Download GitHub module code
  2. Configure module-specific options
  3. Add Mirror Configuration Module

The steps are two, depending on the module and three may be more or less elaborate. Setting up Alexa requires more configuration than, for example, adding snowflakes. In addition, additional software (dependencies) must be installed for this particular Alexa module before downloading the module.

RELATED: Creating Your Own Futuristic Smart Mirror

The Materials Needed

  A Google AIY Voice Kit
Google

This guide assumes that you already have a Smart Have created Mirror. If you have not already, start there, but note the additional materials listed here in your cost and space considerations.

  • Completed Smart Mirror
  • Microphone
  • Speaker

For microphone and speakers, we recommend the original Google AIY Voice Kit. At $ 16 you will find it hard to find a cheaper combination of microphone and speaker. You do not necessarily have to use the supplied box. It may be more effective to omit the components and operate the microphone and speakers outside the mirror.

A second version of the Google AIY Voice Kit is available, but more expensive, and includes a Raspberry Pi Zero, which is not the case. It's powerful enough to run WakeWords or the Magic Mirror software. You should skip it.

Connect the speaker and microphone, and you can install the Alexa module. If you use the Google AIY kit, simply follow the installation instructions to connect the microphone and speaker components.

Installing the Module Dependencies

Before you can download and configure mmm-awesome-alexa, you must install some dependencies on which the module relies. It's always a good idea to update your Raspberry Pi before trying to install anything else. Run the following command on your Raspberry Pi:

  sudo apt update && sudo apt upgrade 

Run the following commands one after the other as soon as your Raspberry Pi is up to date:

  sudo apt-get install sox libsox-fmt-all
sudo apt-get install swig3.0 python-pyaudio python3-pyaudio sox
install pip pyaudio
sudo apt-get install libasound-dev portaudio19-dev libportaudio2 libportaudiocpp0 ffmpeg libav-tools
sudo apt-get install libatlas-base-dev 

Each command installs a dependency and they are all required for execution. Just run a command, wait for the download and installation to complete, and then run the next command.

Downloading the Module Code

The first step in adding a module to the Magic Mirror is to download the Github module code. To do this, you must log in to the Raspberry Pi, open the terminal and change the directory in which the modules are stored. Then use a download command to get the code from Github. If you have shell access, you can do it all remotely.

If you have a terminal open, enter:

  cd ~ / MagicMirror / Module

This command moves you to the working directory of the module folder for the Magic Mirror software. Every time you download a new module, you want to be here to organize everything. The next step is to download the software from Github with the following command:

  git clone https://github.com/dolanmiu/MMM-awesome-alexa.git[19659026)Iftheprocessiscompleteyoucanchangethedirectorieswiththemodulefollowing:[196659025] the MMM-awesome -alexa 

The Alexa module needs some extra dependencies to work properly. Run this command to install it:

  npm install --only = prod 

Now, switch to the newly created node_modules folder:

  cd node_modules 

Delete the Snowboy folder You have added with the previous commands. We need a newer version of snowboy:

  rm -rf snowboy 

Next we download the latest version of snowboy with the following command:

  git clone https://github.com/Kitt-AI/ snowboy.git [19659026<Keepgoingbeforeyouchangeyournewfoldersnowboy

  cd snowboy 

Now you need to remove the node_modules folder and install some additional dependencies. It is important that you stay in the Snowboy folder for these steps. Do not change the directories. Run the following commands one at a time:

  rm -rf node_modules
npm install nan --save
npm install node-pre-gyp@0.12.0 --save
npm install
npm run prepublish
npm install --save-dev electron-rebuild
npm install nan
./node_modules/.bin/electron-rebuild[19659026<Nowmoduleubjectsuploadedandinstalled

Configure the Alexa module

 MMM-awesome-alexa configuration help dialog

After the module installs mmm-awesome-alexa is, we have to configure it. The first step is to change directories to the root of the module. Enter the following command in the terminal and press Enter:

  cd ~ / MagicMirror / modules / MMM-awesome-alexa 

This Alexa module has configuration help. We want to do that. In the terminal type:

  npm run config-helper 

You are prompted to enter a client ID. Because you're essentially setting up a custom echo, you'll need to open a browser and go to the Alexa developer web site. Then sign in with your Amazon account.

After logging in, click the Getting Started button. When you create a device, click Products, and then click Create Product.

 Alexa Developer Dialog with box around option

On the next screen, give your product a name and product ID - We recommend "Magic_Mirror_Alexa" as the name and "YourFirstName_MM_Alexa" as the product ID , Select Smart Home for the category and enable both hands-free and far-field options. A series of yes or no questions will be displayed. Select "No" for everyone, and then click "Next."

On the Security Profile screen, click Create New Profile. Use the same name profile for your security as you did for the product ID. Then enter any description and click Next.

Review the agreement and click Finish.

Click on your newly created product and then on the security profile. You should see a customer ID and a customer secret.

In the allowable entry type for the return URL, click:
https://magic-mirror-avs.github.io/Alexa-Web-Helper/authresponse

Click Then click the Add button. Scroll down and click the update box to finish adding the URL.

The terminal displays a prompt for the client ID. Copy the client ID from the browser, paste it into the terminal, and press Enter. Now the terminal prompts for a client secret. Go back to the browser, copy the client secret, paste it into the terminal, and press Enter.

When prompted to enter the device ID, enter the name created above as the product ID (Magic_Mirror_Alexa in our example).

When prompted for a return URL, type the following command and press Enter:

  https://magic-mirror-avs.github.io/Alexa-Web-Helper/authresponse 

The terminal will display a customized link. Copy that and paste it into your browser. Then sign in with your Amazon account when prompted. On the next screen, click Allow.

 Alexa Voices permissions are shown with a box around the button

There is an error in the browser, but do not worry! This is expected. Scroll through the URL of the error page and find the section "Code = xxxxxx".

 URL with Alexa device code.

Copy the letters and numbers between "code =" and "& scope" and paste them into the terminal. Press Enter when you're done.

When asked if you want to generate the MagicMirror configuration, type Y and press Enter.

You will be asked which word to use. Since Alexa is the default choice, press Enter.

Answer No to use lite mode and visualization.

The configuration helper generates your module information. It will look like this:

  {
Module: "MMM-awesome-alexa",
position: "bottom_bar",
config: {
wakeWord: "Alexa",
clientId: "YOUR_CLIENT_ID",
clientSecret: "YOUR_CLIENT_SECRET",
deviceId: "YOUR_DEVICE_ID",
refreshToken: "YOUR_REFRESH_TOKEN",
lite: wrong,
isSpeechVisualizationEnabled: false
}
}

 Automatically generated module code.

Copy these lines. We have to add it to the Magic Mirror configuration.

Add the Alexa module to the Magic Mirror configuration.

Then go to the Magic Mirror configuration folder with the following command:

cd ~ / MagicMirror / config

Open the config.js file with the nano command:

nano config.js

Immediately after the first instance of }, (the end of the command) Press Enter to get to the next { entry (which marks the beginning of a new module) creates a blank line.

 Module code with a new line past} and before {

In the newly created blank line, insert the module code from the configuration helpfiles. The automatically generated code has an error. After the last bracket, a comma must be entered for the module to end with },

 and a comma after the last bracket .

Use Ctrl + x to close the file. When prompted, type "y" to confirm the save and press Enter to keep the filename.

The module is complete. To restart your Magic Mirror software with the module installed, enter pm2 restart mm and the Magic Mirror software will restart. Alexa should now work on your Magic Mirror.

This is one of the more complicated modules you can set up for the Magic Mirror. For other modules, however, the basic steps are the same. Download the code, configure module-specific options, and add the module to the configuration. You can add snowflakes to your mirror or motion detection, or even view your Google Photos.




Source link