Skip to content

Instantly share code, notes, and snippets.

@llatzhar
Created August 13, 2008 05:57
Show Gist options
  • Save llatzhar/5205 to your computer and use it in GitHub Desktop.
Save llatzhar/5205 to your computer and use it in GitHub Desktop.
require 'win32ole'
context = WIN32OLE.new('SAPI.SpSharedRecoContext.1')
#context = WIN32OLE.new('SAPI.SpInProcRecoContext.1')
grammar = context.CreateGrammar(1)
grammar.DictationLoad()
grammar.DictationSetState(1)
event = WIN32OLE_EVENT.new(context, "_ISpeechRecoContextEvents")
event.on_event("Recognition") do |*e|
result = e[3].PhraseInfo.GetText
puts result
end
loop do
WIN32OLE_EVENT.message_loop
sleep(1)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment