Win32::SAPI4 question (Win32 events and Perl)

Discussion in 'Perl Misc' started by Michael Edmonson, Feb 28, 2004.

  1. 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
     
    Michael Edmonson, Feb 28, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. shiv
    Replies:
    0
    Views:
    493
  2. newbye
    Replies:
    0
    Views:
    586
    newbye
    Jul 6, 2006
  3. Robert Kaplan

    Greetings and win32 com events question

    Robert Kaplan, Jan 28, 2005, in forum: Python
    Replies:
    0
    Views:
    510
    Robert Kaplan
    Jan 28, 2005
  4. Chris

    Events Events Events Please Help

    Chris, Aug 30, 2005, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    388
    Chris
    Aug 30, 2005
  5. Replies:
    1
    Views:
    162
    Peter Michaux
    Apr 27, 2007
Loading...

Share This Page