Showing posts with label control. Show all posts
Showing posts with label control. Show all posts

Voice Control on the Raspberry Pi

Note: Updated version here:
http://stevenhickson.blogspot.com/2013/05/voice-command-v20-for-raspberry-pi.html

Im finally releasing my Raspberry Pi voice control software.
The beauty of this is that you can use it and customize it without programming anything.
This will work on any linux machine but I find it uniquely suited for the Raspberry Pi and thats what I developed it for.
You just type voicecommand -e to edit the configuration file and add any speech and the coinciding command. You can see all of the little nifty commands it can recognize just with my config file in the video. I use all of these pretty often. It is very mutable and works with lots of other programs.

Watch this video to really get a feel for the program:




The commands should be in the format speech=command. Ex:
music=xterm -e pianobar
Doctor Who=playvideo -r -f Doctor Who

Unfortunately, it is caps sensitive voice control right now, but you can test the input by running
speech-recog.sh
on you machine to see what the speech recognition will give you. It uses Googles api and is really good at recognizing what you say. I used to use espeak instead of festival for the text to speech because of the speed difference. However, after some very helpful comments from people, Ive switched to using Googles TTS api, which is much more pleasant to listen to. The video above is still using espeak but the newest code does not.

I hope you will try this out and make some cool things with it. Instructions to install are below.
Im in the process of setting up a repository so until then, here are the instructions (do this in the terminal):


sudo apt-get install git-core
git clone git://github.com/StevenHickson/PiAUISuite.git
cd PiAUISuite/Install/
./InstallAUISuite.sh

Update Instructions 

cd PiAUISuite
git pull
cd Install
sudo ./UpdateAUISuite.sh


Here are the dependencies required to run and build:
sudo apt-get install libboost1.50-dev libboost-regex1.50-dev youtube-dl axel curl xterm libcurl4-gnutls-dev mpg123 flac sox

**Note: If the file .commands.conf doesnt exist in your home directory and you have an old version of code, the program will exit. You should either grab the newest code from github or create the file yourself.

**To make it listen for longer, edit the file /usr/bin/speech-recog.sh and change -f cd -t wav -d 3 to -f cd -t wav -d # where number is how many seconds it should listen.

Consider donating to further my tinkering


Places you can find me
Read More..

Control anything electrical with the Raspberry Pi using 433 MHz RF

Ive gotten a lot of e-mails in the past about controlling lights, plugged-in utilities, etc. with my voicecommand software on the Raspberry Pi and I decided to make a quick easy guide.

Why would you want to do this?

This is an easy question to answer. I walk into a room and I say Pi . . . Let there be light and behold the lights turn on. Or for those with less dramatic flair, just saying lights and having the lights turn on.
Having voice controlled lights in your house just seems convenient.

How can I do this?

Its easy actually.
Ive created an image for the RPi that already has everything you need on it. This means its easier than ever to control electronics with your voice.

You can download it at:
https://mega.co.nz/#!MM8W1JxR!4PlZ_1-dumasDUCYRI4LuiBwEJgtqhfoin0R8ls90NQ

Once you have the image on your Raspberry Pi, buy some RF 433 MHz light switches or sockets like these: 
Etekcity ZAP 5LX Auto-Programmable Function Wireless Remote Control Outlet Light Switch with 2 Remotes, 5-Pack Outlet

You can plug those into an outlet and plug anything (including a light) into them.

Next you need a 433 MHz transmitter and receiver for the RPi. You can get those here:
433Mhz RF transmitter and receiver kit for your Experiment

Then you can wire them up to the pi using the GPIO and use pilight to control them. You wire them in as below:
The smaller unit is plugged into voltage, ground, and pin 17 while the larger board is plugged into voltage, ground, and pin 18.

Once your transmitter and receiver are wired up, simply point the remote at the receiver, run pilight-debug, and press the button on the remote you want to learn. Now you can copy that string and use pilight-send to send it.
Example:
sudo killall pilight-daemon or sudo service pilight stop
sudo pilight-debug
Then CTRL+C when you see a RF string. Mine looks something like this:
172 688 172 688 172 516 172 688 172 688 516 172 172 688 516 172 172 688 172 688 172 688 516 172 172 688 516 172 516 172 516 172 172 688 172 688 172 688 172 688 516 172 516 172 172 688 172 688 172 5814
**Note** Sometimes I have trouble escaping out of pilight-debug. When that happens I kill it (kill -9) from a different terminal
Now I can turn that light on.
First restart the pilight daemon:
sudo pilight-daemon or sudo service pilight start
Now send the command:
sudo pilight-send -p raw -c "172 688 172 688 172 516 172 688 172 688 516 172 172 688 516 172 172 688 172 688 172 688 516 172 172 688 516 172 516 172 516 172 172 688 172 688 172 688 172 688 516 172 516 172 172 688 172 688 172 5814"
but with your own string. Do this for the on and off settings for as many lights as you want.

Now I can add that command in a script and use voicecommand to run it when it hears the right command!
You can do this with voicecommand -e

You can read more about it at the hackaday projects page here.

And here is a quick video demo:

Consider donating to further my tinkering since I do all this and help people out for free.




Also, a contact of mine recently did a computer vision kickstarter. You should join that if you want to learn more about computer vision.
https://www.kickstarter.com/projects/1186001332/pyimagesearch-gurus-become-a-computer-vision-openc

Places you can find me
Read More..

From Pixels to Actions Human level control through Deep Reinforcement Learning



Remember the classic videogame Breakout on the Atari 2600? When you first sat down to try it, you probably learned to play well pretty quickly, because you already knew how to bounce a ball off a wall in real life. You may have even worked up a strategy to maximise your overall score at the expense of more immediate rewards. But what if you didnt possess that real-world knowledge — and only had the pixels on the screen, the control paddle in your hand, and the score to go on? How would you, or equally any intelligent agent faced with this situation, learn this task totally from scratch?

This is exactly the question that we set out to answer in our paper “Human-level control through deep reinforcement learning”, published in Nature this week. We demonstrate that a novel algorithm called a deep Q-network (DQN) is up to this challenge, excelling not only at Breakout but also a wide variety of classic videogames: everything from side-scrolling shooters (River Raid) to boxing (Boxing) and 3D car racing (Enduro). Strikingly, DQN was able to work straight “out of the box” across all these games – using the same network architecture and tuning parameters throughout and provided only with the raw screen pixels, set of available actions and game score as input.

The results: DQN outperformed previous machine learning methods in 43 of the 49 games. In fact, in more than half the games, it performed at more than 75% of the level of a professional human player. In certain games, DQN even came up with surprisingly far-sighted strategies that allowed it to achieve the maximum attainable score—for example, in Breakout, it learned to first dig a tunnel at one end of the brick wall so the ball could bounce around the back and knock out bricks from behind.
Video courtesy of Atari Inc. and Mnih et al. “Human-level control through deep reinforcement learning"
So how does it work? DQN incorporated several key features that for the first time enabled the power of Deep Neural Networks (DNN) to be combined in a scalable fashion with Reinforcement Learning (RL)—a machine learning framework that prescribes how agents should act in an environment in order to maximize future cumulative reward (e.g., a game score). Foremost among these was a neurobiologically inspired mechanism, termed “experience replay,” whereby during the learning phase DQN was trained on samples drawn from a pool of stored episodes—a process physically realized in a brain structure called the hippocampus through the ultra-fast reactivation of recent experiences during rest periods (e.g., sleep). Indeed, the incorporation of experience replay was critical to the success of DQN: disabling this function caused a severe deterioration in performance.
Comparison of the DQN agent with the best reinforcement learning methods in the literature. The performance of DQN is normalized with respect to a professional human games tester (100% level) and random play (0% level). Note that the normalized performance of DQN, expressed as a percentage, is calculated as: 100 X (DQN score - random play score)/(human score - random play score). Error bars indicate s.d. across the 30 evaluation episodes, starting with different initial conditions. Figure courtesy of Mnih et al. “Human-level control through deep reinforcement learning”, Nature 26 Feb. 2015.
This work offers the first demonstration of a general purpose learning agent that can be trained end-to-end to handle a wide variety of challenging tasks, taking in only raw pixels as inputs and transforming these into actions that can be executed in real-time. This kind of technology should help us build more useful products—imagine if you could ask the Google app to complete any kind of complex task (“Okay Google, plan me a great backpacking trip through Europe!”).

We also hope this kind of domain general learning algorithm will give researchers new ways to make sense of complex large-scale data creating the potential for exciting discoveries in fields such as climate science, physics, medicine and genomics. And it may even help scientists better understand the process by which humans learn. After all, as the great physicist Richard Feynman famously said: “What I cannot create, I do not understand.”
Read More..