In the latest version of pVoice, which you can download at http://opensource.pvoice.org these days, I'm using something like this to select the speechengine:
#!/usr/bin/perl use strict; use warnings; use Win32::SAPI4; use Win32::Locale; use Locale::Country; use Locale::Language; # This hashref represents some of the possible LanguageIDs that MS use +s my $Languages = {'Arabic' => 0x0401, 'Basque' => 0x042D, 'Chinese (Simplified)' => 0x0804, 'Chinese (Traditional)' => 0x0404, 'Croatian' => 0x041A, 'Czech' => 0x0405, 'Danish' => 0x0406, 'Dutch' => 0x0413, 'English (British)' => 0x0809, 'English (US)' => 0x0409, 'Finnish' => 0x040B, 'French' => 0x040C, 'German' => 0x0407, 'Greek' => 0x0408, 'Hebrew' => 0x040D, 'Hungarian' => 0x040E, 'Italian' => 0x0410, 'Japanese' => 0x0411, 'Korean' => 0x0412, 'Norwegian' => 0x0414, 'Polish' => 0x0415, 'Portuguese (Portugal)' => 0x0816, 'Portuguese (Brazil)' => 0x0416, 'Romanian' => 0x0418, 'Russian' => 0x0419, 'Slovakian' => 0x041B, 'Slovenian' => 0x0424, 'Spanish' => 0x0C0A, 'Swedish' => 0x041D, 'Thai' => 0x041E, 'Turkish' => 0x041F}; # I'm using my SAPI4 module here, you could also create the # voicetext object yourself. my $vt = Win32::SAPI4::VoiceText->new() || die "Can't start VoiceText" +; # Get All available languages from installed speechengines my @alllangs = getlanguages($vt); print join("\n", @alllangs); # Get all available voices from a specific language, replace # 'Dutch' with the hashkey of your choice (see the $Languages # hashref above) my $language = languageid2language($Languages->{'Dutch'}); my @allvoices =getvoices($language, $vt); print "\n\n", join ("\n", @allvoices); # Say that one of the voices is named 'Adult Female #1 Dutch (L&H)' # which is one of the dutch voices I have installed for (my $i=1; $i <= $vt->CountEngines; $i++) { select($i) if $vt->ModeName($i) eq 'Adult Female #1 Dutch (L&H)'; } #--------------------------------------------------------------------- +- # This sub returns the names of the installed voices sub getvoices { my $language = shift; my $v = shift; my @r; # We wander through the number of installed engines for (my $i=1; $i <= $v->CountEngines; $i++) { my ($t1, $t2) = split(/-/,Win32::Locale::get_language($v->Lang +uageID($i))); push @r, $v->ModeName($i) if $language eq code2language($t1)." + (".code2country($t2).")"; } return @r; } #--------------------------------------------------------------------- +- # This sub returns the names of the installed languages sub getlanguages { my $v = shift; my %r; # Also here we browse through the installed engines for (my $i=1; $i <= $v->CountEngines; $i++) { my ($t1, $t2) = split(/-/,Win32::Locale::get_language($v->Lang +uageID($i))); $r{code2language($t1)." (".code2country($t2).")"}++; } return keys %r; } #--------------------------------------------------------------------- +- # This sub returns a readable language for the given $languageid sub languageid2language { my $languageid = shift; my ($t1, $t2) = split(/-/,Win32::Locale::get_language($languageid) +); return code2language($t1)." (".code2country($t2).")"; }


Jouke Visser, Perl 'Adept'
Using Perl to help the disabled: pVoice and pStory

In reply to Re: Changing the voice in MS Text to speech? by Jouke
in thread Changing the voice in MS Text to speech? by Massyn

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.