I have example for SpeechAPI 5.4 in Delphi XE2. Here's part of it:
try
SpVoice:= TSpVoice.Create(nil);
SOTokens := SpVoice1.GetVoices('', '');
for i := 0 to SOTokens.Count - 1 do begin
SOToken := SOTokens.Item(I);
SOToken._AddRef;
s:=SOToken.GetDescription(0); // raise exception
Log(IntToStr(i)+': '+s);
end;
except
on E : Exception do begin
Log(E.ClassName+' error raised, with message : '+E.Message);
end;
end;
This code works correct on all Windows from XP till 8.1. Unfortunately, Windows 10 raise exception. In log file I can read:
0: Microsoft David Desktop - English (United States)
EOleException error raised, with message : OLE error 8004503A
Standard Windows Text-to-speech tool shows me 2 available voices:
Microsoft David Desktop - English (United States)
Microsoft Zira Desktop - English (United States)
It's important create TSpVoice
dynamically.
How can I work with all voices without exceptions?