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?
In reply to Win32::OLE get list of installed voices by Takamoto
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |