I recently purchased an Amazon Echo (as well as an Echo Dot), and have thoroughly enjoyed watching the girls use it to their hearts content (and using it every chance I get myself). I got even more excited when I realized that Amazon had created an API that would allow other developers to use the same service (at least Most of it) in their own applications/devices. After doing some Googling, I stumbled across Sam Machin’s version that he wrote for the Raspberry Pi. He called it AlexaPi. I jumped as soon as I found it and installed it on one of my Pi’s. I loved the new ability, but quickly discovered that it was lacking in some of the abilities that the Alexa Voice Service had.  My goal with AlexaDotNet is to learn what’s needed so I can help fix these things in the AlexaPi script.

One thing that’s missing from AlexaPi is that some of the responses would come in as multiple audio files, and it would/could only play back the first one. Example, when I ask it what’s on my shopping list, it would tell me that I have two items, and then stop. If I were to ask that very same question to my Echo, it would say the same thing, but then it would proceed to tell me what those items were. To me, this was a big deal. I needed my Pi to be able to play every audio response it could!

The second thing I quickly realized that it couldn’t do was play any of the streaming audio services. For instance, if I asked it to play WKML on TuneIn, it would repeat the station name to me, and then quit. It would never actually start streaming the station.

AlexaPi is written in Python, and I just don’t have “enough” experience with Python to take the task head-on quite yet. So I did the next best thing I knew I could, I decided to write an app in Visal Basic.NET (hence the name, AlexaDotNet) to access the Alexa API so then I could see exactly what was needed in order to resolve the two issues I mentioned above.

Well, I’ve done it! I have a working copy of Alexa running in a .NET app that currently does everything the AlexaPi script does. I plan to release the source code (on my GitHub page) to the public as soon as I clean it up.

Here’s what the application is looking like at this moment:

AlexaDotNet Screenshot

Here’s a list of thing’s I’m looking to accomplish with this project (in no official order):

  • Get the full response from thing’s like the “to-do” list and the “shopping” list.  (working again as of 3/16/2016)
  • Get streaming music to work with all of the following services:
    • Amazon Prime Music (working as of 3/15/2016)
    • TuneIn (working as of 3/16/2016)
    • iHeartRadio (working as of 3/15/2016)
    • Pandora (not supported with the API currently)
    • Spotify (not supported with the API currently)
  • Get the other following streaming services to work:
    • Audible (can’t test as I don’t have a subscription)
    • Kindle Books (working as of 3/15/2016)
Tagged with: , , , , , , , , ,
15 comments on “AlexaDotNET
  1. Mitch says:

    Congrats on getting the streaming working – even if it’s partial!

  2. Mitch says:

    Lenny, got mine working with your latest update. Sounds great! Nice to be able to stream prime and Tune-in!

    • Tom says:

      Mitch and Lenny, how did you get the audio streaming working? I have installed your (Lenny’s) AlexaPi package from GitHub but I can’t get audio streaming working. The Alexa features for home automation and answering questions works, but when I try to stream Tunein or iHeartRadio it says it is starting the station, but then nothing.
      Also when I try to set a timer or alarm it says that is not supported on this device. What am I missing?

  3. I’ve spent days on this trying to get it to work to no avail. It worked perfectly with a webcam mic and the onboard audio port on a Py B, but I absolutely could not get it to work with a Plugable audio card. The Plugable worked with aplay and arecord but not with Alexa. Today, I spent some time going through, found the lines that do the capture and tried running them in a Python session. Lo and behold, it wouldn’t work. After several hours, I finally determined that this whole thing has to run under PYTHON 3 and not the default python 2 that is standard with Jessie on a Pi B. I can’t wait to get home from work tonight to see if this is what is causing the issue.

    • Lenny Shirley says:

      I’m using Python 2.7.9, and AlexaPi works fine for me. I don’t have Python 3 installed. Zero issues…

      • Typically, when I boot with the Plugable inserted, I will not get the “hello” message. When I attempt to use the mic, the light will come on. When I release the button, both lights come on and just stay on until I kill the process. This can happen after a reboot or after starting manually. Often when the plugable is inserted and the process restarted/rebooted, there will be a log message that the connection failed. The failure never happens with the Logitech webcam mic and onboard audio. By the way, if you look in /usr/bin, I think you’ll see that you, indeed, have python 3 installed. I did a default install of the jessie download (not NOOBS) and it installed python 2.7 and 3.4.

      • I fixed the problem. At least for me, but not for everyone. You have a line that says:
        i = vlc.Instance(‘–aout=alsa’, ‘–alsa-audio-device=hw:CARD=ALSA,DEV=0’
        in the play_audio(file) function.

        Well, you’ve hardcoded the cardname here so only ALSA will ever work. I changed the line to say …CARD=Device… (since my audio card is called “Device) and now everything works as expected.With Python2

  4. Sam says:

    Hi. I am wanting to make a choose your own adventure game using .NET for my Amazon Echo. Is your API available. Do you have some sample programs using it. I’ve been a little lost getting started with Alexa programming.

    Thank you.

  5. dontze says:

    Lennysh, is this your AlexaPi github which can run radio streaming?
    I try this, but still cannot run radio streaming like iHeartradio

  6. I decided to start from scratch and try this with a standard usb microphone dongle and the 3.5 Pi audio port. I can get IHeartRadio to play, but TuneIn is just silence with “es demux error: cannot peek” message being displayed on my monitor. Also, alarms and timers are not functional, or so she says when I ask for an alarm to be set.

  7. I built one of these things!

    I tried mimicked Amazon’s design a little bit 🙂

    I can’t get it to read audiobooks or play radio as I think those services are reserved for Echo users.

    Here is a video of it in action:

  8. Ricardo says:

    Hi, any news when it will be available at GitHub?

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.