Have you ever dreamed about controlling your PC with voice commands? Well, now you can (though only some specific actions)!

What do I need?
- A computer with Ubuntu (you can still do the same on other distributions, but this post won’t cover that).
- A microphone (a cheap one will do).
- Some application(s) which you want to control and which can be used with commands on the terminal.

Installation
Go over to my PPA and install packages julius and julius-voxforge from there.

Writing the command and control application
Follow the instructions from /usr/share/doc/julius-voxforge/examples/README to create your own grammar, and then edit the command.py file to suit your needs (the simplest configuration would be to just edit the dictionary near line 60). Finally, to execute it: julius -quiet -input mic -C julian.jconf 2>/dev/null | ./command.py

Problems
I don’t really have much experience with Julius, but if you have problems with the instructions explained here leave a comment or ping me on IRC (RainCT@Freenode) and I’ll try to help you. But first look at the examples below to ensure that you’ve done everything right :).

More?
I’m currently working at further improving those packages and getting them into Ubuntu. Also, I may write another post in the future explaining how to create your own speech corpora and acoustic models, but I can’t promise anything.

Example on how to control Rhythmbox:

* example.voca:

% NS_B
<s>	sil

% NS_E
</s>	sil

% ID
DO	d uw
COMP	k ax m p

% COMMAND
PLAY	p l ey
NEXT	n eh k s t
PREV	p r iy v
SHOW	sh ow
UP	ah p
DOWN	d aw n
SILENCE	s ay l ax n s

* sample.grammar

S: NS_B ID COMMAND NS_E

* command.py’s parse function

def parse(line):
params = [param.lower() for param in line.split() if param]
commands = {
'play': 'rhythmbox-client --play',
'silence': 'rhythmbox-client --pause',
'next': 'rhythmbox-client --next',
'prev': 'rhythmbox-client --previous',
'show': 'rhythmbox-client --notify',
'up': 'rhythmbox-client --volume-up',
'down': 'rhythmbox-client --volume-down',
}
if params[1] in commands:
os.popen(commands[params[1]])

* Usage: (Action – Verbal command)

Reproduce - DO PLAY
Pause - DO SILENCE (I didn't use "DO PAUSE" because like that it had a very high error rate)
Next song - DO NEXT
Previous song - DO PREV ("DO PREVIOUS" can't be used because VoxForge's acoustic models don't support some of it's phonemes)
Show the name of the current song - DO SHOW
Increment Rhythmbox's volume - DO UP
Decrement Rhythmbox's volume - DO DOWN

Random tip:
You can let the computer answer to your commands using either espeak “text to say” or, if you have Festival (which sounds more natural) installed, festival -b ‘(SayText “text to say”)’.

Happy hacking!