I’ve been playing with Google AIY on raspberry pi for nearly an hour now and I love it. If you are lucky you can get your kit from issue 57 of The MagPi Magazine.
Google provided a python based example app that recognises the command you spoke to the box and runs your action. The problem with it is that the command needs to match literally without and option to add variable part (a parameter). In real world I want to give parameters to the commands, for example “Add note my note“. So I’ve hacked the app to do just that. Here are the steps:
1. Modify the actionbase.py to recognize patterns. In class class KeywordHandler(object): change the handle method:
"""Perform the action when the given keyword is in the command."""
def __init__(self, keyword, action):
self.keyword = keyword.lower()
self.action = action
def handle(self, command):
if("*" in self.keyword):
match = re.match(self.keyword.lower(), command.lower())
if self.keyword in command.lower():
2. Make sure the action you are running understands that the param given to it is the variable part. I’ve modified the SpeakAction to do just that:
"""Says the given text via TTS."""
def __init__(self, say, words):
self.say = say
self.words = words
def run(self, voice_command):
I’m using Raspberry Pi as a media center using raspmbc, which is amazing for streaming (bbc iplayer, 4od) and playing files from NAS and USB. For DVDs I still needed to connect my laptop to TV, which is just an unnecessary effort. Being geek I knew I have to enable RPi to play my DVDs.
First thing I discovered about RPi as DVD is that it let’s you skip all anti-piracy warnings!:
People say it will also ignore region protection (quite useful for my collection of dvds I bought in US)!
So what did I need?
* External DVD (I have actually bought a blu-ray external drive from ebay for 15.89GBP + 2.99P&P, which will work with my macbook air as well).
* Powered USB hub. Raspberry Pi won’t provide the drive with enough power. I’m actually connecting the DVD directly to RPi and using the hub to supply power only. It seems RPi can be powered from the same hub via normal USB connection, which eliminates a need for second power supply.
* A bit of the software:
** MPEG2 Licence – 2.4GBP from rasberrypi.org
** DVD plugin for XMBC (OOTB support doesn’t work good enough yet): http://forum.xbmc.org/showthread.php?tid=158896
ps. when you buy stuff from ebay please check if the seller is paying taxes in your country (eg. is company registered in your country). If not, find another one even if you cost you a pound more. Thanks!
This weekend I decided to work on my soldering skills and finally assemble the PWM driver PCA9685 I bought from Adafruit couple weeks back. Not all solder points looks perfect, but I’ve manage not to burn the PCB which I consider a major success. I thank all the
guys how put soldering tutorials on the youtube!
Then I played with software.
* I2C: I used python to steer servo controller via I2C interface. For some reason the Raspbian image has I2C kernel module disabled, so I had to comment blacklist i2c-bcm2708 in /etc/modprobe.d/raspi-blacklist.conf and the add i2c-dev and i2c-bcm2708 to /etc/modprobe to enable them to start.
* GPIO: Raspbian has all libraries loaded by default for GPIO development in python. I had encountered hardware problem instead – there’re many sources on the web describing pin layout of GPIO port, but non of them says which pin is the physical pin 1! I have some gaps in basic knowledge, so I have missed a small rectangle marking P1 – it’s the one nearest to the side of the board in bottom row. See a picture with pins P3, P5, P9, P10 and P11 connected: