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

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.