Alexa on your Pi

Amazon ECHO, a smart speaker was a great hit in the market as it was first of its kind. With ECHO, you can do a lot of stuffs like asking questions,doing calculations,controlling appliances,asking about traffic or weather, or you can just interact with it. The heart of this product is AVS(Alexa Voice Service), if we install this heart in our own speaker than our speaker will turn to into ECHO. And this is what we gonna do right now!!!

We gonna build ECHO on our Raspberry Pi but before starting, we all should thank Sam Machin for
making client code for Raspberry Pi. Sam has made amazing projects using this AVS service. He made “Call Alexa” in which we can ask Alexa by just dialing a number on our phone.After that he made “Alexa in the Browser” and the 3rd and most famous work by him is AVS on RPI.Lets start how to do the stuff and how does it works.

Things Required

  1. Raspberry Pi with latest updates installed(I am using RPi 3 with Raspbian Jessie lite) Get Raspberry Pi3 at lowest Rate on Internet
  2. a speaker
  3. AUX cable to connect the speaker
  4. an USB mic ( if you don’t have a USB mic like me, you can attach normal mic with USB Soundcard. I have used the mic of my headphones along with USB soundcard) (Use this sound card)
  5. a push button

 



Getting started with AVS

We need to have an account on amazon to access Alexa Voice Service. If you already have an account just goto developer.amazon.com and log In to your account. Then goto Apps&Services and then into Alexa.




After that goto Alexa Voice Services. Here you need to register your device i.e. Raspberry Pi to get access to AVS. For that follow the steps shown in this video.

On Raspberry Pi

On raspberry pi first of all you need to install git by the command,

sudo apt-get install git

Note : make sure you are in @root

After that clone AlexaPi,

git clone https://github.com/techiesms/AlexaPi.git

After cloning go inside AlexaPi

cd AlexaPi

Before running the setup, see this video,

sudo sh setup.sh

After following all the steps, run the main.py script on your RPI and in response the board will say “hello” via speaker.(Note: You board must be connected to Internet)

sudo python main.py

 

How does it works?

Amazon ECHO and our ECHO Pi both runs on the same service and same procedure. Right now just talking about working of our code. In our code, as soon as we run the main script it will check the internet connection. If the connection is established, it will play hello.mp3 file which is inbuilt through speaker.

After that it will wait for the user to press the button. As soon as we press the button, it will start recording our voice and save it in a file called recording.wav. So when we release the button according to the code, this recording file will be sent to Alexa’s voice recognition algorithm which is on the server of Amazon.When we send data to the server, everytime it checks the client ID, secret profile, refresh_token and all to verify that this device is the registered device. After recognizing the voice, it will be calling specific API(Application Program Interface) according to the given command.All this process takes place on the server side.

 


After the process, the server will send a mp3 file in response which will be saved as response.mp3 on our board. And after receiving the file, RPI will simply play that file. And this is how ECHO Pi works.

DIY Video

[ENGLISH]

[HINDI]

 

 

#techiesms

explore | learn | share

Leave a Reply

Your email address will not be published. Required fields are marked *