Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hello fellow coders,

I'm having a problem registering a Microsoft OLE class using Win32::OLE. I'm trying to do some voice recognition using the Speech.VoiceCommand object that comes with the Microsoft Speech API. I've already gotten Perl to talk using Speech.VoiceText by using examples posted here. (PS: Thanks for that!)

When I try to register the Speech.VoiceCommand object, I get the following error:

Win32::OLE(0.1502) error 0x80020009: "Exception occurred in METHOD/PROPERTYGET "Register" at hear.pl line 14

I don't know how to _start_ debugging this! I tried reinstalling the Microsoft Speech API, but it didn't help. I created my code by hacking up some source code from the MisterHouse code on sourceforge. Thanks in advance!!

Here's my code: --------------------------------------------------------

use Win32::OLE; use strict; my $vcmd_ms; $Win32::OLE::Warn = 1; # Warn if ole fails eval {$vcmd_ms = Win32::OLE->GetActiveObject('Speech.VoiceCommand')}; die "VoiceCommand not installed" if $@; unless (defined $vcmd_ms) { $vcmd_ms = Win32::OLE->new('Speech.VoiceCommand'); die Win32::OLE->LastError if (Win32::OLE->LastError()); } $vcmd_ms->Register(""); # this is the line that barfs die Win32::OLE->LastError if (Win32::OLE->LastError());

Replies are listed 'Best First'.
Re: Win32::OLE: Problems registering Speech.VoiceCommand
by Anonymous Monk on Aug 30, 2002 at 21:41 UTC
    Ah ha! In the installation area of MasterHouse, there's this nugget of love:

    "The 5.1 VR engine does not work in mh yet, due to a perl problem handeling COM events."

    ... roughly translates to... The newest voice recognition engine from Microsoft doesn't work with perl because of COM poo poo...

    I'll keep reading, and post the solution if I find it.

Re: Win32::OLE: Problems registering Speech.VoiceCommand
by Mr. Muskrat (Canon) on Aug 30, 2002 at 21:04 UTC

    Okay, if you are using ActiveState Perl then you should open the OLE Browser in Internet Explorer. It's located at C:\Perl\html\OLE-Browser\Browser.html unless you installed Perl somewhere other than C:\Perl.

    I don't have the Speech API installed here and I am not downloading it with dialup. Perhaps if I'm feeling extra generous, I'll give it a go when I get home.

    Gosh, it's been a while since I have messed with Win32::OLE... You might try $vcmd_ms->Register(undef); or $vcmd_ms->Register(undef, $0);.

Re: Win32::OLE: Problems registering Speech.VoiceCommand
by Anonymous Monk on Aug 30, 2002 at 21:25 UTC
    Thanks for the advice so far...

    I went to C:\Perl\html\OLE-Browser\Browser.html as requested and looked at the Register method. Here's the only information that popped up:

    Sub Register(pszSite As String)
    Register application with Voice Commands.

    If you look in the MasterHouse code, his call to ->Register() looks like this:

    $vcmd_ms->Register("Local PC");

    ... athough I think he pulled "Local PC" out of his bottom. I tried the same thing and it didn't work. The microsoft speech API added a "speech" control panel widget. I looked at it, and everything checks out.

    I also downloaded something called "COM Explorer". It lists the 'Voice Command Object' under EXE Servers. It doesn't show any missing dependancies or any other obvious trouble with it.

    Thanks! Perhaps I'll try to register the voice command object using Visual Basic Script. It's been a while since I did that! :-)

Re: Win32::OLE: Problems registering Speech.VoiceCommand
by RMGir (Prior) on Aug 30, 2002 at 21:00 UTC
    Hmmm, looking at what few examples I could find online, it looks like you're doing it exactly right.

    Not a lot of help, eh?

    Do you get better results trying from VB, VBA, or some other OLE-enabled environment?
    --
    Mike