in reply to Win32::OLE get list of installed voices

Hello Takamoto,

I found a sub in an experiment of mines dating 2007.. I rearranged for you:

use strict; use warnings; use Data::Dumper; use Win32::OLE; my %voices = SAPIgetVoices(); print Dumper \%voices; sub SAPIgetVoices{ my $tts = Win32::OLE->new("Sapi.SpVoice") or die "Sapi.SpVoice fai +led"; my %VOICES; for(my $VoiceCnt=0;$VoiceCnt < $tts->GetVoices->Count();$VoiceCnt+ ++) { my $desc = $tts->GetVoices->Item($VoiceCnt)->GetDescription; #print "descr= $desc\n"; $VOICES{"$desc"} = $VoiceCnt; } return %VOICES; } # OUTPUT $VAR1 = { 'Microsoft Elsa Desktop - Italian (Italy)' => 0, 'Microsoft Zira Desktop - English (United States)' => 1 };

L*

There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

Replies are listed 'Best First'.
Re^2: Win32::OLE get list of installed voices
by Takamoto (Monk) on May 15, 2019 at 11:05 UTC

    Lovely, Discipulus. Simply perfect!