Created
December 15, 2009 22:18
-
-
Save mikeymckay/257361 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
output = "" | |
application_path = File.dirname(__FILE__) | |
command = "pocketsphinx_continuous -hmm /usr/share/pocketsphinx/model/hmm/wsj1 -lm #{application_path}/voice_recognition/7892.lm -dict #{application_path}/voice_recognition/7892.dic 2>/dev/null" | |
def fork_off(command) | |
puts "Forking off #{command}" | |
(pid = fork) ? Process.detach(pid) : exec(command) | |
end | |
def kill_existing_processes | |
fork_off "pkill main.rb" | |
fork_off "pkill feh" | |
Kernel.sleep(0.1) | |
end | |
def overlay(type) | |
type.downcase! | |
fork_off "./overlay_text.rb #{type}" | |
Kernel.sleep(3) # Let the temperature overlay get started | |
kill_existing_processes | |
fork_off "#{application_path}/main.rb photos_with_#{type}" | |
end | |
# Clean out existing | |
kill_existing_processes | |
fork_off "#{application_path}/main.rb" | |
puts "Starting voice recognition" | |
IO.popen(command) do |readme| | |
readme.each do |line| | |
case line | |
when /(weather)/i | |
overlay $1 | |
when /(news)/i | |
overlay $1 | |
when /(facebook)/i | |
puts "Facebook no yet implemented!" | |
else | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment