Skip to content

Instantly share code, notes, and snippets.

@mikeymckay
Created December 15, 2009 22:18
Show Gist options
  • Save mikeymckay/257361 to your computer and use it in GitHub Desktop.
Save mikeymckay/257361 to your computer and use it in GitHub Desktop.
#!/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