Friday, November 22, 2013

Autonomously Estimating Attractiveness using Computer Vision


How do you go about teaching a computer what is attractive and what is not?

This is a very difficult question I have been thinking about recently.
Do you create a duck face detector and subtract points? Is it a series of features we are looking for (specific hair color, eye color, skin smoothness symmetry).
Would this data come out in some sort of statistical analysis?
I decided to research this further using Eigen Faces and SVMs.

For those of you that don't know about Eigen Faces[1], they are a decomposition of a set of images into eigenvalues (weights) and eigenvectors (eigenfaces). The amazing thing about these is that given a large enough training set, any image of a face can be reconstructed by multiplying a set of weights (eigenvalues) with the eigenvectors (eigenfaces).

Facial recognition simply extracts the eigenvalues from an image and finds the L2 Norm (a distance metric) between it and the weights of the training data set. The closest distance (below a certain threshold) indicates which face it is.

Top 20 Eigen Faces from our data set



Average image from our data set 


The attractiveness of the average of all images is greater than the average of the attractiveness of all images.


We are currenlty using a similar model for detecting attractiveness. Currently we are accurate ~64% of the time; however, that is just using the L2 Norm. The hope is that using an SVM classifier and the weights for all the faces, we will be able to determine the important eigenfaces and their weights for attractiveness and then create a classification system.

If you review the heat-mapped eigenfaces in the first figure, you will notice specific expressions and features that are highlighted. We have 2027 of these eigenfaces and each face can be seen as a weighted combination of these. Our hope is to find the most attractive and unattractive features in the eigenfaces.

I hypothesize that somewhere in their is an eigenface that corresponds to duckface. Think of the utilization of such a thing. Anytime someone uploads a duckface on facebook, it could warn them that they should stop doing that.

Below are our current statistics of the mean and standard deviation of the weight vectors for each level of attractiveness (1 - 5 with 5 being the most attractive). We have also included a close view of the first 50 weights and a histogram of the weights.








Histogram




It seems there are some very interesting differences in the mean, standard deviation, and histogram based on the level of attractiveness. However, this may be because we have a different amount of training examples for each level of attractiveness (attractiveness is semi-gaussian).

It will be interesting what more tinkering will yield. We can only hope to find the elusive eigenface corresponding to duck face.

References:
[1] Turk, Matthew A and Pentland, Alex P. Face recognition using eigenfaces.Computer Vision and Pattern Recognition, 1991. Proceedings {CVPR'91.}, {IEEE} Computer Society Conference on 1991

Consider donating to further my tinkering.



Places you can find me

Monday, September 30, 2013

Raspberry Pi Automatic Video Looper


Download the image here:
https://onedrive.live.com/redir?resid=e0f17bd2b1ffe81!411&authkey=!AGW37ozZuaeyjDw&ithint=file%2czip

MIRROR: https://mega.co.nz/#!JBcDxLhQ!z41lixcpCS0-zvF2X9SkX-T98Gj5I4m3QIFjXKiZ5p4

Recently I helped out with an Architecture exhibition where they needed 8 projectors looping videos all at the same time. Deciding they didn't want to pay for 8 computers and pay for the electricity for 8 computers, they contacted me to see if I could help (Pictures to come soon!). They got 8 Raspberry Pis, which together cost less than one PC and use less an energy than one PC. That's over 16 times the cost savings and energy savings.

I found a link that did this here. However, it has a couple big issues. It only supports certain file types, doesn't allow spaces in the files and a couple of other things, the escape key stops the whole loop, and their is a longer delay than I want. It also doesn't have the newest version of omxplayer, which plays subtitles and has other new fixes.

So I started creating my own and my version fixes these problems. So I now have decided to publish my image here.

How to set up the looper

  1. Copy this image to an SD card following these directions
  2. Put your video files in the /home/pi/videos directory
  3. Plug it in

Features

  • Supports all raspberry pi video types (mp4,avi,mkv,mp3,mov,mpg,flv,m4v)
  • Supports subtitles (just put the srt file in the same directory as the videos)
  • Reduces time between videos
  • Allows spaces and special characters in the filename
  • Allows pausing and skipping
  • Full screen with a black background and no flicker
  • SSH automatically enabled with user:pi and password:raspberry
  • Allows easy video conversion using ffmpeg (ffmpeg INFILE -sameq OUTFILE)
  • Has a default of HDMI audio output with one quick file change (replace -o hdmi with -o local in startvideos.sh).
  • Can support external HDDs and other directories easily with one quick file change (Change FILES=/home/pi/videos/ to FILES=/YOUR DIRECTORY/ in startvideos.sh)

Source code

The source code can be found on github here. There are a couple main files listed below:
startvideos.sh
startfullscreen.sh
videoloop

This is perfect if you are working on a museum or school exhibit. Don't spend a lot of money and energy on a PC running windows and have problems like below (courtesy of the Atlanta Aquarium).

If you are a museum or other educationally based program and need help, you can contact me by e-mail at help@stevenhickson.com

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

Places you can find me

Monday, September 16, 2013

PiAUISuite Update and Voicecommand v3.1

Voicecommand allows you to control your raspberry pi using only your voice. More information and videos on this can be found on my YouTube channel or the original blog posts.

I've made a couple of key changes and their is a new option for people who want to help with the sox implementation to make the speech recognition more continuous rather than chunk-based.


  • The bug in the voicecommand -s hardware has been fixed.
  • Allows multilingual support with !lang and !language
  • Fixed casing bug when matching multiple variables
  • Install, Uninstall, and Update scripts are now seperated by project. So now if you want to only update youtube, just run UpdateAUISuite.sh youtube
  • tts and tts-nofill have been combined.
  • Moving away from yt.js to browse youtube in the browser. Now adding node.js youtube browsing API. See https://github.com/StevenHickson/RaspberryPiTV
  • Building https://github.com/StevenHickson/RaspberryPiTV to work with voicecommand and adding omxcontrols using https://github.com/StevenHickson/omxplayer_fifo
  • With the above, this allows a control panel that can control videos, play pandora, browse youtube, control music, and run voicecommand. Note that this is in beta and will require a lot of manual installation as their is no installation or readme yet (Hopefully soon to come).
  • Added youtube-dl cron update so that youtube-dl updates automatically every night. Often if someone says the youtube script doesn't work, it is because youtube-dl is out of date and YouTube has updated their security algorithms. Running sudo youtube-dl -U often fixes this problem.
  • Added an option in speech-recog.sh to use sox instead of arecord. Simply uncomment out the sox portion and comment the arecord portion in /usr/bin/speech-recog.sh as below:

sox -r 16000 -t alsa $hardware /dev/shm/out.flac silence 1 0.3 1% 1 0.5 1%
wget -q -U "rate=16000" -O - --post-file /dev/shm/out.flac --header="Content-Type: audio/x-flac; rate=16000" "http://www.google.com/speech-api/v1/recognize?lang=en&client=Mozilla/5.0" | sed -e 's/[{}]/''/g'| awk -v k="text" '{n=split($0,a,","); for (i=1; i<=n; i++) print a[i]; exit }' | awk -F: 'NR==3 { print $3; exit }'
#arecord -D $hardware -f cd -t wav -d $duration -r 16000 | flac - -f --best --sample-rate 16000 -o /dev/shm/out.flac 1>/dev/shm/voice.log 2>/dev/shm/voice.log; wget -O - -o /dev/null --post-file /dev/shm/out.flac --header="Content-Type: audio/x-flac; rate=16000" http://www.google.com/speech-api/v1/recognize?lang="$lang" | sed -e 's/[{}]/''/g'| awk -v k="text" '{n=split($0,a,","); for (i=1; i<=n; i++) print a[i]; exit }' | awk -F: 'NR==3 { print $3; exit }'
rm /dev/shm/out.flac
Please let me know how this works for people so I can debug and get this working permanently.  As always, you can find the install, update, and new YouTube videos at my YouTube channel here:
If you are wondering why I've been so quiet, it's because I moved, started grad school at Georgia Tech, and have been doing a technical review for a computer vision book.
Since I'm a poor graduate student, please support my tinkering:


Places you can find me
Get 10% offsitewide when you shop at
at Yescom USA. Valid until October 2013! Retractable Banner Stand at Yescom USA . Valid until October 2013!

Saturday, June 29, 2013

Voice Command v3.0 for the Raspberry Pi

Voicecommand v3.0 Changes


I've made some big changes and their are even bigger things in the works. Here is a small list. I've had some help from a couple of committed users who have come up with some new good ideas which is awesome.


  • There is now a ~ option that finds the word anywhere in a command. For instance ~music==pianobar will work if you say: let's hear some music, play music, or music.
  • !filler is now a string so you can set it manually. If you put it to 0, it will be empty and if you put it to 1, it will be FILLER FILL for compatibility issues.
  • Example scripts have been added in the Misc folder for you to play with. These can send and receive emails and text messages as well as posting to facebook; all using only your voice.
  • Flags can now overwrite the config options and can be reversed by following them with a 0 or enforced if followed with a 1. Ex. if !continuous==1 in your config file, you can force it to run only once with voicecommand -c0
  • The commands and keywords are now case insensitive. So no tricky case matching.
  • Multiple language support has been added. This is based on your country code which I think you can find here (plus en_uk and en_us). Look up your country code and use that. Ex. For US: !language==en_us, for Spain !language==es, for Germany !language==de.
  • You can set a Wolfram Alpha API and maxResponse (the number of branches) like !api==XXXXXX-XXXXXXXXXX and !maxResponse==3. This will give you better answers. You can sign up for a Wolfram Alpha API on their website for free.
  • Logging has been enabled into /dev/shm/voice.log. It throws stuff to this instead of /dev/null
  • The need for tts-nofill has been removed!! Now tts doesn't use any filler unless you send it yourself.

New Install and Update videos have been added. They can be found here:
http://stevenhickson.blogspot.com/2013/06/installing-and-updating-piauisuite-and.html

Consider donating to further my tinkering since I do all this and help people out for free.
Places you can find me
As always, the updated man page can be found below:

voicecommand

Section: voicecommand man page (8)
Updated: 13 May 2013
Index   

NAME

voicecommand - Listen to user defined strings and run the corresponding command   

SYNOPSIS

voicecommand [OPTIONS]...  

DESCRIPTION

voicecommand was developed for the Raspberry Pi but will work on any linux system with a microphone attached. It is a crude program, which uses basic comparisons to determine if your voicecommand fits a format specified in a config file; it it does, it runs the corresponding linux command. It supports auto-completion and variables as well as command verification, a continuous mode, and other options. For help/comments/questions, feel free to e-mail me at help@stevenhickson.com. I answer sporadically but do eventually respond.


Note: All of the flags that turn something on are off can be reversed and overwritten by following it with a 1 or 0. So for instance if you have !continuous==1 in your config file, you can run voicecommand -c0 to turn continuous off.
 

OPTIONS

?
Same as -h
-b
Turns off the FILL audio. The purpose of this was because the Raspbery Pi (or mine at least) cuts off the first few seconds of audio. This flag turns that feature off. You should only be concerned with this if you hear FILL before everything it says.
-c
Makes voicecommand run in continuous mode, where it will keep listening over and over again.
-d
Sets the duration for listening to the audio for voice commands
-D
Sets the audio hardware. The default is plughw:1,0 -
-e
Edits the voicecommand config file.
The format is voice==command
You can use any character except for newlines or ==
If the voice starts with ~, the program looks for the keyword anywhere. Ex: ~weather would pick up on weather or what's the weather
You can use ... at the end of the command to specify that everything after the given keyword should be options to the command.
Ex: play==playvideo ...
This means that if you say "play Futurama", it will run the command playvideo Futurama
You can use $# (where # is any number 1 to 9) to represent a variable. These should go in order from 1 to 9
Ex: $1 season $2 episode $3==playvideo -s $2 -e $3 $1
This means if you say game of thrones season 1 episode 2, it will run playvideo with the -s flag as 1, the -e flag as 2, and the main argument as game of thrones, i.e. playvideo -s 1 -e 2 game of thrones
Because of these options, it is important that the arguments range from most strict to least strict.
This means that ~ arguments should probably be at the end.
You can also put comments if the line starts with # and special options if the line starts with a !
Default options are shown as follows:
!keyword==pi,!verify==1,!continuous==1,!quiet==0,!ignore==0,!thresh==0.7,!maxResponse==-1
api==BLANK,!filler==FILLER FILL,!response==Yes Sir?,!duration==3,!com_dur==2,!hardware==plughw:1,0,!language==en_us
Keyword, filler, and response accept strings. verify, continuous, quiet, and ignore except 1 or 0 (true or false respectively). thresh excepts a floating point number. These allow you to set some of the flags as permanent options (If these are set, you can overwrite them with the flag options).
You can set a WolframAlpha API and maxResponse (the number of branches) like !api==XXXXXX-XXXXXXXXXX amd !maxResponse==3
You can now customize the language support for speech recognition and some text to speech with the language flag. Look up your country code and use that. Ex. For US: !language==en_us, for Spain !language==es, for Germany !language==de.
-f /my-location/config-file
This allows you to load a different config file located in a different spot. The default one is in your home directory and is ~/.commands.conf
The config file must be formatted the same way.
-h
Shows this man page.
-i
Sets the ignore mode. When this flag is activated, if a command is not in the config file, nothing happens. The default behavior is to try to find an answer or response to that question and then speak it. This turns off that behavior.
-I string
Sets the forced input mode. This allows you to test it without the microphone or get it to parse typed information. It will not run in continuous mode with this.
-k word
Sets the keyword. The default is pi. If this flag is set, the verify and continuous flags are also set since this is only checked during those two modes.
      Ex. voicecommand -c -v -k Jarvis

-l
Sets the duration for listening to the audio for the command keyword. This is different than the -d flag that listens for the voice commands.
-s
Runs a setup operation that attempts to set all of the config options in the config file so that voicecommand works properly
-r word
Sets the response. The default is "Yes Sir?" (For version 1.0, it was Ready?. If this response is more than one word, it should be put in quotes, otherwise it doesn't need to be
      Ex. voicecommand -r Ready?

-t #
Sets the threshold for volume to determine if the keyword was spoken. This should be a floating point number. The default value is 0.7 which works well with the Logitech C310 camera/mic from about 6 feet away.
Ex. voicecommand -t 1.2
-p
Sets passthrough mode on so that instead of running the commands, it just prints them. This is going to be used for the XBMC plugin and Android app.
-q
Sets quiet mode on so that voicecommand never speaks through the audio output. It still prints everything but doesn't ever respond. This includes the keyword response.
-v
Makes voicecommand verify the keyword. This only happens in continuous mode so if this flag is set, the continuous flag will be set as well. The default mode is to not verify. When voicecommand hears any sound above the threshold, it says the response then listens for a command. The default keyword is pi. When the verify flag is set, after the threshold is met, voicecommand verifies that the keyword was spoken.

AUTHOR

Steven Hickson (help@stevenhickson.com)  

BUGS

No known bugs. To report bugs, send a clear description to help@stevenhickson.com Since this program is fairly crude, user typos could cause crashes/failed responses. Please read the man page thoroughly before submitting a bug.  

COPYRIGHT

Copyright © 2013 Steven Hickson. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>. This is free software: you are free to change and redistribute it as long as you give credit to the author and include this license. There is NO WARRANTY, to the extent permitted by law.  

HISTORY

This is the second major version of this program  

SEE ALSO

http://stevenhickson.blogspot.com/


Friday, June 28, 2013

Installing and Updating PiAUISuite and voicecommand

Here are some in depth demo videos on how to install and update PiAUISuite and voicecommand.

If something goes wrong, get the newest code and reinstall. Make sure you read the README file and regularly update to fix errors and get new features.

Install instructions:

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



Voicecommand setup instructions:

voicecommand -s





Update instructions:



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





If you've watched the videos and read the posts and read the README and something still doesn't work, feel free to contact me and ask questions.

Thanks!



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


Places you can find me

Thursday, June 27, 2013

PiAUISuite Update

Quick update on everything that is going on!

I've been sick (still am but going to the doctors on Friday hopefully) so updates have been slow.

I just pushed out a bunch of stuff and finally voicecommand v3.0 is coming out officialy tomorrow night.

NEW FEATURES!
  • Add logging to /dev/shm/voice.log
  • Allow filler to be a set string that can be changed
  • Add push through mode with text so that voice isn't required for testing, -I flag (that is a capital i)
  • Remove quotes in Misc scripts
  • Switch flags to make more sense (now you follow them by a 0 or 1 to override config file options, ex: voicecommand -c0 overrides continuous to turn it off)
  • Add language support with !language==NN (NN is country code such as en_us or es or de, etc.)
  • Added Wolfram alpha API support. If you have an API you can set !api==YOUR-API
  • Better Youtube streaming (still working on making this even better but youtube is messing with me)
  • Added Hulu/Vimeo support and streaming
  • Removed need for tts-nofill
  • More advanced install scripts
  • Case insensitive commands and keywords
  • Passthrough support to output command instead of running it
  • Am going to finish the install instruction THIS WEEKEND!
  • Am going to make a GPIO example with a video hopefully this weekend
Features for 4.0 that are looking hopeful
  • Getting rid of duration and having voicecommand detect when you stop talking using sox (I've almost got this working as well as the current implementation)
  • A nodejs server that is a variant of RPiTV to control voicecommand, youtube, and my other scripts with a pretty HTML front end.
  • Smart phone control
  • Android advanced app to allow you to record voice on phone and send data
  • XBMC plugin (maybe, this is still a stretch goal).
  • emulationstation and video game support (need to figure out how to get this running from within X11)

Tuesday, June 18, 2013

Getting Hulu/Vimeo to work on the Raspberry Pi

This one isn't quite for the faint of heart as you have to install a lot of scripts but here is what I did to get hulu and vimeo working on the Raspberry Pi.

sudo apt-get install libwww-mechanize-perl libxml-simple-perl libcrypt-ssleay-perl libio-all-lwp-perl liblwp-protocol-http-socketunix-perl liblwp-protocol-socks-perl libdigest-hmac-perl libcrypt-blowfish-perl

sudo cpan "Module::Find"
sudo cpan "Crypt::Blowfish_PP"
sudo cpan "Crypt::Rijndael"

cd ~
git clone https://github.com/monsieurvideo/get-flash-videos.git
cd get-flash-videos
perl Makefile.PL
make
sudo make install

get_flash_videos --add-plugin http://gitorious.org/get-flash-videos-plugins/gfv-plugins/blobs/raw/release/Hulu.pm

It doesn't look to bad written out but it will take you a bit to install everything.
Once you do that, you can download any video from hulu (not the members only ones), vimeo, and many other sites without commercials like so:

get_flash_videos "http://vimeo.com/50796424"

Now you can get my updated youtube-safe script from here and use it to play videos for you as well.
I'll work on making a browser plugin for this as well. Then you can stream videos from those sites by typing:

youtube-safe "http://vimeo.com/50796424"

Consider donating to further my tinkering

Wednesday, June 12, 2013

Streaming Other HD Video Sites on the Raspberry PI



For those that are interested, this will allow you to stream internet shows like The Daily Show on your Raspberry Pi in HD with no lag.

A week or so ago I posted a hack which allowed people to stream youtube videos in the browser here. Unfortunately, this same method didn't work out of the box for some other video sites. They would stream a couple seconds then just end (I found this to happen with the daily show).



I now have a fix for that and have a script called youtube-safe, which can stream (high-quality with no lag on a decent internet connection) any video site that works with youtube-dl.

If you already have the Youtube scripts in my PiAUISuite installed, you can just update, otherwise you have to go through the install script and select which parts you want (this one being under youtube).

Install Instructions


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

**NOTE, this will ask you if you want to install a lot of different scripts because it is a SUITE. You only have to pick the ones you want to use. If you only want to use the youtube scripts, press n on any other question except for the dependencies and youtube.

Update Instructions 

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



Once that is done, you can watch the daily show in 1080p like so:
youtube-safe "http://www.thedailyshow.com/full-episodes/"

Even better, if you have voicecommand installed on your system, add the following line to the bottom of your config file for it to play the newest daily show with your voice:
~Daily Show==youtube-safe "http://www.thedailyshow.com/full-episodes/"

I'll work on making a browser plugin for this as well.

Consider donating to further my tinkering


Places you can find me

Friday, June 7, 2013

Playing YouTube videos in the browser on the Raspberry Pi

This will allow you to stream up to 1080p youtube videos in the browser on the Raspberry pi using omxplayer. It's a crude hack but it seems to work pretty well on my system. Install instructions and a demonstration video are shown below.

You can install this by pulling the git repository and running the scripts below.
Commands to install are below (your user should have sudo privileges but you don't need to be root):

You may have to enable user scripts in Midori by going to Menu>Preferences>Extensions>UserScripts and clicking the check box.


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

**NOTE, this will ask you if you want to install a lot of different scripts because it is a SUITE. You only have to pick the ones you want to use. If you only want to use the youtube scripts, press n on any other question except for the dependencies and youtube.

Update Instructions 

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



Demonstration


There is a lot of misinformation out there on how to do this. Using gnash or HTML5 is going to result in a frame rate so slow it can be considered unworkable. I've tried both of them out and you can't really watch videos with them. XBMC has a youtube plugin but it is buggy and crashes often.

I've been playing youtube videos using the command line and my voicecommand using the scripts found here.
After seeing a couple people ask about playing youtube in the browser last night, I decided to go ahead and do that and create some user scripts for midori which allow the browser to utilize the same hack.

Here is the technical overview:
I created a script called youtube which uses the youtube-dl -g flag to grab the video URL. It also handles playlists and other parsing. Then it passes that video URL to omxplayer for it to stream. 
Next I registered a new URL protocol yt:// and made it pass it's information to the youtube program whenever it runs. 
Finally, I created a user script in Midori which simply replaces all http://youtube.com/watch?* URLs with yt://youtube.com/watch?*.

Feel free to let me know any problems you have and enjoy your Youtube browsing experience.


 Consider donating to further my tinkering


Places you can find me

Friday, May 24, 2013

Using the Google Voice C++ API

First of all, this obviously isn't an official Google API. I wrote it because I wanted one in C++ and couldn't find one that worked.

That being said, the code is on github here (in the TextCommand folder) and is available under GPLv3 for anyone to use.
I know this could (maybe even should) have its own github project but since I use it for my home automation projects, its included in the PiAUISuite. That being said, the current gvapi binary is also compiled for the Pi. So you will need to run make gvapi if you want to use it on any other linux machine.

To include the C++ code in your own project, you just need to include gvoice.h in your file and then you should be able to access the GoogleVoice class. An excellent example to look at is gvapi.cpp since it shows how to interact with it. You should need only to call Init and Login, then you should be able to do any of the Google voice functions.

If you only to use gtextcommand to send commands to your pi, see here. If you want to send or check SMS without having to include the source in your code/project, just use the gvapi program. It can get contacts, send, receive, and delete SMS. It also comes in with built in spoof protection (this is included in GoogleVoice::CheckSMS).

Here's a quick video demo as an example of the kinds of things you can do with gvapi


Using the gvapi program is fairly simple and it's man page is below:


gvapi


gvapi - Use of Google voice API in order to send and receive SMS  

SYNOPSIS

gvapi [OPTIONS]...  

DESCRIPTION

gvapi was compiled for use with home automation on the Raspberry Pi but will work on any linux system with an internet connection. It uses curl and boost regex in order to login and stores the cookie in /dev/shm. It only logs in once every 24 hours to save time. It supports a multitude of different options and parameters. For help/comments/questions, feel free to e-mail me at help@stevenhickson.com. I answer sporadically but do eventually respond.
 

OPTIONS

-?
Same as -h
-c
Checks your incoming text messages to see if you have anything unread. It will mark it whatever it outputs as read unless you also use the -r flag. If you include a number with the -n flag, you can specify it to only check messages received from that number. You can also use the -k flag to specify that the message must start with a certain keyword.
-d
Sets debug mode on. You can also specify debug mode from 1 - 3, where 3 is the most verbose.
Ex: gvapi -c -d2
-h
Asks for some quick general use help for gvapi.
-i
Outputs the contacts of your google voice account in the form name==number
-k KEYWORD
Sets a keyword that has to be in the beginning of the text message for it to be returned. This is useful as a password for parsing only certain messages.
-m MESSAGE
Sends the message you specify. This should be in quotes if it contains special characters or a space. The number also has to be specified otherwise it won't have a message to send
Ex: gvapi -n +15551234 -m Hello
-n NUMBER
Can be used with the -c flag to check messages from a certain number or the -m flag to send a message. Can be in a format without the country code, with just the country code, or with a plus sign and the country code. If the formost, it interprets it as a US number.
Ex: gvapi -n 5551234 -c
-p PASSWORD
Can be used with the -u flag to log in manually. If not specified, the program uses the default username and password specified in ~/.gv
-r
Receives and deletes SMS messges. Can be used with the -c flag or without. It is the same as the -c flag but instead of just marking the messages as read. It deletes them.
-u USERNAME
Can be used with the -p flag to log in manually. See the -p flag for more details. Cannot be used without the -p flag.
-v
Outputs version and creater information

AUTHOR

Steven Hickson (help@stevenhickson.com)  

BUGS

No known bugs. To report bugs, send a clear description to help@stevenhickson.com Since this program is fairly crude, user typos could cause crashes/failed responses. Please read the man page thoroughly before submitting a bug.  

COPYRIGHT

Copyright © 2013 Steven Hickson. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>. This is free software: you are free to change and redistribute it as long as you give credit to the author and include this license. There is NO WARRANTY, to the extent permitted by law.  

HISTORY

This is the second major version of this program  

SEE ALSO

http://stevenhickson.blogspot.com/

Consider donating to further my tinkering.


Places you can find me

Monday, May 13, 2013

Voice Command v2.0 for the Raspberry Pi

Voice Command 2.0 differences

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

I've made some big changes since my last post with voice control with the Raspberry Pi.
You can now verify the keyword, change the keyword, change the response, put it in quiet mode to not talk to you, and put it in ignore mode to not try to answer questions not in your config file.
The config file format has also been changed from voice=command to voice==command, comments have been allowed in the config file by starting a line with #, and special settings can be done by starting a line with !.
I've updated the TTS from espeak to Google's API since it sounds a lot better.
Finally, I've made an update script in the Install folder, that way you don't have to reinstall every time new changes get pushed out to github. All of the source code is at:
https://github.com/StevenHickson/PiAUISuite

Video:

Here's a video demonstrating the new changes:


Special Options


The default special options are as follows:
!keyword==pi
!verify==1
!continuous==1
!quiet==0
!ignore==0
!filler==1
!thresh=0.7
!response=Yes sir?

response and keyword can be any string.
verify, continuous, quiet, filler, and ignore can be 1 or 0 (true or false respectively).
thresh can be any floating point number to set the appropriate volume.

Install Instructions

(this requires git)

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


Consider donating to further my tinkering



I've also created a man page fore voicecommand. You can access it with man voicecommand. It is shown below:

voicecommand

Section: voicecommand man page (8)
Updated: 13 May 2013
Index  

NAME

voicecommand - Listen to user defined strings and run the corresponding command  

SYNOPSIS

voicecommand [OPTIONS]...  

DESCRIPTION

voicecommand was developed for the Raspberry Pi but will work on any linux system with a microphone attached. It is a crude program, which uses basic comparisons to determine if your voicecommand fits a format specified in a config file; it it does, it runs the corresponding linux command. It supports auto-completion and variables as well as command verification, a continuous mode, and other options. For help/comments/questions, feel free to e-mail me at me@stevenhickson.com. I answer sporadically but do eventually respond.
 

OPTIONS

-?
Same as -h
-b
Turns off the FILL audio. The purpose of this was because the Raspbery Pi (or mine at least) cuts off the first few seconds of audio. This flag turns that feature off. You should only be concerned with this if you hear FILL before everything it says.
-c
Makes voicecommand run in continuous mode, where it will keep listening over and over again.
-e
Edits the voicecommand config file.
The format is voice==command
You can use any character except for newlines or ==
You can also put comments if the line starts with # and special options if the line starts with a !
Default options are shown as follows:
!keyword==pi,!verify==1,!continuous==1,!quiet==0,!ignore==0,!thresh=0.7,!response=Yes sir? keyword and response accept strings. verify, continuous, quiet, and ignore except 1 or 0 (true or false respectively). thresh excepts a floating point number. These allow you to set some of the flags as permanent options (though the flags can overwrite them temporarily).
-f /my-location/config-file

This allows you to load a different config file located in a different spot. The default one is in your home directory and is ~/.commands.conf
The config file must be formatted the same way.
-h

Shows this man page.
-i

Sets the ignore mode. When this flag is activated, if a command is not in the config file, nothing happens. The default behavior is to try to find an answer or response to that question and then speak it. This turns off that behavior.
-k word

Sets the keyword. The default is pi. If this flag is set, the verify and continuous flags are also set since this is only checked during those two modes.
      Ex. voicecommand -c -v -k Jarvis

-r word

Sets the response. The default is "Yes Sir?" (For version 1.0, it was Ready?. If this response is more than one word, it should be put in quotes, otherwise it doesn't need to be
      Ex. voicecommand -r Ready?

-t #

Sets the threshold for volume to determine if the keyword was spoken. This should be a floating point number. The default value is 0.7 which works well with the Logitech C310 camera/mic from about 6 feet away.
Ex. voicecommand -t 1.2
-q

Sets quiet mode on so that voicecommand never speaks through the audio output. It still prints everything but doesn't ever respond. This includes the keyword response.
-v

Makes voicecommand verify the keyword. This only happens in continuous mode so if this flag is set, the continuous flag will be set as well. The default mode is to not verify. When voicecommand hears any sound above the threshold, it says the response then listens for a command. The default keyword is pi. When the verify flag is set, after the threshold is met, voicecommand verifies that the keyword was spoken.

AUTHOR

Steven Hickson (me@stevenhickson.com)  

BUGS

No known bugs. To report bugs, send a clear description to me@stevenhickson.com Since this program is fairly crude, user typos could cause crashes/failed responses. Please read the man page thoroughly before submitting a bug.  

COPYRIGHT

Copyright © 2013 Steven Hickson. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>. This is free software: you are free to change and redistribute it as long as you give credit to the author and include this license. There is NO WARRANTY, to the extent permitted by law.  

HISTORY

This is the second major version of this program  

SEE ALSO

http://stevenhickson.blogspot.com/



Consider donating to further my tinkering

Tuesday, April 30, 2013

Voice Control on the Raspberry Pi

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

I'm 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 that's 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 Google's 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, I've switched to using Google's 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.
I'm 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 doesn't 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

Thursday, April 25, 2013

Raspberry Pi Settlers of Catan Server

So a couple of days ago I decided I wanted my Pi to be a Settlers of Catan server.
I decided on using a custom compiled JSettlers version instead of the C++ pioneer version because of the extra perks it had.

It runs surprisingly well considering it is in java but it makes sense since it is making the client's computer do most of the work. I was also decently surprised with the bots. The server allows you to create practice games against bots or real games where other people can sign up to play with you.

It also has multiple scenarios and lots of documentation. Sometimes it is a little buggy but overall I'm pretty happy with it as of right now.

I've uploaded the version I have compiled and an install script. To run it, first you need to have java and apache (or some other web server) installed. If you don't, run:
sudo apt-get install apache2 openjdk-7-*

**Note, you don't need apache to run, you could use others such as NGinx or no web server at all and just play the game by yourself.

Then download the file, unzip it, and install:
wget "https://stevenhickson-code.googlecode.com/files/PiSettlers.tar.gz"
tar -xvf PiSettlers.tar.gz
cd JSettlers2
sudo ./install-web.sh

and now you should be done, you can go to your IP address in any computer on your network and play it.
Mine is at http://192.168.1.100/settlers/
**Note, if you want to play it outside of your network, i.e. you have a domain name, then you need to open port 8880 on your router to go to the pi.

Here is what it looks like playing a game hosted from the pi on my fedora laptop.

Consider donating to further my tinkering


Places you can find me