Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Win32::SAPI4 question (Win32 events and Perl)

Reply
Thread Tools

Win32::SAPI4 question (Win32 events and Perl)

 
 
Michael Edmonson
Guest
Posts: n/a
 
      02-28-2004
I've been playing around with the Win32::SAPI4 module, which provides
access to a slightly crufty version of Microsoft's speech API. I've
been able to get a simple speech example working, though I've been
unable to figure out how how events such as "SpeakingStarted" and
"SpeakingDone" are accessed. These are mentioned in the "vb.chm"
documentation (Microsoft Speech SDK/document/vb.chm, under Voice Text
Control, Events), which says only:

Events
The Voice Text control can receive the following events:

SpeakingDone()
Occurs when speaking is finished and no text remains in the
playback queue.

SpeakingStarted()
Occurs when speaking has started.

I was wondering if anyone has any idea how these events, or Win32
events in general, may be accessed via Perl. Is Win32::Event involved?
Or are they supposed to be implemented and registered somehow as
callback subs? Or something else?

Here is some code that speaks a string (that part works, anyway),
trying to receive notification when playback is finished:

#!/usr/bin/perl -w
# speech demo

use strict;
use Win32::SAPI4;
use Win32::Event;

my $vt = new Win32::SAPI4::VoiceText();

$vt->Select($vt->find("Gender=1"));

my $text = "this is only a test";

$vt->Speak($text);

sub SpeakingDone {
# ???
die "speakingdone";
}

sub SpeakingStarted {
# ???
die "speakingstarted";
}

my $ev = new Win32::Event(0,0,"SpeakingDone");
$ev->wait(5000);
# seems to block the speech from starting for 5 seconds
# rather than being signaled when it ends

print "done\n";

Unfortunately, neither callback sub is ever invoked, and the
Win32::Event code just seems to get in the way. I know I can just loop
while testing the "IsSpeaking" property, which is okay, but I'm actually
mostly concerned about events because interacting with them seems
unavoidable when using the Voice Dictation control.

Any advice at all would be appreciated. The Win32::SAPI4 and
Win32::Event docs are woefully brief, and Google has been surprisingly
coy about coughing up Win32 event-related Perl code.

Michael
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Differentiate between user caused events and script generated events jmpinchot@gmail.com Javascript 1 04-27-2007 03:05 AM
runtime events that generate other controls and events newbye ASP .Net 0 07-06-2006 06:27 PM
Events Events Events Please Help Chris ASP .Net Web Controls 0 08-30-2005 08:21 PM
Re: passing variables between web page events & httpmodules events Alvin Bruney ASP .Net 1 11-24-2003 04:14 PM
Passing Variables between Web Page Events and HttpModule Events shiv ASP .Net 0 11-21-2003 04:29 PM



Advertisments