This was actually a lot easier then I thought it would be when I got the idea from watching Star Trek. I found this to work about 70%, but this could be just because I'm using a $5 computer mic. It works best when using simple words and speaking in a monotone voice.
There are 3 main components required.
1. sphinx-2 - speech recognition engine
2. perlbox - front end for configuring voice commands
3. festival - text to speech engine, not required but I use it for the system to tell me the time.
Other programs required are:
telnet - used to connect to mythfrontend and send commands to it
expect - a way to script those telnet commands
perl-tk - graphical library for perlbox's gui configuration
festvox-kallpc16k - a voice for festival
Installation
apt-get install expect festival festvox-kallpc16k telnet sphinx2-bin
wget
http://prdownloads.sourceforge.net/perl ... noarch.deb or you can get it from
http://perlbox.org. I recommend going there to read up on how it works.
You will also need to enable the telnet control in Myth through Setup > Setup > General > 3rd page > Enable network remote control
To begin you can start perlbox-voice and use the gui to play around. From here you can start the listener and add custom commands. To control myth I wrote a script to control a bunch of sub scripts by feeding an argument in to it. This way I only had to make a shortcut for on script in the path.
Configuration
My configuration is as follows:
/home/mythtv/.perlbox-voice/Listener.conf #This is my config for perlbox. it contains all the voice to command codes I use.
Code:
# Maintained by Config::Simple/3.7
# -----------------------------------
[path_section]
task=/home/mythtv/.perlbox-voice/commands
agent_bin=/usr/lib/perlbox-voice/PerlboxListener.pl
dict=/home/mythtv/.perlbox-voice/commands/current.dic
language_model=/home/mythtv/.perlbox-voice/commands/current.lm
hmm=/usr/share/sphinx2/model/hmm/6k
perlbox_lib=/usr/lib/perlbox-voice/Perlbox/
sent=/home/mythtv/.perlbox-voice/commands/current.sent
s2continuous=/usr/bin/sphinx2-continuous
[option_section]
magic=listen
verbosity_level=3
playsound=1
perlbox-voice-version=.09
use_magic=0
magic_interval=5
help_browser=mozilla
desktop_plugin=none
[command_section]
left=voice-control.sh left
remove=voice-control.sh delete
main menu=voice-control.sh mainmenu
exit=pkill mythfrontend
forward=voice-control.sh ff
save=voice-control.sh save
real time=voice-control.sh realtime
down=voice-control.sh down
unpause=voice-control.sh unpause
show=voice-control.sh recordings
video=voice-control.sh videos
night=say sleep well
paws=voice-control.sh pause
guide=voice-conrtol.sh livetvguide
console=xterm
stat=voice-control.sh status
enter=voice-control.sh select
morning=say and good morning to you
cancel=voice-control.sh cancel
display recordings=voice-control.sh recordings
time=voice-control.sh time
confirm delete=voice-control.sh confirmdelete
up=voice-control.sh up
terminal=xterm
start myth=mythfrontend
myth=mythfrontend
stop=voice-control.sh stop
right=voice-control.sh right
videos=voice-control.sh videos
skip=voice-control.sh skip
rewind=voicecontrol.sh rw
replay=voice-control.sh replay
Below are the scripts that I call to control myth
voice-control.sh ###This is the min script that is use to call the command for myth.
Code:
#!/bin/bash
#This script controls which expect scripts to run when the switch is given
SCRIPTHOME="/myth/backup/scripts/voice" ##Change this to your scripts dir
case $1 in
start) perlbox-voice --nogui & >> /dev/null;;
recordings) $SCRIPTHOME/voice-recordings.sh;;
mainmenu) $SCRIPTHOME/voice-mainmenu.sh >> /dev/null;;
down) $SCRIPTHOME/voice-down.sh >> /dev/null;;
ff) $SCRIPTHOME/voice-ff.sh >> /dev/null;;
left) $SCRIPTHOME/voice-left.sh >> /dev/null;;
livetv) $SCRIPTHOME/voice-livetv.sh >> /dev/null;;
livetvguide) $SCRIPTHOME/voice-livetvguide.sh >> /dev/null;;
status) $SCRIPTHOME/voice-mythstatus.sh >> /dev/null;;
pause) $SCRIPTHOME/voice-pause.sh >> /dev/null;;
unpause) $SCRIPTHOME/voice-unpause.sh >> /dev/null;;
right) $SCRIPTHOME/voice-right-.sh >> /dev/null;;
rw) $SCRIPTHOME/voice-rw.sh >> /dev/null;;
select) $SCRIPTHOME/voice-select.sh >> /dev/null;;
realtime) $SCRIPTHOME/voice-speed-realtime.sh >> /dev/null;;
stop) $SCRIPTHOME/voice-stop.sh >> /dev/null;;
up) $SCRIPTHOME/voice-up.sh >> /dev/null;;
videos) $SCRIPTHOME/voice-videos.sh >> /dev/null;;
delete) $SCRIPTHOME/voice-delete.sh >> /dev/null;;
confirmdelete) $SCRIPTHOME/voice-confirm-delete.sh >> /dev/null;;
time) $SCRIPTHOME/voice-time.sh >> /dev/null;;
skip) $SCRIPTHOME/voice-skip.sh >> /dev/null;;
replay) $SCRIPTHOME/voice-replay.sh >> /dev/null;;
save) $SCRIPTHOME/voice-save.sh >> /dev/null;;
cancel) $SCRIPTHOME/voice-cancel.sh >> /dev/null;;
# ) $SCRIPTHOME/voice-.sh >> /dev/null;;
# ) $SCRIPTHOME/voice-.sh >> /dev/null;;
help) echo " Available arguments: start, recordings, mainmenu, down, ff, left, livetv...";;
*) echo " usage: voice-control.sh [arg]";;
esac
Below here are the sub-scripts.
voice-cancel.sh
Code:
#!/usr/bin/expect --
# Test expect script to telnet.
spawn telnet localhost 6546
expect "#"
send "key escape\r"
expect "OK"
send "exit\r"
# end of expect script.
voice-confirm-delete.sh
Code:
#!/usr/bin/expect --
# Test expect script to telnet.
spawn telnet localhost 6546
expect "#"
send "key d\r"
expect "OK"
send "key up\r"
expect "OK"
send "key enter\r"
expect "OK"
send "exit\r"
# end of expect script.
voice-delete.sh
Code:
#!/usr/bin/expect --
# Test expect script to telnet.
spawn telnet localhost 6546
expect "#"
send "key d\r"
expect "OK"
send "key up\r"
expect "OK"
send "exit\r"
# end of expect script.
voice-down.sh
Code:
#!/usr/bin/expect --
# Test expect script to telnet.
spawn telnet localhost 6546
expect "#"
send "key down\r"
expect "OK"
send "exit\r"
# end of expect script.
voice-ff.sh
Code:
#!/usr/bin/expect --
# Test expect script to telnet.
spawn telnet localhost 6546
expect "#"
send "play seek forward\r"
expect "OK"
send "exit\r"
# end of expect script.
voice-left.sh
Code:
#!/usr/bin/expect --
# Test expect script to telnet.
spawn telnet localhost 6546
expect "#"
send "key left\r"
expect "OK"
send "exit\r"
# end of expect script.
voice-livetv.sh
Code:
#!/usr/bin/expect --
# Test expect script to telnet.
spawn telnet localhost 6546
expect "#"
send "jump livetv\r"
expect "OK"
send "exit\r"
# end of expect script.
voice-livetvguide.sh
Code:
#!/usr/bin/expect --
# Test expect script to telnet.
spawn telnet localhost 6546
expect "#"
send "jump livetvguide\r"
expect "OK"
send "exit\r"
# end of expect script.
voice-mainmenu.sh
Code:
#!/usr/bin/expect --
# Test expect script to telnet.
spawn telnet localhost 6546
expect "#"
send "jump mainmenu\r"
expect "OK"
send "exit\r"
# end of expect script.
voice-mythstatus.sh
Code:
#!/usr/bin/expect --
# Test expect script to telnet.
spawn telnet localhost 6546
expect "#"
send "jump statusbox\r"
expect "OK"
send "exit\r"
# end of expect script.
voice-pause.sh
Code:
#!/usr/bin/expect --
# Test expect script to telnet.
spawn telnet localhost 6546
expect "#"
send "play speed pause\r"
expect "OK"
send "exit\r"
# end of expect script.
voice-recordings.sh
Code:
#!/usr/bin/expect --
# Test expect script to telnet.
spawn telnet localhost 6546
expect "#"
send "jump playbackrecordings\r"
expect "OK"
send "exit\r"
# end of expect script.
voice-replay.sh
Code:
#!/usr/bin/expect --
# Test expect script to telnet.
spawn telnet localhost 6546
expect "#"
send "key q\r"
expect "OK"
send "exit\r"
# end of expect script.
voice-right.sh
Code:
#!/usr/bin/expect --
# Test expect script to telnet.
spawn telnet localhost 6546
expect "#"
send "key right\r"
expect "OK"
send "exit\r"
# end of expect script.
voice-rw.sh
Code:
#!/usr/bin/expect --
# Test expect script to telnet.
spawn telnet localhost 6546
expect "#"
send "play seek backward\r"
expect "OK"
send "exit\r"
# end of expect script.
voice-save.sh
Code:
#!/usr/bin/expect --
# Test expect script to telnet.
spawn telnet localhost 6546
expect "#"
send "key escape\r"
expect "OK"
send "key enter\r"
expect "OK"
send "exit\r"
# end of expect script.
voice-select.sh
Code:
#!/usr/bin/expect --
# Test expect script to telnet.
spawn telnet localhost 6546
expect "#"
send "key enter\r"
expect "OK"
send "exit\r"
# end of expect script.
voice-skip.sh
Code:
#!/usr/bin/expect --
# Test expect script to telnet.
spawn telnet localhost 6546
expect "#"
send "key z\r"
expect "OK"
send "exit\r"
# end of expect script.
voice-speed-realtime.sh
Code:
#!/usr/bin/expect --
# Test expect script to telnet.
spawn telnet localhost 6546
expect "#"
send "play speed 1x\r"
expect "OK"
send "exit\r"
# end of expect script.
voice-stop.sh
Code:
#!/usr/bin/expect --
# Test expect script to telnet.
spawn telnet localhost 6546
expect "#"
send "play stop\r"
expect "OK"
send "exit\r"
# end of expect script.
voice-time.sh
Code:
#!/bin/bash
#echo "The time is $(date +%I" "%M" "%p)" > /tmp/currenttime
echo "The time is $(date +%H" "%M" "hours)" > /tmp/currenttime
festival --tts /tmp/currenttime
rm -f /tmp/currenttime
voice-unpause.sh
Code:
#!/usr/bin/expect --
# Test expect script to telnet.
spawn telnet localhost 6546
expect "#"
send "key p\r"
expect "OK"
send "exit\r"
# end of expect script.
voice-up.sh
Code:
#!/usr/bin/expect --
# Test expect script to telnet.
spawn telnet localhost 6546
expect "#"
send "key up\r"
expect "OK"
send "exit\r"
# end of expect script.
voice-videos.sh
Code:
#!/usr/bin/expect --
# Test expect script to telnet.
spawn telnet localhost 6546
expect "#"
send "jump mythvideo\r"
expect "OK"
send "exit\r"
# end of expect script.
Enjoy!