본문 바로가기

카테고리 없음

amazon echo raspberry 에서 동작 시키기

반응형

아래  Link에서 참조하였습니다.


http://lifehacker.com/how-to-build-your-own-amazon-echo-with-a-raspberry-pi-178772693


Step One: Register for an Amazon Developer Account

Before you do anything, you’ll need to register for a free Amazon Developer Account, then create a profile for your DIY Echo. This is pretty straightforward:

  1. Log into your Amazon Developer Account.
  2. Click on the Alexa Tab.
  3. Click Register a Product Type > Device.
  4. Name your device type and display name (We chose “Raspberry Pi” for both).
  5. Click Next.
  6. On the Security Profile screen, slick “Create new profile.”
  7. Under the General tab, next to “Security Profile Name” name your profile. Do the same for the description. Click Next.
  8. Make a note of the Product ID, Client ID, and Client Secret that the site generates for you.
  9. Click the Web Settings tab, then click the Edit button next to the profile dropdown.
  10. Next to Allowed Origins, click, “Add Another” and type in: https://localhost:3000.
  11. Next to Allowed Return URLs, click “Add Another” and type in: https://localhost:3000/authresponse Click Next when you’re done.
  12. The Device Details tab is next. It doesn’t matter much what you enter here. Pick a category, write a description, pick an expected timeline, and enter a 0 on the form next to how many devices you plan on using this on. Click Next.
  13. Finally, you can choose to add in Amazon Music here. This does not work on the Pi powered device, so leave it checked as “No.” Click Save.

Now you have an Amazon Developer Account and you’ve created a profile for your Pi-powered Echo. It’s time to head over to the Raspberry Pi and get Alexa working.

Step Two: Clone and Install Alexa

Plug everything into your Pi and boot it up. You’ll need to be in the graphic user interface (now dubbed PIXEL) for this because you eventually use a web browser to authenticate your device.

  1. Open the Terminal application on the Raspberry Pi and type: cd Desktopand press Enter.
  2. Type in git clone https://github.com/alexa/alexa-avs-sample-app.git and press Enter.
  3. Once that’s complete, type in: cd ~/Desktop/alexa-avs-sample-app and press Enter.
  4. Type in nano automated_install.sh and press Enter.
  5. This pulls up your text editor. Here, you’ll need to enter your ProductID, ClientID, and ClientSecret that you notes in the step above. Use the arrow keys to navigate to each entry. Enter each detail after the = sign as noted in the image above. When you’re done, tap CTRL+X to save and exit.
  6. You’re now back at the command line. It’s time to run the install script. Type incd ~/Desktop/alexa-avs-sample-app and press Enter.
  7. Type in . automated_install.sh and press Enter.
  8. When prompted, press Y for the different questions, and answer as you see fit for the rest. This will configure your Pi and install some extra software. This can take up to 30 minutes, so just let it do it’s thing.

Once that finishes, it’s time to start the Alexa service.

Step Three: Run the Alexa Web Service

Next, you’re going to run three sets of commands at once in three different Terminal windows. You’ll create a new Terminal window for each of the following steps. Don’t close any windows! You’ll need to do steps three (this one,) four, and five every time you reboot your Raspberry Pi.

The first one you’ll start is the Alexa Web Service:

  1. Type in cd ~/Desktop/alexa-avs-sample-app/samples and press Enter.
  2. Type in cd companionService && npm start and press Enter.

This starts the companion service and opens up a port to communicate with Amazon. Leave this window open.

Step Four: Run the Sample App and Confirm Your Account

Open up a second Terminal window (File > New Window). This next step runs a Java app and launches a web browser that registers your Pi-powered Echo with the Alexa web service.

  1. In your new Terminal window type in cd ~/Desktop/alexa-avs-sample-app/samples and press Enter.
  2. Type in cd javaclient && mvn exec:exec and press Enter.
  3. A window will pop up asking you to authenticate your device. Click Yes. This opens up a browser window. A second pop-up will appear in the Java app asking you to click Ok. Do not click this yet.
  4. Log into your Amazon account in the browser.
  5. You’ll see an authentication screen for your device. Click Okay. Your browser will now display “device tokens ready.”
  6. You can now Click the Ok pop-up in the Java app.

Now, your Raspberry Pi has the necessary tokens to communicate with Amazon’s server. Leave this Terminal window open.

Step Five: Start Your Wake Word Engine

Finally, open a third Terminal window (File > New Window). Here, you’ll start the wake word engine. This makes it so you can say “Alexa” to make your Raspberry Pi start listening to you. You have two options for wake word software, Sensory and KITT.AI. Both are free, but Sensory expires after 90 days, so let’s use KITT instead:

  1. Type in cd ~/Desktop/alexa-avs-sample-app/samples and press Enter.
  2. Type in cd wakeWordAgent/src && ./wakeWordAgent -e kitt_ai

That’s it, your DIY Echo is now running. Go ahead and try it out by saying “Alexa.” You should hear a beep indicating that it’s listening. When you hear that beep, ask a question like, “What’s the weather?” or “What’s the score in the Dodgers game?”

Step Six: Improve the Microphone and Make Sure Your Echo Can Hear You

Finally, depending on the quality of your microphone, you may notice that it has trouble hearing you. Instead of screaming “Alexa” at the top of your lungs, let’s go to the command line one last time.

  1. From the command line, type in alsamixer and press Enter.
  2. Tap F6 to select a different USB device. Use the arrow keys to select your microphone.
  3. Use the arrow keys to increase the capture volume.
  4. When you’re happy with the volume, tap ESC to exit.
  5. Type insudo alsactl store and press Enter to make the settings permanent.

Now, you should be able to trigger your DIY Echo by talking to it like a normal human instead of yelling. You can also change the default volume here if you need to.

Extra Credit: Add AirPlay Support

One thing your DIY Echo is missing from the commercial version is the ability to function as a Bluetooth speaker. You can add similar functionality with AirPlay. This way, your Echo also acts as a receiver that you can send music from your phone or computer to. It’s easy to add, you’ll just need one last trip to the command line through Terminal:

  1. Type in sudo apt-get install git libao-dev libssl-dev libcrypt-openssl-rsa-perl libio-socket-inet6-perl libwww-perl avahi-utils libmodule-build-perland press Enter. This installs different software you’ll need.
  2. Press Y when prompted and wait for everything to download and install.
  3. Type in git clone https://github.com/njh/perl-net-sdp.gitand press Enter. This is required for the newest version of AirPlay’s software. The next few commands build and install this software.
  4. Type incd perl-net-sdp and press Enter.
  5. Type in perl Build.PL and press Enter.
  6. Type in sudo ./Build and press Enter.
  7. Type in sudo ./Build test and press Enter.
  8. Type in sudo ./Build install and press Enter.
  9. Type in CD .. and press Enter.
  10. Now you’ll grab shairport, the DIY Airport software. Type in git clone https://github.com/hendrikw82/shairport.git and press Enter.
  11. Type in cd shairport and press Enter.
  12. Type in make and press Enter.
  13. Type in ./shairport.pl -a AlexaPi and press Enter.

With that, you can now stream music or other audio to your DIY Echo using the AirPlay protocol. Now that your Echo is up and running, go ahead and start playing around with it.


반응형