Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

Re: Changing the voice in MS Text to speech?

by Jouke (Curate)
on Sep 08, 2003 at 10:09 UTC ( #289734=note: print w/replies, xml ) Need Help??

in reply to Changing the voice in MS Text to speech?

In the latest version of pVoice, which you can download at 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

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://289734]
[Corion]: Congratulations Lady_Aleena ;)
[Lady_Aleena]: Thanks Corion.
[Lady_Aleena]: This is one of my oldest accounts on the web. 8)
[Corion]: Lady_Aleena: Hehe - I think this is also my oldest active account on the web. I have an old university email address but that only gets spam nowadays :)
Discipulus arrived at work 1 hour late.. he do not noticed the clock bell
[Lady_Aleena]: My Wikipedia account is 3 years - 10 days younger.

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (8)
As of 2017-04-26 07:39 GMT
Find Nodes?
    Voting Booth?
    I'm a fool:

    Results (469 votes). Check out past polls.