loading

These are instructions for building a box enclosure from a set of old USB speakers that will implement an Amazon Alexa Echo device using the C.H.I.P. $9 computer from Next Thing Co. (http://www.getchip.com/).

So what's an "Echo" device? An Amazon Echo is a wireless voice command product sold by Amazon.com. An Echo device can be a device built by you that uses Amazon's Alexa service. The device would be capable of voice interaction, and providing news, weather, and other real time information. Using the service your device would be limited compared to Amazon's product.

Limited by the software you create to interface with the service and also limited by the licensing restrictions set by Amazon to use the service. For example this type of device does not support setting a timer, or playing music like the Amazon Echo product. Another license restriction is not allowing the use of keyword detection. This means that your device would need a button to submit a question for example. The Amazon Echo product costs $179.99 and the Amazon Dot, a similar product, costs $89.99 at Amazon.com.

NOTE: this DIY device can also be developed using a Raspberry Pi as well but is not the focus of these instructions. For more info on how to do this with a Raspberry Pi see: https://github.com/amzn/alexa-avs-raspberry-pi,

I am a big fan of C.H.I.P. because it packs a lot of functionality in a small footprint, and since I just got mine in February I decided to use it on this project. I have also developed a home control application on Raspberry Pi using an iPhone, so the Raspberry Pi is a very similar platform.

Anyway..... I was tinkering around and got this working from Sam Machin’s “The $10 Echo” site (http://sammachin.com/the-10-echo/). I got it working with a USB thumb microphone and I had a set of old USB speakers lying around that I could not get rid of, so I decided to use them to create a box to contain “Alexa”.

I like reusing old equipment and gutting things like this rather than creating a new enclosure. My "Making" and handcrafting skills are not the best... In these instructions I will not go into too much detail on the specifics of the hardware modifications to the speakers I used, since you may choose to use other speakers or a completely different enclosure. I will just document my steps as an example and hopefully that will motivate you to create an even better enclosure and/or device. I will provide the configuration information, adding to Sam Machin's efforts, and recommendations from those on the C.H.I.P. forum site that were helpful to me.

Difficulty: Easy to medium software build, and medium hardware build effort with some soldering and disassembly & assembly

Limitations / Options / Alternative Approaches:

  • Amazon does not support using their service with keyword detection: This means implementing it on your own device with keyword detection is against Amazon’s service agreement. Therefore a push button is used to send commands and invoke the Alexa service. (Turns out I like this approach better anyway).
  • Microphone: I used the USB thumb mic because it was the simplest for me. Its low power and self contained requiring no amplification circuit or wiring or other additions.
  • Enclosure: I used the chosen USB speakers because I had them lying around, no extra costs for me. But also because they have built in audio amplification, power and volume adjust that I did not have to come up with. Alternatives: a more fancy box, your own amplification or fixed volume control or other enhancements.
  • Board modifications for C.H.I.P. not required: In the original article, Sam used a USB audio and mic combination device that also required him to cut a trace on the back of the C.H.I.P. board to enable audio input through the TRRS 3.5mm jack. I preferred not to do this and therefore, for my prototype, I used the TRRS 3.5mm jack for output only and a USB mic numb for voice input. For details on board modifications see README.MD on Sam’s github: http://tinyurl.com/jxy2xpu. I wanted to be able to re-use my C.H.I.P. at a later time and did not want to modify it. NOTE: later on you will see that for my final build I used the C.H.I.P. header connections U14 pins 4,6 & 8 for audio out rather than the TRRS jack because of space constraints in the enclosure.
  • Python code: ...and of course further optimization of the code and my steps for implementing the code could be developed and I welcome any comments.

Potential issues: software latency and wireless communications issues with the Alexa services and finding the right enclosure can be issues for you. There are frequent errors that can occur from communications with the Amazon service for multiple reasons. I tried to compensate for it by adding error checking that forces a restart of the code but they did not resolve these much. I am sure there may be further software optimization that can be done to improve on these issues. I think these happened when I got too impatient with it and was looking for faster responses... It can take 3 seconds or more for a response to a question. Be patient. Your mileage may vary on the 3 seconds depending on how fast your wireless & internet connections are.

NOTE: I suggest that you prototype (Steps 1 through Step 5) before investing a lot of time on a making or modifying a final enclosure, to better understand these issues and reconcile them with your expectations.

Materials list:

  • C.H.I.P $9 computer from Next Thing Co. @ http://docs.getchip.com/ ($9 + shipping = $15.47. They are not readily available as of this writing. You can preorder on the website for June 2016 delivery. )
  • Old set of USB speakers that will provide room for mounting C.H.I.P. and wiring, (~$10 or so on ebay)
  • USB Thumb Microphone: @Amazon: http://tinyurl.com/hoowvmn (~$2.55)
  • Momentary SPST Push Button Switch: @Amazon: http://tinyurl.com/hoowvmn (~$2.34)

Step 1: Setup & Pre-configure C.H.I.P.:

NOTE: depending on your C.H.I.P. build and any work you may have already done on it, there may be items on the list below, that you DO NOT need to include. For example: if you have already installed one of the software components such as "git".

    For an Initial setup of C.H.I.P.: See a great post on “Setting up C.H.I.P. as a headless server with minimal tools”: http://tinyurl.com/zw42n4q. Once that is done...

    I suggest you always upgrade C.H.I.P. as the first step:

    sudo apt-get update

    Install git:

    sudo apt-get install git

    Install some other software...:

    sudo apt-get install libasound2-dev memcached python-pip
    
    sudo apt-get install mpg321

    Get Sam's python code and set it up:

    sudo git clone  https://github.com/sammachin/AlexaCHIP

    cd AlexaCHIP

    sudo pip install -r requirements.txt

    And in case these are not installed yet:

    apt-get install --upgrade python
    apt-get install python-alsaaudio
    apt-get install python-pyalsa

    Step 2: Setup Alexa Service

    Use the following video: "Installing Alexa Voice Service to Raspberry Pi" (http://tinyurl.com/zzxywbt) to setup the Amazon Alexa device service. This setup allows you to use the Amazon Alexa service on the device and provides you a device ID, security codes and permission via your Amazon account to use the service on your device.

    This step involves going to "https://developer.amazon.com" per the video above to setup the service. I would recommend reviewing the whole video but the interesting parts to setup the service starts at 3:37 minutes where the actual service is setup.

    You will end up with

    • a Product ID, mine was: "EchoCHIP" - you can name it whatever you like,
    • a Security Profile Description "Echo CHIP" - I kept it short but you can give a longer description,
    • a Client ID (long id string provided by Amazon) ,
    • a Client Secret (long string provided by Amazon).

    A "refresh token" will be need to be retrieved in our next step to complete the Alexa Service config.

    Copy and maintain a record of all these items (although you can always also go back to the Amazon site to get these).

    Step 3: Update C.H.I.P. With Alexa & Python3 Settings:

    Using the “The $10 Echo” setup from http://sammachin.com/the-10-echo/ and the README.md file from his github files at: http://sammachin.com/the-10-echo/ do the following steps:

      Create the Alexa service credentials file and authorization files:

      1. Make a copy of example_creds.py to work with:
      cp example_creds.py creds.py

      Edit the creds.py to add the Alexa service device ID, security codes,etc and use your previous recorded details for the creds.py file:

      nano creds.py  

      Run the authorization request from the device :

       sudo python ./auth_web.py   
      

      On your computer go to your web browser using your C.H.I.P. local ip address: http://192.168.###.###:5000 and then you can get the refresh token from Amazon to add to cred.py. Copy this very long token into the cred.py.

      Edit the cred.py file and now add the "refresh token" you got from the Amazon site on your browser. This authenticates your device with your Amazon account:

      nano creds.py


      Ready to Test

      Install a momentary push button switch across: GPIO1 and GND (pins 14 and 1 on U14). See C.H.I.P. connector pinouts: http://docs.getchip.com/#pin-headers. NOTE: I suggest doing this for test and prototyping purposes now without final mounting it yet.

      At the C.H.I.P. :

      sudo apt-get install python3-pip     
      
      sudo pip3 install python3-memcached
      
      sudo pip3 install pyalsaaudio

      For the USB microphone setup: edit your /usr/share/alsa/alsa.conf file so that "pcm.front cards.pcm.front" is renamed "pcm.front cards.pcm.default" (for correct audio device selection and identification)

      nano /usr/share/alsa/alsa.conf

      For USB microphone setup: edit /etc/asound.conf and add the following code. This initializes the microphone and audio settings:

      pcm.usb {
          format S16_LE
          rate 44100
          type hw
          card 1
          device 0
      }
      pcm.!default {
          type asym
          playback.pcm {
            type plug
            slave.pcm "hw:0,0"
          }
          capture.pcm {
             type plug
             slave.pcm "usb"
          }
      }

      "reboot your C.H.I.P."

      sudo reboot

      At this point in this process, I wanted to verify and test the use of the USB mic and the audio output before running the Python code. With the microphone installed and a speaker plugged in I manually tested this by using...

      arecord -D plughw:1,0 -f cd test.wav

      ...to record some audio and...

      aplay test.wav

      ...to play that recording. This allowed me to make sure before running the Python code that input and record of audio with my chosen microphone and audio output were working. You may need to use "amixer" and/or "alsamixer" commands at the command lines to adjust mic and audio output settings. See the links below for more information.

      Here are some references to getting audio and recording working. Some of these are Raspberry Pi articles and some are general Linux articles but they provide some guidance on audio architectures:

      1. Raspberry Pi microphone setup with USB sound card | Linux Circle: http://www.linuxcircle.com/2013/05/08/raspberry-pi-microphone-setup-with-usb-sound-card/

      2. Using a USB Audio Device With a Raspberry Pi - Envato Tuts+ Computer Skills Article: http://computers.tutsplus.com/articles/using-a-usb-audio-device-with-a-raspberry-pi--mac-55876
      1. Advanced Linux Sound Architecture - ArchWiki: https://wiki.archlinux.org/index.php/Advanced_Linux_Sound_Architecture

      Step 4: Update to New Python Code & Try It Out

      IMPORTANT Update: replace the "main.py" in the AlexaCHIP folder with the following update from github: http://tinyurl.com/zrjaldy (Thanks to Justine Thomas). This update contains updates to the code to support the use of the USB Thumb Microphone. It uses "mplayer" to code to convert recordings to be compatible with the Alexa service. Unfortunately this adds some delay to the communication with the service. (A possible opportunity for optimization in the future).

      Let's now test the code. First let's enable the GPIO pins by running the setup script to enable pushbutton switch::

      sudo ./setup _gpio.sh

      At this point you should be able to test your configuration to communicate with the Alexa service. Run the python code:

      sudo python3 main.py

      Alexa should respond after a few seconds by saying "Hello". At this point you are ready to ask your first question:

      Press the pushbutton switch and keep it pressed while asking your question. For example:

      "Alexa, who are you?"

      After at least 3 seconds Alexa will then respond with a short explanation of who she is. Other related questions you can ask are:

      "When is your birthday?" or "Who made you?" or "Where were you born"

      Alexa will respond to each of these differently. Notice you did not need to use the name "Alexa" in front of these questions while hold down the pushbutton switch. This is because the switch replaces the "keyword detection" mechanism mentioned previously.

      Here are some other questions you can test:

        What time is it? or What day is it? 
        
        What is the weather? or What's new? or Who is JJ Watt? 

        If you setup Alexa with location settings it can respond with weather from your location. To do this you can setup the Alexa service settings using an iPhone app (Alexa app) or an Android app (Alexa app) or at this address: http://alexa.amazon.com. Here you can customize Alexa (i.e. setup your zip code & location etc).

        Now, it's just a matter of putting it all together in the hardware. But first let's button up the software automation a bit before that....

        Step 5: Automate the Software & Bootup

        In order to get the python code to run automatically you will need to set it up to run at bootup. I used a script in /etc/init.d to accomplish this.

        The following script allows you to stop, start and restart the Alexa service python application. See the script contents for the syntax for doing this.

        NOTE: using this script the Python code will start automatically when you apply power to the box and Alexa will be accessible without having to start it in any other way.

        Below is the code that should be copied to /etc/init.d as /etc/init.d/alexa-service.sh,

        #!/bin/sh 
        ### BEGIN INIT INFO
        # Provides:          alexa-service
        # Required-Start:    $remote_fs $syslog
        # Required-Stop:     $remote_fs $syslog
        # Default-Start:     2 3 4 5
        # Default-Stop:      0 1 6
        # Short-Description: Simple script to start a Alexa Service program at boot
        # Description:       A simple script which will start / stop a program a boot / shutdown.
        ### END INIT INFO
        #
        workdir=/home/chip/AlexaCHIP
        progname="/home/chip/AlexaCHIP/setup_alexa.sh"
        start() {
            echo "Starting service..."
            cd $workdir
            /home/chip/AlexaCHIP/setup_gpio.sh
            $progname
        }
        stop() {
            pid=`ps -ef | grep '[p]ython3 main.py' | awk '{ print $2 }'`
            echo $pid
            kill $pid
            sleep 2
            echo "Server killed."
        }
        case "$1" in
          start)
            start
            ;;
          stop)
            stop   
            ;;
          restart)
            stop
            start
            ;;
          *)
            echo "Usage: /etc/init.d/alexa-service {start|stop|restart}"
            exit 1
            ;;
        esac
        exit 0 

        After you copy the above script to /etc/init.d as /etc/init.d/alexa-service.sh, do the following:

          Make the script executable:

          sudo chmod 755/etc/init.d/alexa-service.sh

          Register script to be run at start-up:

          sudo update-rc.d alexa-service.sh defaults

          If you ever want to remove the script from start-up, run the following command: "sudo update-rc.d -f alexa-service.sh remove"

          The setup script: "setup_alexa.sh" script, used and refrerenced in the above startup script, is what I used to keep the python code running continuously. I first created it to invoke the "python3 main.py" command to troubleshoot the code. It helped me manage what I wanted to execute and do some troubleshooting. When I did not use it, there were too many times where there were errors that halted the code with no response from Alexa, even though it would be working correctly when it did respond. These errors tended to be communications or software latency issues I suspect, so the "setup_alexa.sh" script allowed me to keep it running. THis is not the best solution but it works, and keeps the service running for me. It just re-executes the code again if there was an error.

          Below is the contents of the "setup_alexa.sh" script:

          #!/bin/bash 
          PROGNAME='sudo python3 main.py'
          
          cd /home/chip/AlexaCHIP
          # Run the code until CTRL-C 
          while [ $? -ne 130 ]; do
              $PROGNAME
              sleep 5
          done
          exit $?

          Step 6: Modifying the Hardware

          Disassembly of the speaker box and modifications depend on the speaker or enclosure you decide to use. I used a set of HP Multimedia Speakers, Model no. UC236. These are USB powered speakers with a standard audio plug for audio input. For my purposes I eliminated the second speaker and kept the control speaker that had power, volume and tone controls. I also removed the audio plug since I intended on using it internally.

          The speaker board used in the control speaker has a power circuit to turn power to the speakers on/off and also has volume & tone controls.

          The control speaker PCB board had solder pads (connections for the audio plug which I removed). These I used to for input from the C.H.I.P. board so that you can hear Alexa's response.

          The control speaker enclosure also had to be modified to mount a pushbutton switch for activation of the Alexa service.

          Concerns: while the C.H.I.P computer does not usually get hot I realized after completing this that the control speaker enclosure does NOT have vents or ventilation of any kind. Before running it for too long I intend on making some vent holes in the enclosure to ensure it has some ventilation for the C.H.I.P.

          Step 7: Wiring the Power to the C.H.I.P. and the Speaker Board

          I did not want to take the chance of damaging my C.H.I.P. with power from the speaker PCB since I did not have a schematic and was not sure that switching the speaker board on / off would spike the C.H.I.P input.

          I also was not sure it drove enough current to power the C.H.I.P. So I wired power for the C.H.I.P. directly from the USB input power connection.

          So I have to live with the fact that as soon as I plug in the USB power connector the C.H.I.P would power on rather than using the control speaker power switch.

          The board has PCB pads for USB power input which I used to wire to the the C.H.I.P. board power pins on U13 header pins 1 (GND) & 3 (VCC-5V). These connections are not switched on by control speaker and therefore not susceptible to electrical noise from the power switch. Also, not having a schematic or knowing too much about this board I could not count on it providing enough power for the C.H.I.P.

          At later time I will look at this and see how I can improve on this.

          Step 8: Wiring the Audio Connections From the Speaker Board to the C.H.I.P.

          The speaker board had connections for audio input (from the audio plug I removed) and therefore I used these inputs to wire output audio from the C.H.I.P. You may ask why I did not use the TRRS 3.5mm jack. Using the jack would take up too much space and not allowed me to fit the C.H.I.P. board in the speaker enclosure.

          The USB Thumb Microphone: I used a USB Thumb Microphone (see Amazon: http://tinyurl.com/hoowvmn). This provided a better solution for me since it is low power, and does not require any amplification or other wiring. I also wanted to be able to re-use it, like the C.H.I.P. board, in case one day I wanted to disassemble this project and reuse the materials.

          Therefore I decided to cut a hole in the speaker box with my Dremel tool for the USB mic (see picture below). This allowed me to take it out and put it back in, in case I needed to use it with my Raspberry Pi units or other uses. Cutting this hole also worked out well since it allowed for more room in the speaker enclosure.

          Step 9: Wiring the Momentary Pushbutton Switch

          As mentioned above the pushbutton switch is used to initiate Alexa service and ask it questions. I mounted a large red switch (see Amazon: http://tinyurl.com/zr3ph8b) to the front panel and wired one side of the switch to U14 header connector pin 1 (GND) and the other to U14 header connector pin 14 (XIO-P1).

          Mounting the switch required me to drill out a hole for it with my Dremel tool to the front of the control speaker.

          Step 10: Mounting the C.H.I.P. Board Inside the Speaker Enclosure

          I wanted to be able to possibly reuse the C.H.I.P. board again. They are not readily available as of this writing. But you can preorder on the website for June 2016 delivery so I am waiting for my 2nd one.

          So I may reuse this one until I get another one. Therefore I decide to use velcro (handy man secret weapon #3, besides duck tape #1 and WD-40 #2). So I applied velcro to the back of the C.H.I.P. board and to the top of the inside of the speaker enclosure.

          NOTE: this is an important point, I had enough clearance for the board to fit behind the speaker and toward the top of the enclosure. I got lucky, since it can be hard to find room in most speaker boxes.

          I also plugged in the USB thumb mic.

          Step 11: Test and Reassemble the Whole Thing

          I then tested the unit with power without closing up the speakers to make sure everything was working correctly. Afterwards I closed it up and tested it again.

          As I mentioned above, while the C.H.I.P computer does not usually get hot I realized after completing this that the control speaker enclosure does NOT have vents or ventilation of any kind. Before running it for too long I intend on making some vent holes in the enclosure to ensure it has some ventilation for the C.H.I.P.

          Code Sources & Information References

          • Video on Alexa service setup: Use the following video on Installing Alexa Voice Service to Raspberry Pi and it is the same for C.H.I.P.: http://tinyurl.com/zzxywbt
          • Below are some questions you can try with the device:
          • Alexa, What time is it?
          • What day is it?
          • What's the weather? (make sure and set your location in Alexa app or @ http://alexa.amazon.com )
          • What's new?
          • What is 2 + 2?
          • How many days until September 1?
          • What are some movies playing nearby?
          • What movie won best picture in 1991?
          • Who are you?
          • Where do you live?
          • Who made you?
          • When is your birthday?
          • Where were you born?
          • How many cups are in a quart?
          • How many tablespoons are in a stick of butter?
          • Do aliens exist?
          • What is the answer to life, the universe, and everything?
          • What are you going to do today?
          • Tell me a joke.
          • Meow
          • Do you know Siri?
          • Can you rap?
          • Can you beatbox?
          • Who is the real slim shady?
          • Beam me up
          • Close the Pod Bay Doors
          • Tea. Earl Grey. Hot
          • What are the Laws of Robotics
          • What are the rules of fight club?
          • Do you have Prince Albert in a can?
          • Surely you can't be serious
          • Who's on first
          • To be or not to be...
          • Who is the fairest of them all? (ask this one twice)
          • What came first, the chicken or the egg?
          • How much wood would a wood chuck chuck if a wood chuck could chuck wood?\
          • How many licks does it take to get to the center of a tootsie pop?
          • Who loves ya baby?
          • What is love?.
          • How much is that doggie in the window?

          • Who let the dogs out?
          • Play a song. - NOT SUPPORTED FOR THIS DEVICE
          • Set a timer for 10 minutes. - NOT SUPPORTED FOR THIS DEVICE

          Although there are some differences & limitations to this device compared to the Amazon products, this link may be helpful also: http://blog.anythings.co/ultimate-guide-amazon-echo-alexa/

          I hope that making this will be as much fun for you as it has been for me. I take very little credit for originating any of this code or process. I take credit for compiling it all and for being too verbose here.... :-)

          Now go find a great way to build your own.

          <p>I made the listed changes for 4.4 (gpio1017) and my recording test worked fine.</p><p>I run main.py and get the &quot;Hello&quot;</p><p>That's about it though. I see these errors when I run main.py:</p><p>ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.sun4i-codec.pcm.front.0:CARD=0'</p><p>ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory</p><p>ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory</p><p>Not sure where to go from here. Thanks for the great project though. I know I'll get it working at some point</p>
          <p>Finally made it work, I also added the GPIO library so no more file system hacks .<br><br>I used Teraterm as well as tightvncserver. <br><br>Using the computer Xterminal made it possible to edit and download files into the right places. . Next up is operating the fish <br><br>Using the comp</p>
          <p>Very Nice Instructable. Thank you. I have it running on 4.4 Lite(no gui). I changed the gpio references to 1017. I used an old 8Ohm speaker from a pc attached directly to HP COM and HP R. It is loud enough to function in a quiet room.</p>
          <p>Nice project,May i customize the questions and Alexa's answers?</p>
          <p>I did and it works but my Chip (4.4) uses systemd and not init.d</p><p>Can anyone help me to start it on boot using systemd?</p><p>Thanks</p>
          <p>I'm sort of stuck in that I don't think my gpio pins are activating anything.</p><p>Running kernel 4.4. Gpiochip1016 is what's in my directory (versus 408 or 409 in the documentaton).<br><br>I've modified the python code for this gpio1016 directory.<br><br>I have the USB mic running. I can make a test recording and play it back.<br>I run the main.py using python3 and I get a &quot;hello&quot;<br><br>I've activated the gpio script and I get returned the following...<br>1016<br>in<br>1</p><p>But pressing the push button, or even shorting out the leads from pin 1 and pin 14 on U14 does nothing....<br><br>It sort of stops after Hello.<br><br><br> </p>
          <p>Well, I installed Kernel 4.3 and went through everything again and it works. Something about GPIO director of 1016 versus 409 that's preventing this from working in kernel 4.4.</p>
          <p>Hi: I made mine work on 4.4 kernel. The pin base is differnet on both kernels, on 4.3 it starts at 408 and on 4.4 it starts at 1016 for the zero pin. Since in this example we are using the pin #1 then you need to change the setup_gpio.sh to echo 1017 and the paths to point to the directory gpio1017. Also you need to change the main.py, find the line of code that's looking for the gpio path and change the 408 reference to 1017 as well. Make sure you run it with the python3 command. Hope this helps.</p>
          <p>Yeah, I have not tried 4.4 yet. I repurposed my CHIP (only have one... waiting on another) and have been using it for something else. Still on 4.3. I remember seeing something about GPIO and 4.4 on Sam Machin's GITHUB and/or on CHIP community pages, you may want to check there.</p>
          <p>Hi! First off, great project!</p><p>I was wondering if there was any chance we could modify the code to take the input from a headphone, and also output Alexa's response through the headphone. I've ordered the USB Mic but it's gonna be a while before it gets to me, and don't want to wait till then to get this to work</p>
          <p>Hi! First off, great project!</p><p>I was wondering if there was any chance we could modify the code to take the input from a headphone, and also output Alexa's response through the headphone. I've ordered the USB Mic but it's gonna be a while before it gets to me, and don't want to wait till then to get this to work</p>
          <p>Hi! First off, great project!</p><p>I was wondering if there was any chance we could modify the code to take the input from a headphone, and also output Alexa's response through the headphone. I've ordered the USB Mic but it's gonna be a while before it gets to me, and don't want to wait till then to get this to work</p>
          <p>Hi! First off, great project!</p><p>I was wondering if there was any chance we could modify the code to take the input from a headphone, and also output Alexa's response through the headphone. I've ordered the USB Mic but it's gonna be a while before it gets to me, and don't want to wait till then to get this to work</p>
          <p>Hi! First off, great project!</p><p>I was wondering if there was any chance we could modify the code to take the input from a headphone, and also output Alexa's response through the headphone. I've ordered the USB Mic but it's gonna be a while before it gets to me, and don't want to wait till then to get this to work</p>
          <p>Hi! First off, great project!</p><p>I was wondering if there was any chance we could modify the code to take the input from a headphone, and also output Alexa's response through the headphone. I've ordered the USB Mic but it's gonna be a while before it gets to me, and don't want to wait till then to get this to work</p>
          <p>Hi! First off, great project!</p><p>I was wondering if there was any chance we could modify the code to take the input from a headphone, and also output Alexa's response through the headphone. I've ordered the USB Mic but it's gonna be a while before it gets to me, and don't want to wait till then to get this to work</p>
          <p>Hi! First off, great project!</p><p>I was wondering if there was any chance we could modify the code to take the input from a headphone, and also output Alexa's response through the headphone. I've ordered the USB Mic but it's gonna be a while before it gets to me, and don't want to wait till then to get this to work</p>
          <p>I also encounter this error when first starting up the alexa by python3 main.py. But I got around it by creating a 'recording.wav' manually (not sure if that is legit way to do it or not)</p><pre>root@chip:~/AlexaCHIP# python3 main.py<br>sh: mplayer: command not found<br>Traceback (most recent call last):<br> File &quot;main.py&quot;, line 124, in &lt;module&gt;<br> alexa()<br> File &quot;main.py&quot;, line 90, in alexa<br> with open('recording.wav', 'rb') as inf:<br>FileNotFoundError: [Errno 2] No such file or directory: 'recording.wav'</pre>
          <p>Chip 4.3 headless is paired down build and may not include things like mplayer any longer. You may be able to do &quot;sudo apt-get update &amp;&amp; sudo apt-get upgrade&quot; and if mplayer is still not installed after that you can do &quot;sudo apt-get install mplayer&quot;.</p>
          <p>also this </p><p>im using chip 4.3 headless, logitech USB microphone and normal speaker.</p><pre>root@chip:~/AlexaCHIP# python3 main.py<br>sh: mplayer: command not found<br>Traceback (most recent call last):<br> File &quot;main.py&quot;, line 124, in &lt;module&gt;<br> alexa()<br> File &quot;main.py&quot;, line 99, in alexa<br> data = r.content.split(boundary.encode('utf-8'))<br>UnboundLocalError: local variable 'boundary' referenced before assignment</pre>
          <p>I've been looking for something with which to use one of my CHIPs. This is excellent! Thank you for the tutorial! I am going to give this a shot. I'm thinking I'm going to strip the speaker and build my own wooden enclosure and then install everything into that.If I use a wired USB speaker does anyone know if the bluetooth capability of the CHIP will still work? What I would ideally like to do is to create my own ECHO like above but when playing music through it to pair it to my bluetooth capable soundbar which would offer much better sound. If it is possible, do you know how I would pair it? </p>
          <p>Got it working beautifully!! Thanks to all the contributors to make this project so easily. And I was able to finally order an ECHO DOT!! But it arrives in July :-(( But better than never. As I did not want the echo tower. </p><p>A missing step also</p><p>Sudo apt-get install mpg321</p><p>again thanks to Al, Sam Machin and Justine Thomas. Very impressive how smooth the installation was except a few bugs and my learning curve as first project on CHIP!!</p>
          <p>Good to hear you got it working. Good catch. Went back to my original notes and found that line (&quot;sudo apt-get install mpg321&quot;). I updated the instructions above. Thanks Joe!</p>
          <p>I am testing the audio following the instruction. I am getting error on testing the record. I am using the usb mic with command: arecord -D plughw:1,0 -f cd test.wav</p><p>I get this error message :</p><p>chip@chip:~$ arecord -D plughw:1,0 -f cd test.wav</p><p>ALSA lib conf.c:1697:(snd_config_load1) _toplevel_:2:5:Unexpected char</p><p>ALSA lib conf.c:3417:(config_file_open) /etc/asound.conf may be old or corrupted: consider to remove or fix it</p><p>ALSA lib conf.c:3339:(snd_config_hooks_call) function snd_config_hook_load returned error: Invalid argument</p><p>ALSA lib conf.c:3788:(snd_config_update_r) hooks failed, removing configuration</p><p>arecord: main:722: audio open error: Invalid argument</p><p>I checked my /etc/asound.conf... it is as instructed (there were no previous such file, so created new one)</p><p>Any suggestions....????</p>
          <p>Sorry you having issues with the sound. Since it references ALSA lib conf.c then that must be the installed audio drivers. Make sure you CHIP was up-to-date and then my suggestion is that you try re-installing the alsaaudio software. You can get some info from this link: <a href="http://www.linuxcircle.com/2013/05/08/raspberry-pi-microphone-setup-with-usb-sound-card/" rel="nofollow">http://www.linuxcircle.com/2013/05/08/raspberry-pi...</a> and this link as well: <a href="http://computers.tutsplus.com/articles/using-a-usb-audio-device-with-a-raspberry-pi--mac-55876" rel="nofollow">http://computers.tutsplus.com/articles/using-a-usb...</a> </p>
          <p>Hey Al, thanks for the quick response. I reflashed the whole OS and made sure I started clean. I tested the sound and it worked prior to installation of ALEXA. But as soon as the testing of record, that is where I got the error. I think I narrowed down to my problem. it is with somehow a bad asound.conf file. </p><p>Can you verify 1) There was no previous asound.conf so i had to create a new one. is there maybe permissions that I need to set for file permission? 2) are there some strange hidden char I am picking up from copy and paste in your example code? I put it through notepad++ and did not see any difference.. 3) are the curly brackets correct on the &quot; pcm.!default&quot;</p><p>i have a feeling it is here I am having problems as I removed the file and rebooted and amixer at least came up, where as with the asound.conf it was giving me errors..</p><p>Thanks for your help and great tutorial</p>
          <p>Hey Joe, 1) Yes there was no previous asound.conf file that I had to modify. Also, I was able to use arecord after Alexa was working as well. 2) No hidden char. There was a mistaken &quot;.&quot; after the { in Step 3 for the asound.conf file contents. I updated the instructions to remove the typo. 3) Yes the brackets are correct. The format was not, so I updated the instructables to remove the &quot;.&quot; and format the code correctly. </p>
          <p>thanks Al, that pesky dot was the problem . unfortunately, I am testing sound but no luck. So tracking that down now</p><p>thanks again</p>
          <p>Try using amixer to set mic &amp; audio out volume. When I first tested they were set low, so recording volume was very low and did not hear anything.</p>
          Al. I am at home now so no way to test. But looking at your around.conf. I see &quot;pcm.usb{.&quot; with a dot after the left curly. Is the DOT suppose to be there? Seems odd to me but don't know the intricacies of a conf file.
          <p>No. I fixed the instructions to remove the &quot;.&quot;</p><p>If this helps, I have had feedback from others that they have gotten these instructions to work for them. Keep trying, the alsa sound infrastructure is overly complex in my opinion, so it can be convoluted to troubleshoot. Make sure you also have done the previous step to edit the /usr/share/alsa/alsa.conf file as well. </p>
          <p>I keep recieving an error when I press the button&quot;</p><p>alsaaudio.ALSAAudioError: Capture data too large. Try decreasing period size</p><p>Any ideas on this? I'm using the same Mic suggested above (after having the same issue with two I already had).</p>
          <p>Look at STEP 4 of the Instructable to make sure you updated the Python code &quot;main.py&quot; with the code at the link specified. It adjusts the mics input rate. I remember see this error when I first set it up in one of the comments on github for that code so I am pretty sure it fixes that.</p>
          <p>This is why I love this site. I've got a CHIP and we're getting the echo dot to extend our echo.</p><p>I'm building this for my workshop!</p><p>I'm going to try it with bluetooth speakers though, figure see if I can put the chip's bluetooth to work.</p>
          <p><em>Very nice job Now I know what to do w/my CHIP. My wife will not let me get an Echo, so now I will just build one. Thanks again very smart man!!</em></p>
          <p>Glad to hear it! Thank you sir.</p>
          <p>Very cool. I am going to add this to my next Robot (if I ever finish the other 8 I have started)</p>
          <p>That is a really cool system for $9</p>
          Yeah, it is cool. $9 is for the CHIP board (computer). With shipping charges it comes to ~$15. The parts all add up to about $20 or so, depending on if you buy some speakers for this.

          About This Instructable

          8,714views

          58favorites

          License:

          More by al-j:An Echo Device using the C.H.I.P. $9 Computer  
          Add instructable to: