Takamoto has asked for the wisdom of the Perl Monks concerning the following question:
Dear Monks
On a Windows machine I need to get all installed voices for TTS in order to pick one and let the machine convert text to speech. I am using the following script, which is fine. I can set the voice I want. What I am failing is to read the available voice. Probably I am committing a very naive error.
use strict; use warnings; use Data::Dumper; use Win32::OLE; my $speech = Win32::OLE->new("SAPI.SpVoice") or die ("Error with TTS") +; #trying to get installed voices my $AvailableVoices = $speech->GetVoices(); print Dumper $AvailableVoices; say ("Hello user."); # I am using the default voice say ("Hello user.", "Microsoft David Desktop"); # I am setting a diffe +rent voice which is installed on the machine sub say { my ($text, $voice) = @_; $speech->{voice} = $speech->GetVoices("name = $voice")->Item(0) if $ +voice; $speech->Speak($text); }
This is the output of $AvailableVoices:
$VAR1 = bless( { 'Count' => 5 }, 'Win32::OLE' );
At least is the count right, I have 5 voices installed. Any suggestions?
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Win32::OLE get list of installed voices
by Discipulus (Canon) on May 15, 2019 at 09:19 UTC | |
by Takamoto (Monk) on May 15, 2019 at 11:05 UTC | |
Re: Win32::OLE get list of installed voices
by NetWallah (Canon) on May 16, 2019 at 05:42 UTC |