I stumbled across the ruby library for this while poking around for
something else in RAA, and it seemed interesting. I tried to port
something relatively simple to see if I could get it working…
require “win32/sapi5”
include Win32
listener = SpSharedRecognizer.new
context = listener.CreateRecoContext()
grammar = context.CreateGrammar(1)
grammar.DictationLoad
grammar.DictationSetState(1)
ev = WIN32OLE_EVENT.new(context, “ISpRecoContext”)
… And that last line is as far as it gets, with this error message:
recotest.rb:15:in initialize': failed to query IConnectionPoint (RuntimeError) HRESULT error code:0x80040200 from recotest.rb:15:in
new’
from recotest.rb:15
I don’t think more initialization is required before being able to
receive events from the object. (At least, it didn’t appear to be in the
examples that I looked at.) And I don’t think that’s the wrong
interface, though with the way the documentation is set up it’s hard to
be sure.
In any case, there’s something wrong, but I’m not sure what. Anyone have
any ideas? (Alternately, anyone have some working ruby speech
recognition code. Once I have something that works, I can start tweaking
it until I figure out what I’m doing, but without having some kind of
starting point…)
-Morgan.
Err, from what I see, I don’t even think that’s a ruby library, it
kindof looks like straight win32ole stuff.
I’ve played with this before to use sapi for TTS (opposite direction
of what you’re doing). The way to really get into it is to dig
through the microsoft devnet docs for it. All the usable examples
will be in C/C++, and there’s even some useful stuff in vb, but I
always found it easier to follow their c docs.
Good luck
and if you get it recognizing, I’d love to see the code,
cause I’ve wanted to use it too, never had the time to muck with it
though.
–Kyle
The best thing to do is to use
Kyle S. wrote:
Err, from what I see, I don’t even think that’s a ruby library, it
kindof looks like straight win32ole stuff.
I’ve played with this before to use sapi for TTS (opposite direction
of what you’re doing). The way to really get into it is to dig
through the microsoft devnet docs for it. All the usable examples
will be in C/C++, and there’s even some useful stuff in vb, but I
always found it easier to follow their c docs.
Microsoft Speech API (SAPI) 5.3 | Microsoft Learn
I’m not sure there isn’t something a bit ruby-specific in here somewhere
though. I’ve been mostly looking at perl and python examples, and none
of them specify an interface when setting up to receive events. Maybe
I’m just doing ruby win32ole wrong somehow.
The only C example so far that I’ve even been able to figure out how
it’s receiving the events is the “talkback” one, which appears to be
using polling instead of setting up event callbacks. And while that
could probably be made to work, callbacks seem better.
-Morgan.