USES ComObj;
procedure Speak(const sText : String; bWithVoice : Boolean = True);
const
SVSFDefault = $00000000;
SVSFlagsAsync = $00000001;
var
oVoice: OLEVariant;
begin
if bWithVoice then begin
oVoice := CreateOLEObject('SAPI.SpVoice');
oVoice.Speak(sText, SVSFlagsAsync);
end;
Showmessage(sText);
oVoice := Unassigned;
end;
Examples:
//With voice.
Speak('Hello people');
//Without voice.
Speak('Hello people', False);