아래 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:
- Log into your Amazon Developer Account.
- Click on the Alexa Tab.
- Click Register a Product Type > Device.
- Name your device type and display name (We chose “Raspberry Pi” for both).
- Click Next.
- On the Security Profile screen, slick “Create new profile.”
- Under the General tab, next to “Security Profile Name” name your profile. Do the same for the description. Click Next.
- Make a note of the Product ID, Client ID, and Client Secret that the site generates for you.
- Click the Web Settings tab, then click the Edit button next to the profile dropdown.
- Next to Allowed Origins, click, “Add Another” and type in:
https://localhost:3000. - Next to Allowed Return URLs, click “Add Another” and type in:
https://localhost:3000/authresponseClick Next when you’re done. - 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.
- 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.
- Open the Terminal application on the Raspberry Pi and type:
cd Desktopand press Enter. - Type in
git clone https://github.com/alexa/alexa-avs-sample-app.gitand press Enter. - Once that’s complete, type in:
cd ~/Desktop/alexa-avs-sample-appand press Enter. - Type in
nano automated_install.shand press Enter. - 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. - You’re now back at the command line. It’s time to run the install script. Type in
cd ~/Desktop/alexa-avs-sample-appand press Enter. - Type in
. automated_install.shand press Enter. - 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:
- Type in
cd ~/Desktop/alexa-avs-sample-app/samplesand press Enter. - Type in
cd companionService && npm startand 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.
- In your new Terminal window type in
cd ~/Desktop/alexa-avs-sample-app/samplesand press Enter. - Type in
cd javaclient && mvn exec:execand press Enter. - 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.
- Log into your Amazon account in the browser.
- You’ll see an authentication screen for your device. Click Okay. Your browser will now display “device tokens ready.”
- 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:
- Type in
cd ~/Desktop/alexa-avs-sample-app/samplesand press Enter. - 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.
- From the command line, type in
alsamixerand press Enter. - Tap F6 to select a different USB device. Use the arrow keys to select your microphone.
- Use the arrow keys to increase the capture volume.
- When you’re happy with the volume, tap ESC to exit.
- Type in
sudo alsactl storeand 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:
- 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. - Press Y when prompted and wait for everything to download and install.
- 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. - Type in
cd perl-net-sdpand press Enter. - Type in
perl Build.PLand press Enter. - Type in
sudo ./Buildand press Enter. - Type in
sudo ./Build testand press Enter. - Type in
sudo ./Build installand press Enter. - Type in
CD ..and press Enter. - Now you’ll grab shairport, the DIY Airport software. Type in
git clone https://github.com/hendrikw82/shairport.gitand press Enter. - Type in
cd shairportand press Enter. - Type in
makeand press Enter. - Type in
./shairport.pl -a AlexaPiand 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.



