Jon Bjornstad wrote:
> This code:
>
> use Win32::Ole;
> my $voice = Win32::Ole->new("Speech.VoiceText");
> $voice->Register('', 'Perl');
> $voice->speak("hello world");
> <STDIN>; # wait til it finishes speaking
>
> has been used succesfully on Windows98 (with the
> Microsoft Speech SDK installed) and on Windows 2000
> (which has it installed by default, apparently).
>
> The same code does not, however, work on Windows XP.
>
> What has changed?
> There IS a text-to-speech service on XP.
> How do I connect to it?
I got it working on XP Pro after switching to Jan's classname :
use strict;
use warnings;
use Win32::OLE;
my $voice = Win32::OLE->new('SAPI.SpVoice'); # "Speech.VoiceText");
# $voice->Register('', 'Perl');
$voice->speak("hello world");
<STDIN>; # wait til it finishes speaking
__END__
and the tie example also:
use strict;
use warnings;
use Win32::OLE;
tie *SPEECH, 'Speech'; END { untie *SPEECH; }
print SPEECH "It is now ", scalar localtime;
exit;
package Speech;
sub TIEHANDLE {
my $voice = Win32::OLE->new('SAPI.SpVoice') or die "new SAPI.SPVoice: $! ($^E)";
# $voice->Register('', 'Perl');
bless \$voice => shift;
}
sub PRINT {
my $voice = shift;
my $text = join '', @_;
print STDOUT $text, "\n";
$$voice->Speak($text, 0);
}
sub DESTROY {
my $voice = shift;
# sleep (1) while $$voice->IsSpeaking;
my $ret = $$voice->WaitUntilDone(1000);
# print "ret=", $ret ? 'finished' : 'killed', "\n";
}
__END__
--
,-/- __ _ _ $Bill Luebkert Mailto:[EMAIL PROTECTED]
(_/ / ) // // DBE Collectibles Mailto:[EMAIL PROTECTED]
/ ) /--< o // // Castle of Medieval Myth & Magic http://www.todbe.com/
-/-' /___/_<_</_</_ http://dbecoll.tripod.com/ (My Perl/Lakers stuff)
_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs