If this isn't a cool use for perl, then by god, I don't know what is. This script uses Microsoft's Speech API http://www.microsoft.com/speech to say whatever you tell it to. I found this originally on Progressive Perl (don't have a link) and fooled around with it. It is by no means my own code. The speech, however, was created by myself and primus.

use Win32::OLE qw( EVENTS ); my $DirectSS = new Win32::OLE( "{EEE78591-FE22-11D0-8BEF-0060081841DE}" ); $DirectSS->Speak("Good evening, Mr. Anderson. How's your day been? G +oooood. Well, listen, I'm going to have to ask you to be assimilated + into the Borg because, yeah, resistance is futile. Oh, and about th +ose TPS reports. Yeah, didja get that memo? You see, we're putting +new cover sheets on all our TPS reports. By the way, I've taken the +liberty of searching, searching, searching out. your domain controlle +rs. It seems they're named charles and michael. or should i say, we +re? cuz now they're pete and repeat. yeah. how do you like that? +by the way, if pete and repeat are in a boat and pete jumps out, who's left? Ok, i'll say it again. if pete and repeat are in a boat +and pete jumps out, who's left? that was a little borg humor for you +. most people don't know about it, but we can be a regular barrel of + laughs when we want to. and remember: anything is possible, except +skiing through a revolving door. Because then where would we be? no +where, that's where. by the way, you're logged in as " . getlogin . +". We Borg know that kind of stuff. It's what we do, so we have to +be good at it. and we are. we're really good. really good. really +, really good. in fact, so good that we know that everything about yo +ur computer. everything. have a pleasant remainder of your day. ch +eers from the borg. "); while( $DirectSS->{Speaking} ) { Win32::OLE->SpinMessageLoop(); Win32::Sleep( 100 ); }
This code runs on Windows 2000. It doesn't seem to work on my XP Pro box, but the docs say it's supposed to work on ME, XP Home, XP Pro, and 2000. Then again, maybe I shouldn't trust Microsoft documentation....

Anyways, if you're running 2000, give this a shot. And if you're running some other flavor of windows and you get it to work anyway, comment here so the rest of us can figure it out. :)

Some parts of this really have to be heard to appreciate. Listening to Sam (the primary M$oft voice) say "searching, searching, searching out. your domain controllers" is a whole lot better to hear than to read.

Update: The trick to using this on XP is to download the SAPI 4.0 from Microsoft's Speech site.

Here's a Tk program that will say whatever you tell it:

use Win32::OLE qw( EVENTS ); use Tk; my $DirectSS = new Win32::OLE( "{EEE78591-FE22-11D0-8BEF-0060081841DE} +" ) or die "$!"; $mw = MainWindow->new(-title => "the BATKINS speaker"); my $text = $mw->Text->pack; $text->focus; $mw->Button(-text => 'say it', -command => sub { say($text->get("0.0", + "end")); })->pack; MainLoop; sub say { my $say = shift; $DirectSS->Speak($say); while( $DirectSS->{Speaking} ) { Win32::OLE->SpinMessageLoop(); Win32::Sleep( 100 ); } }

For added fun, tell this program to say "he. a-he. a-he-he-he."


In reply to speak to me! by batkins

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.