Skip to content

Instantly share code, notes, and snippets.

@fragtastic
Created March 14, 2016 02:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fragtastic/5ef35c131e240524b274 to your computer and use it in GitHub Desktop.
Save fragtastic/5ef35c131e240524b274 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'pocketsphinx-ruby'
require "espeak"
include ESpeak
require "require_all"
def run_listen
configuration = Pocketsphinx::Configuration::Grammar.new('grammars/activate.gram')
Speech.new("Loaded grammer/activate.gram").speak
recognizer = Pocketsphinx::LiveSpeechRecognizer.new(configuration)
Speech.new("Recognizer created")
recognizer.recognize do |speech|
case speech
when "activate"
Speech.new("Activated").speak
return run_listen
when "deactivate"
Speech.new("Deactivated").speak
return run_listen
end
end
end
Speech.new("Voice Control started.").speak
run_listen
# activate.gram
#JSGF V1.0;
#grammar module;
#public <command> = ( activate | deactivate );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment